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

Side by Side Diff: mojo/services/view_manager/view_manager_connection.cc

Issue 267293004: Wires up view manager to an actual display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « mojo/services/view_manager/view_manager_connection.h ('k') | mojo/shell/context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_connection.h" 5 #include "mojo/services/view_manager/view_manager_connection.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "mojo/public/cpp/bindings/allocation_scope.h" 8 #include "mojo/public/cpp/bindings/allocation_scope.h"
9 #include "mojo/services/view_manager/node.h" 9 #include "mojo/services/view_manager/node.h"
10 #include "mojo/services/view_manager/root_node_manager.h" 10 #include "mojo/services/view_manager/root_node_manager.h"
11 #include "mojo/services/view_manager/view.h" 11 #include "mojo/services/view_manager/view.h"
12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "ui/gfx/codec/png_codec.h"
12 14
13 namespace mojo { 15 namespace mojo {
14 namespace services { 16 namespace services {
15 namespace view_manager { 17 namespace view_manager {
16 namespace { 18 namespace {
17 19
18 // Implementation of NodeCount(). |count| is the current count. 20 // Implementation of NodeCount(). |count| is the current count.
19 void NodeCountImpl(Node* node, size_t* count) { 21 void NodeCountImpl(Node* node, size_t* count) {
20 (*count)++; 22 (*count)++;
21 std::vector<Node*> children(node->GetChildren()); 23 std::vector<Node*> children(node->GetChildren());
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 void ViewManagerConnection::SetView( 266 void ViewManagerConnection::SetView(
265 TransportNodeId transport_node_id, 267 TransportNodeId transport_node_id,
266 TransportViewId transport_view_id, 268 TransportViewId transport_view_id,
267 TransportChangeId change_id, 269 TransportChangeId change_id,
268 const Callback<void(bool)>& callback) { 270 const Callback<void(bool)>& callback) {
269 const NodeId node_id(NodeIdFromTransportId(transport_node_id)); 271 const NodeId node_id(NodeIdFromTransportId(transport_node_id));
270 callback.Run(SetViewImpl(node_id, ViewIdFromTransportId(transport_view_id), 272 callback.Run(SetViewImpl(node_id, ViewIdFromTransportId(transport_view_id),
271 change_id)); 273 change_id));
272 } 274 }
273 275
276 void ViewManagerConnection::SetViewContents(
277 TransportViewId view_id,
278 ScopedSharedBufferHandle buffer,
279 uint32_t buffer_size) {
280 View* view = GetView(ViewIdFromTransportId(view_id));
281 if (!view)
282 return;
283 void* handle_data;
284 if (MapBuffer(buffer.get(), 0, buffer_size, &handle_data,
285 MOJO_MAP_BUFFER_FLAG_NONE) != MOJO_RESULT_OK) {
286 return;
287 }
288 SkBitmap bitmap;
289 gfx::PNGCodec::Decode(static_cast<const unsigned char*>(handle_data),
290 buffer_size, &bitmap);
291 view->SetBitmap(bitmap);
292 UnmapBuffer(handle_data);
293 }
294
274 void ViewManagerConnection::OnNodeHierarchyChanged(const NodeId& node, 295 void ViewManagerConnection::OnNodeHierarchyChanged(const NodeId& node,
275 const NodeId& new_parent, 296 const NodeId& new_parent,
276 const NodeId& old_parent) { 297 const NodeId& old_parent) {
277 context()->NotifyNodeHierarchyChanged(node, new_parent, old_parent); 298 context()->NotifyNodeHierarchyChanged(node, new_parent, old_parent);
278 } 299 }
279 300
280 void ViewManagerConnection::OnNodeViewReplaced(const NodeId& node, 301 void ViewManagerConnection::OnNodeViewReplaced(const NodeId& node,
281 const ViewId& new_view_id, 302 const ViewId& new_view_id,
282 const ViewId& old_view_id) { 303 const ViewId& old_view_id) {
283 context()->NotifyNodeViewReplaced(node, new_view_id, old_view_id); 304 context()->NotifyNodeViewReplaced(node, new_view_id, old_view_id);
284 } 305 }
285 306
286 } // namespace view_manager 307 } // namespace view_manager
287 } // namespace services 308 } // namespace services
288 } // namespace mojo 309 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_connection.h ('k') | mojo/shell/context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698