Chromium Code Reviews| Index: mojo/services/public/cpp/view_manager/lib/view.cc |
| diff --git a/mojo/services/public/cpp/view_manager/lib/view.cc b/mojo/services/public/cpp/view_manager/lib/view.cc |
| index 797e8d519e32795910a15f6c4232aa95adbdbe1f..b413eabe986a3da98f01f04c1e8e0b43f04c6a1a 100644 |
| --- a/mojo/services/public/cpp/view_manager/lib/view.cc |
| +++ b/mojo/services/public/cpp/view_manager/lib/view.cc |
| @@ -4,10 +4,15 @@ |
| #include "mojo/services/public/cpp/view_manager/view.h" |
| +#include "mojo/public/cpp/application/connect.h" |
| #include "mojo/public/cpp/application/service_provider_impl.h" |
| +#include "mojo/public/interfaces/application/shell.mojom.h" |
| +#include "mojo/services/public/cpp/view_manager/lib/bitmap_uploader.h" |
| #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" |
| #include "mojo/services/public/cpp/view_manager/lib/view_private.h" |
| #include "mojo/services/public/cpp/view_manager/view_observer.h" |
| +#include "mojo/services/public/interfaces/gpu/gpu.mojom.h" |
| +#include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" |
| #include "ui/gfx/canvas.h" |
| namespace mojo { |
| @@ -299,15 +304,20 @@ void View::SetSurfaceId(SurfaceIdPtr id) { |
| void View::SetContents(const SkBitmap& contents) { |
| if (manager_) { |
| - static_cast<ViewManagerClientImpl*>(manager_)->SetViewContents(id_, |
| - contents); |
| + if (!bitmap_uploader_) |
| + LocalCreateBitmapUploader(); |
| + bitmap_uploader_->SetSize(bounds_.size()); |
| + bitmap_uploader_->SetBitmap(contents); |
| } |
| } |
| void View::SetColor(SkColor color) { |
| - gfx::Canvas canvas(bounds_.size(), 1.0f, true); |
| - canvas.DrawColor(color); |
| - SetContents(skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(true)); |
| + if (manager_) { |
| + if (!bitmap_uploader_) |
| + LocalCreateBitmapUploader(); |
| + bitmap_uploader_->SetSize(bounds_.size()); |
| + bitmap_uploader_->SetColor(color); |
| + } |
| } |
| void View::SetFocus() { |
| @@ -390,4 +400,20 @@ void View::LocalSetBounds(const gfx::Rect& old_bounds, |
| bounds_ = new_bounds; |
| } |
| +void View::LocalCreateBitmapUploader() { |
|
Ben Goodger (Google)
2014/09/15 17:36:51
don't need the prefix "Local" ... that convention
|
| + ViewManagerClientImpl* vmci = static_cast<ViewManagerClientImpl*>(manager_); |
| + SurfacesServicePtr surfaces_service; |
| + InterfacePtr<ServiceProvider> surfaces_service_provider; |
| + vmci->shell()->ConnectToApplication("mojo:mojo_surfaces_service", |
| + Get(&surfaces_service_provider)); |
| + ConnectToService(surfaces_service_provider.get(), &surfaces_service); |
| + GpuPtr gpu_service; |
| + InterfacePtr<ServiceProvider> gpu_service_provider; |
| + vmci->shell()->ConnectToApplication("mojo:mojo_native_viewport_service", |
| + Get(&gpu_service_provider)); |
| + ConnectToService(gpu_service_provider.get(), &gpu_service); |
| + bitmap_uploader_.reset(new BitmapUploader( |
| + vmci, id_, surfaces_service.Pass(), gpu_service.Pass())); |
| +} |
| + |
| } // namespace mojo |