Fixup Fuchsia content handler post shell refactor. (flutter/engine#5072)

This commit is contained in:
Chinmay Garde
2018-04-23 20:16:01 -07:00
committed by GitHub
parent 82678dc356
commit 7293d4cef9
8 changed files with 59 additions and 43 deletions

View File

@@ -26,6 +26,10 @@ class NativeLibrary : public fxl::RefCountedThreadSafe<NativeLibrary> {
static fxl::RefPtr<NativeLibrary> Create(const char* path);
static fxl::RefPtr<NativeLibrary> CreateWithHandle(
Handle handle,
bool close_handle_when_done);
static fxl::RefPtr<NativeLibrary> CreateForCurrentProcess();
const uint8_t* ResolveSymbol(const char* symbol);

View File

@@ -45,6 +45,14 @@ fxl::RefPtr<NativeLibrary> NativeLibrary::Create(const char* path) {
return library->GetHandle() != nullptr ? library : nullptr;
}
fxl::RefPtr<NativeLibrary> 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> NativeLibrary::CreateForCurrentProcess() {
return fxl::AdoptRef(new NativeLibrary(RTLD_DEFAULT, false));
}

View File

@@ -37,6 +37,14 @@ fxl::RefPtr<NativeLibrary> NativeLibrary::Create(const char* path) {
return library->GetHandle() != nullptr ? library : nullptr;
}
fxl::RefPtr<NativeLibrary> 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> NativeLibrary::CreateForCurrentProcess() {
return fxl::AdoptRef(new NativeLibrary(::GetModuleHandle(nullptr), false));
}

View File

@@ -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",
]
}

View File

@@ -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"

View File

@@ -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<flow::CompositorContext>()) {}
Rasterizer::Rasterizer(
blink::TaskRunners task_runners,
std::unique_ptr<flow::CompositorContext> 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> Rasterizer::GetWeakPtr() const {
void Rasterizer::Setup(std::unique_ptr<Surface> 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);

View File

@@ -8,6 +8,7 @@
#include <memory>
#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<flow::CompositorContext> compositor_context);
~Rasterizer();
void Setup(std::unique_ptr<Surface> surface);
@@ -62,7 +66,7 @@ class Rasterizer final {
private:
blink::TaskRunners task_runners_;
std::unique_ptr<Surface> surface_;
flow::CompositorContext compositor_context_;
std::unique_ptr<flow::CompositorContext> compositor_context_;
std::unique_ptr<flow::LayerTree> last_layer_tree_;
fxl::Closure next_frame_callback_;
fml::WeakPtrFactory<Rasterizer> weak_factory_;

View File

@@ -223,12 +223,12 @@ sk_sp<SkSurface> 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()) {