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

Side by Side Diff: sky/shell/ui/engine.cc

Issue 1134913003: Teach SkyView path to draw a circle (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « sky/shell/ui/engine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 skia::RefPtr<SkPicture> Engine::Paint() { 79 skia::RefPtr<SkPicture> Engine::Paint() {
80 TRACE_EVENT0("sky", "Engine::Paint"); 80 TRACE_EVENT0("sky", "Engine::Paint");
81 81
82 SkRTreeFactory factory; 82 SkRTreeFactory factory;
83 SkPictureRecorder recorder; 83 SkPictureRecorder recorder;
84 auto canvas = skia::SharePtr(recorder.beginRecording( 84 auto canvas = skia::SharePtr(recorder.beginRecording(
85 physical_size_.width(), physical_size_.height(), &factory, 85 physical_size_.width(), physical_size_.height(), &factory,
86 SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag)); 86 SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag));
87 87
88 if (sky_view_) {
89 skia::RefPtr<SkPicture> picture = sky_view_->Paint();
90 canvas->clear(SK_ColorBLACK);
91 if (picture)
92 canvas->drawPicture(picture.get());
93 }
94
88 if (web_view_) 95 if (web_view_)
89 web_view_->paint(canvas.get(), blink::WebRect(gfx::Rect(physical_size_))); 96 web_view_->paint(canvas.get(), blink::WebRect(gfx::Rect(physical_size_)));
90 97
91 return skia::AdoptRef(recorder.endRecordingAsPicture()); 98 return skia::AdoptRef(recorder.endRecordingAsPicture());
92 } 99 }
93 100
94 void Engine::ConnectToViewportObserver( 101 void Engine::ConnectToViewportObserver(
95 mojo::InterfaceRequest<ViewportObserver> request) { 102 mojo::InterfaceRequest<ViewportObserver> request) {
96 viewport_observer_binding_.Bind(request.Pass()); 103 viewport_observer_binding_.Bind(request.Pass());
97 } 104 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 scoped_ptr<blink::WebInputEvent> web_event = 149 scoped_ptr<blink::WebInputEvent> web_event =
143 ConvertEvent(event, device_pixel_ratio_); 150 ConvertEvent(event, device_pixel_ratio_);
144 if (!web_event) 151 if (!web_event)
145 return; 152 return;
146 web_view_->handleInputEvent(*web_event); 153 web_view_->handleInputEvent(*web_event);
147 } 154 }
148 155
149 void Engine::LoadURL(const mojo::String& url) { 156 void Engine::LoadURL(const mojo::String& url) {
150 // Enable SkyView here. 157 // Enable SkyView here.
151 if (false) { 158 if (false) {
152 sky_view_ = blink::SkyView::Create(); 159 sky_view_ = blink::SkyView::Create(this);
153 sky_view_->Load(GURL(url)); 160 sky_view_->Load(GURL(url));
154 return; 161 return;
155 } 162 }
156 163
157 // Something bad happens if you try to call WebView::close and replace 164 // Something bad happens if you try to call WebView::close and replace
158 // the webview. So for now we just load into the existing one. :/ 165 // the webview. So for now we just load into the existing one. :/
159 if (!web_view_) 166 if (!web_view_)
160 web_view_ = blink::WebView::create(this); 167 web_view_ = blink::WebView::create(this);
161 ConfigureSettings(web_view_->settings()); 168 ConfigureSettings(web_view_->settings());
162 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); 169 web_view_->setMainFrame(blink::WebLocalFrame::create(this));
(...skipping 12 matching lines...) Expand all
175 void Engine::scheduleVisualUpdate() { 182 void Engine::scheduleVisualUpdate() {
176 animator_->RequestFrame(); 183 animator_->RequestFrame();
177 } 184 }
178 185
179 void Engine::didCreateIsolate(blink::WebLocalFrame* frame, 186 void Engine::didCreateIsolate(blink::WebLocalFrame* frame,
180 Dart_Isolate isolate) { 187 Dart_Isolate isolate) {
181 Internals::Create(isolate, 188 Internals::Create(isolate,
182 CreateServiceProvider(config_.service_provider_context)); 189 CreateServiceProvider(config_.service_provider_context));
183 } 190 }
184 191
192 void Engine::SchedulePaint() {
193 animator_->RequestFrame();
194 }
195
185 blink::ServiceProvider* Engine::services() { 196 blink::ServiceProvider* Engine::services() {
186 return this; 197 return this;
187 } 198 }
188 199
189 mojo::NavigatorHost* Engine::NavigatorHost() { 200 mojo::NavigatorHost* Engine::NavigatorHost() {
190 return this; 201 return this;
191 } 202 }
192 203
193 void Engine::RequestNavigate(mojo::Target target, 204 void Engine::RequestNavigate(mojo::Target target,
194 mojo::URLRequestPtr request) { 205 mojo::URLRequestPtr request) {
195 // Ignoring target for now. 206 // Ignoring target for now.
196 base::MessageLoop::current()->PostTask(FROM_HERE, 207 base::MessageLoop::current()->PostTask(FROM_HERE,
197 base::Bind(&Engine::LoadURL, GetWeakPtr(), request->url)); 208 base::Bind(&Engine::LoadURL, GetWeakPtr(), request->url));
198 } 209 }
199 210
200 void Engine::DidNavigateLocally(const mojo::String& url) { 211 void Engine::DidNavigateLocally(const mojo::String& url) {
201 } 212 }
202 213
203 void Engine::RequestNavigateHistory(int32_t delta) { 214 void Engine::RequestNavigateHistory(int32_t delta) {
204 NOTIMPLEMENTED(); 215 NOTIMPLEMENTED();
205 } 216 }
206 217
207 } // namespace shell 218 } // namespace shell
208 } // namespace sky 219 } // namespace sky
OLDNEW
« no previous file with comments | « sky/shell/ui/engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698