Skip to content

Commit

Permalink
embedder: Exclude GL code (flutter#21544)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbreng authored Oct 1, 2020
1 parent fc0616f commit 2c3fc4a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 25 deletions.
13 changes: 10 additions & 3 deletions shell/platform/embedder/embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ extern const intptr_t kPlatformStrongDillSize;
#include "rapidjson/rapidjson.h"
#include "rapidjson/writer.h"

#ifdef SHELL_ENABLE_GL
#include "flutter/shell/platform/embedder/embedder_external_texture_gl.h"
#endif

const int32_t kFlutterSemanticsNodeIdBatchEnd = -1;
const int32_t kFlutterSemanticsCustomActionIdBatchEnd = -1;

Expand Down Expand Up @@ -1034,11 +1038,11 @@ FlutterEngineResult FlutterEngineInitialize(size_t version,
return std::make_unique<flutter::Rasterizer>(shell);
};

#ifdef SHELL_ENABLE_GL
// TODO(chinmaygarde): This is the wrong spot for this. It belongs in the
// platform view jump table.
flutter::EmbedderExternalTextureGL::ExternalTextureCallback
external_texture_callback;
#ifdef SHELL_ENABLE_GL
if (config->type == kOpenGL) {
const FlutterOpenGLRendererConfig* open_gl_config = &config->open_gl;
if (SAFE_ACCESS(open_gl_config, gl_external_texture_frame_callback,
Expand Down Expand Up @@ -1135,8 +1139,11 @@ FlutterEngineResult FlutterEngineInitialize(size_t version,
std::move(settings), //
std::move(run_configuration), //
on_create_platform_view, //
on_create_rasterizer, //
external_texture_callback //
on_create_rasterizer //
#ifdef SHELL_ENABLE_GL
,
external_texture_callback //
#endif
);

// Release the ownership of the embedder engine to the caller.
Expand Down
27 changes: 22 additions & 5 deletions shell/platform/embedder/embedder_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,24 @@ EmbedderEngine::EmbedderEngine(
flutter::Settings settings,
RunConfiguration run_configuration,
Shell::CreateCallback<PlatformView> on_create_platform_view,
Shell::CreateCallback<Rasterizer> on_create_rasterizer,
EmbedderExternalTextureGL::ExternalTextureCallback
external_texture_callback)
Shell::CreateCallback<Rasterizer> on_create_rasterizer
#ifdef SHELL_ENABLE_GL
,
EmbedderExternalTextureGL::ExternalTextureCallback external_texture_callback
#endif
)
: thread_host_(std::move(thread_host)),
task_runners_(task_runners),
run_configuration_(std::move(run_configuration)),
shell_args_(std::make_unique<ShellArgs>(std::move(settings),
on_create_platform_view,
on_create_rasterizer)),
external_texture_callback_(external_texture_callback) {}
on_create_rasterizer))
#ifdef SHELL_ENABLE_GL
,
external_texture_callback_(external_texture_callback)
#endif
{
}

EmbedderEngine::~EmbedderEngine() = default;

Expand Down Expand Up @@ -144,28 +152,37 @@ bool EmbedderEngine::SendPlatformMessage(
}

bool EmbedderEngine::RegisterTexture(int64_t texture) {
#ifdef SHELL_ENABLE_GL
if (!IsValid() || !external_texture_callback_) {
return false;
}
shell_->GetPlatformView()->RegisterTexture(
std::make_unique<EmbedderExternalTextureGL>(texture,
external_texture_callback_));
#endif

return true;
}

bool EmbedderEngine::UnregisterTexture(int64_t texture) {
#ifdef SHELL_ENABLE_GL
if (!IsValid() || !external_texture_callback_) {
return false;
}
shell_->GetPlatformView()->UnregisterTexture(texture);
#endif

return true;
}

bool EmbedderEngine::MarkTextureFrameAvailable(int64_t texture) {
#ifdef SHELL_ENABLE_GL
if (!IsValid() || !external_texture_callback_) {
return false;
}
shell_->GetPlatformView()->MarkTextureFrameAvailable(texture);
#endif

return true;
}

Expand Down
15 changes: 12 additions & 3 deletions shell/platform/embedder/embedder_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
#include "flutter/shell/common/shell.h"
#include "flutter/shell/common/thread_host.h"
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/embedder/embedder_external_texture_gl.h"
#include "flutter/shell/platform/embedder/embedder_thread_host.h"

#ifdef SHELL_ENABLE_GL
#include "flutter/shell/platform/embedder/embedder_external_texture_gl.h"
#endif

namespace flutter {

struct ShellArgs;
Expand All @@ -28,9 +31,13 @@ class EmbedderEngine {
Settings settings,
RunConfiguration run_configuration,
Shell::CreateCallback<PlatformView> on_create_platform_view,
Shell::CreateCallback<Rasterizer> on_create_rasterizer,
Shell::CreateCallback<Rasterizer> on_create_rasterizer
#ifdef SHELL_ENABLE_GL
,
EmbedderExternalTextureGL::ExternalTextureCallback
external_texture_callback);
external_texture_callback
#endif
);

~EmbedderEngine();

Expand Down Expand Up @@ -90,8 +97,10 @@ class EmbedderEngine {
RunConfiguration run_configuration_;
std::unique_ptr<ShellArgs> shell_args_;
std::unique_ptr<Shell> shell_;
#ifdef SHELL_ENABLE_GL
const EmbedderExternalTextureGL::ExternalTextureCallback
external_texture_callback_;
#endif

FML_DISALLOW_COPY_AND_ASSIGN(EmbedderEngine);
};
Expand Down
18 changes: 10 additions & 8 deletions shell/platform/embedder/platform_view_embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,30 @@ namespace flutter {
PlatformViewEmbedder::PlatformViewEmbedder(
PlatformView::Delegate& delegate,
flutter::TaskRunners task_runners,
EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table,
bool fbo_reset_after_present,
EmbedderSurfaceSoftware::SoftwareDispatchTable software_dispatch_table,
PlatformDispatchTable platform_dispatch_table,
std::unique_ptr<EmbedderExternalViewEmbedder> external_view_embedder)
: PlatformView(delegate, std::move(task_runners)),
embedder_surface_(std::make_unique<EmbedderSurfaceGL>(
gl_dispatch_table,
fbo_reset_after_present,
embedder_surface_(std::make_unique<EmbedderSurfaceSoftware>(
software_dispatch_table,
std::move(external_view_embedder))),
platform_dispatch_table_(platform_dispatch_table) {}

#ifdef SHELL_ENABLE_GL
PlatformViewEmbedder::PlatformViewEmbedder(
PlatformView::Delegate& delegate,
flutter::TaskRunners task_runners,
EmbedderSurfaceSoftware::SoftwareDispatchTable software_dispatch_table,
EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table,
bool fbo_reset_after_present,
PlatformDispatchTable platform_dispatch_table,
std::unique_ptr<EmbedderExternalViewEmbedder> external_view_embedder)
: PlatformView(delegate, std::move(task_runners)),
embedder_surface_(std::make_unique<EmbedderSurfaceSoftware>(
software_dispatch_table,
embedder_surface_(std::make_unique<EmbedderSurfaceGL>(
gl_dispatch_table,
fbo_reset_after_present,
std::move(external_view_embedder))),
platform_dispatch_table_(platform_dispatch_table) {}
#endif

PlatformViewEmbedder::~PlatformViewEmbedder() = default;

Expand Down
17 changes: 11 additions & 6 deletions shell/platform/embedder/platform_view_embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
#include "flutter/shell/common/platform_view.h"
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/embedder/embedder_surface.h"
#include "flutter/shell/platform/embedder/embedder_surface_gl.h"
#include "flutter/shell/platform/embedder/embedder_surface_software.h"
#include "flutter/shell/platform/embedder/vsync_waiter_embedder.h"

#ifdef SHELL_ENABLE_GL
#include "flutter/shell/platform/embedder/embedder_surface_gl.h"
#endif

namespace flutter {

class PlatformViewEmbedder final : public PlatformView {
Expand All @@ -40,22 +43,24 @@ class PlatformViewEmbedder final : public PlatformView {
compute_platform_resolved_locale_callback;
};

// Creates a platform view that sets up an OpenGL rasterizer.
// Create a platform view that sets up a software rasterizer.
PlatformViewEmbedder(
PlatformView::Delegate& delegate,
flutter::TaskRunners task_runners,
EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table,
bool fbo_reset_after_present,
EmbedderSurfaceSoftware::SoftwareDispatchTable software_dispatch_table,
PlatformDispatchTable platform_dispatch_table,
std::unique_ptr<EmbedderExternalViewEmbedder> external_view_embedder);

// Create a platform view that sets up a software rasterizer.
#ifdef SHELL_ENABLE_GL
// Creates a platform view that sets up an OpenGL rasterizer.
PlatformViewEmbedder(
PlatformView::Delegate& delegate,
flutter::TaskRunners task_runners,
EmbedderSurfaceSoftware::SoftwareDispatchTable software_dispatch_table,
EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table,
bool fbo_reset_after_present,
PlatformDispatchTable platform_dispatch_table,
std::unique_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
#endif

~PlatformViewEmbedder() override;

Expand Down

0 comments on commit 2c3fc4a

Please sign in to comment.