OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "cc/surfaces/surface_hittest.h" | |
6 | |
7 #include "cc/output/compositor_frame.h" | |
8 #include "cc/output/delegated_frame_data.h" | |
9 #include "cc/quads/draw_quad.h" | |
10 #include "cc/quads/surface_draw_quad.h" | |
11 #include "cc/surfaces/surface.h" | |
12 #include "cc/surfaces/surface_manager.h" | |
13 #include "ui/gfx/geometry/point.h" | |
14 #include "ui/gfx/transform.h" | |
15 | |
16 namespace cc { | |
17 SurfaceHittest::SurfaceHittest(SurfaceManager* manager) : manager_(manager) {} | |
18 | |
19 SurfaceHittest::~SurfaceHittest() {} | |
20 | |
21 SurfaceId SurfaceHittest::Hittest(SurfaceId surface_id, | |
22 const gfx::Point& point) { | |
23 Surface* surface = manager_->GetSurfaceForId(surface_id); | |
24 | |
25 const CompositorFrame* surface_frame = surface->GetEligibleFrame(); | |
jbauman
2015/07/31 22:00:28
To avoid infinite recursion, this should check tha
lfg
2015/08/04 21:21:42
Done.
| |
26 if (!surface_frame) | |
27 return surface_id; | |
28 const DelegatedFrameData* frame_data = | |
29 surface_frame->delegated_frame_data.get(); | |
30 | |
31 for (const auto& render_pass : frame_data->render_pass_list) { | |
jbauman
2015/07/31 22:00:28
It would probably be best to look at the root pass
lfg
2015/08/04 21:21:42
Done.
| |
32 for (const auto& quad : render_pass->quad_list) { | |
jbauman
2015/07/31 22:00:28
This should go from the end of the list to the beg
lfg
2015/08/04 21:21:42
This is the only point I'm not sure about. For ren
| |
33 if (quad->material == DrawQuad::SURFACE_CONTENT) { | |
34 const SurfaceDrawQuad* surface_quad = | |
35 SurfaceDrawQuad::MaterialCast(quad); | |
36 gfx::Transform root_to_surface_transform; | |
37 if (gfx::Transform( | |
38 render_pass->transform_to_root_target, | |
39 surface_quad->shared_quad_state->quad_to_target_transform) | |
40 .GetInverse(&root_to_surface_transform)) { | |
41 gfx::Point transformed_point(point); | |
42 root_to_surface_transform.TransformPoint(&transformed_point); | |
43 | |
44 if (transformed_point.x() > 0 && transformed_point.y() > 0 && | |
45 transformed_point.x() < surface_quad->rect.width() && | |
46 transformed_point.y() < surface_quad->rect.height()) { | |
jbauman
2015/07/31 22:00:28
Should check clip rect as well.
lfg
2015/08/04 21:21:42
I've added the check to clip rect, but I'm wonderi
| |
47 return Hittest(surface_quad->surface_id, transformed_point); | |
48 } | |
49 } | |
50 } | |
51 } | |
52 } | |
53 | |
54 return surface_id; | |
55 } | |
56 } // namespace cc | |
OLD | NEW |