flutter_flutter/shell/platform/embedder/platform_view_embedder.h
Chinmay Garde def8061d49 Create a window toolkit agnostic Flutter engine API. (#3987)
* The Flutter engine will be shipped as a shared library.
* The engine is renderer and window toolkit agnostic.
* The simple public C API is described in embedder.h.
* ABI breaking changes will be indicated by changing the FLUTTER_ENGINE_VERSION.
* A simple GLFW based example of this API is available at https://gist.github.com/chinmaygarde/8abf44921f7d87f6da7bf026267c4792
2017-08-23 16:05:16 -07:00

62 lines
1.7 KiB
C++

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_PLATFORM_VIEW_EMBEDDER_H_
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_PLATFORM_VIEW_EMBEDDER_H_
#include "flutter/shell/common/platform_view.h"
#include "flutter/shell/gpu/gpu_surface_gl.h"
#include "lib/ftl/macros.h"
namespace shell {
class PlatformViewEmbedder : public PlatformView, public GPUSurfaceGLDelegate {
public:
struct DispatchTable {
std::function<bool(void)> gl_make_current_callback;
std::function<bool(void)> gl_clear_current_callback;
std::function<bool(void)> gl_present_callback;
std::function<intptr_t(void)> gl_fbo_callback;
};
PlatformViewEmbedder(DispatchTable dispatch_table);
~PlatformViewEmbedder();
// |shell::GPUSurfaceGLDelegate|
bool GLContextMakeCurrent() override;
// |shell::GPUSurfaceGLDelegate|
bool GLContextClearCurrent() override;
// |shell::GPUSurfaceGLDelegate|
bool GLContextPresent() override;
// |shell::GPUSurfaceGLDelegate|
intptr_t GLContextFBO() const override;
// |shell::GPUSurfaceGLDelegate|
bool SurfaceSupportsSRGB() const override;
// |shell::PlatformView|
void Attach() override;
// |shell::PlatformView|
bool ResourceContextMakeCurrent() override;
// |shell::PlatformView|
void RunFromSource(const std::string& assets_directory,
const std::string& main,
const std::string& packages) override;
private:
DispatchTable dispatch_table_;
FTL_DISALLOW_COPY_AND_ASSIGN(PlatformViewEmbedder);
};
} // namespace shell
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_PLATFORM_VIEW_EMBEDDER_H_