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

Side by Side Diff: services/view_manager/display_manager.cc

Issue 822903003: Fix math in view_manager's display_manager (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | 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 "services/view_manager/display_manager.h" 5 #include "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/converters/geometry/geometry_type_converters.h" 9 #include "mojo/converters/geometry/geometry_type_converters.h"
10 #include "mojo/converters/surfaces/surfaces_type_converters.h" 10 #include "mojo/converters/surfaces/surfaces_type_converters.h"
11 #include "mojo/public/cpp/application/application_connection.h" 11 #include "mojo/public/cpp/application/application_connection.h"
12 #include "mojo/services/gpu/public/interfaces/gpu.mojom.h" 12 #include "mojo/services/gpu/public/interfaces/gpu.mojom.h"
13 #include "mojo/services/surfaces/public/cpp/surfaces_utils.h" 13 #include "mojo/services/surfaces/public/cpp/surfaces_utils.h"
14 #include "mojo/services/surfaces/public/interfaces/quads.mojom.h" 14 #include "mojo/services/surfaces/public/interfaces/quads.mojom.h"
15 #include "services/view_manager/connection_manager.h" 15 #include "services/view_manager/connection_manager.h"
16 #include "services/view_manager/server_view.h" 16 #include "services/view_manager/server_view.h"
17 #include "services/view_manager/view_coordinate_conversions.h" 17 #include "services/view_manager/view_coordinate_conversions.h"
18 18
19 using mojo::Rect; 19 using mojo::Rect;
20 using mojo::Size; 20 using mojo::Size;
21 21
22 namespace view_manager { 22 namespace view_manager {
23 namespace { 23 namespace {
24 24
25 void DrawViewTree(mojo::Pass* pass, 25 void DrawViewTree(mojo::Pass* pass,
26 const ServerView* view, 26 const ServerView* view,
27 const gfx::Vector2d& offset, 27 const gfx::Vector2d& parent_to_root_origin_offset,
28 float opacity) { 28 float opacity) {
29 if (!view->visible()) 29 if (!view->visible())
30 return; 30 return;
31 31
32 const gfx::Rect node_bounds = view->bounds() + offset; 32 const gfx::Rect absolute_bounds =
33 view->bounds() + parent_to_root_origin_offset;
33 std::vector<const ServerView*> children(view->GetChildren()); 34 std::vector<const ServerView*> children(view->GetChildren());
34 const float combined_opacity = opacity * view->opacity(); 35 const float combined_opacity = opacity * view->opacity();
35 for (std::vector<const ServerView*>::reverse_iterator it = children.rbegin(); 36 for (std::vector<const ServerView*>::reverse_iterator it = children.rbegin();
36 it != children.rend(); 37 it != children.rend();
37 ++it) { 38 ++it) {
38 DrawViewTree(pass, *it, node_bounds.OffsetFromOrigin(), combined_opacity); 39 DrawViewTree(pass, *it, absolute_bounds.OffsetFromOrigin(),
40 combined_opacity);
39 } 41 }
40 42
41 cc::SurfaceId node_id = view->surface_id(); 43 cc::SurfaceId node_id = view->surface_id();
42 44
43 auto surface_quad_state = mojo::SurfaceQuadState::New(); 45 auto surface_quad_state = mojo::SurfaceQuadState::New();
44 surface_quad_state->surface = mojo::SurfaceId::From(node_id); 46 surface_quad_state->surface = mojo::SurfaceId::From(node_id);
45 47
46 gfx::Transform node_transform; 48 gfx::Transform node_transform;
47 node_transform.Translate(node_bounds.x(), node_bounds.y()); 49 node_transform.Translate(absolute_bounds.x(), absolute_bounds.y());
48 50
51 const gfx::Rect bounds_at_origin(view->bounds().size());
49 auto surface_quad = mojo::Quad::New(); 52 auto surface_quad = mojo::Quad::New();
50 surface_quad->material = mojo::Material::MATERIAL_SURFACE_CONTENT; 53 surface_quad->material = mojo::Material::MATERIAL_SURFACE_CONTENT;
51 surface_quad->rect = Rect::From(node_bounds); 54 surface_quad->rect = Rect::From(bounds_at_origin);
52 surface_quad->opaque_rect = Rect::From(node_bounds); 55 surface_quad->opaque_rect = Rect::From(bounds_at_origin);
53 surface_quad->visible_rect = Rect::From(node_bounds); 56 surface_quad->visible_rect = Rect::From(bounds_at_origin);
54 surface_quad->needs_blending = true; 57 surface_quad->needs_blending = true;
55 surface_quad->shared_quad_state_index = 58 surface_quad->shared_quad_state_index =
56 base::saturated_cast<int32_t>(pass->shared_quad_states.size()); 59 base::saturated_cast<int32_t>(pass->shared_quad_states.size());
57 surface_quad->surface_quad_state = surface_quad_state.Pass(); 60 surface_quad->surface_quad_state = surface_quad_state.Pass();
58 61
59 auto sqs = CreateDefaultSQS(*Size::From(node_bounds.size())); 62 auto sqs = CreateDefaultSQS(*Size::From(view->bounds().size()));
60 sqs->blend_mode = mojo::SK_XFERMODE_kSrcOver_Mode; 63 sqs->blend_mode = mojo::SK_XFERMODE_kSrcOver_Mode;
61 sqs->opacity = combined_opacity; 64 sqs->opacity = combined_opacity;
62 sqs->content_to_target_transform = mojo::Transform::From(node_transform); 65 sqs->content_to_target_transform = mojo::Transform::From(node_transform);
63 66
64 pass->quads.push_back(surface_quad.Pass()); 67 pass->quads.push_back(surface_quad.Pass());
65 pass->shared_quad_states.push_back(sqs.Pass()); 68 pass->shared_quad_states.push_back(sqs.Pass());
66 } 69 }
67 70
68 } // namespace 71 } // namespace
69 72
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 182
180 void DefaultDisplayManager::SetIdNamespace(uint32_t id_namespace) { 183 void DefaultDisplayManager::SetIdNamespace(uint32_t id_namespace) {
181 } 184 }
182 185
183 void DefaultDisplayManager::ReturnResources( 186 void DefaultDisplayManager::ReturnResources(
184 mojo::Array<mojo::ReturnedResourcePtr> resources) { 187 mojo::Array<mojo::ReturnedResourcePtr> resources) {
185 DCHECK_EQ(0u, resources.size()); 188 DCHECK_EQ(0u, resources.size());
186 } 189 }
187 190
188 } // namespace view_manager 191 } // namespace view_manager
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698