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