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

Side by Side Diff: mojo/services/public/cpp/view_manager/lib/view.cc

Issue 555953007: Fixes for surfaces bindings exposed by wm_flow app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/services/public/cpp/view_manager/view.h" 5 #include "mojo/services/public/cpp/view_manager/view.h"
6 6
7 #include "mojo/public/cpp/application/connect.h"
7 #include "mojo/public/cpp/application/service_provider_impl.h" 8 #include "mojo/public/cpp/application/service_provider_impl.h"
9 #include "mojo/public/interfaces/application/shell.mojom.h"
10 #include "mojo/services/public/cpp/view_manager/lib/bitmap_uploader.h"
8 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" 11 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h"
9 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" 12 #include "mojo/services/public/cpp/view_manager/lib/view_private.h"
10 #include "mojo/services/public/cpp/view_manager/view_observer.h" 13 #include "mojo/services/public/cpp/view_manager/view_observer.h"
14 #include "mojo/services/public/interfaces/gpu/gpu.mojom.h"
15 #include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h"
11 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
12 17
13 namespace mojo { 18 namespace mojo {
14 19
15 namespace { 20 namespace {
16 21
17 void NotifyViewTreeChangeAtReceiver( 22 void NotifyViewTreeChangeAtReceiver(
18 View* receiver, 23 View* receiver,
19 const ViewObserver::TreeChangeParams& params, 24 const ViewObserver::TreeChangeParams& params,
20 bool change_applied) { 25 bool change_applied) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 297 }
293 298
294 void View::SetSurfaceId(SurfaceIdPtr id) { 299 void View::SetSurfaceId(SurfaceIdPtr id) {
295 if (manager_) { 300 if (manager_) {
296 static_cast<ViewManagerClientImpl*>(manager_)->SetSurfaceId(id_, id.Pass()); 301 static_cast<ViewManagerClientImpl*>(manager_)->SetSurfaceId(id_, id.Pass());
297 } 302 }
298 } 303 }
299 304
300 void View::SetContents(const SkBitmap& contents) { 305 void View::SetContents(const SkBitmap& contents) {
301 if (manager_) { 306 if (manager_) {
302 static_cast<ViewManagerClientImpl*>(manager_)->SetViewContents(id_, 307 if (!bitmap_uploader_)
303 contents); 308 CreateBitmapUploader();
309 bitmap_uploader_->SetSize(bounds_.size());
310 bitmap_uploader_->SetBitmap(contents);
304 } 311 }
305 } 312 }
306 313
307 void View::SetColor(SkColor color) { 314 void View::SetColor(SkColor color) {
308 gfx::Canvas canvas(bounds_.size(), 1.0f, true); 315 if (manager_) {
309 canvas.DrawColor(color); 316 if (!bitmap_uploader_)
310 SetContents(skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(true)); 317 CreateBitmapUploader();
318 bitmap_uploader_->SetSize(bounds_.size());
319 bitmap_uploader_->SetColor(color);
320 }
311 } 321 }
312 322
313 void View::SetFocus() { 323 void View::SetFocus() {
314 if (manager_) 324 if (manager_)
315 static_cast<ViewManagerClientImpl*>(manager_)->SetFocus(id_); 325 static_cast<ViewManagerClientImpl*>(manager_)->SetFocus(id_);
316 } 326 }
317 327
318 void View::Embed(const String& url) { 328 void View::Embed(const String& url) {
319 static_cast<ViewManagerClientImpl*>(manager_)->Embed(url, id_); 329 static_cast<ViewManagerClientImpl*>(manager_)->Embed(url, id_);
320 } 330 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 return ReorderImpl(&parent_->children_, this, relative, direction); 393 return ReorderImpl(&parent_->children_, this, relative, direction);
384 } 394 }
385 395
386 void View::LocalSetBounds(const gfx::Rect& old_bounds, 396 void View::LocalSetBounds(const gfx::Rect& old_bounds,
387 const gfx::Rect& new_bounds) { 397 const gfx::Rect& new_bounds) {
388 DCHECK(old_bounds == bounds_); 398 DCHECK(old_bounds == bounds_);
389 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); 399 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds);
390 bounds_ = new_bounds; 400 bounds_ = new_bounds;
391 } 401 }
392 402
403 void View::CreateBitmapUploader() {
404 ViewManagerClientImpl* vmci = static_cast<ViewManagerClientImpl*>(manager_);
405 SurfacesServicePtr surfaces_service;
406 InterfacePtr<ServiceProvider> surfaces_service_provider;
407 vmci->shell()->ConnectToApplication("mojo:mojo_surfaces_service",
408 Get(&surfaces_service_provider));
409 ConnectToService(surfaces_service_provider.get(), &surfaces_service);
410 GpuPtr gpu_service;
411 InterfacePtr<ServiceProvider> gpu_service_provider;
412 vmci->shell()->ConnectToApplication("mojo:mojo_native_viewport_service",
413 Get(&gpu_service_provider));
414 ConnectToService(gpu_service_provider.get(), &gpu_service);
415 bitmap_uploader_.reset(new BitmapUploader(
416 vmci, id_, surfaces_service.Pass(), gpu_service.Pass()));
417 }
418
393 } // namespace mojo 419 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698