From 44c10c9f6b3d6a2571f2750e9fa2fe04187478f9 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Tue, 19 May 2015 13:51:12 -0700 Subject: [PATCH] Teach SkyView code path to print hello, world This CL makes the SkyView codepath smart enough to print "hello, world" to the console. The code path is off by default but can be enabled by changing one line of code. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1131673011 --- engine/src/flutter/shell/ui/engine.cc | 17 ++++++++++++++--- engine/src/flutter/shell/ui/engine.h | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/shell/ui/engine.cc b/engine/src/flutter/shell/ui/engine.cc index c0e464e319..058682ded1 100644 --- a/engine/src/flutter/shell/ui/engine.cc +++ b/engine/src/flutter/shell/ui/engine.cc @@ -70,8 +70,10 @@ void Engine::BeginFrame(base::TimeTicks frame_time) { double interval_sec = 1.0 / 60; blink::WebBeginFrameArgs args(frame_time_sec, deadline_sec, interval_sec); - web_view_->beginFrame(args); - web_view_->layout(); + if (web_view_) { + web_view_->beginFrame(args); + web_view_->layout(); + } } skia::RefPtr Engine::Paint() { @@ -83,7 +85,9 @@ skia::RefPtr Engine::Paint() { physical_size_.width(), physical_size_.height(), &factory, SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag)); - web_view_->paint(canvas.get(), blink::WebRect(gfx::Rect(physical_size_))); + if (web_view_) + web_view_->paint(canvas.get(), blink::WebRect(gfx::Rect(physical_size_))); + return skia::AdoptRef(recorder.endRecordingAsPicture()); } @@ -143,6 +147,13 @@ void Engine::OnInputEvent(InputEventPtr event) { } void Engine::LoadURL(const mojo::String& url) { + // Enable SkyView here. + if (false) { + sky_view_ = blink::SkyView::Create(); + sky_view_->Load(GURL(url)); + return; + } + // Something bad happens if you try to call WebView::close and replace // the webview. So for now we just load into the existing one. :/ if (!web_view_) diff --git a/engine/src/flutter/shell/ui/engine.h b/engine/src/flutter/shell/ui/engine.h index 97f485b7c3..e10781a21e 100644 --- a/engine/src/flutter/shell/ui/engine.h +++ b/engine/src/flutter/shell/ui/engine.h @@ -15,6 +15,7 @@ #include "mojo/services/navigation/public/interfaces/navigation.mojom.h" #include "skia/ext/refptr.h" #include "sky/engine/public/platform/ServiceProvider.h" +#include "sky/engine/public/sky/sky_view.h" #include "sky/engine/public/web/WebFrameClient.h" #include "sky/engine/public/web/WebViewClient.h" #include "sky/shell/gpu_delegate.h" @@ -89,7 +90,10 @@ class Engine : public UIDelegate, mojo::ServiceProviderPtr service_provider_; scoped_ptr platform_impl_; scoped_ptr animator_; + + std::unique_ptr sky_view_; blink::WebView* web_view_; + float device_pixel_ratio_; gfx::Size physical_size_; mojo::Binding viewport_observer_binding_;