From 7293d4cef9f8b92cd546201c9c78545bd5e44211 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Mon, 23 Apr 2018 20:16:01 -0700 Subject: [PATCH] Fixup Fuchsia content handler post shell refactor. (flutter/engine#5072) --- engine/src/flutter/fml/native_library.h | 4 ++ .../platform/posix/native_library_posix.cc | 8 ++++ .../fml/platform/win/native_library_win.cc | 8 ++++ engine/src/flutter/lib/snapshot/BUILD.gn | 38 +++++-------------- .../src/flutter/lib/ui/compositing/scene.cc | 2 +- engine/src/flutter/shell/common/rasterizer.cc | 22 ++++++++--- engine/src/flutter/shell/common/rasterizer.h | 6 ++- engine/src/flutter/vulkan/vulkan_swapchain.cc | 14 +++---- 8 files changed, 59 insertions(+), 43 deletions(-) diff --git a/engine/src/flutter/fml/native_library.h b/engine/src/flutter/fml/native_library.h index a52d01a3e0..a223802b8d 100644 --- a/engine/src/flutter/fml/native_library.h +++ b/engine/src/flutter/fml/native_library.h @@ -26,6 +26,10 @@ class NativeLibrary : public fxl::RefCountedThreadSafe { static fxl::RefPtr Create(const char* path); + static fxl::RefPtr CreateWithHandle( + Handle handle, + bool close_handle_when_done); + static fxl::RefPtr CreateForCurrentProcess(); const uint8_t* ResolveSymbol(const char* symbol); diff --git a/engine/src/flutter/fml/platform/posix/native_library_posix.cc b/engine/src/flutter/fml/platform/posix/native_library_posix.cc index 1255c38fc0..934d1d1a7c 100644 --- a/engine/src/flutter/fml/platform/posix/native_library_posix.cc +++ b/engine/src/flutter/fml/platform/posix/native_library_posix.cc @@ -45,6 +45,14 @@ fxl::RefPtr NativeLibrary::Create(const char* path) { return library->GetHandle() != nullptr ? library : nullptr; } +fxl::RefPtr NativeLibrary::CreateWithHandle( + Handle handle, + bool close_handle_when_done) { + auto library = + fxl::AdoptRef(new NativeLibrary(handle, close_handle_when_done)); + return library->GetHandle() != nullptr ? library : nullptr; +} + fxl::RefPtr NativeLibrary::CreateForCurrentProcess() { return fxl::AdoptRef(new NativeLibrary(RTLD_DEFAULT, false)); } diff --git a/engine/src/flutter/fml/platform/win/native_library_win.cc b/engine/src/flutter/fml/platform/win/native_library_win.cc index 6992f06f3e..55da45fcd1 100644 --- a/engine/src/flutter/fml/platform/win/native_library_win.cc +++ b/engine/src/flutter/fml/platform/win/native_library_win.cc @@ -37,6 +37,14 @@ fxl::RefPtr NativeLibrary::Create(const char* path) { return library->GetHandle() != nullptr ? library : nullptr; } +fxl::RefPtr NativeLibrary::CreateWithHandle( + Handle handle, + bool close_handle_when_done) { + auto library = + fxl::AdoptRef(new NativeLibrary(handle, close_handle_when_done)); + return library->GetHandle() != nullptr ? library : nullptr; +} + fxl::RefPtr NativeLibrary::CreateForCurrentProcess() { return fxl::AdoptRef(new NativeLibrary(::GetModuleHandle(nullptr), false)); } diff --git a/engine/src/flutter/lib/snapshot/BUILD.gn b/engine/src/flutter/lib/snapshot/BUILD.gn index 8c568f4773..1f119da0a8 100644 --- a/engine/src/flutter/lib/snapshot/BUILD.gn +++ b/engine/src/flutter/lib/snapshot/BUILD.gn @@ -29,33 +29,14 @@ if (is_fuchsia) { # The sole purpose of this target is to generate a .packages file. sources = [] - dot_packages_file = "$target_gen_dir/snapshot.packages" - outputs = [ - dot_packages_file, - ] - deps = [] - foreach(dep, dart_deps) { - deps += [ "$dep($dart_toolchain)" ] - } + infer_package_name = true disable_analysis = true - script = "//build/dart/gen_dot_packages.py" - args = [ - "--out", - rebase_path(dot_packages_file, root_build_dir), - "--source-dir", - rebase_path("."), - "--root-build-dir", - rebase_path(root_build_dir), - "--root-gen-dir", - rebase_path(dart_root_gen_dir), - "--package-name", - "snapshot_root", - "--depfile", - rebase_path(depfile), - "--deps", - ] + dart_deps + deps = [ + "//topaz/public/dart/fuchsia", + "//topaz/public/dart/zircon", + ] } } @@ -148,10 +129,11 @@ action("generate_snapshot_bin") { } if (is_fuchsia) { - package_gen_dir = get_label_info(":bogus($dart_toolchain)", - "target_gen_dir") + package_gen_dir = + get_label_info(":bogus($dart_toolchain)", "target_gen_dir") package_file = "$package_gen_dir/generate_package_map.packages" - inputs += zircon_sdk_ext_files + mozart_dart_sdk_ext_files + [package_file] + inputs += + zircon_sdk_ext_files + mozart_dart_sdk_ext_files + [ package_file ] zircon_path = rebase_path(zircon_sdk_ext_lib) fuchsia_path = rebase_path(fuchsia_sdk_ext_lib) mozart_internal_path = rebase_path(mozart_dart_sdk_ext_lib) @@ -329,7 +311,7 @@ copy_entry_points_extra_json("entry_points_extra_json") { group("entry_points_json_files") { public_deps = [ - ":entry_points_json", ":entry_points_extra_json", + ":entry_points_json", ] } diff --git a/engine/src/flutter/lib/ui/compositing/scene.cc b/engine/src/flutter/lib/ui/compositing/scene.cc index 37514350b4..69279c1375 100644 --- a/engine/src/flutter/lib/ui/compositing/scene.cc +++ b/engine/src/flutter/lib/ui/compositing/scene.cc @@ -4,7 +4,7 @@ #include "flutter/lib/ui/compositing/scene.h" -#include "flutter/fml/trace_event.h" +#include "flutter/glue/trace_event.h" #include "flutter/lib/ui/painting/image.h" #include "lib/fxl/functional/make_copyable.h" #include "lib/tonic/converter/dart_converter.h" diff --git a/engine/src/flutter/shell/common/rasterizer.cc b/engine/src/flutter/shell/common/rasterizer.cc index 9c1b8efd7e..db940ce944 100644 --- a/engine/src/flutter/shell/common/rasterizer.cc +++ b/engine/src/flutter/shell/common/rasterizer.cc @@ -16,7 +16,17 @@ namespace shell { Rasterizer::Rasterizer(blink::TaskRunners task_runners) - : task_runners_(std::move(task_runners)), weak_factory_(this) {} + : Rasterizer(std::move(task_runners), + std::make_unique()) {} + +Rasterizer::Rasterizer( + blink::TaskRunners task_runners, + std::unique_ptr compositor_context) + : task_runners_(std::move(task_runners)), + compositor_context_(std::move(compositor_context)), + weak_factory_(this) { + FXL_DCHECK(compositor_context_); +} Rasterizer::~Rasterizer() = default; @@ -26,17 +36,17 @@ fml::WeakPtr Rasterizer::GetWeakPtr() const { void Rasterizer::Setup(std::unique_ptr surface) { surface_ = std::move(surface); - compositor_context_.OnGrContextCreated(); + compositor_context_->OnGrContextCreated(); } void Rasterizer::Teardown() { - compositor_context_.OnGrContextDestroyed(); + compositor_context_->OnGrContextDestroyed(); surface_.reset(); last_layer_tree_.reset(); } flow::TextureRegistry* Rasterizer::GetTextureRegistry() { - return &compositor_context_.texture_registry(); + return &compositor_context_->texture_registry(); } flow::LayerTree* Rasterizer::GetLastLayerTree() { @@ -96,12 +106,12 @@ bool Rasterizer::DrawToSurface(flow::LayerTree& layer_tree) { // There is no way for the compositor to know how long the layer tree // construction took. Fortunately, the layer tree does. Grab that time // for instrumentation. - compositor_context_.engine_time().SetLapTime(layer_tree.construction_time()); + compositor_context_->engine_time().SetLapTime(layer_tree.construction_time()); auto canvas = frame->SkiaCanvas(); auto compositor_frame = - compositor_context_.AcquireFrame(surface_->GetContext(), canvas, true); + compositor_context_->AcquireFrame(surface_->GetContext(), canvas, true); if (canvas) { canvas->clear(SK_ColorBLACK); diff --git a/engine/src/flutter/shell/common/rasterizer.h b/engine/src/flutter/shell/common/rasterizer.h index 79dda4ac9c..873b817f8d 100644 --- a/engine/src/flutter/shell/common/rasterizer.h +++ b/engine/src/flutter/shell/common/rasterizer.h @@ -8,6 +8,7 @@ #include #include "flutter/common/task_runners.h" +#include "flutter/flow/compositor_context.h" #include "flutter/flow/layers/layer_tree.h" #include "flutter/fml/memory/weak_ptr.h" #include "flutter/shell/common/surface.h" @@ -21,6 +22,9 @@ class Rasterizer final { public: Rasterizer(blink::TaskRunners task_runners); + Rasterizer(blink::TaskRunners task_runners, + std::unique_ptr compositor_context); + ~Rasterizer(); void Setup(std::unique_ptr surface); @@ -62,7 +66,7 @@ class Rasterizer final { private: blink::TaskRunners task_runners_; std::unique_ptr surface_; - flow::CompositorContext compositor_context_; + std::unique_ptr compositor_context_; std::unique_ptr last_layer_tree_; fxl::Closure next_frame_callback_; fml::WeakPtrFactory weak_factory_; diff --git a/engine/src/flutter/vulkan/vulkan_swapchain.cc b/engine/src/flutter/vulkan/vulkan_swapchain.cc index 2eb6d6e1c7..c59c16620f 100644 --- a/engine/src/flutter/vulkan/vulkan_swapchain.cc +++ b/engine/src/flutter/vulkan/vulkan_swapchain.cc @@ -223,12 +223,12 @@ sk_sp VulkanSwapchain::CreateSkiaSurface( } const GrVkImageInfo image_info = { - image, // image - GrVkAlloc(), // alloc - VK_IMAGE_TILING_OPTIMAL, // tiling - VK_IMAGE_LAYOUT_UNDEFINED, // layout - surface_format_.format, // format - 1, // level count + image, // image + GrVkAlloc(), // alloc + VK_IMAGE_TILING_OPTIMAL, // tiling + VK_IMAGE_LAYOUT_UNDEFINED, // layout + surface_format_.format, // format + 1, // level count }; // TODO(chinmaygarde): Setup the stencil buffer and the sampleCnt. @@ -460,7 +460,7 @@ VulkanSwapchain::AcquireResult VulkanSwapchain::AcquireSurface() { FXL_DLOG(INFO) << "Could not access surface at the image index."; return error; } - + GrBackendRenderTarget backendRT = surface->getBackendRenderTarget( SkSurface::kFlushRead_BackendHandleAccess); if (!backendRT.isValid()) {