Skip to content

Commit

Permalink
Add a proc table version of embedder API (flutter#21813)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmorgan authored and chaselatta committed Nov 30, 2020
1 parent 0ab5ff9 commit 3fec149
Show file tree
Hide file tree
Showing 10 changed files with 414 additions and 62 deletions.
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ group("flutter") {
"//flutter/lib/ui:ui_unittests",
"//flutter/runtime:runtime_unittests",
"//flutter/shell/common:shell_unittests",
"//flutter/shell/platform/embedder:embedder_proctable_unittests",
"//flutter/shell/platform/embedder:embedder_unittests",
"//flutter/testing:testing_unittests",
"//flutter/third_party/txt:txt_unittests",
Expand Down
3 changes: 2 additions & 1 deletion ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ FILE: ../../../flutter/shell/platform/embedder/embedder_render_target.cc
FILE: ../../../flutter/shell/platform/embedder/embedder_render_target.h
FILE: ../../../flutter/shell/platform/embedder/embedder_render_target_cache.cc
FILE: ../../../flutter/shell/platform/embedder/embedder_render_target_cache.h
FILE: ../../../flutter/shell/platform/embedder/embedder_safe_access.h
FILE: ../../../flutter/shell/platform/embedder/embedder_struct_macros.h
FILE: ../../../flutter/shell/platform/embedder/embedder_surface.cc
FILE: ../../../flutter/shell/platform/embedder/embedder_surface.h
FILE: ../../../flutter/shell/platform/embedder/embedder_surface_gl.cc
Expand Down Expand Up @@ -1121,6 +1121,7 @@ FILE: ../../../flutter/shell/platform/embedder/fixtures/verifyb143464703.png
FILE: ../../../flutter/shell/platform/embedder/fixtures/verifyb143464703_soft_noxform.png
FILE: ../../../flutter/shell/platform/embedder/platform_view_embedder.cc
FILE: ../../../flutter/shell/platform/embedder/platform_view_embedder.h
FILE: ../../../flutter/shell/platform/embedder/test_utils/proc_table_replacement.h
FILE: ../../../flutter/shell/platform/embedder/vsync_waiter_embedder.cc
FILE: ../../../flutter/shell/platform/embedder/vsync_waiter_embedder.h
FILE: ../../../flutter/shell/platform/fuchsia/dart-pkg/fuchsia/lib/fuchsia.dart
Expand Down
37 changes: 36 additions & 1 deletion shell/platform/embedder/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ template("embedder_source_set") {
"embedder_render_target.h",
"embedder_render_target_cache.cc",
"embedder_render_target_cache.h",
"embedder_safe_access.h",
"embedder_struct_macros.h",
"embedder_surface.cc",
"embedder_surface.h",
"embedder_surface_software.cc",
Expand Down Expand Up @@ -110,6 +110,14 @@ source_set("embedder_headers") {
public_configs = [ "//flutter:config" ]
}

source_set("embedder_test_utils") {
public = [ "test_utils/proc_table_replacement.h" ]

deps = [ ":embedder_headers" ]

public_configs = [ "//flutter:config" ]
}

# For using the embedder API as internal implementation detail of an
# embedding.
config("embedder_internal_library_config") {
Expand Down Expand Up @@ -200,6 +208,33 @@ if (enable_unittests) {
deps += [ "//flutter/testing:opengl" ]
}
}

# Tests the build in FLUTTER_ENGINE_NO_PROTOTYPES mode.
executable("embedder_proctable_unittests") {
testonly = true

configs += [
":embedder_gpu_configuration_config",
"//flutter:export_dynamic_symbols",
]

sources = [ "tests/embedder_unittests_proctable.cc" ]

defines = [ "FLUTTER_ENGINE_NO_PROTOTYPES" ]

deps = [
":embedder",
":embedder_gpu_configuration",
":fixtures",
"//flutter/testing",

#"//flutter/testing:dart",
#"//flutter/testing:skia",
#"//flutter/third_party/tonic",
#"//third_party/dart/runtime/bin:elf_loader",
#"//third_party/skia",
]
}
}

shared_library("flutter_engine_library") {
Expand Down
56 changes: 55 additions & 1 deletion shell/platform/embedder/embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extern const intptr_t kPlatformStrongDillSize;
#include "flutter/shell/platform/embedder/embedder_engine.h"
#include "flutter/shell/platform/embedder/embedder_platform_message_response.h"
#include "flutter/shell/platform/embedder/embedder_render_target.h"
#include "flutter/shell/platform/embedder/embedder_safe_access.h"
#include "flutter/shell/platform/embedder/embedder_struct_macros.h"
#include "flutter/shell/platform/embedder/embedder_task_runner.h"
#include "flutter/shell/platform/embedder/embedder_thread_host.h"
#include "flutter/shell/platform/embedder/platform_view_embedder.h"
Expand Down Expand Up @@ -2048,3 +2048,57 @@ FlutterEngineResult FlutterEngineNotifyDisplayUpdate(
"Invalid FlutterEngineDisplaysUpdateType type specified.");
}
}

FlutterEngineResult FlutterEngineGetProcAddresses(
FlutterEngineProcTable* table) {
if (!table) {
return LOG_EMBEDDER_ERROR(kInvalidArguments, "Null table specified.");
}
#define SET_PROC(member, function) \
if (STRUCT_HAS_MEMBER(table, member)) { \
table->member = &function; \
}

SET_PROC(CreateAOTData, FlutterEngineCreateAOTData);
SET_PROC(CollectAOTData, FlutterEngineCollectAOTData);
SET_PROC(Run, FlutterEngineRun);
SET_PROC(Shutdown, FlutterEngineShutdown);
SET_PROC(Initialize, FlutterEngineInitialize);
SET_PROC(Deinitialize, FlutterEngineDeinitialize);
SET_PROC(RunInitialized, FlutterEngineRunInitialized);
SET_PROC(SendWindowMetricsEvent, FlutterEngineSendWindowMetricsEvent);
SET_PROC(SendPointerEvent, FlutterEngineSendPointerEvent);
SET_PROC(SendPlatformMessage, FlutterEngineSendPlatformMessage);
SET_PROC(PlatformMessageCreateResponseHandle,
FlutterPlatformMessageCreateResponseHandle);
SET_PROC(PlatformMessageReleaseResponseHandle,
FlutterPlatformMessageReleaseResponseHandle);
SET_PROC(SendPlatformMessageResponse,
FlutterEngineSendPlatformMessageResponse);
SET_PROC(RegisterExternalTexture, FlutterEngineRegisterExternalTexture);
SET_PROC(UnregisterExternalTexture, FlutterEngineUnregisterExternalTexture);
SET_PROC(MarkExternalTextureFrameAvailable,
FlutterEngineMarkExternalTextureFrameAvailable);
SET_PROC(UpdateSemanticsEnabled, FlutterEngineUpdateSemanticsEnabled);
SET_PROC(UpdateAccessibilityFeatures,
FlutterEngineUpdateAccessibilityFeatures);
SET_PROC(DispatchSemanticsAction, FlutterEngineDispatchSemanticsAction);
SET_PROC(OnVsync, FlutterEngineOnVsync);
SET_PROC(ReloadSystemFonts, FlutterEngineReloadSystemFonts);
SET_PROC(TraceEventDurationBegin, FlutterEngineTraceEventDurationBegin);
SET_PROC(TraceEventDurationEnd, FlutterEngineTraceEventDurationEnd);
SET_PROC(TraceEventInstant, FlutterEngineTraceEventInstant);
SET_PROC(PostRenderThreadTask, FlutterEnginePostRenderThreadTask);
SET_PROC(GetCurrentTime, FlutterEngineGetCurrentTime);
SET_PROC(RunTask, FlutterEngineRunTask);
SET_PROC(UpdateLocales, FlutterEngineUpdateLocales);
SET_PROC(RunsAOTCompiledDartCode, FlutterEngineRunsAOTCompiledDartCode);
SET_PROC(PostDartObject, FlutterEnginePostDartObject);
SET_PROC(NotifyLowMemoryWarning, FlutterEngineNotifyLowMemoryWarning);
SET_PROC(PostCallbackOnAllNativeThreads,
FlutterEnginePostCallbackOnAllNativeThreads);
SET_PROC(NotifyDisplayUpdate, FlutterEngineNotifyDisplayUpdate);
#undef SET_PROC

return kSuccess;
}
Loading

0 comments on commit 3fec149

Please sign in to comment.