OLD | NEW |
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/public/cpp/view_manager/lib/view_manager_synchronizer.h" | 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "mojo/public/cpp/application/connect.h" | 9 #include "mojo/public/cpp/application/connect.h" |
10 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 10 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
11 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" | 11 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" |
12 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" | 12 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" |
13 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h" | 13 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h" |
14 #include "mojo/services/public/cpp/view_manager/util.h" | 14 #include "mojo/services/public/cpp/view_manager/util.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "ui/gfx/codec/png_codec.h" | 16 #include "ui/gfx/codec/png_codec.h" |
17 | 17 |
18 namespace mojo { | 18 namespace mojo { |
19 namespace view_manager { | 19 namespace view_manager { |
20 | 20 |
21 uint32_t MakeTransportId(uint16_t connection_id, uint16_t local_id) { | 21 uint32_t MakeTransportId(uint16_t connection_id, uint16_t local_id) { |
22 return (connection_id << 16) | local_id; | 22 return (connection_id << 16) | local_id; |
23 } | 23 } |
24 | 24 |
25 // Helper called to construct a local node/view object from transport data. | 25 // Helper called to construct a local node/view object from transport data. |
26 ViewTreeNode* AddNodeToViewManager(ViewManager* manager, | 26 ViewTreeNode* AddNodeToViewManager(ViewManager* manager, |
27 ViewTreeNode* parent, | 27 ViewTreeNode* parent, |
28 TransportNodeId node_id, | 28 TransportNodeId node_id, |
29 TransportViewId view_id) { | 29 TransportViewId view_id, |
| 30 const gfx::Rect& bounds) { |
30 // We don't use the ctor that takes a ViewManager here, since it will call | 31 // We don't use the ctor that takes a ViewManager here, since it will call |
31 // back to the service and attempt to create a new node. | 32 // back to the service and attempt to create a new node. |
32 ViewTreeNode* node = ViewTreeNodePrivate::LocalCreate(); | 33 ViewTreeNode* node = ViewTreeNodePrivate::LocalCreate(); |
33 ViewTreeNodePrivate private_node(node); | 34 ViewTreeNodePrivate private_node(node); |
34 private_node.set_view_manager(manager); | 35 private_node.set_view_manager(manager); |
35 private_node.set_id(node_id); | 36 private_node.set_id(node_id); |
| 37 private_node.LocalSetBounds(gfx::Rect(), bounds); |
36 if (parent) | 38 if (parent) |
37 ViewTreeNodePrivate(parent).LocalAddChild(node); | 39 ViewTreeNodePrivate(parent).LocalAddChild(node); |
38 ViewManagerPrivate private_manager(manager); | 40 ViewManagerPrivate private_manager(manager); |
39 private_manager.AddNode(node->id(), node); | 41 private_manager.AddNode(node->id(), node); |
40 | 42 |
41 // View. | 43 // View. |
42 if (view_id != 0) { | 44 if (view_id != 0) { |
43 View* view = ViewPrivate::LocalCreate(); | 45 View* view = ViewPrivate::LocalCreate(); |
44 ViewPrivate private_view(view); | 46 ViewPrivate private_view(view); |
45 private_view.set_view_manager(manager); | 47 private_view.set_view_manager(manager); |
(...skipping 16 matching lines...) Expand all Loading... |
62 if (last_node && nodes[i].parent_id() == last_node->id()) { | 64 if (last_node && nodes[i].parent_id() == last_node->id()) { |
63 parents.push_back(last_node); | 65 parents.push_back(last_node); |
64 } else if (!parents.empty()) { | 66 } else if (!parents.empty()) { |
65 while (parents.back()->id() != nodes[i].parent_id()) | 67 while (parents.back()->id() != nodes[i].parent_id()) |
66 parents.pop_back(); | 68 parents.pop_back(); |
67 } | 69 } |
68 ViewTreeNode* node = AddNodeToViewManager( | 70 ViewTreeNode* node = AddNodeToViewManager( |
69 manager, | 71 manager, |
70 !parents.empty() ? parents.back() : NULL, | 72 !parents.empty() ? parents.back() : NULL, |
71 nodes[i].node_id(), | 73 nodes[i].node_id(), |
72 nodes[i].view_id()); | 74 nodes[i].view_id(), |
| 75 nodes[i].bounds()); |
73 if (!last_node) | 76 if (!last_node) |
74 root = node; | 77 root = node; |
75 last_node = node; | 78 last_node = node; |
76 } | 79 } |
77 return root; | 80 return root; |
78 } | 81 } |
79 | 82 |
80 class ViewManagerTransaction { | 83 class ViewManagerTransaction { |
81 public: | 84 public: |
82 virtual ~ViewManagerTransaction() {} | 85 virtual ~ViewManagerTransaction() {} |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 void ViewManagerSynchronizer::RemoveFromPendingQueue( | 622 void ViewManagerSynchronizer::RemoveFromPendingQueue( |
620 ViewManagerTransaction* transaction) { | 623 ViewManagerTransaction* transaction) { |
621 DCHECK_EQ(transaction, pending_transactions_.front()); | 624 DCHECK_EQ(transaction, pending_transactions_.front()); |
622 pending_transactions_.erase(pending_transactions_.begin()); | 625 pending_transactions_.erase(pending_transactions_.begin()); |
623 if (pending_transactions_.empty() && !changes_acked_callback_.is_null()) | 626 if (pending_transactions_.empty() && !changes_acked_callback_.is_null()) |
624 changes_acked_callback_.Run(); | 627 changes_acked_callback_.Run(); |
625 } | 628 } |
626 | 629 |
627 } // namespace view_manager | 630 } // namespace view_manager |
628 } // namespace mojo | 631 } // namespace mojo |
OLD | NEW |