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

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: 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 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 "ui/aura/window.h"
16 #include "ui/gfx/codec/png_codec.h"
17 15
18 namespace mojo { 16 namespace mojo {
19 namespace service { 17 namespace service {
20 18
21 ViewManagerServiceImpl::ViewManagerServiceImpl( 19 ViewManagerServiceImpl::ViewManagerServiceImpl(
22 ConnectionManager* connection_manager, 20 ConnectionManager* connection_manager,
23 ConnectionSpecificId creator_id, 21 ConnectionSpecificId creator_id,
24 const std::string& creator_url, 22 const std::string& creator_url,
25 const std::string& url, 23 const std::string& url,
26 const ViewId& root_id, 24 const ViewId& root_id,
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 const Callback<void(Array<ViewDataPtr>)>& callback) { 421 const Callback<void(Array<ViewDataPtr>)>& callback) {
424 ServerView* view = GetView(ViewIdFromTransportId(view_id)); 422 ServerView* view = GetView(ViewIdFromTransportId(view_id));
425 std::vector<const ServerView*> views; 423 std::vector<const ServerView*> views;
426 if (view) { 424 if (view) {
427 GetViewTreeImpl(view, &views); 425 GetViewTreeImpl(view, &views);
428 // TODO(sky): this should map in views that weren't none. 426 // TODO(sky): this should map in views that weren't none.
429 } 427 }
430 callback.Run(ViewsToViewDatas(views)); 428 callback.Run(ViewsToViewDatas(views));
431 } 429 }
432 430
433 void ViewManagerServiceImpl::SetViewContents( 431 void ViewManagerServiceImpl::SetViewSurfaceId(
434 Id view_id, 432 Id view_id,
435 ScopedSharedBufferHandle buffer, 433 SurfaceIdPtr surface_id,
436 uint32_t buffer_size,
437 const Callback<void(bool)>& callback) { 434 const Callback<void(bool)>& callback) {
438 // TODO(sky): add coverage of not being able to set for random view. 435 // TODO(sky): add coverage of not being able to set for random node.
439 ServerView* view = GetView(ViewIdFromTransportId(view_id)); 436 ServerView* view = GetView(ViewIdFromTransportId(view_id));
440 if (!view || !access_policy_->CanSetViewContents(view)) { 437 if (!view || !access_policy_->CanSetViewSurfaceId(view)) {
441 callback.Run(false); 438 callback.Run(false);
442 return; 439 return;
443 } 440 }
444 void* handle_data; 441 view->SetSurfaceId(surface_id.To<cc::SurfaceId>());
445 if (MapBuffer(buffer.get(), 0, buffer_size, &handle_data,
446 MOJO_MAP_BUFFER_FLAG_NONE) != MOJO_RESULT_OK) {
447 callback.Run(false);
448 return;
449 }
450 SkBitmap bitmap;
451 gfx::PNGCodec::Decode(static_cast<const unsigned char*>(handle_data),
452 buffer_size, &bitmap);
453 view->SetBitmap(bitmap);
454 UnmapBuffer(handle_data);
455 callback.Run(true); 442 callback.Run(true);
456 } 443 }
457 444
458 void ViewManagerServiceImpl::SetViewBounds( 445 void ViewManagerServiceImpl::SetViewBounds(
459 Id view_id, 446 Id view_id,
460 RectPtr bounds, 447 RectPtr bounds,
461 const Callback<void(bool)>& callback) { 448 const Callback<void(bool)>& callback) {
462 ServerView* view = GetView(ViewIdFromTransportId(view_id)); 449 ServerView* view = GetView(ViewIdFromTransportId(view_id));
463 const bool success = view && access_policy_->CanSetViewBounds(view); 450 const bool success = view && access_policy_->CanSetViewBounds(view);
464 if (success) { 451 if (success) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 555
569 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy( 556 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy(
570 const ServerView* view) const { 557 const ServerView* view) const {
571 ViewManagerServiceImpl* connection = 558 ViewManagerServiceImpl* connection =
572 connection_manager_->GetConnectionWithRoot(view->id()); 559 connection_manager_->GetConnectionWithRoot(view->id());
573 return connection && connection != this; 560 return connection && connection != this;
574 } 561 }
575 562
576 } // namespace service 563 } // namespace service
577 } // namespace mojo 564 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_service_impl.h ('k') | mojo/services/view_manager/window_manager_access_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698