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

Unified Diff: mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc

Issue 534843002: Convert view manager to surfaces with uploading shim in client lib (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove overzealous shutdown check in cc/surfaces, add NON_EXPORTED_BASE for windows build, saturate… 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_manager_client_impl.cc
diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc b/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc
index 7df75a87c69f3d1b7a40b7b3968f4f0d0fb904e4..aaadf8aabf3e10ecf9352e277f6240da5de30db5 100644
--- a/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc
+++ b/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc
@@ -12,11 +12,14 @@
#include "mojo/public/cpp/application/service_provider_impl.h"
#include "mojo/public/interfaces/application/service_provider.mojom.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_private.h"
#include "mojo/services/public/cpp/view_manager/util.h"
#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
#include "mojo/services/public/cpp/view_manager/view_observer.h"
#include "mojo/services/public/cpp/view_manager/window_manager_delegate.h"
+#include "mojo/services/public/interfaces/gpu/gpu.mojom.h"
+#include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/codec/png_codec.h"
@@ -123,7 +126,8 @@ ViewManagerClientImpl::ViewManagerClientImpl(ViewManagerDelegate* delegate,
connection_id_(0),
next_id_(1),
delegate_(delegate),
- window_manager_delegate_(NULL) {
+ window_manager_delegate_(NULL),
+ shell_(shell) {
// TODO(beng): Come up with a better way of establishing a configuration for
// what the active window manager is.
std::string window_manager_url = "mojo:mojo_window_manager";
@@ -199,26 +203,38 @@ void ViewManagerClientImpl::SetBounds(Id view_id, const gfx::Rect& bounds) {
ActionCompletedCallback());
}
-void ViewManagerClientImpl::SetViewContents(Id view_id,
- const SkBitmap& contents) {
+void ViewManagerClientImpl::SetSurfaceId(Id view_id, SurfaceIdPtr surface_id) {
DCHECK(connected_);
- std::vector<unsigned char> data;
- gfx::PNGCodec::EncodeBGRASkBitmap(contents, false, &data);
-
- void* memory = NULL;
- ScopedSharedBufferHandle duped, shared_state_handle;
- bool result = CreateMapAndDupSharedBuffer(data.size(),
- &memory,
- &shared_state_handle,
- &duped);
- if (!result)
+ if (surface_id.is_null())
return;
+ service_->SetViewSurfaceId(
+ view_id, surface_id.Pass(), ActionCompletedCallback());
+}
- memcpy(memory, &data[0], data.size());
-
- service_->SetViewContents(view_id, duped.Pass(),
- static_cast<uint32_t>(data.size()),
- ActionCompletedCallback());
+void ViewManagerClientImpl::SetViewContents(Id view_id,
+ const SkBitmap& contents) {
+ DCHECK(connected_);
+ if (!bitmap_uploader_) {
+ SurfacesServicePtr surfaces_service;
+ InterfacePtr<ServiceProvider> surfaces_service_provider;
+ 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;
+ shell_->ConnectToApplication("mojo:mojo_native_viewport_service",
+ Get(&gpu_service_provider));
+ ConnectToService(gpu_service_provider.get(), &gpu_service);
+ bitmap_uploader_.reset(
+ new BitmapUploader(surfaces_service.Pass(), gpu_service.Pass()));
+ }
+ bitmap_uploader_->Upload(
+ contents,
+ base::Bind(&ViewManagerClientImpl::SetSurfaceId,
+ // We'll destroy the bitmap_uploader before we are destroyed,
+ // so we can use an unretained pointer here.
+ base::Unretained(this),
+ view_id));
}
void ViewManagerClientImpl::SetFocus(Id view_id) {
« no previous file with comments | « mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h ('k') | mojo/services/public/cpp/view_manager/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698