| 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/view_manager/display_manager.h" | 5 #include "mojo/services/view_manager/display_manager.h" |
| 6 | 6 |
| 7 #include "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
| 8 #include "cc/surfaces/surface_id_allocator.h" | 8 #include "cc/surfaces/surface_id_allocator.h" |
| 9 #include "mojo/public/cpp/application/application_connection.h" | 9 #include "mojo/public/cpp/application/application_connection.h" |
| 10 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" | 10 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 gfx::Point origin(bounds.origin()); | 22 gfx::Point origin(bounds.origin()); |
| 23 while (view->parent()) { | 23 while (view->parent()) { |
| 24 origin += view->bounds().OffsetFromOrigin(); | 24 origin += view->bounds().OffsetFromOrigin(); |
| 25 view = view->parent(); | 25 view = view->parent(); |
| 26 if (!view->visible()) | 26 if (!view->visible()) |
| 27 return gfx::Rect(); | 27 return gfx::Rect(); |
| 28 } | 28 } |
| 29 return gfx::Rect(origin, bounds.size()); | 29 return gfx::Rect(origin, bounds.size()); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void DrawViewTree(Pass* pass, const ServerView* view) { | 32 void DrawViewTree(Pass* pass, const ServerView* view, gfx::Vector2d offset) { |
| 33 if (!view->visible()) | 33 if (!view->visible()) |
| 34 return; | 34 return; |
| 35 | 35 |
| 36 gfx::Rect node_bounds = view->bounds() + offset; |
| 37 std::vector<const ServerView*> children(view->GetChildren()); |
| 38 for (std::vector<const ServerView*>::reverse_iterator it = children.rbegin(); |
| 39 it != children.rend(); |
| 40 ++it) { |
| 41 DrawViewTree(pass, *it, offset + view->bounds().OffsetFromOrigin()); |
| 42 } |
| 43 |
| 36 cc::SurfaceId node_id = view->surface_id(); | 44 cc::SurfaceId node_id = view->surface_id(); |
| 37 | 45 |
| 38 SurfaceQuadStatePtr surface_quad_state = SurfaceQuadState::New(); | 46 SurfaceQuadStatePtr surface_quad_state = SurfaceQuadState::New(); |
| 39 surface_quad_state->surface = SurfaceId::From(node_id); | 47 surface_quad_state->surface = SurfaceId::From(node_id); |
| 40 | 48 |
| 41 const gfx::Rect& node_bounds = view->bounds(); | |
| 42 gfx::Transform node_transform; | 49 gfx::Transform node_transform; |
| 43 node_transform.Translate(node_bounds.x(), node_bounds.y()); | 50 node_transform.Translate(node_bounds.x(), node_bounds.y()); |
| 44 | 51 |
| 45 QuadPtr surface_quad = Quad::New(); | 52 QuadPtr surface_quad = Quad::New(); |
| 46 surface_quad->material = Material::MATERIAL_SURFACE_CONTENT; | 53 surface_quad->material = Material::MATERIAL_SURFACE_CONTENT; |
| 47 surface_quad->rect = Rect::From(node_bounds); | 54 surface_quad->rect = Rect::From(node_bounds); |
| 48 surface_quad->opaque_rect = Rect::From(node_bounds); | 55 surface_quad->opaque_rect = Rect::From(node_bounds); |
| 49 surface_quad->visible_rect = Rect::From(node_bounds); | 56 surface_quad->visible_rect = Rect::From(node_bounds); |
| 50 surface_quad->needs_blending = true; | 57 surface_quad->needs_blending = true; |
| 51 surface_quad->shared_quad_state_index = | 58 surface_quad->shared_quad_state_index = |
| 52 base::saturated_cast<int32_t>(pass->shared_quad_states.size()); | 59 base::saturated_cast<int32_t>(pass->shared_quad_states.size()); |
| 53 surface_quad->surface_quad_state = surface_quad_state.Pass(); | 60 surface_quad->surface_quad_state = surface_quad_state.Pass(); |
| 54 | 61 |
| 55 SharedQuadStatePtr sqs = CreateDefaultSQS(node_bounds.size()); | 62 SharedQuadStatePtr sqs = CreateDefaultSQS(node_bounds.size()); |
| 56 sqs->content_to_target_transform = Transform::From(node_transform); | 63 sqs->content_to_target_transform = Transform::From(node_transform); |
| 57 | 64 |
| 58 pass->quads.push_back(surface_quad.Pass()); | 65 pass->quads.push_back(surface_quad.Pass()); |
| 59 pass->shared_quad_states.push_back(sqs.Pass()); | 66 pass->shared_quad_states.push_back(sqs.Pass()); |
| 60 | |
| 61 std::vector<const ServerView*> children(view->GetChildren()); | |
| 62 for (std::vector<const ServerView*>::reverse_iterator it = children.rbegin(); | |
| 63 it != children.rend(); | |
| 64 ++it) { | |
| 65 DrawViewTree(pass, *it); | |
| 66 } | |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 DisplayManager::DisplayManager( | 71 DisplayManager::DisplayManager( |
| 72 ApplicationConnection* app_connection, | 72 ApplicationConnection* app_connection, |
| 73 ConnectionManager* connection_manager, | 73 ConnectionManager* connection_manager, |
| 74 const Callback<void()>& native_viewport_closed_callback) | 74 const Callback<void()>& native_viewport_closed_callback) |
| 75 : connection_manager_(connection_manager), | 75 : connection_manager_(connection_manager), |
| 76 in_setup_(false), | 76 in_setup_(false), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (!surface_) | 119 if (!surface_) |
| 120 return; | 120 return; |
| 121 if (surface_id_.is_null()) { | 121 if (surface_id_.is_null()) { |
| 122 surface_id_ = surface_id_allocator_->GenerateId(); | 122 surface_id_ = surface_id_allocator_->GenerateId(); |
| 123 surface_->CreateSurface(SurfaceId::From(surface_id_), Size::From(bounds_)); | 123 surface_->CreateSurface(SurfaceId::From(surface_id_), Size::From(bounds_)); |
| 124 } | 124 } |
| 125 | 125 |
| 126 PassPtr pass = CreateDefaultPass(1, gfx::Rect(bounds_)); | 126 PassPtr pass = CreateDefaultPass(1, gfx::Rect(bounds_)); |
| 127 pass->damage_rect = Rect::From(dirty_rect_); | 127 pass->damage_rect = Rect::From(dirty_rect_); |
| 128 | 128 |
| 129 DrawViewTree(pass.get(), connection_manager_->root()); | 129 DrawViewTree(pass.get(), connection_manager_->root(), gfx::Vector2d()); |
| 130 | 130 |
| 131 FramePtr frame = Frame::New(); | 131 FramePtr frame = Frame::New(); |
| 132 frame->passes.push_back(pass.Pass()); | 132 frame->passes.push_back(pass.Pass()); |
| 133 frame->resources.resize(0u); | 133 frame->resources.resize(0u); |
| 134 surface_->SubmitFrame(SurfaceId::From(surface_id_), frame.Pass()); | 134 surface_->SubmitFrame(SurfaceId::From(surface_id_), frame.Pass()); |
| 135 | 135 |
| 136 native_viewport_->SubmittedFrame(SurfaceId::From(surface_id_)); | 136 native_viewport_->SubmittedFrame(SurfaceId::From(surface_id_)); |
| 137 | 137 |
| 138 dirty_rect_ = gfx::Rect(); | 138 dirty_rect_ = gfx::Rect(); |
| 139 } | 139 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 160 connection_manager_->DispatchViewInputEventToWindowManager(event.Pass()); | 160 connection_manager_->DispatchViewInputEventToWindowManager(event.Pass()); |
| 161 callback.Run(); | 161 callback.Run(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void DisplayManager::ReturnResources(Array<ReturnedResourcePtr> resources) { | 164 void DisplayManager::ReturnResources(Array<ReturnedResourcePtr> resources) { |
| 165 DCHECK_EQ(0u, resources.size()); | 165 DCHECK_EQ(0u, resources.size()); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace service | 168 } // namespace service |
| 169 } // namespace mojo | 169 } // namespace mojo |
| OLD | NEW |