Index: sky/shell/ui/engine.cc |
diff --git a/sky/shell/ui/engine.cc b/sky/shell/ui/engine.cc |
index 07deb847c24e59da3022b478b6b4f12c87ab4044..dd3e318153bd7b71e418807750eb6b7c5394d43a 100644 |
--- a/sky/shell/ui/engine.cc |
+++ b/sky/shell/ui/engine.cc |
@@ -4,15 +4,22 @@ |
#include "sky/shell/ui/engine.h" |
+#include "base/bind.h" |
#include "sky/engine/public/web/Sky.h" |
#include "sky/engine/public/web/WebLocalFrame.h" |
#include "sky/engine/public/web/WebView.h" |
+#include "sky/shell/ui/animator.h" |
#include "sky/shell/ui/platform_impl.h" |
+#include "third_party/skia/include/core/SkCanvas.h" |
+#include "third_party/skia/include/core/SkPictureRecorder.h" |
namespace sky { |
namespace shell { |
-Engine::Engine() : web_view_(nullptr), weak_factory_(this) { |
+Engine::Engine(const Config& config) |
+ : animator_(new Animator(config, this)), |
+ web_view_(nullptr), |
+ weak_factory_(this) { |
} |
Engine::~Engine() { |
@@ -24,20 +31,54 @@ base::WeakPtr<Engine> Engine::GetWeakPtr() { |
return weak_factory_.GetWeakPtr(); |
} |
-void Engine::Init() { |
- platform_impl_.reset(new PlatformImpl); |
+void Engine::Init(mojo::ScopedMessagePipeHandle service_provider) { |
+ platform_impl_.reset(new PlatformImpl(mojo::MakeProxy<mojo::ServiceProvider>( |
+ service_provider.Pass()))); |
blink::initialize(platform_impl_.get()); |
web_view_ = blink::WebView::create(this); |
web_view_->setMainFrame(blink::WebLocalFrame::create(this)); |
+ web_view_->mainFrame()->load( |
+ GURL("http://127.0.0.1:8000/sky/examples/spinning-square.sky")); |
} |
-void Engine::OnViewportMetricsChanged(const gfx::Size& size, |
+void Engine::BeginFrame(base::TimeTicks frame_time) { |
+ double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF(); |
+ double deadline_sec = frame_time_sec; |
+ double interval_sec = 1.0 / 60; |
+ blink::WebBeginFrameArgs args(frame_time_sec, deadline_sec, interval_sec); |
+ |
+ web_view_->beginFrame(args); |
+ web_view_->layout(); |
+} |
+ |
+skia::RefPtr<SkPicture> Engine::Paint() { |
+ SkRTreeFactory factory; |
+ SkPictureRecorder recorder; |
+ auto canvas = skia::SharePtr(recorder.beginRecording( |
+ physical_size_.width(), physical_size_.height(), &factory, |
+ SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag)); |
+ |
+ web_view_->paint(canvas.get(), blink::WebRect(0, 0, physical_size_.width(), |
eseidel
2015/02/18 20:55:57
blink::WebRect(gfx::Rect(physical_size))
|
+ physical_size_.height())); |
+ |
+ return skia::AdoptRef(recorder.endRecordingAsPicture()); |
+} |
+ |
+void Engine::OnViewportMetricsChanged(const gfx::Size& physical_size, |
float device_pixel_ratio) { |
- blink::WebSize web_size(size.width() / device_pixel_ratio, |
- size.height() / device_pixel_ratio); |
+ physical_size_ = physical_size; |
web_view_->setDeviceScaleFactor(device_pixel_ratio); |
- web_view_->resize(web_size); |
+ web_view_->resize( |
eseidel
2015/02/18 20:55:57
blink::WebSize(gfx::ScaleSize(physical_size, 1 / d
|
+ blink::WebSize(physical_size.width() / device_pixel_ratio, |
+ physical_size.height() / device_pixel_ratio)); |
+} |
+ |
+void Engine::initializeLayerTreeView() { |
+} |
+ |
+void Engine::scheduleVisualUpdate() { |
+ animator_->RequestFrame(); |
} |
} // namespace shell |