Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2347)

Unified Diff: sky/shell/ui/engine.cc

Issue 932283002: Port touch-demo.sky to Dart and make it work in SkyShell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/shell/ui/engine.cc
diff --git a/sky/shell/ui/engine.cc b/sky/shell/ui/engine.cc
index b316c4cfed2fdb0d8ac5fe95bc577df6b9b1caa2..5b1e6da613a8047cb96398f3df8e68da43d937c7 100644
--- a/sky/shell/ui/engine.cc
+++ b/sky/shell/ui/engine.cc
@@ -5,10 +5,12 @@
#include "sky/shell/ui/engine.h"
#include "base/bind.h"
+#include "sky/engine/public/platform/WebInputEvent.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/input_event_converter.h"
#include "sky/shell/ui/platform_impl.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
@@ -19,6 +21,8 @@ namespace shell {
Engine::Engine(const Config& config)
: animator_(new Animator(config, this)),
web_view_(nullptr),
+ device_pixel_ratio_(1.0f),
+ viewport_observer_binding_(this),
weak_factory_(this) {
}
@@ -39,7 +43,7 @@ void Engine::Init(mojo::ScopedMessagePipeHandle service_provider) {
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"));
+ GURL("http://domokit.github.io/sky/examples/spinning-square.sky"));
}
void Engine::BeginFrame(base::TimeTicks frame_time) {
@@ -63,16 +67,30 @@ skia::RefPtr<SkPicture> Engine::Paint() {
return skia::AdoptRef(recorder.endRecordingAsPicture());
}
-void Engine::OnViewportMetricsChanged(const gfx::Size& physical_size,
+void Engine::ConnectToViewportObserver(
+ mojo::InterfaceRequest<ViewportObserver> request) {
+ viewport_observer_binding_.Bind(request.Pass());
+}
+
+void Engine::OnViewportMetricsChanged(int width, int height,
float device_pixel_ratio) {
- physical_size_ = physical_size;
+ physical_size_.SetSize(width, height);
+ device_pixel_ratio_ = device_pixel_ratio;
web_view_->setDeviceScaleFactor(device_pixel_ratio);
- gfx::SizeF size = gfx::ScaleSize(physical_size, 1 / device_pixel_ratio);
+ gfx::SizeF size = gfx::ScaleSize(physical_size_, 1 / device_pixel_ratio);
// FIXME: We should be able to set the size of the WebView in floating point
// because its in logical pixels.
web_view_->resize(blink::WebSize(size.width(), size.height()));
}
+void Engine::OnInputEvent(InputEventPtr event) {
+ scoped_ptr<blink::WebInputEvent> web_event =
+ ConvertEvent(event, device_pixel_ratio_);
+ if (!web_event)
+ return;
+ web_view_->handleInputEvent(*web_event);
+}
+
void Engine::initializeLayerTreeView() {
}

Powered by Google App Engine
This is Rietveld 408576698