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

Unified 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 side-by-side diff with in-line comments
Download patch
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..c3bf63a750824e753ec5d2c36b6fb38b87b8d0bd 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_)
+ CreateBitmapUploader();
+ 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_)
+ CreateBitmapUploader();
+ 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::CreateBitmapUploader() {
+ 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

Powered by Google App Engine
This is Rietveld 408576698