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

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

Issue 2184033003: Refactor browser process coordinate transformation methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed problematic DCHECK Created 4 years, 4 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
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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // Reset the output transform to identity. 48 // Reset the output transform to identity.
49 if (transform) 49 if (transform)
50 *transform = gfx::Transform(); 50 *transform = gfx::Transform();
51 51
52 std::set<const RenderPass*> referenced_passes; 52 std::set<const RenderPass*> referenced_passes;
53 return GetTransformToTargetSurfaceInternal(root_surface_id, target_surface_id, 53 return GetTransformToTargetSurfaceInternal(root_surface_id, target_surface_id,
54 RenderPassId(), &referenced_passes, 54 RenderPassId(), &referenced_passes,
55 transform); 55 transform);
56 } 56 }
57 57
58 bool SurfaceHittest::TransformPointToTargetSurface(
59 const SurfaceId& original_surface_id,
60 const SurfaceId& target_surface_id,
61 gfx::Point* point) {
62 gfx::Transform transform;
63 // Two possibilities need to be considered: original_surface_id can be
64 // embedded in target_surface_id, or vice versa.
65 if (GetTransformToTargetSurface(target_surface_id, original_surface_id,
66 &transform)) {
67 if (transform.GetInverse(&transform))
68 transform.TransformPoint(point);
69 else
70 return false;
71 } else if (GetTransformToTargetSurface(original_surface_id, target_surface_id,
72 &transform)) {
73 // No need to invert the transform matrix in this case.
74 transform.TransformPoint(point);
75 } else {
76 return false;
77 }
78
79 return true;
80 }
81
58 bool SurfaceHittest::GetTargetSurfaceAtPointInternal( 82 bool SurfaceHittest::GetTargetSurfaceAtPointInternal(
59 const SurfaceId& surface_id, 83 const SurfaceId& surface_id,
60 const RenderPassId& render_pass_id, 84 const RenderPassId& render_pass_id,
61 const gfx::Point& point_in_root_target, 85 const gfx::Point& point_in_root_target,
62 std::set<const RenderPass*>* referenced_passes, 86 std::set<const RenderPass*>* referenced_passes,
63 SurfaceId* out_surface_id, 87 SurfaceId* out_surface_id,
64 gfx::Transform* out_transform) { 88 gfx::Transform* out_transform) {
65 const RenderPass* render_pass = 89 const RenderPass* render_pass =
66 GetRenderPassForSurfaceById(surface_id, render_pass_id); 90 GetRenderPassForSurfaceById(surface_id, render_pass_id);
67 if (!render_pass) 91 if (!render_pass)
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return false; 299 return false;
276 } 300 }
277 301
278 *point_in_quad_space = point_in_render_pass_space; 302 *point_in_quad_space = point_in_render_pass_space;
279 target_to_quad_transform->TransformPoint(point_in_quad_space); 303 target_to_quad_transform->TransformPoint(point_in_quad_space);
280 304
281 return quad->rect.Contains(*point_in_quad_space); 305 return quad->rect.Contains(*point_in_quad_space);
282 } 306 }
283 307
284 } // namespace cc 308 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_hittest.h ('k') | content/browser/frame_host/cross_process_frame_connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698