| 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/test/surface_hittest_test_helpers.h" | 5 #include "cc/test/surface_hittest_test_helpers.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/render_pass_draw_quad.h" | 9 #include "cc/quads/render_pass_draw_quad.h" |
| 10 #include "cc/quads/shared_quad_state.h" | 10 #include "cc/quads/shared_quad_state.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 scoped_ptr<CompositorFrame> root_frame = | 87 scoped_ptr<CompositorFrame> root_frame = |
| 88 CreateCompositorFrameWithRenderPassList(&render_pass_list); | 88 CreateCompositorFrameWithRenderPassList(&render_pass_list); |
| 89 | 89 |
| 90 *render_pass = | 90 *render_pass = |
| 91 root_frame->delegated_frame_data->render_pass_list.back().get(); | 91 root_frame->delegated_frame_data->render_pass_list.back().get(); |
| 92 return root_frame; | 92 return root_frame; |
| 93 } | 93 } |
| 94 | 94 |
| 95 TestSurfaceHittestDelegate::TestSurfaceHittestDelegate() | 95 TestSurfaceHittestDelegate::TestSurfaceHittestDelegate() |
| 96 : target_overrides_(0) {} | 96 : reject_target_overrides_(0), accept_target_overrides_(0) {} |
| 97 | 97 |
| 98 TestSurfaceHittestDelegate::~TestSurfaceHittestDelegate() {} | 98 TestSurfaceHittestDelegate::~TestSurfaceHittestDelegate() {} |
| 99 | 99 |
| 100 void TestSurfaceHittestDelegate::AddInsetsForSurface( | 100 void TestSurfaceHittestDelegate::AddInsetsForRejectSurface( |
| 101 const SurfaceId& surface_id, | 101 const SurfaceId& surface_id, |
| 102 const gfx::Insets& inset) { | 102 const gfx::Insets& inset) { |
| 103 insets_for_surface_.insert(std::make_pair(surface_id, inset)); | 103 insets_for_reject_.insert(std::make_pair(surface_id, inset)); |
| 104 } |
| 105 |
| 106 void TestSurfaceHittestDelegate::AddInsetsForAcceptSurface( |
| 107 const SurfaceId& surface_id, |
| 108 const gfx::Insets& inset) { |
| 109 insets_for_accept_.insert(std::make_pair(surface_id, inset)); |
| 104 } | 110 } |
| 105 | 111 |
| 106 bool TestSurfaceHittestDelegate::RejectHitTarget( | 112 bool TestSurfaceHittestDelegate::RejectHitTarget( |
| 107 const SurfaceDrawQuad* surface_quad, | 113 const SurfaceDrawQuad* surface_quad, |
| 108 const gfx::Point& point_in_quad_space) { | 114 const gfx::Point& point_in_quad_space) { |
| 109 if (!insets_for_surface_.count(surface_quad->surface_id)) | 115 if (!insets_for_reject_.count(surface_quad->surface_id)) |
| 110 return false; | 116 return false; |
| 111 gfx::Rect bounds(surface_quad->rect); | 117 gfx::Rect bounds(surface_quad->rect); |
| 112 bounds.Inset(insets_for_surface_[surface_quad->surface_id]); | 118 bounds.Inset(insets_for_reject_[surface_quad->surface_id]); |
| 113 // If the point provided falls outside the inset, then we skip this surface. | 119 // If the point provided falls outside the inset, then we skip this surface. |
| 114 if (!bounds.Contains(point_in_quad_space)) { | 120 if (!bounds.Contains(point_in_quad_space)) { |
| 115 if (surface_quad->rect.Contains(point_in_quad_space)) | 121 if (surface_quad->rect.Contains(point_in_quad_space)) |
| 116 ++target_overrides_; | 122 ++reject_target_overrides_; |
| 117 return true; | 123 return true; |
| 118 } | 124 } |
| 119 return false; | 125 return false; |
| 126 } |
| 127 |
| 128 bool TestSurfaceHittestDelegate::AcceptHitTarget( |
| 129 const SurfaceDrawQuad* surface_quad, |
| 130 const gfx::Point& point_in_quad_space) { |
| 131 if (!insets_for_accept_.count(surface_quad->surface_id)) |
| 132 return false; |
| 133 gfx::Rect bounds(surface_quad->rect); |
| 134 bounds.Inset(insets_for_accept_[surface_quad->surface_id]); |
| 135 // If the point provided falls outside the inset, then we accept this surface. |
| 136 if (!bounds.Contains(point_in_quad_space)) { |
| 137 ++accept_target_overrides_; |
| 138 return true; |
| 139 } |
| 140 return false; |
| 120 } | 141 } |
| 121 | 142 |
| 122 } // namespace test | 143 } // namespace test |
| 123 } // namespace cc | 144 } // namespace cc |
| OLD | NEW |