| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "sky/shell/ui/engine.h" | 5 #include "sky/shell/ui/engine.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" | 
| 9 #include "mojo/public/cpp/application/connect.h" | 9 #include "mojo/public/cpp/application/connect.h" | 
| 10 #include "sky/engine/public/platform/WebInputEvent.h" | 10 #include "sky/engine/public/platform/WebInputEvent.h" | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 63 } | 63 } | 
| 64 | 64 | 
| 65 void Engine::BeginFrame(base::TimeTicks frame_time) { | 65 void Engine::BeginFrame(base::TimeTicks frame_time) { | 
| 66   TRACE_EVENT0("sky", "Engine::BeginFrame"); | 66   TRACE_EVENT0("sky", "Engine::BeginFrame"); | 
| 67 | 67 | 
| 68   double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF(); | 68   double frame_time_sec = (frame_time - base::TimeTicks()).InSecondsF(); | 
| 69   double deadline_sec = frame_time_sec; | 69   double deadline_sec = frame_time_sec; | 
| 70   double interval_sec = 1.0 / 60; | 70   double interval_sec = 1.0 / 60; | 
| 71   blink::WebBeginFrameArgs args(frame_time_sec, deadline_sec, interval_sec); | 71   blink::WebBeginFrameArgs args(frame_time_sec, deadline_sec, interval_sec); | 
| 72 | 72 | 
| 73   web_view_->beginFrame(args); | 73   if (web_view_) { | 
| 74   web_view_->layout(); | 74     web_view_->beginFrame(args); | 
|  | 75     web_view_->layout(); | 
|  | 76   } | 
| 75 } | 77 } | 
| 76 | 78 | 
| 77 skia::RefPtr<SkPicture> Engine::Paint() { | 79 skia::RefPtr<SkPicture> Engine::Paint() { | 
| 78   TRACE_EVENT0("sky", "Engine::Paint"); | 80   TRACE_EVENT0("sky", "Engine::Paint"); | 
| 79 | 81 | 
| 80   SkRTreeFactory factory; | 82   SkRTreeFactory factory; | 
| 81   SkPictureRecorder recorder; | 83   SkPictureRecorder recorder; | 
| 82   auto canvas = skia::SharePtr(recorder.beginRecording( | 84   auto canvas = skia::SharePtr(recorder.beginRecording( | 
| 83       physical_size_.width(), physical_size_.height(), &factory, | 85       physical_size_.width(), physical_size_.height(), &factory, | 
| 84       SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag)); | 86       SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag)); | 
| 85 | 87 | 
| 86   web_view_->paint(canvas.get(), blink::WebRect(gfx::Rect(physical_size_))); | 88   if (web_view_) | 
|  | 89     web_view_->paint(canvas.get(), blink::WebRect(gfx::Rect(physical_size_))); | 
|  | 90 | 
| 87   return skia::AdoptRef(recorder.endRecordingAsPicture()); | 91   return skia::AdoptRef(recorder.endRecordingAsPicture()); | 
| 88 } | 92 } | 
| 89 | 93 | 
| 90 void Engine::ConnectToViewportObserver( | 94 void Engine::ConnectToViewportObserver( | 
| 91     mojo::InterfaceRequest<ViewportObserver> request) { | 95     mojo::InterfaceRequest<ViewportObserver> request) { | 
| 92   viewport_observer_binding_.Bind(request.Pass()); | 96   viewport_observer_binding_.Bind(request.Pass()); | 
| 93 } | 97 } | 
| 94 | 98 | 
| 95 void Engine::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) { | 99 void Engine::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) { | 
| 96   config_.gpu_task_runner->PostTask( | 100   config_.gpu_task_runner->PostTask( | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 136 void Engine::OnInputEvent(InputEventPtr event) { | 140 void Engine::OnInputEvent(InputEventPtr event) { | 
| 137   TRACE_EVENT0("sky", "Engine::OnInputEvent"); | 141   TRACE_EVENT0("sky", "Engine::OnInputEvent"); | 
| 138   scoped_ptr<blink::WebInputEvent> web_event = | 142   scoped_ptr<blink::WebInputEvent> web_event = | 
| 139       ConvertEvent(event, device_pixel_ratio_); | 143       ConvertEvent(event, device_pixel_ratio_); | 
| 140   if (!web_event) | 144   if (!web_event) | 
| 141     return; | 145     return; | 
| 142   web_view_->handleInputEvent(*web_event); | 146   web_view_->handleInputEvent(*web_event); | 
| 143 } | 147 } | 
| 144 | 148 | 
| 145 void Engine::LoadURL(const mojo::String& url) { | 149 void Engine::LoadURL(const mojo::String& url) { | 
|  | 150   // Enable SkyView here. | 
|  | 151   if (false) { | 
|  | 152     sky_view_ = blink::SkyView::Create(); | 
|  | 153     sky_view_->Load(GURL(url)); | 
|  | 154     return; | 
|  | 155   } | 
|  | 156 | 
| 146   // Something bad happens if you try to call WebView::close and replace | 157   // Something bad happens if you try to call WebView::close and replace | 
| 147   // the webview.  So for now we just load into the existing one. :/ | 158   // the webview.  So for now we just load into the existing one. :/ | 
| 148   if (!web_view_) | 159   if (!web_view_) | 
| 149     web_view_ = blink::WebView::create(this); | 160     web_view_ = blink::WebView::create(this); | 
| 150   ConfigureSettings(web_view_->settings()); | 161   ConfigureSettings(web_view_->settings()); | 
| 151   web_view_->setMainFrame(blink::WebLocalFrame::create(this)); | 162   web_view_->setMainFrame(blink::WebLocalFrame::create(this)); | 
| 152   UpdateWebViewSize(); | 163   UpdateWebViewSize(); | 
| 153   web_view_->mainFrame()->load(GURL(url)); | 164   web_view_->mainFrame()->load(GURL(url)); | 
| 154 } | 165 } | 
| 155 | 166 | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 188 | 199 | 
| 189 void Engine::DidNavigateLocally(const mojo::String& url) { | 200 void Engine::DidNavigateLocally(const mojo::String& url) { | 
| 190 } | 201 } | 
| 191 | 202 | 
| 192 void Engine::RequestNavigateHistory(int32_t delta) { | 203 void Engine::RequestNavigateHistory(int32_t delta) { | 
| 193   NOTIMPLEMENTED(); | 204   NOTIMPLEMENTED(); | 
| 194 } | 205 } | 
| 195 | 206 | 
| 196 }  // namespace shell | 207 }  // namespace shell | 
| 197 }  // namespace sky | 208 }  // namespace sky | 
| OLD | NEW | 
|---|