diff options
author | fsamuel <fsamuel@chromium.org> | 2015-12-06 06:54:05 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-06 14:55:08 +0000 |
commit | a40c9c16df5a0c9a9e14411dc3aa9a3dcde7e498 (patch) | |
tree | fca19c1e1f0b0c49f567c661ea35e7c4580f5a68 /cc/test | |
parent | 79adad4e7973e44df1ee34b4952c2bfade88ee01 (diff) | |
download | chromium_src-a40c9c16df5a0c9a9e14411dc3aa9a3dcde7e498.zip chromium_src-a40c9c16df5a0c9a9e14411dc3aa9a3dcde7e498.tar.gz chromium_src-a40c9c16df5a0c9a9e14411dc3aa9a3dcde7e498.tar.bz2 |
cc: Allow Surfaces clients to customize hit testing
Until we have a better hit testing data structure based on
slimming paint work, Mus needs to annotate surfaces hit
testing with additional information for shadows.
This CL provides a generic customization hook to allow a
Surfaces client to make a hit testing decision based on
factors unknown to cc.
Note that this is a short term solution until we have a
better hit testing data structure from slimming paint.
BUG=548424
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1503553002
Cr-Commit-Position: refs/heads/master@{#363371}
Diffstat (limited to 'cc/test')
-rw-r--r-- | cc/test/surface_hittest_test_helpers.cc | 27 | ||||
-rw-r--r-- | cc/test/surface_hittest_test_helpers.h | 26 |
2 files changed, 53 insertions, 0 deletions
diff --git a/cc/test/surface_hittest_test_helpers.cc b/cc/test/surface_hittest_test_helpers.cc index 8c57959..b83d6d4 100644 --- a/cc/test/surface_hittest_test_helpers.cc +++ b/cc/test/surface_hittest_test_helpers.cc @@ -92,5 +92,32 @@ scoped_ptr<CompositorFrame> CreateCompositorFrame(const gfx::Rect& root_rect, return root_frame; } +TestSurfaceHittestDelegate::TestSurfaceHittestDelegate() + : target_overrides_(0) {} + +TestSurfaceHittestDelegate::~TestSurfaceHittestDelegate() {} + +void TestSurfaceHittestDelegate::AddInsetsForSurface( + const SurfaceId& surface_id, + const gfx::Insets& inset) { + insets_for_surface_.insert(std::make_pair(surface_id, inset)); +} + +bool TestSurfaceHittestDelegate::RejectHitTarget( + const SurfaceDrawQuad* surface_quad, + const gfx::Point& point_in_quad_space) { + if (!insets_for_surface_.count(surface_quad->surface_id)) + return false; + gfx::Rect bounds(surface_quad->rect); + bounds.Inset(insets_for_surface_[surface_quad->surface_id]); + // If the point provided falls outside the inset, then we skip this surface. + if (!bounds.Contains(point_in_quad_space)) { + if (surface_quad->rect.Contains(point_in_quad_space)) + ++target_overrides_; + return true; + } + return false; +} + } // namespace test } // namespace cc diff --git a/cc/test/surface_hittest_test_helpers.h b/cc/test/surface_hittest_test_helpers.h index be4ad2e..4a27659 100644 --- a/cc/test/surface_hittest_test_helpers.h +++ b/cc/test/surface_hittest_test_helpers.h @@ -5,9 +5,14 @@ #ifndef CC_TEST_SURFACE_HITTEST_TEST_HELPERS_H_ #define CC_TEST_SURFACE_HITTEST_TEST_HELPERS_H_ +#include <map> + +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "cc/quads/render_pass.h" #include "cc/surfaces/surface_factory_client.h" +#include "cc/surfaces/surface_hittest_delegate.h" +#include "ui/gfx/geometry/insets.h" namespace gfx { class Transform; @@ -60,6 +65,27 @@ scoped_ptr<CompositorFrame> CreateCompositorFrameWithRenderPassList( scoped_ptr<CompositorFrame> CreateCompositorFrame(const gfx::Rect& root_rect, RenderPass** render_pass); +class TestSurfaceHittestDelegate : public SurfaceHittestDelegate { + public: + TestSurfaceHittestDelegate(); + ~TestSurfaceHittestDelegate(); + + int target_overrides() const { return target_overrides_; } + + void AddInsetsForSurface(const SurfaceId& surface_id, + const gfx::Insets& inset); + + // SurfaceHittestDelegate implementation. + bool RejectHitTarget(const SurfaceDrawQuad* surface_quad, + const gfx::Point& point_in_quad_space) override; + + private: + int target_overrides_; + std::map<SurfaceId, gfx::Insets> insets_for_surface_; + + DISALLOW_COPY_AND_ASSIGN(TestSurfaceHittestDelegate); +}; + } // namespace test } // namespace cc |