| OLD | NEW |
| 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" | |
| 9 #include "cc/quads/draw_quad.h" | 8 #include "cc/quads/draw_quad.h" |
| 10 #include "cc/quads/render_pass_draw_quad.h" | 9 #include "cc/quads/render_pass_draw_quad.h" |
| 11 #include "cc/quads/surface_draw_quad.h" | 10 #include "cc/quads/surface_draw_quad.h" |
| 12 #include "cc/surfaces/surface.h" | 11 #include "cc/surfaces/surface.h" |
| 13 #include "cc/surfaces/surface_hittest_delegate.h" | 12 #include "cc/surfaces/surface_hittest_delegate.h" |
| 14 #include "cc/surfaces/surface_manager.h" | 13 #include "cc/surfaces/surface_manager.h" |
| 15 #include "ui/gfx/geometry/point.h" | 14 #include "ui/gfx/geometry/point.h" |
| 16 #include "ui/gfx/transform.h" | 15 #include "ui/gfx/transform.h" |
| 17 | 16 |
| 18 namespace cc { | 17 namespace cc { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // The target surface was not found. | 251 // The target surface was not found. |
| 253 return false; | 252 return false; |
| 254 } | 253 } |
| 255 | 254 |
| 256 const RenderPass* SurfaceHittest::GetRenderPassForSurfaceById( | 255 const RenderPass* SurfaceHittest::GetRenderPassForSurfaceById( |
| 257 const SurfaceId& surface_id, | 256 const SurfaceId& surface_id, |
| 258 const RenderPassId& render_pass_id) { | 257 const RenderPassId& render_pass_id) { |
| 259 Surface* surface = manager_->GetSurfaceForId(surface_id); | 258 Surface* surface = manager_->GetSurfaceForId(surface_id); |
| 260 if (!surface) | 259 if (!surface) |
| 261 return nullptr; | 260 return nullptr; |
| 261 if (!surface->HasFrame()) |
| 262 return nullptr; |
| 263 const CompositorFrame& surface_frame = surface->GetEligibleFrame(); |
| 262 | 264 |
| 263 const CompositorFrame& surface_frame = surface->GetEligibleFrame(); | 265 if (surface_frame.render_pass_list.empty()) |
| 264 if (!surface_frame.delegated_frame_data) | |
| 265 return nullptr; | |
| 266 | |
| 267 const DelegatedFrameData* frame_data = | |
| 268 surface_frame.delegated_frame_data.get(); | |
| 269 if (frame_data->render_pass_list.empty()) | |
| 270 return nullptr; | 266 return nullptr; |
| 271 | 267 |
| 272 if (!render_pass_id.IsValid()) | 268 if (!render_pass_id.IsValid()) |
| 273 return frame_data->render_pass_list.back().get(); | 269 return surface_frame.render_pass_list.back().get(); |
| 274 | 270 |
| 275 for (const auto& render_pass : frame_data->render_pass_list) { | 271 for (const auto& render_pass : surface_frame.render_pass_list) { |
| 276 if (render_pass->id == render_pass_id) | 272 if (render_pass->id == render_pass_id) |
| 277 return render_pass.get(); | 273 return render_pass.get(); |
| 278 } | 274 } |
| 279 | 275 |
| 280 return nullptr; | 276 return nullptr; |
| 281 } | 277 } |
| 282 | 278 |
| 283 bool SurfaceHittest::PointInQuad(const DrawQuad* quad, | 279 bool SurfaceHittest::PointInQuad(const DrawQuad* quad, |
| 284 const gfx::Point& point_in_render_pass_space, | 280 const gfx::Point& point_in_render_pass_space, |
| 285 gfx::Transform* target_to_quad_transform, | 281 gfx::Transform* target_to_quad_transform, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 299 return false; | 295 return false; |
| 300 } | 296 } |
| 301 | 297 |
| 302 *point_in_quad_space = point_in_render_pass_space; | 298 *point_in_quad_space = point_in_render_pass_space; |
| 303 target_to_quad_transform->TransformPoint(point_in_quad_space); | 299 target_to_quad_transform->TransformPoint(point_in_quad_space); |
| 304 | 300 |
| 305 return quad->rect.Contains(*point_in_quad_space); | 301 return quad->rect.Contains(*point_in_quad_space); |
| 306 } | 302 } |
| 307 | 303 |
| 308 } // namespace cc | 304 } // namespace cc |
| OLD | NEW |