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

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

Issue 275853002: Revert of Wires up view manager to an actual display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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"
14 12
15 namespace mojo { 13 namespace mojo {
16 namespace services { 14 namespace services {
17 namespace view_manager { 15 namespace view_manager {
18 namespace { 16 namespace {
19 17
20 // Implementation of NodeCount(). |count| is the current count. 18 // Implementation of NodeCount(). |count| is the current count.
21 void NodeCountImpl(Node* node, size_t* count) { 19 void NodeCountImpl(Node* node, size_t* count) {
22 (*count)++; 20 (*count)++;
23 std::vector<Node*> children(node->GetChildren()); 21 std::vector<Node*> children(node->GetChildren());
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 void ViewManagerConnection::SetView( 264 void ViewManagerConnection::SetView(
267 TransportNodeId transport_node_id, 265 TransportNodeId transport_node_id,
268 TransportViewId transport_view_id, 266 TransportViewId transport_view_id,
269 TransportChangeId change_id, 267 TransportChangeId change_id,
270 const Callback<void(bool)>& callback) { 268 const Callback<void(bool)>& callback) {
271 const NodeId node_id(NodeIdFromTransportId(transport_node_id)); 269 const NodeId node_id(NodeIdFromTransportId(transport_node_id));
272 callback.Run(SetViewImpl(node_id, ViewIdFromTransportId(transport_view_id), 270 callback.Run(SetViewImpl(node_id, ViewIdFromTransportId(transport_view_id),
273 change_id)); 271 change_id));
274 } 272 }
275 273
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
295 void ViewManagerConnection::OnNodeHierarchyChanged(const NodeId& node, 274 void ViewManagerConnection::OnNodeHierarchyChanged(const NodeId& node,
296 const NodeId& new_parent, 275 const NodeId& new_parent,
297 const NodeId& old_parent) { 276 const NodeId& old_parent) {
298 context()->NotifyNodeHierarchyChanged(node, new_parent, old_parent); 277 context()->NotifyNodeHierarchyChanged(node, new_parent, old_parent);
299 } 278 }
300 279
301 void ViewManagerConnection::OnNodeViewReplaced(const NodeId& node, 280 void ViewManagerConnection::OnNodeViewReplaced(const NodeId& node,
302 const ViewId& new_view_id, 281 const ViewId& new_view_id,
303 const ViewId& old_view_id) { 282 const ViewId& old_view_id) {
304 context()->NotifyNodeViewReplaced(node, new_view_id, old_view_id); 283 context()->NotifyNodeViewReplaced(node, new_view_id, old_view_id);
305 } 284 }
306 285
307 } // namespace view_manager 286 } // namespace view_manager
308 } // namespace services 287 } // namespace services
309 } // namespace mojo 288 } // 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