| 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 ec4ec6125e49e64a32221d8882b6c50eecc8f67a..f724c83c1d7cd6e6e6adbc63233d649924624302 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/connect.h"
|
| #include "mojo/public/cpp/application/service_provider_impl.h"
|
| #include "mojo/public/interfaces/application/service_provider.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"
|
|
|
| @@ -124,7 +127,8 @@ ViewManagerClientImpl::ViewManagerClientImpl(
|
| connection_id_(0),
|
| next_id_(1),
|
| delegate_(delegate),
|
| - window_manager_delegate_(NULL) {
|
| + window_manager_delegate_(NULL),
|
| + app_connection_(app_connection) {
|
| // 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";
|
| @@ -198,26 +202,34 @@ 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;
|
| + app_connection_->ConnectToService("mojo:mojo_surfaces_service",
|
| + &surfaces_service);
|
| + GpuPtr gpu_service;
|
| + app_connection_->ConnectToService("mojo:mojo_native_viewport_service",
|
| + &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) {
|
|
|