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

Side by Side Diff: mojo/services/view_manager/view_manager_service_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: 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/view_manager/view_manager_service_impl.h" 5 #include "mojo/services/view_manager/view_manager_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" 8 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
9 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" 9 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
10 #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h"
10 #include "mojo/services/view_manager/connection_manager.h" 11 #include "mojo/services/view_manager/connection_manager.h"
11 #include "mojo/services/view_manager/default_access_policy.h" 12 #include "mojo/services/view_manager/default_access_policy.h"
12 #include "mojo/services/view_manager/server_view.h" 13 #include "mojo/services/view_manager/server_view.h"
13 #include "mojo/services/view_manager/window_manager_access_policy.h" 14 #include "mojo/services/view_manager/window_manager_access_policy.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
sky 2014/09/03 22:45:28 nit: remove
jamesr 2014/09/03 23:32:47 Done.
15 #include "ui/aura/window.h"
16 #include "ui/gfx/codec/png_codec.h" 16 #include "ui/gfx/codec/png_codec.h"
sky 2014/09/03 22:45:28 nit: remove.
jamesr 2014/09/03 23:32:47 Done.
17 17
18 namespace mojo { 18 namespace mojo {
19 namespace service { 19 namespace service {
20 20
21 ViewManagerServiceImpl::ViewManagerServiceImpl( 21 ViewManagerServiceImpl::ViewManagerServiceImpl(
22 ConnectionManager* connection_manager, 22 ConnectionManager* connection_manager,
23 ConnectionSpecificId creator_id, 23 ConnectionSpecificId creator_id,
24 const std::string& creator_url, 24 const std::string& creator_url,
25 const std::string& url, 25 const std::string& url,
26 const ViewId& root_id, 26 const ViewId& root_id,
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 const Callback<void(Array<ViewDataPtr>)>& callback) { 390 const Callback<void(Array<ViewDataPtr>)>& callback) {
391 ServerView* view = GetView(ViewIdFromTransportId(view_id)); 391 ServerView* view = GetView(ViewIdFromTransportId(view_id));
392 std::vector<const ServerView*> views; 392 std::vector<const ServerView*> views;
393 if (view) { 393 if (view) {
394 GetViewTreeImpl(view, &views); 394 GetViewTreeImpl(view, &views);
395 // TODO(sky): this should map in views that weren't none. 395 // TODO(sky): this should map in views that weren't none.
396 } 396 }
397 callback.Run(ViewsToViewDatas(views)); 397 callback.Run(ViewsToViewDatas(views));
398 } 398 }
399 399
400 void ViewManagerServiceImpl::SetViewContents( 400 void ViewManagerServiceImpl::SetViewSurfaceId(
401 Id view_id, 401 Id view_id,
402 ScopedSharedBufferHandle buffer, 402 SurfaceIdPtr surface_id,
403 uint32_t buffer_size,
404 const Callback<void(bool)>& callback) { 403 const Callback<void(bool)>& callback) {
405 // TODO(sky): add coverage of not being able to set for random view. 404 // TODO(sky): add coverage of not being able to set for random node.
406 ServerView* view = GetView(ViewIdFromTransportId(view_id)); 405 ServerView* view = GetView(ViewIdFromTransportId(view_id));
407 if (!view || !access_policy_->CanSetViewContents(view)) { 406 if (!view || !access_policy_->CanSetViewContents(view)) {
sky 2014/09/03 22:45:28 CanSetViewContents->CanSetViewSurfaceId
jamesr 2014/09/03 23:32:47 Done.
408 callback.Run(false); 407 callback.Run(false);
409 return; 408 return;
410 } 409 }
411 void* handle_data; 410 view->SetSurfaceId(surface_id.To<cc::SurfaceId>());
412 if (MapBuffer(buffer.get(), 0, buffer_size, &handle_data,
413 MOJO_MAP_BUFFER_FLAG_NONE) != MOJO_RESULT_OK) {
414 callback.Run(false);
415 return;
416 }
417 SkBitmap bitmap;
418 gfx::PNGCodec::Decode(static_cast<const unsigned char*>(handle_data),
419 buffer_size, &bitmap);
420 view->SetBitmap(bitmap);
421 UnmapBuffer(handle_data);
422 callback.Run(true); 411 callback.Run(true);
423 } 412 }
424 413
425 void ViewManagerServiceImpl::SetViewBounds( 414 void ViewManagerServiceImpl::SetViewBounds(
426 Id view_id, 415 Id view_id,
427 RectPtr bounds, 416 RectPtr bounds,
428 const Callback<void(bool)>& callback) { 417 const Callback<void(bool)>& callback) {
429 ServerView* view = GetView(ViewIdFromTransportId(view_id)); 418 ServerView* view = GetView(ViewIdFromTransportId(view_id));
430 const bool success = view && access_policy_->CanSetViewBounds(view); 419 const bool success = view && access_policy_->CanSetViewBounds(view);
431 if (success) { 420 if (success) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 530
542 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy( 531 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy(
543 const ServerView* view) const { 532 const ServerView* view) const {
544 ViewManagerServiceImpl* connection = 533 ViewManagerServiceImpl* connection =
545 connection_manager_->GetConnectionWithRoot(view->id()); 534 connection_manager_->GetConnectionWithRoot(view->id());
546 return connection && connection != this; 535 return connection && connection != this;
547 } 536 }
548 537
549 } // namespace service 538 } // namespace service
550 } // namespace mojo 539 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698