mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
@@ -47,6 +47,7 @@ mojo_native_application("sky") {
|
||||
"//mojo/services/surfaces/public/interfaces",
|
||||
"//mojo/services/view_manager/public/cpp",
|
||||
"//mojo/services/view_manager/public/interfaces",
|
||||
"//services/asset_bundle:lib",
|
||||
"//services/sky/compositor",
|
||||
"//skia",
|
||||
"//sky/engine/public/sky",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/location.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/thread_task_runner_handle.h"
|
||||
@@ -17,6 +18,7 @@
|
||||
#include "mojo/services/view_manager/public/cpp/view.h"
|
||||
#include "mojo/services/view_manager/public/cpp/view_manager.h"
|
||||
#include "mojo/services/view_manager/public/interfaces/view_manager.mojom.h"
|
||||
#include "services/asset_bundle/asset_unpacker_job.h"
|
||||
#include "services/sky/compositor/layer.h"
|
||||
#include "services/sky/compositor/layer_host.h"
|
||||
#include "services/sky/compositor/rasterizer_bitmap.h"
|
||||
@@ -34,9 +36,13 @@
|
||||
#include "third_party/skia/include/core/SkDevice.h"
|
||||
#include "ui/events/gestures/gesture_recognizer.h"
|
||||
|
||||
using mojo::asset_bundle::AssetUnpackerJob;
|
||||
|
||||
namespace sky {
|
||||
namespace {
|
||||
|
||||
const char kSnapshotKey[] = "snapshot_blob.bin";
|
||||
|
||||
ui::EventType ConvertEventTypeToUIEventType(blink::WebInputEvent::Type type) {
|
||||
if (type == blink::WebInputEvent::PointerDown)
|
||||
return ui::ET_TOUCH_PRESSED;
|
||||
@@ -133,17 +139,34 @@ void DocumentView::OnEmbed(
|
||||
void DocumentView::OnViewManagerDisconnected(mojo::ViewManager* view_manager) {
|
||||
// TODO(aa): Need to figure out how shutdown works.
|
||||
}
|
||||
|
||||
void DocumentView::LoadFromSnapshotStream(
|
||||
String name, mojo::ScopedDataPipeConsumerHandle snapshot) {
|
||||
if (sky_view_)
|
||||
sky_view_->RunFromSnapshot(name, snapshot.Pass());
|
||||
}
|
||||
|
||||
void DocumentView::Load(mojo::URLResponsePtr response) {
|
||||
String name = String::fromUTF8(response->url);
|
||||
library_provider_.reset(new DartLibraryProviderImpl(
|
||||
network_service_.get(),
|
||||
CreatePrefetchedLibraryIfNeeded(name, response.Pass())));
|
||||
sky_view_ = blink::SkyView::Create(this);
|
||||
layer_host_.reset(new LayerHost(this));
|
||||
root_layer_ = make_scoped_refptr(new Layer(this));
|
||||
root_layer_->set_rasterizer(CreateRasterizer());
|
||||
layer_host_->SetRootLayer(root_layer_);
|
||||
|
||||
String name = String::fromUTF8(response->url);
|
||||
if (name.endsWith(".skyx")) {
|
||||
AssetUnpackerJob* unpacker = new AssetUnpackerJob(
|
||||
mojo::GetProxy(&root_bundle_),
|
||||
base::MessageLoop::current()->task_runner());
|
||||
unpacker->Unpack(response->body.Pass());
|
||||
root_bundle_->GetAsStream(kSnapshotKey,
|
||||
base::Bind(&DocumentView::LoadFromSnapshotStream,
|
||||
weak_factory_.GetWeakPtr(), name));
|
||||
return;
|
||||
}
|
||||
library_provider_.reset(new DartLibraryProviderImpl(
|
||||
network_service_.get(),
|
||||
CreatePrefetchedLibraryIfNeeded(name, response.Pass())));
|
||||
sky_view_->RunFromLibrary(name, library_provider_.get());
|
||||
}
|
||||
|
||||
@@ -163,6 +186,10 @@ void DocumentView::GetPixelsForTesting(std::vector<unsigned char>* pixels) {
|
||||
return bitmap_rasterizer_->GetPixelsForTesting(pixels);
|
||||
}
|
||||
|
||||
mojo::ScopedMessagePipeHandle DocumentView::TakeRootBundleHandle() {
|
||||
return root_bundle_.PassInterface().PassHandle();
|
||||
}
|
||||
|
||||
mojo::ScopedMessagePipeHandle DocumentView::TakeServicesProvidedToEmbedder() {
|
||||
return services_provided_to_embedder_.PassMessagePipe();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "mojo/public/cpp/application/service_provider_impl.h"
|
||||
#include "mojo/public/cpp/bindings/strong_binding.h"
|
||||
#include "mojo/public/interfaces/application/application.mojom.h"
|
||||
#include "mojo/services/asset_bundle/public/interfaces/asset_bundle.mojom.h"
|
||||
#include "mojo/services/content_handler/public/interfaces/content_handler.mojom.h"
|
||||
#include "mojo/services/navigation/public/interfaces/navigation.mojom.h"
|
||||
#include "mojo/services/network/public/interfaces/network_service.mojom.h"
|
||||
@@ -70,6 +71,7 @@ class DocumentView : public blink::ServiceProvider,
|
||||
|
||||
void GetPixelsForTesting(std::vector<unsigned char>* pixels);
|
||||
|
||||
mojo::ScopedMessagePipeHandle TakeRootBundleHandle();
|
||||
mojo::ScopedMessagePipeHandle TakeServicesProvidedToEmbedder();
|
||||
mojo::ScopedMessagePipeHandle TakeServicesProvidedByEmbedder();
|
||||
mojo::ScopedMessagePipeHandle TakeServiceRegistry();
|
||||
@@ -104,6 +106,9 @@ class DocumentView : public blink::ServiceProvider,
|
||||
float GetDevicePixelRatio() const;
|
||||
scoped_ptr<Rasterizer> CreateRasterizer();
|
||||
|
||||
void LoadFromSnapshotStream(String name,
|
||||
mojo::ScopedDataPipeConsumerHandle snapshot);
|
||||
|
||||
void UpdateRootSizeAndViewportMetrics(const mojo::Rect& new_bounds);
|
||||
|
||||
void InitServiceRegistry();
|
||||
@@ -115,6 +120,7 @@ class DocumentView : public blink::ServiceProvider,
|
||||
mojo::ServiceProviderPtr services_provided_by_embedder_;
|
||||
mojo::NetworkServicePtr network_service_;
|
||||
mojo::Shell* shell_;
|
||||
mojo::asset_bundle::AssetBundlePtr root_bundle_;
|
||||
mojo::NavigatorHostPtr navigator_host_;
|
||||
std::unique_ptr<blink::SkyView> sky_view_;
|
||||
mojo::View* root_;
|
||||
|
||||
@@ -31,7 +31,8 @@ void NotifyTestComplete(Dart_NativeArguments args) {
|
||||
}
|
||||
|
||||
void TakeRootBundleHandle(Dart_NativeArguments args) {
|
||||
Dart_SetIntegerReturnValue(args, 0);
|
||||
Dart_SetIntegerReturnValue(args,
|
||||
GetInternals()->TakeRootBundleHandle().value());
|
||||
}
|
||||
|
||||
void TakeShellProxyHandle(Dart_NativeArguments args) {
|
||||
@@ -100,6 +101,12 @@ Internals::Internals(DocumentView* document_view)
|
||||
Internals::~Internals() {
|
||||
}
|
||||
|
||||
mojo::Handle Internals::TakeRootBundleHandle() {
|
||||
if (!document_view_)
|
||||
return mojo::Handle();
|
||||
return document_view_->TakeRootBundleHandle().release();
|
||||
}
|
||||
|
||||
mojo::Handle Internals::TakeServicesProvidedToEmbedder() {
|
||||
if (!document_view_)
|
||||
return mojo::Handle();
|
||||
|
||||
@@ -28,6 +28,7 @@ class Internals : public base::SupportsUserData::Data,
|
||||
mojo::ServiceProviderPtr exposed_services) override;
|
||||
|
||||
mojo::Handle TakeShellProxyHandle();
|
||||
mojo::Handle TakeRootBundleHandle();
|
||||
mojo::Handle TakeServicesProvidedToEmbedder();
|
||||
mojo::Handle TakeServicesProvidedByEmbedder();
|
||||
mojo::Handle TakeServiceRegistry();
|
||||
|
||||
@@ -30,11 +30,10 @@
|
||||
|
||||
namespace sky {
|
||||
namespace shell {
|
||||
namespace {
|
||||
|
||||
const char kSnapshotKey[] = "snapshot_blob.bin";
|
||||
|
||||
namespace {
|
||||
|
||||
void Ignored(bool) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user