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

Side by Side Diff: cc/surfaces/surface_hittest.cc

Issue 2150633002: cc: Pass SurfaceId by const ref in more places (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « cc/surfaces/surface_hittest.h ('k') | cc/surfaces/surface_manager.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "cc/surfaces/surface_hittest.h" 5 #include "cc/surfaces/surface_hittest.h"
6 6
7 #include "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "cc/output/delegated_frame_data.h" 8 #include "cc/output/delegated_frame_data.h"
9 #include "cc/quads/draw_quad.h" 9 #include "cc/quads/draw_quad.h"
10 #include "cc/quads/render_pass_draw_quad.h" 10 #include "cc/quads/render_pass_draw_quad.h"
11 #include "cc/quads/surface_draw_quad.h" 11 #include "cc/quads/surface_draw_quad.h"
12 #include "cc/surfaces/surface.h" 12 #include "cc/surfaces/surface.h"
13 #include "cc/surfaces/surface_hittest_delegate.h" 13 #include "cc/surfaces/surface_hittest_delegate.h"
14 #include "cc/surfaces/surface_manager.h" 14 #include "cc/surfaces/surface_manager.h"
15 #include "ui/gfx/geometry/point.h" 15 #include "ui/gfx/geometry/point.h"
16 #include "ui/gfx/transform.h" 16 #include "ui/gfx/transform.h"
17 17
18 namespace cc { 18 namespace cc {
19 19
20 SurfaceHittest::SurfaceHittest(SurfaceHittestDelegate* delegate, 20 SurfaceHittest::SurfaceHittest(SurfaceHittestDelegate* delegate,
21 SurfaceManager* manager) 21 SurfaceManager* manager)
22 : delegate_(delegate), manager_(manager) {} 22 : delegate_(delegate), manager_(manager) {}
23 23
24 SurfaceHittest::~SurfaceHittest() {} 24 SurfaceHittest::~SurfaceHittest() {}
25 25
26 SurfaceId SurfaceHittest::GetTargetSurfaceAtPoint(SurfaceId root_surface_id, 26 SurfaceId SurfaceHittest::GetTargetSurfaceAtPoint(
27 const gfx::Point& point, 27 const SurfaceId& root_surface_id,
28 gfx::Transform* transform) { 28 const gfx::Point& point,
29 gfx::Transform* transform) {
29 SurfaceId out_surface_id = root_surface_id; 30 SurfaceId out_surface_id = root_surface_id;
30 31
31 // Reset the output transform to identity. 32 // Reset the output transform to identity.
32 if (transform) 33 if (transform)
33 *transform = gfx::Transform(); 34 *transform = gfx::Transform();
34 35
35 std::set<const RenderPass*> referenced_passes; 36 std::set<const RenderPass*> referenced_passes;
36 GetTargetSurfaceAtPointInternal(root_surface_id, RenderPassId(), point, 37 GetTargetSurfaceAtPointInternal(root_surface_id, RenderPassId(), point,
37 &referenced_passes, &out_surface_id, 38 &referenced_passes, &out_surface_id,
38 transform); 39 transform);
39 40
40 return out_surface_id; 41 return out_surface_id;
41 } 42 }
42 43
43 bool SurfaceHittest::GetTransformToTargetSurface(SurfaceId root_surface_id, 44 bool SurfaceHittest::GetTransformToTargetSurface(
44 SurfaceId target_surface_id, 45 const SurfaceId& root_surface_id,
45 gfx::Transform* transform) { 46 const SurfaceId& target_surface_id,
47 gfx::Transform* transform) {
46 // Reset the output transform to identity. 48 // Reset the output transform to identity.
47 if (transform) 49 if (transform)
48 *transform = gfx::Transform(); 50 *transform = gfx::Transform();
49 51
50 std::set<const RenderPass*> referenced_passes; 52 std::set<const RenderPass*> referenced_passes;
51 return GetTransformToTargetSurfaceInternal(root_surface_id, target_surface_id, 53 return GetTransformToTargetSurfaceInternal(root_surface_id, target_surface_id,
52 RenderPassId(), &referenced_passes, 54 RenderPassId(), &referenced_passes,
53 transform); 55 transform);
54 } 56 }
55 57
56 bool SurfaceHittest::GetTargetSurfaceAtPointInternal( 58 bool SurfaceHittest::GetTargetSurfaceAtPointInternal(
57 SurfaceId surface_id, 59 const SurfaceId& surface_id,
58 const RenderPassId& render_pass_id, 60 const RenderPassId& render_pass_id,
59 const gfx::Point& point_in_root_target, 61 const gfx::Point& point_in_root_target,
60 std::set<const RenderPass*>* referenced_passes, 62 std::set<const RenderPass*>* referenced_passes,
61 SurfaceId* out_surface_id, 63 SurfaceId* out_surface_id,
62 gfx::Transform* out_transform) { 64 gfx::Transform* out_transform) {
63 const RenderPass* render_pass = 65 const RenderPass* render_pass =
64 GetRenderPassForSurfaceById(surface_id, render_pass_id); 66 GetRenderPassForSurfaceById(surface_id, render_pass_id);
65 if (!render_pass) 67 if (!render_pass)
66 return false; 68 return false;
67 69
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // need to iterate anymore, this is the quad that receives the event. 143 // need to iterate anymore, this is the quad that receives the event.
142 *out_surface_id = surface_id; 144 *out_surface_id = surface_id;
143 return true; 145 return true;
144 } 146 }
145 147
146 // No quads were found beneath the provided |point|. 148 // No quads were found beneath the provided |point|.
147 return false; 149 return false;
148 } 150 }
149 151
150 bool SurfaceHittest::GetTransformToTargetSurfaceInternal( 152 bool SurfaceHittest::GetTransformToTargetSurfaceInternal(
151 SurfaceId root_surface_id, 153 const SurfaceId& root_surface_id,
152 SurfaceId target_surface_id, 154 const SurfaceId& target_surface_id,
153 const RenderPassId& render_pass_id, 155 const RenderPassId& render_pass_id,
154 std::set<const RenderPass*>* referenced_passes, 156 std::set<const RenderPass*>* referenced_passes,
155 gfx::Transform* out_transform) { 157 gfx::Transform* out_transform) {
156 if (root_surface_id == target_surface_id) { 158 if (root_surface_id == target_surface_id) {
157 *out_transform = gfx::Transform(); 159 *out_transform = gfx::Transform();
158 return true; 160 return true;
159 } 161 }
160 162
161 const RenderPass* render_pass = 163 const RenderPass* render_pass =
162 GetRenderPassForSurfaceById(root_surface_id, render_pass_id); 164 GetRenderPassForSurfaceById(root_surface_id, render_pass_id);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 223
222 continue; 224 continue;
223 } 225 }
224 } 226 }
225 227
226 // The target surface was not found. 228 // The target surface was not found.
227 return false; 229 return false;
228 } 230 }
229 231
230 const RenderPass* SurfaceHittest::GetRenderPassForSurfaceById( 232 const RenderPass* SurfaceHittest::GetRenderPassForSurfaceById(
231 SurfaceId surface_id, 233 const SurfaceId& surface_id,
232 const RenderPassId& render_pass_id) { 234 const RenderPassId& render_pass_id) {
233 Surface* surface = manager_->GetSurfaceForId(surface_id); 235 Surface* surface = manager_->GetSurfaceForId(surface_id);
234 if (!surface) 236 if (!surface)
235 return nullptr; 237 return nullptr;
236 238
237 const CompositorFrame& surface_frame = surface->GetEligibleFrame(); 239 const CompositorFrame& surface_frame = surface->GetEligibleFrame();
238 if (!surface_frame.delegated_frame_data) 240 if (!surface_frame.delegated_frame_data)
239 return nullptr; 241 return nullptr;
240 242
241 const DelegatedFrameData* frame_data = 243 const DelegatedFrameData* frame_data =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return false; 275 return false;
274 } 276 }
275 277
276 *point_in_quad_space = point_in_render_pass_space; 278 *point_in_quad_space = point_in_render_pass_space;
277 target_to_quad_transform->TransformPoint(point_in_quad_space); 279 target_to_quad_transform->TransformPoint(point_in_quad_space);
278 280
279 return quad->rect.Contains(*point_in_quad_space); 281 return quad->rect.Contains(*point_in_quad_space);
280 } 282 }
281 283
282 } // namespace cc 284 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_hittest.h ('k') | cc/surfaces/surface_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698