[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1 | // Copyright 2012 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 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 5 | #include "cc/trees/occlusion_tracker.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 6 | |
[email protected] | 95e4e1a0 | 2013-03-18 07:09:09 | [diff] [blame] | 7 | #include "cc/animation/layer_animation_controller.h" |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 8 | #include "cc/base/math_util.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 9 | #include "cc/layers/layer.h" |
| 10 | #include "cc/layers/layer_impl.h" |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 11 | #include "cc/output/copy_output_request.h" |
| 12 | #include "cc/output/copy_output_result.h" |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 13 | #include "cc/output/filter_operation.h" |
| 14 | #include "cc/output/filter_operations.h" |
[email protected] | 101441ce | 2012-10-16 01:45:03 | [diff] [blame] | 15 | #include "cc/test/animation_test_common.h" |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 16 | #include "cc/test/fake_impl_proxy.h" |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 17 | #include "cc/test/fake_layer_tree_host.h" |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 18 | #include "cc/test/fake_layer_tree_host_impl.h" |
[email protected] | 101441ce | 2012-10-16 01:45:03 | [diff] [blame] | 19 | #include "cc/test/geometry_test_utils.h" |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 20 | #include "cc/test/test_occlusion_tracker.h" |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 21 | #include "cc/trees/layer_tree_host_common.h" |
| 22 | #include "cc/trees/single_thread_proxy.h" |
[email protected] | 7f0c53db | 2012-10-02 00:23:18 | [diff] [blame] | 23 | #include "testing/gmock/include/gmock/gmock.h" |
| 24 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 25 | #include "ui/gfx/transform.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 26 | |
[email protected] | ba56574 | 2012-11-10 09:29:48 | [diff] [blame] | 27 | namespace cc { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 28 | namespace { |
| 29 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 30 | class TestContentLayer : public Layer { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 31 | public: |
[email protected] | afc4f26 | 2013-10-05 01:14:10 | [diff] [blame] | 32 | TestContentLayer() : Layer(), override_opaque_contents_rect_(false) { |
| 33 | SetIsDrawable(true); |
| 34 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 35 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 36 | virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const OVERRIDE { |
| 37 | if (override_opaque_contents_rect_) { |
| 38 | return SimpleEnclosedRegion( |
| 39 | gfx::IntersectRects(opaque_contents_rect_, visible_content_rect())); |
| 40 | } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 41 | return Layer::VisibleContentOpaqueRegion(); |
| 42 | } |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 43 | void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 44 | override_opaque_contents_rect_ = true; |
| 45 | opaque_contents_rect_ = opaque_contents_rect; |
| 46 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 47 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 48 | private: |
| 49 | virtual ~TestContentLayer() {} |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 50 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 51 | bool override_opaque_contents_rect_; |
| 52 | gfx::Rect opaque_contents_rect_; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 53 | }; |
| 54 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 55 | class TestContentLayerImpl : public LayerImpl { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 56 | public: |
| 57 | TestContentLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 58 | : LayerImpl(tree_impl, id), override_opaque_contents_rect_(false) { |
| 59 | SetDrawsContent(true); |
| 60 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 61 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 62 | virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const OVERRIDE { |
| 63 | if (override_opaque_contents_rect_) { |
| 64 | return SimpleEnclosedRegion( |
| 65 | gfx::IntersectRects(opaque_contents_rect_, visible_content_rect())); |
| 66 | } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 67 | return LayerImpl::VisibleContentOpaqueRegion(); |
| 68 | } |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 69 | void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 70 | override_opaque_contents_rect_ = true; |
| 71 | opaque_contents_rect_ = opaque_contents_rect; |
| 72 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 73 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 74 | private: |
| 75 | bool override_opaque_contents_rect_; |
| 76 | gfx::Rect opaque_contents_rect_; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 77 | }; |
| 78 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 79 | template <typename LayerType> |
| 80 | class TestOcclusionTrackerWithClip : public TestOcclusionTracker<LayerType> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 81 | public: |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 82 | explicit TestOcclusionTrackerWithClip(const gfx::Rect& viewport_rect) |
[email protected] | 97c6a734 | 2014-03-12 20:36:43 | [diff] [blame] | 83 | : TestOcclusionTracker<LayerType>(viewport_rect) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 84 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 85 | bool OccludedLayer(const LayerType* layer, |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 86 | const gfx::Rect& content_rect) const { |
[email protected] | cfc2d2d | 2013-10-04 23:26:45 | [diff] [blame] | 87 | DCHECK(layer->visible_content_rect().Contains(content_rect)); |
[email protected] | 7d6d6c9 | 2014-03-06 01:18:50 | [diff] [blame] | 88 | return this->Occluded( |
| 89 | layer->render_target(), content_rect, layer->draw_transform()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 90 | } |
[email protected] | fbc29332 | 2013-10-01 05:07:15 | [diff] [blame] | 91 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 92 | // Gives an unoccluded sub-rect of |content_rect| in the content space of the |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 93 | // layer. Simple wrapper around UnoccludedContentRect. |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 94 | gfx::Rect UnoccludedLayerContentRect(const LayerType* layer, |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 95 | const gfx::Rect& content_rect) const { |
[email protected] | cfc2d2d | 2013-10-04 23:26:45 | [diff] [blame] | 96 | DCHECK(layer->visible_content_rect().Contains(content_rect)); |
[email protected] | ce4738e | 2014-06-13 14:54:02 | [diff] [blame] | 97 | return this->UnoccludedContentRect(content_rect, layer->draw_transform()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 98 | } |
[email protected] | e312aca | 2014-03-20 22:11:55 | [diff] [blame] | 99 | |
| 100 | gfx::Rect UnoccludedSurfaceContentRect(const LayerType* layer, |
| 101 | bool for_replica, |
| 102 | const gfx::Rect& content_rect) const { |
| 103 | typename LayerType::RenderSurfaceType* surface = layer->render_surface(); |
| 104 | gfx::Transform draw_transform = for_replica |
| 105 | ? surface->replica_draw_transform() |
| 106 | : surface->draw_transform(); |
[email protected] | ce4738e | 2014-06-13 14:54:02 | [diff] [blame] | 107 | return this->UnoccludedContributingSurfaceContentRect(content_rect, |
| 108 | draw_transform); |
[email protected] | e312aca | 2014-03-20 22:11:55 | [diff] [blame] | 109 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 110 | }; |
| 111 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 112 | struct OcclusionTrackerTestMainThreadTypes { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 113 | typedef Layer LayerType; |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 114 | typedef FakeLayerTreeHost HostType; |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 115 | typedef RenderSurface RenderSurfaceType; |
| 116 | typedef TestContentLayer ContentLayerType; |
| 117 | typedef scoped_refptr<Layer> LayerPtrType; |
| 118 | typedef scoped_refptr<ContentLayerType> ContentLayerPtrType; |
[email protected] | ba1b33e | 2014-02-28 16:44:51 | [diff] [blame] | 119 | typedef LayerIterator<Layer> TestLayerIterator; |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 120 | typedef OcclusionTracker<Layer> OcclusionTrackerType; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 121 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 122 | static LayerPtrType CreateLayer(HostType* host) { return Layer::Create(); } |
| 123 | static ContentLayerPtrType CreateContentLayer(HostType* host) { |
| 124 | return make_scoped_refptr(new ContentLayerType()); |
| 125 | } |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 126 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 127 | static LayerPtrType PassLayerPtr(ContentLayerPtrType* layer) { |
| 128 | LayerPtrType ref(*layer); |
| 129 | *layer = NULL; |
| 130 | return ref; |
| 131 | } |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 132 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 133 | static LayerPtrType PassLayerPtr(LayerPtrType* layer) { |
| 134 | LayerPtrType ref(*layer); |
| 135 | *layer = NULL; |
| 136 | return ref; |
| 137 | } |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 138 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 139 | static void DestroyLayer(LayerPtrType* layer) { *layer = NULL; } |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 140 | |
| 141 | static void RecursiveUpdateNumChildren(LayerType* layerType) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 142 | }; |
| 143 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 144 | struct OcclusionTrackerTestImplThreadTypes { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 145 | typedef LayerImpl LayerType; |
| 146 | typedef LayerTreeImpl HostType; |
| 147 | typedef RenderSurfaceImpl RenderSurfaceType; |
| 148 | typedef TestContentLayerImpl ContentLayerType; |
| 149 | typedef scoped_ptr<LayerImpl> LayerPtrType; |
| 150 | typedef scoped_ptr<ContentLayerType> ContentLayerPtrType; |
[email protected] | ba1b33e | 2014-02-28 16:44:51 | [diff] [blame] | 151 | typedef LayerIterator<LayerImpl> TestLayerIterator; |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 152 | typedef OcclusionTracker<LayerImpl> OcclusionTrackerType; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 153 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 154 | static LayerPtrType CreateLayer(HostType* host) { |
| 155 | return LayerImpl::Create(host, next_layer_impl_id++); |
| 156 | } |
| 157 | static ContentLayerPtrType CreateContentLayer(HostType* host) { |
| 158 | return make_scoped_ptr(new ContentLayerType(host, next_layer_impl_id++)); |
| 159 | } |
| 160 | static int next_layer_impl_id; |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 161 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 162 | static LayerPtrType PassLayerPtr(LayerPtrType* layer) { |
| 163 | return layer->Pass(); |
| 164 | } |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 165 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 166 | static LayerPtrType PassLayerPtr(ContentLayerPtrType* layer) { |
| 167 | return layer->PassAs<LayerType>(); |
| 168 | } |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 169 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 170 | static void DestroyLayer(LayerPtrType* layer) { layer->reset(); } |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 171 | |
| 172 | static void RecursiveUpdateNumChildren(LayerType* layer) { |
| 173 | FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(layer); |
| 174 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 175 | }; |
| 176 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 177 | int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 178 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 179 | template <typename Types> class OcclusionTrackerTest : public testing::Test { |
| 180 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 181 | explicit OcclusionTrackerTest(bool opaque_layers) |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 182 | : opaque_layers_(opaque_layers), host_(FakeLayerTreeHost::Create()) {} |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 183 | |
| 184 | virtual void RunMyTest() = 0; |
| 185 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 186 | virtual void TearDown() { DestroyLayers(); } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 187 | |
| 188 | typename Types::HostType* GetHost(); |
| 189 | |
| 190 | typename Types::ContentLayerType* CreateRoot(const gfx::Transform& transform, |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 191 | const gfx::PointF& position, |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 192 | const gfx::Size& bounds) { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 193 | typename Types::ContentLayerPtrType layer( |
| 194 | Types::CreateContentLayer(GetHost())); |
| 195 | typename Types::ContentLayerType* layer_ptr = layer.get(); |
| 196 | SetProperties(layer_ptr, transform, position, bounds); |
| 197 | |
[email protected] | 22898ed | 2013-06-01 04:52:30 | [diff] [blame] | 198 | DCHECK(!root_.get()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 199 | root_ = Types::PassLayerPtr(&layer); |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 200 | |
| 201 | SetRootLayerOnMainThread(layer_ptr); |
| 202 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 203 | return layer_ptr; |
| 204 | } |
| 205 | |
| 206 | typename Types::LayerType* CreateLayer(typename Types::LayerType* parent, |
| 207 | const gfx::Transform& transform, |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 208 | const gfx::PointF& position, |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 209 | const gfx::Size& bounds) { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 210 | typename Types::LayerPtrType layer(Types::CreateLayer(GetHost())); |
| 211 | typename Types::LayerType* layer_ptr = layer.get(); |
| 212 | SetProperties(layer_ptr, transform, position, bounds); |
| 213 | parent->AddChild(Types::PassLayerPtr(&layer)); |
| 214 | return layer_ptr; |
| 215 | } |
| 216 | |
| 217 | typename Types::LayerType* CreateSurface(typename Types::LayerType* parent, |
| 218 | const gfx::Transform& transform, |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 219 | const gfx::PointF& position, |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 220 | const gfx::Size& bounds) { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 221 | typename Types::LayerType* layer = |
| 222 | CreateLayer(parent, transform, position, bounds); |
| 223 | layer->SetForceRenderSurface(true); |
| 224 | return layer; |
| 225 | } |
| 226 | |
| 227 | typename Types::ContentLayerType* CreateDrawingLayer( |
| 228 | typename Types::LayerType* parent, |
| 229 | const gfx::Transform& transform, |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 230 | const gfx::PointF& position, |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 231 | const gfx::Size& bounds, |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 232 | bool opaque) { |
| 233 | typename Types::ContentLayerPtrType layer( |
| 234 | Types::CreateContentLayer(GetHost())); |
| 235 | typename Types::ContentLayerType* layer_ptr = layer.get(); |
| 236 | SetProperties(layer_ptr, transform, position, bounds); |
| 237 | |
| 238 | if (opaque_layers_) { |
| 239 | layer_ptr->SetContentsOpaque(opaque); |
| 240 | } else { |
| 241 | layer_ptr->SetContentsOpaque(false); |
| 242 | if (opaque) |
[email protected] | 2c7c670 | 2013-03-26 03:14:05 | [diff] [blame] | 243 | layer_ptr->SetOpaqueContentsRect(gfx::Rect(bounds)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 244 | else |
| 245 | layer_ptr->SetOpaqueContentsRect(gfx::Rect()); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 246 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 247 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 248 | parent->AddChild(Types::PassLayerPtr(&layer)); |
| 249 | return layer_ptr; |
| 250 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 251 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 252 | typename Types::LayerType* CreateReplicaLayer( |
| 253 | typename Types::LayerType* owning_layer, |
| 254 | const gfx::Transform& transform, |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 255 | const gfx::PointF& position, |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 256 | const gfx::Size& bounds) { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 257 | typename Types::ContentLayerPtrType layer( |
| 258 | Types::CreateContentLayer(GetHost())); |
| 259 | typename Types::ContentLayerType* layer_ptr = layer.get(); |
| 260 | SetProperties(layer_ptr, transform, position, bounds); |
| 261 | SetReplica(owning_layer, Types::PassLayerPtr(&layer)); |
| 262 | return layer_ptr; |
| 263 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 264 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 265 | typename Types::LayerType* CreateMaskLayer( |
| 266 | typename Types::LayerType* owning_layer, |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 267 | const gfx::Size& bounds) { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 268 | typename Types::ContentLayerPtrType layer( |
| 269 | Types::CreateContentLayer(GetHost())); |
| 270 | typename Types::ContentLayerType* layer_ptr = layer.get(); |
| 271 | SetProperties(layer_ptr, identity_matrix, gfx::PointF(), bounds); |
| 272 | SetMask(owning_layer, Types::PassLayerPtr(&layer)); |
| 273 | return layer_ptr; |
| 274 | } |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 275 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 276 | typename Types::ContentLayerType* CreateDrawingSurface( |
| 277 | typename Types::LayerType* parent, |
| 278 | const gfx::Transform& transform, |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 279 | const gfx::PointF& position, |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 280 | const gfx::Size& bounds, |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 281 | bool opaque) { |
| 282 | typename Types::ContentLayerType* layer = |
| 283 | CreateDrawingLayer(parent, transform, position, bounds, opaque); |
| 284 | layer->SetForceRenderSurface(true); |
| 285 | return layer; |
| 286 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 287 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 288 | void DestroyLayers() { |
| 289 | Types::DestroyLayer(&root_); |
| 290 | render_surface_layer_list_.reset(); |
| 291 | render_surface_layer_list_impl_.clear(); |
| 292 | replica_layers_.clear(); |
| 293 | mask_layers_.clear(); |
| 294 | ResetLayerIterator(); |
| 295 | } |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 296 | |
| 297 | void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} |
| 298 | |
| 299 | void AddCopyRequest(Layer* layer) { |
| 300 | layer->RequestCopyOfOutput( |
| 301 | CopyOutputRequest::CreateBitmapRequest(base::Bind( |
| 302 | &OcclusionTrackerTest<Types>::CopyOutputCallback, |
| 303 | base::Unretained(this)))); |
| 304 | } |
| 305 | |
| 306 | void AddCopyRequest(LayerImpl* layer) { |
| 307 | ScopedPtrVector<CopyOutputRequest> requests; |
| 308 | requests.push_back( |
| 309 | CopyOutputRequest::CreateBitmapRequest(base::Bind( |
| 310 | &OcclusionTrackerTest<Types>::CopyOutputCallback, |
| 311 | base::Unretained(this)))); |
| 312 | layer->PassCopyRequests(&requests); |
| 313 | } |
| 314 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 315 | void CalcDrawEtc(TestContentLayerImpl* root) { |
| 316 | DCHECK(root == root_.get()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 317 | DCHECK(!root->render_surface()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 318 | |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 319 | Types::RecursiveUpdateNumChildren(root); |
[email protected] | 7aad55f | 2013-07-26 11:25:53 | [diff] [blame] | 320 | LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 321 | root, root->bounds(), &render_surface_layer_list_impl_); |
| 322 | inputs.can_adjust_raster_scales = true; |
| 323 | LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 324 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 325 | layer_iterator_ = layer_iterator_begin_ = |
| 326 | Types::TestLayerIterator::Begin(&render_surface_layer_list_impl_); |
| 327 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 328 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 329 | void CalcDrawEtc(TestContentLayer* root) { |
| 330 | DCHECK(root == root_.get()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 331 | DCHECK(!root->render_surface()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 332 | |
[email protected] | 989386c | 2013-07-18 21:37:23 | [diff] [blame] | 333 | render_surface_layer_list_.reset(new RenderSurfaceLayerList); |
[email protected] | 7aad55f | 2013-07-26 11:25:53 | [diff] [blame] | 334 | LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
| 335 | root, root->bounds(), render_surface_layer_list_.get()); |
| 336 | inputs.can_adjust_raster_scales = true; |
| 337 | LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 338 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 339 | layer_iterator_ = layer_iterator_begin_ = |
[email protected] | 989386c | 2013-07-18 21:37:23 | [diff] [blame] | 340 | Types::TestLayerIterator::Begin(render_surface_layer_list_.get()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 341 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 342 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 343 | void EnterLayer(typename Types::LayerType* layer, |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 344 | typename Types::OcclusionTrackerType* occlusion) { |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 345 | ASSERT_EQ(*layer_iterator_, layer); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 346 | ASSERT_TRUE(layer_iterator_.represents_itself()); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 347 | occlusion->EnterLayer(layer_iterator_); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 348 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 349 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 350 | void LeaveLayer(typename Types::LayerType* layer, |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 351 | typename Types::OcclusionTrackerType* occlusion) { |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 352 | ASSERT_EQ(*layer_iterator_, layer); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 353 | ASSERT_TRUE(layer_iterator_.represents_itself()); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 354 | occlusion->LeaveLayer(layer_iterator_); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 355 | ++layer_iterator_; |
| 356 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 357 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 358 | void VisitLayer(typename Types::LayerType* layer, |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 359 | typename Types::OcclusionTrackerType* occlusion) { |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 360 | EnterLayer(layer, occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 361 | LeaveLayer(layer, occlusion); |
| 362 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 363 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 364 | void EnterContributingSurface( |
| 365 | typename Types::LayerType* layer, |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 366 | typename Types::OcclusionTrackerType* occlusion) { |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 367 | ASSERT_EQ(*layer_iterator_, layer); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 368 | ASSERT_TRUE(layer_iterator_.represents_target_render_surface()); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 369 | occlusion->EnterLayer(layer_iterator_); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 370 | occlusion->LeaveLayer(layer_iterator_); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 371 | ++layer_iterator_; |
| 372 | ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 373 | occlusion->EnterLayer(layer_iterator_); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 374 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 375 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 376 | void LeaveContributingSurface( |
| 377 | typename Types::LayerType* layer, |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 378 | typename Types::OcclusionTrackerType* occlusion) { |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 379 | ASSERT_EQ(*layer_iterator_, layer); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 380 | ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 381 | occlusion->LeaveLayer(layer_iterator_); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 382 | ++layer_iterator_; |
| 383 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 384 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 385 | void VisitContributingSurface( |
| 386 | typename Types::LayerType* layer, |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 387 | typename Types::OcclusionTrackerType* occlusion) { |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 388 | EnterContributingSurface(layer, occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 389 | LeaveContributingSurface(layer, occlusion); |
| 390 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 391 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 392 | void ResetLayerIterator() { layer_iterator_ = layer_iterator_begin_; } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 393 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 394 | const gfx::Transform identity_matrix; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 395 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 396 | private: |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 397 | void SetRootLayerOnMainThread(Layer* root) { |
| 398 | host_->SetRootLayer(scoped_refptr<Layer>(root)); |
| 399 | } |
| 400 | |
| 401 | void SetRootLayerOnMainThread(LayerImpl* root) {} |
| 402 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 403 | void SetBaseProperties(typename Types::LayerType* layer, |
| 404 | const gfx::Transform& transform, |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 405 | const gfx::PointF& position, |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 406 | const gfx::Size& bounds) { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 407 | layer->SetTransform(transform); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 408 | layer->SetPosition(position); |
| 409 | layer->SetBounds(bounds); |
| 410 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 411 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 412 | void SetProperties(Layer* layer, |
| 413 | const gfx::Transform& transform, |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 414 | const gfx::PointF& position, |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 415 | const gfx::Size& bounds) { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 416 | SetBaseProperties(layer, transform, position, bounds); |
| 417 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 418 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 419 | void SetProperties(LayerImpl* layer, |
| 420 | const gfx::Transform& transform, |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 421 | const gfx::PointF& position, |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 422 | const gfx::Size& bounds) { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 423 | SetBaseProperties(layer, transform, position, bounds); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 424 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 425 | layer->SetContentBounds(layer->bounds()); |
| 426 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 427 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 428 | void SetReplica(Layer* owning_layer, scoped_refptr<Layer> layer) { |
| 429 | owning_layer->SetReplicaLayer(layer.get()); |
| 430 | replica_layers_.push_back(layer); |
| 431 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 432 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 433 | void SetReplica(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) { |
| 434 | owning_layer->SetReplicaLayer(layer.Pass()); |
| 435 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 436 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 437 | void SetMask(Layer* owning_layer, scoped_refptr<Layer> layer) { |
| 438 | owning_layer->SetMaskLayer(layer.get()); |
| 439 | mask_layers_.push_back(layer); |
| 440 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 441 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 442 | void SetMask(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) { |
| 443 | owning_layer->SetMaskLayer(layer.Pass()); |
| 444 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 445 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 446 | bool opaque_layers_; |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 447 | scoped_ptr<FakeLayerTreeHost> host_; |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 448 | // These hold ownership of the layers for the duration of the test. |
| 449 | typename Types::LayerPtrType root_; |
[email protected] | 989386c | 2013-07-18 21:37:23 | [diff] [blame] | 450 | scoped_ptr<RenderSurfaceLayerList> render_surface_layer_list_; |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 451 | LayerImplList render_surface_layer_list_impl_; |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 452 | typename Types::TestLayerIterator layer_iterator_begin_; |
| 453 | typename Types::TestLayerIterator layer_iterator_; |
| 454 | typename Types::LayerType* last_layer_visited_; |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 455 | LayerList replica_layers_; |
| 456 | LayerList mask_layers_; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 457 | }; |
| 458 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 459 | template <> |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 460 | FakeLayerTreeHost* |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 461 | OcclusionTrackerTest<OcclusionTrackerTestMainThreadTypes>::GetHost() { |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 462 | return host_.get(); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 463 | } |
| 464 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 465 | template <> |
| 466 | LayerTreeImpl* |
| 467 | OcclusionTrackerTest<OcclusionTrackerTestImplThreadTypes>::GetHost() { |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 468 | return host_->host_impl()->active_tree(); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 469 | } |
| 470 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 471 | #define RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \ |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 472 | class ClassName##MainThreadOpaqueLayers \ |
| 473 | : public ClassName<OcclusionTrackerTestMainThreadTypes> { \ |
| 474 | public: /* NOLINT(whitespace/indent) */ \ |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 475 | ClassName##MainThreadOpaqueLayers() \ |
| 476 | : ClassName<OcclusionTrackerTestMainThreadTypes>(true) {} \ |
| 477 | }; \ |
| 478 | TEST_F(ClassName##MainThreadOpaqueLayers, RunTest) { RunMyTest(); } |
| 479 | #define RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName) \ |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 480 | class ClassName##MainThreadOpaquePaints \ |
| 481 | : public ClassName<OcclusionTrackerTestMainThreadTypes> { \ |
| 482 | public: /* NOLINT(whitespace/indent) */ \ |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 483 | ClassName##MainThreadOpaquePaints() \ |
| 484 | : ClassName<OcclusionTrackerTestMainThreadTypes>(false) {} \ |
| 485 | }; \ |
| 486 | TEST_F(ClassName##MainThreadOpaquePaints, RunTest) { RunMyTest(); } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 487 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 488 | #define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 489 | class ClassName##ImplThreadOpaqueLayers \ |
| 490 | : public ClassName<OcclusionTrackerTestImplThreadTypes> { \ |
| 491 | public: /* NOLINT(whitespace/indent) */ \ |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 492 | ClassName##ImplThreadOpaqueLayers() \ |
| 493 | : ClassName<OcclusionTrackerTestImplThreadTypes>(true) {} \ |
| 494 | }; \ |
| 495 | TEST_F(ClassName##ImplThreadOpaqueLayers, RunTest) { RunMyTest(); } |
| 496 | #define RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName) \ |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 497 | class ClassName##ImplThreadOpaquePaints \ |
| 498 | : public ClassName<OcclusionTrackerTestImplThreadTypes> { \ |
| 499 | public: /* NOLINT(whitespace/indent) */ \ |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 500 | ClassName##ImplThreadOpaquePaints() \ |
| 501 | : ClassName<OcclusionTrackerTestImplThreadTypes>(false) {} \ |
| 502 | }; \ |
| 503 | TEST_F(ClassName##ImplThreadOpaquePaints, RunTest) { RunMyTest(); } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 504 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 505 | #define ALL_OCCLUSIONTRACKER_TEST(ClassName) \ |
| 506 | RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \ |
| 507 | RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName) \ |
| 508 | RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ |
| 509 | RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 510 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 511 | #define MAIN_THREAD_TEST(ClassName) \ |
| 512 | RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 513 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 514 | #define IMPL_THREAD_TEST(ClassName) \ |
| 515 | RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 516 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 517 | #define MAIN_AND_IMPL_THREAD_TEST(ClassName) \ |
| 518 | RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \ |
| 519 | RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 520 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 521 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 522 | class OcclusionTrackerTestIdentityTransforms |
| 523 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 524 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 525 | explicit OcclusionTrackerTestIdentityTransforms(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 526 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 527 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 528 | void RunMyTest() { |
| 529 | typename Types::ContentLayerType* root = this->CreateRoot( |
| 530 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| 531 | typename Types::ContentLayerType* parent = this->CreateDrawingLayer( |
| 532 | root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
| 533 | typename Types::ContentLayerType* layer = |
| 534 | this->CreateDrawingLayer(parent, |
| 535 | this->identity_matrix, |
| 536 | gfx::PointF(30.f, 30.f), |
| 537 | gfx::Size(500, 500), |
| 538 | true); |
| 539 | parent->SetMasksToBounds(true); |
| 540 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 541 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 542 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | 97c6a734 | 2014-03-12 20:36:43 | [diff] [blame] | 543 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 544 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 545 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 546 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 547 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 548 | EXPECT_EQ(gfx::Rect().ToString(), |
| 549 | occlusion.occlusion_from_outside_target().ToString()); |
| 550 | EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
| 551 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 552 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 553 | EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 554 | parent, gfx::Rect(30, 30, 70, 70)).IsEmpty()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 555 | EXPECT_EQ(gfx::Rect(29, 30, 1, 70), |
| 556 | occlusion.UnoccludedLayerContentRect(parent, |
| 557 | gfx::Rect(29, 30, 70, 70))); |
| 558 | EXPECT_EQ(gfx::Rect(29, 29, 70, 70), |
| 559 | occlusion.UnoccludedLayerContentRect(parent, |
| 560 | gfx::Rect(29, 29, 70, 70))); |
| 561 | EXPECT_EQ(gfx::Rect(30, 29, 70, 1), |
| 562 | occlusion.UnoccludedLayerContentRect(parent, |
| 563 | gfx::Rect(30, 29, 70, 70))); |
| 564 | EXPECT_EQ(gfx::Rect(31, 29, 69, 1), |
| 565 | occlusion.UnoccludedLayerContentRect(parent, |
| 566 | gfx::Rect(31, 29, 69, 70))); |
| 567 | EXPECT_EQ(gfx::Rect(), |
| 568 | occlusion.UnoccludedLayerContentRect(parent, |
| 569 | gfx::Rect(31, 30, 69, 70))); |
| 570 | EXPECT_EQ(gfx::Rect(), |
| 571 | occlusion.UnoccludedLayerContentRect(parent, |
| 572 | gfx::Rect(31, 31, 69, 69))); |
| 573 | EXPECT_EQ(gfx::Rect(), |
| 574 | occlusion.UnoccludedLayerContentRect(parent, |
| 575 | gfx::Rect(30, 31, 70, 69))); |
| 576 | EXPECT_EQ(gfx::Rect(29, 31, 1, 69), |
| 577 | occlusion.UnoccludedLayerContentRect(parent, |
| 578 | gfx::Rect(29, 31, 70, 69))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 579 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 580 | }; |
| 581 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 582 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestIdentityTransforms); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 583 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 584 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 585 | class OcclusionTrackerTestQuadsMismatchLayer |
| 586 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 587 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 588 | explicit OcclusionTrackerTestQuadsMismatchLayer(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 589 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 590 | void RunMyTest() { |
| 591 | gfx::Transform layer_transform; |
| 592 | layer_transform.Translate(10.0, 10.0); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 593 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 594 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 595 | this->identity_matrix, gfx::Point(0, 0), gfx::Size(100, 100)); |
| 596 | typename Types::ContentLayerType* layer1 = this->CreateDrawingLayer( |
| 597 | parent, layer_transform, gfx::PointF(), gfx::Size(90, 90), true); |
| 598 | typename Types::ContentLayerType* layer2 = this->CreateDrawingLayer( |
| 599 | layer1, layer_transform, gfx::PointF(), gfx::Size(50, 50), true); |
| 600 | this->CalcDrawEtc(parent); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 601 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 602 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 603 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 604 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 605 | this->VisitLayer(layer2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 606 | this->EnterLayer(layer1, &occlusion); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 607 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 608 | EXPECT_EQ(gfx::Rect().ToString(), |
| 609 | occlusion.occlusion_from_outside_target().ToString()); |
| 610 | EXPECT_EQ(gfx::Rect(20, 20, 50, 50).ToString(), |
| 611 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 612 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 613 | // This checks cases where the quads don't match their "containing" |
| 614 | // layers, e.g. in terms of transforms or clip rect. This is typical for |
| 615 | // DelegatedRendererLayer. |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 616 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 617 | gfx::Transform quad_transform; |
| 618 | quad_transform.Translate(30.0, 30.0); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 619 | |
[email protected] | ce4738e | 2014-06-13 14:54:02 | [diff] [blame] | 620 | EXPECT_TRUE(occlusion.UnoccludedContentRect(gfx::Rect(0, 0, 10, 10), |
[email protected] | 7d6d6c9 | 2014-03-06 01:18:50 | [diff] [blame] | 621 | quad_transform).IsEmpty()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 622 | EXPECT_EQ(gfx::Rect(40, 40, 10, 10), |
| 623 | occlusion.UnoccludedContentRect(gfx::Rect(40, 40, 10, 10), |
| 624 | quad_transform)); |
| 625 | EXPECT_EQ(gfx::Rect(40, 30, 5, 10), |
| 626 | occlusion.UnoccludedContentRect(gfx::Rect(35, 30, 10, 10), |
| 627 | quad_transform)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 628 | } |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 629 | }; |
| 630 | |
| 631 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestQuadsMismatchLayer); |
| 632 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 633 | template <class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 634 | class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 635 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 636 | explicit OcclusionTrackerTestRotatedChild(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 637 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 638 | void RunMyTest() { |
| 639 | gfx::Transform layer_transform; |
| 640 | layer_transform.Translate(250.0, 250.0); |
| 641 | layer_transform.Rotate(90.0); |
| 642 | layer_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 643 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 644 | typename Types::ContentLayerType* root = this->CreateRoot( |
| 645 | this->identity_matrix, gfx::Point(0, 0), gfx::Size(200, 200)); |
| 646 | typename Types::ContentLayerType* parent = this->CreateDrawingLayer( |
| 647 | root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
| 648 | typename Types::ContentLayerType* layer = |
| 649 | this->CreateDrawingLayer(parent, |
| 650 | layer_transform, |
| 651 | gfx::PointF(30.f, 30.f), |
| 652 | gfx::Size(500, 500), |
| 653 | true); |
| 654 | parent->SetMasksToBounds(true); |
| 655 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 656 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 657 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 658 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 659 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 660 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 661 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 662 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 663 | EXPECT_EQ(gfx::Rect().ToString(), |
| 664 | occlusion.occlusion_from_outside_target().ToString()); |
| 665 | EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
| 666 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 667 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 668 | EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 669 | parent, gfx::Rect(30, 30, 70, 70)).IsEmpty()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 670 | EXPECT_EQ(gfx::Rect(29, 30, 1, 70), |
| 671 | occlusion.UnoccludedLayerContentRect(parent, |
| 672 | gfx::Rect(29, 30, 69, 70))); |
| 673 | EXPECT_EQ(gfx::Rect(29, 29, 70, 70), |
| 674 | occlusion.UnoccludedLayerContentRect(parent, |
| 675 | gfx::Rect(29, 29, 70, 70))); |
| 676 | EXPECT_EQ(gfx::Rect(30, 29, 70, 1), |
| 677 | occlusion.UnoccludedLayerContentRect(parent, |
| 678 | gfx::Rect(30, 29, 70, 70))); |
| 679 | EXPECT_EQ(gfx::Rect(31, 29, 69, 1), |
| 680 | occlusion.UnoccludedLayerContentRect(parent, |
| 681 | gfx::Rect(31, 29, 69, 70))); |
| 682 | EXPECT_EQ(gfx::Rect(), |
| 683 | occlusion.UnoccludedLayerContentRect(parent, |
| 684 | gfx::Rect(31, 30, 69, 70))); |
| 685 | EXPECT_EQ(gfx::Rect(), |
| 686 | occlusion.UnoccludedLayerContentRect(parent, |
| 687 | gfx::Rect(31, 31, 69, 69))); |
| 688 | EXPECT_EQ(gfx::Rect(), |
| 689 | occlusion.UnoccludedLayerContentRect(parent, |
| 690 | gfx::Rect(30, 31, 70, 69))); |
| 691 | EXPECT_EQ(gfx::Rect(29, 31, 1, 69), |
| 692 | occlusion.UnoccludedLayerContentRect(parent, |
| 693 | gfx::Rect(29, 31, 70, 69))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 694 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 695 | }; |
| 696 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 697 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestRotatedChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 698 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 699 | template <class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 700 | class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 701 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 702 | explicit OcclusionTrackerTestTranslatedChild(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 703 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 704 | void RunMyTest() { |
| 705 | gfx::Transform layer_transform; |
| 706 | layer_transform.Translate(20.0, 20.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 707 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 708 | typename Types::ContentLayerType* root = this->CreateRoot( |
| 709 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| 710 | typename Types::ContentLayerType* parent = this->CreateDrawingLayer( |
| 711 | root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
| 712 | typename Types::ContentLayerType* layer = |
| 713 | this->CreateDrawingLayer(parent, |
| 714 | layer_transform, |
| 715 | gfx::PointF(30.f, 30.f), |
| 716 | gfx::Size(500, 500), |
| 717 | true); |
| 718 | parent->SetMasksToBounds(true); |
| 719 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 720 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 721 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 722 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 723 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 724 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 725 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 726 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 727 | EXPECT_EQ(gfx::Rect().ToString(), |
| 728 | occlusion.occlusion_from_outside_target().ToString()); |
| 729 | EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), |
| 730 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 731 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 732 | EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 733 | parent, gfx::Rect(50, 50, 50, 50)).IsEmpty()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 734 | EXPECT_EQ(gfx::Rect(49, 50, 1, 50), |
| 735 | occlusion.UnoccludedLayerContentRect(parent, |
| 736 | gfx::Rect(49, 50, 50, 50))); |
| 737 | EXPECT_EQ(gfx::Rect(49, 49, 50, 50), |
| 738 | occlusion.UnoccludedLayerContentRect(parent, |
| 739 | gfx::Rect(49, 49, 50, 50))); |
| 740 | EXPECT_EQ(gfx::Rect(50, 49, 50, 1), |
| 741 | occlusion.UnoccludedLayerContentRect(parent, |
| 742 | gfx::Rect(50, 49, 50, 50))); |
| 743 | EXPECT_EQ(gfx::Rect(51, 49, 49, 1), |
| 744 | occlusion.UnoccludedLayerContentRect(parent, |
| 745 | gfx::Rect(51, 49, 49, 50))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 746 | EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
[email protected] | cfc2d2d | 2013-10-04 23:26:45 | [diff] [blame] | 747 | parent, gfx::Rect(51, 50, 49, 50)).IsEmpty()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 748 | EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
[email protected] | cfc2d2d | 2013-10-04 23:26:45 | [diff] [blame] | 749 | parent, gfx::Rect(51, 51, 49, 49)).IsEmpty()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 750 | EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
[email protected] | cfc2d2d | 2013-10-04 23:26:45 | [diff] [blame] | 751 | parent, gfx::Rect(50, 51, 50, 49)).IsEmpty()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 752 | EXPECT_EQ(gfx::Rect(49, 51, 1, 49), |
| 753 | occlusion.UnoccludedLayerContentRect(parent, |
| 754 | gfx::Rect(49, 51, 50, 49))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 755 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 756 | }; |
| 757 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 758 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestTranslatedChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 759 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 760 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 761 | class OcclusionTrackerTestChildInRotatedChild |
| 762 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 763 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 764 | explicit OcclusionTrackerTestChildInRotatedChild(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 765 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 766 | void RunMyTest() { |
| 767 | gfx::Transform child_transform; |
| 768 | child_transform.Translate(250.0, 250.0); |
| 769 | child_transform.Rotate(90.0); |
| 770 | child_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 771 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 772 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 773 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 774 | parent->SetMasksToBounds(true); |
[email protected] | 3a9a92d | 2013-07-11 04:37:00 | [diff] [blame] | 775 | typename Types::LayerType* child = this->CreateSurface( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 776 | parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500)); |
| 777 | child->SetMasksToBounds(true); |
| 778 | typename Types::ContentLayerType* layer = |
| 779 | this->CreateDrawingLayer(child, |
| 780 | this->identity_matrix, |
| 781 | gfx::PointF(10.f, 10.f), |
| 782 | gfx::Size(500, 500), |
| 783 | true); |
| 784 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 785 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 786 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 787 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 788 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 789 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 790 | this->EnterContributingSurface(child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 791 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 792 | EXPECT_EQ(gfx::Rect().ToString(), |
| 793 | occlusion.occlusion_from_outside_target().ToString()); |
| 794 | EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
| 795 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 796 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 797 | this->LeaveContributingSurface(child, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 798 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 799 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 800 | EXPECT_EQ(gfx::Rect().ToString(), |
| 801 | occlusion.occlusion_from_outside_target().ToString()); |
| 802 | EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), |
| 803 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 804 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 805 | /* Justification for the above occlusion from |layer|: |
| 806 | 100 |
| 807 | +---------------------+ |
| 808 | | | |
| 809 | | 30 | rotate(90) |
| 810 | | 30 + ---------------------------------+ |
| 811 | 100 | | 10 | | ==> |
| 812 | | |10+---------------------------------+ |
| 813 | | | | | | | |
| 814 | | | | | | | |
| 815 | | | | | | | |
| 816 | +----|--|-------------+ | | |
| 817 | | | | | |
| 818 | | | | | |
| 819 | | | | |500 |
| 820 | | | | | |
| 821 | | | | | |
| 822 | | | | | |
| 823 | | | | | |
| 824 | +--|-------------------------------+ | |
| 825 | | | |
| 826 | +---------------------------------+ |
| 827 | 500 |
| 828 | |
| 829 | +---------------------+ |
| 830 | | |30 Visible region of |layer|: ///// |
| 831 | | | |
| 832 | | +---------------------------------+ |
| 833 | 100| | |10 | |
| 834 | | +---------------------------------+ | |
| 835 | | | |///////////////| 420 | | |
| 836 | | | |///////////////|60 | | |
| 837 | | | |///////////////| | | |
| 838 | +--|--|---------------+ | | |
| 839 | 20|10| 70 | | |
| 840 | | | | | |
| 841 | | | | | |
| 842 | | | | | |
| 843 | | | | | |
| 844 | | | | | |
| 845 | | | |10| |
| 846 | | +------------------------------|--+ |
| 847 | | 490 | |
| 848 | +---------------------------------+ |
| 849 | 500 |
| 850 | |
| 851 | */ |
| 852 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 853 | }; |
| 854 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 855 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestChildInRotatedChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 856 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 857 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 858 | class OcclusionTrackerTestScaledRenderSurface |
| 859 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 860 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 861 | explicit OcclusionTrackerTestScaledRenderSurface(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 862 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 863 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 864 | void RunMyTest() { |
| 865 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 866 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 867 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 868 | gfx::Transform layer1_matrix; |
| 869 | layer1_matrix.Scale(2.0, 2.0); |
| 870 | typename Types::ContentLayerType* layer1 = this->CreateDrawingLayer( |
| 871 | parent, layer1_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
| 872 | layer1->SetForceRenderSurface(true); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 873 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 874 | gfx::Transform layer2_matrix; |
| 875 | layer2_matrix.Translate(25.0, 25.0); |
| 876 | typename Types::ContentLayerType* layer2 = this->CreateDrawingLayer( |
| 877 | layer1, layer2_matrix, gfx::PointF(), gfx::Size(50, 50), true); |
| 878 | typename Types::ContentLayerType* occluder = |
| 879 | this->CreateDrawingLayer(parent, |
| 880 | this->identity_matrix, |
| 881 | gfx::PointF(100.f, 100.f), |
| 882 | gfx::Size(500, 500), |
| 883 | true); |
| 884 | this->CalcDrawEtc(parent); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 885 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 886 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 887 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 888 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 889 | this->VisitLayer(occluder, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 890 | this->EnterLayer(layer2, &occlusion); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 891 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 892 | EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), |
| 893 | occlusion.occlusion_from_outside_target().ToString()); |
| 894 | EXPECT_EQ(gfx::Rect().ToString(), |
| 895 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 896 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 897 | EXPECT_EQ( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 898 | gfx::Rect(0, 0, 25, 25), |
| 899 | occlusion.UnoccludedLayerContentRect(layer2, gfx::Rect(0, 0, 25, 25))); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 900 | EXPECT_EQ(gfx::Rect(10, 25, 15, 25), |
| 901 | occlusion.UnoccludedLayerContentRect(layer2, |
| 902 | gfx::Rect(10, 25, 25, 25))); |
| 903 | EXPECT_EQ(gfx::Rect(25, 10, 25, 15), |
| 904 | occlusion.UnoccludedLayerContentRect(layer2, |
| 905 | gfx::Rect(25, 10, 25, 25))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 906 | EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 907 | layer2, gfx::Rect(25, 25, 25, 25)).IsEmpty()); |
| 908 | } |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 909 | }; |
| 910 | |
| 911 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledRenderSurface); |
| 912 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 913 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 914 | class OcclusionTrackerTestVisitTargetTwoTimes |
| 915 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 916 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 917 | explicit OcclusionTrackerTestVisitTargetTwoTimes(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 918 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 919 | void RunMyTest() { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 920 | typename Types::ContentLayerType* root = this->CreateRoot( |
| 921 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 922 | typename Types::LayerType* surface = this->CreateSurface( |
| 923 | root, this->identity_matrix, gfx::PointF(30.f, 30.f), gfx::Size()); |
| 924 | typename Types::ContentLayerType* surface_child = |
| 925 | this->CreateDrawingLayer(surface, |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 926 | this->identity_matrix, |
| 927 | gfx::PointF(10.f, 10.f), |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 928 | gfx::Size(50, 50), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 929 | true); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 930 | // |top_layer| makes |root|'s surface get considered by OcclusionTracker |
| 931 | // first, instead of |surface|'s. This exercises different code in |
| 932 | // LeaveToRenderTarget, as the target surface has already been seen when |
| 933 | // leaving |surface| later. |
| 934 | typename Types::ContentLayerType* top_layer = |
| 935 | this->CreateDrawingLayer(root, |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 936 | this->identity_matrix, |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 937 | gfx::PointF(40.f, 90.f), |
| 938 | gfx::Size(50, 20), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 939 | true); |
| 940 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 941 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 942 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 943 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 944 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 945 | this->VisitLayer(top_layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 946 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 947 | EXPECT_EQ(gfx::Rect().ToString(), |
| 948 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 949 | EXPECT_EQ(gfx::Rect(40, 90, 50, 20).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 950 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 951 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 952 | this->VisitLayer(surface_child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 953 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 954 | EXPECT_EQ(gfx::Rect(10, 60, 50, 20).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 955 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 956 | EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 957 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 958 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 959 | this->EnterContributingSurface(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 960 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 961 | EXPECT_EQ(gfx::Rect(10, 60, 50, 20).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 962 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 963 | EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 964 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 965 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 966 | // Occlusion from |top_layer| already in the root target should get merged |
| 967 | // with the occlusion from the |surface| we are leaving now. |
| 968 | this->LeaveContributingSurface(surface, &occlusion); |
| 969 | this->EnterLayer(root, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 970 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 971 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 972 | EXPECT_EQ(gfx::Rect(40, 40, 50, 70).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 973 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 974 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 975 | }; |
| 976 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 977 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestVisitTargetTwoTimes); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 978 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 979 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 980 | class OcclusionTrackerTestSurfaceRotatedOffAxis |
| 981 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 982 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 983 | explicit OcclusionTrackerTestSurfaceRotatedOffAxis(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 984 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 985 | void RunMyTest() { |
| 986 | gfx::Transform child_transform; |
| 987 | child_transform.Translate(250.0, 250.0); |
| 988 | child_transform.Rotate(95.0); |
| 989 | child_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 990 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 991 | gfx::Transform layer_transform; |
| 992 | layer_transform.Translate(10.0, 10.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 993 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 994 | typename Types::ContentLayerType* root = this->CreateRoot( |
| 995 | this->identity_matrix, gfx::PointF(), gfx::Size(1000, 1000)); |
| 996 | typename Types::ContentLayerType* parent = this->CreateDrawingLayer( |
| 997 | root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
| 998 | typename Types::LayerType* child = this->CreateLayer( |
| 999 | parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500)); |
| 1000 | child->SetMasksToBounds(true); |
| 1001 | typename Types::ContentLayerType* layer = this->CreateDrawingLayer( |
| 1002 | child, layer_transform, gfx::PointF(), gfx::Size(500, 500), true); |
| 1003 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1004 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1005 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1006 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1007 | |
[email protected] | 8a82269 | 2014-02-12 17:30:55 | [diff] [blame] | 1008 | gfx::Rect clipped_layer_in_child = MathUtil::MapEnclosingClippedRect( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1009 | layer_transform, layer->visible_content_rect()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1010 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1011 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1012 | this->EnterContributingSurface(child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1013 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1014 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1015 | occlusion.occlusion_from_outside_target().ToString()); |
| 1016 | EXPECT_EQ(clipped_layer_in_child.ToString(), |
| 1017 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1018 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1019 | this->LeaveContributingSurface(child, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1020 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1021 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1022 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1023 | occlusion.occlusion_from_outside_target().ToString()); |
| 1024 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1025 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1026 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1027 | EXPECT_EQ( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1028 | gfx::Rect(75, 55, 1, 1), |
| 1029 | occlusion.UnoccludedLayerContentRect(parent, gfx::Rect(75, 55, 1, 1))); |
| 1030 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1031 | }; |
| 1032 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1033 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceRotatedOffAxis); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1034 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1035 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1036 | class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren |
| 1037 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1038 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1039 | explicit OcclusionTrackerTestSurfaceWithTwoOpaqueChildren(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1040 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1041 | void RunMyTest() { |
| 1042 | gfx::Transform child_transform; |
| 1043 | child_transform.Translate(250.0, 250.0); |
| 1044 | child_transform.Rotate(90.0); |
| 1045 | child_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1046 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1047 | typename Types::ContentLayerType* root = this->CreateRoot( |
| 1048 | this->identity_matrix, gfx::PointF(), gfx::Size(1000, 1000)); |
| 1049 | typename Types::ContentLayerType* parent = this->CreateDrawingLayer( |
| 1050 | root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
| 1051 | parent->SetMasksToBounds(true); |
| 1052 | typename Types::ContentLayerType* child = |
[email protected] | 3a9a92d | 2013-07-11 04:37:00 | [diff] [blame] | 1053 | this->CreateDrawingSurface(parent, |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1054 | child_transform, |
| 1055 | gfx::PointF(30.f, 30.f), |
| 1056 | gfx::Size(500, 500), |
| 1057 | false); |
| 1058 | child->SetMasksToBounds(true); |
| 1059 | typename Types::ContentLayerType* layer1 = |
| 1060 | this->CreateDrawingLayer(child, |
| 1061 | this->identity_matrix, |
| 1062 | gfx::PointF(10.f, 10.f), |
| 1063 | gfx::Size(500, 500), |
| 1064 | true); |
| 1065 | typename Types::ContentLayerType* layer2 = |
| 1066 | this->CreateDrawingLayer(child, |
| 1067 | this->identity_matrix, |
| 1068 | gfx::PointF(10.f, 450.f), |
| 1069 | gfx::Size(500, 60), |
| 1070 | true); |
| 1071 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1072 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1073 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1074 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1075 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1076 | this->VisitLayer(layer2, &occlusion); |
| 1077 | this->VisitLayer(layer1, &occlusion); |
| 1078 | this->VisitLayer(child, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1079 | this->EnterContributingSurface(child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1080 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1081 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1082 | occlusion.occlusion_from_outside_target().ToString()); |
| 1083 | EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
| 1084 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1085 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1086 | EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 1087 | child, gfx::Rect(10, 430, 60, 70)).IsEmpty()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1088 | EXPECT_EQ( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1089 | gfx::Rect(9, 430, 1, 70), |
| 1090 | occlusion.UnoccludedLayerContentRect(child, gfx::Rect(9, 430, 60, 70))); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1091 | EXPECT_EQ(gfx::Rect(), |
| 1092 | occlusion.UnoccludedLayerContentRect(child, |
| 1093 | gfx::Rect(11, 430, 59, 70))); |
| 1094 | EXPECT_EQ(gfx::Rect(), |
| 1095 | occlusion.UnoccludedLayerContentRect(child, |
| 1096 | gfx::Rect(10, 431, 60, 69))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1097 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1098 | this->LeaveContributingSurface(child, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1099 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1100 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1101 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1102 | occlusion.occlusion_from_outside_target().ToString()); |
| 1103 | EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), |
| 1104 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1105 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1106 | EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 1107 | parent, gfx::Rect(30, 40, 70, 60)).IsEmpty()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1108 | EXPECT_EQ(gfx::Rect(29, 40, 1, 60), |
| 1109 | occlusion.UnoccludedLayerContentRect(parent, |
| 1110 | gfx::Rect(29, 40, 70, 60))); |
| 1111 | EXPECT_EQ(gfx::Rect(30, 39, 70, 1), |
| 1112 | occlusion.UnoccludedLayerContentRect(parent, |
| 1113 | gfx::Rect(30, 39, 70, 60))); |
| 1114 | EXPECT_EQ(gfx::Rect(), |
| 1115 | occlusion.UnoccludedLayerContentRect(parent, |
| 1116 | gfx::Rect(31, 40, 69, 60))); |
| 1117 | EXPECT_EQ(gfx::Rect(), |
| 1118 | occlusion.UnoccludedLayerContentRect(parent, |
| 1119 | gfx::Rect(30, 41, 70, 59))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1120 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1121 | /* Justification for the above occlusion from |layer1| and |layer2|: |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1122 | |
| 1123 | +---------------------+ |
| 1124 | | |30 Visible region of |layer1|: ///// |
| 1125 | | | Visible region of |layer2|: \\\\\ |
| 1126 | | +---------------------------------+ |
| 1127 | | | |10 | |
| 1128 | | +---------------+-----------------+ | |
| 1129 | | | |\\\\\\\\\\\\|//| 420 | | |
| 1130 | | | |\\\\\\\\\\\\|//|60 | | |
| 1131 | | | |\\\\\\\\\\\\|//| | | |
| 1132 | +--|--|------------|--+ | | |
| 1133 | 20|10| 70 | | | |
| 1134 | | | | | | |
| 1135 | | | | | | |
| 1136 | | | | | | |
| 1137 | | | | | | |
| 1138 | | | | | | |
| 1139 | | | | |10| |
| 1140 | | +------------|-----------------|--+ |
| 1141 | | | 490 | |
| 1142 | +---------------+-----------------+ |
| 1143 | 60 440 |
| 1144 | */ |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1145 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1146 | }; |
| 1147 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1148 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithTwoOpaqueChildren); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1149 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1150 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1151 | class OcclusionTrackerTestOverlappingSurfaceSiblings |
| 1152 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1153 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1154 | explicit OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1155 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1156 | void RunMyTest() { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1157 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1158 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 1159 | parent->SetMasksToBounds(true); |
| 1160 | typename Types::LayerType* child1 = this->CreateSurface( |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1161 | parent, this->identity_matrix, gfx::PointF(10.f, 0.f), gfx::Size()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1162 | typename Types::LayerType* child2 = this->CreateSurface( |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1163 | parent, this->identity_matrix, gfx::PointF(30.f, 0.f), gfx::Size()); |
| 1164 | typename Types::ContentLayerType* layer1 = this->CreateDrawingLayer( |
| 1165 | child1, this->identity_matrix, gfx::PointF(), gfx::Size(40, 50), true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1166 | typename Types::ContentLayerType* layer2 = |
| 1167 | this->CreateDrawingLayer(child2, |
| 1168 | this->identity_matrix, |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1169 | gfx::PointF(10.f, 0.f), |
| 1170 | gfx::Size(40, 50), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1171 | true); |
| 1172 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1173 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1174 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1175 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1176 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1177 | this->VisitLayer(layer2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1178 | this->EnterContributingSurface(child2, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1179 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1180 | // layer2's occlusion. |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1181 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1182 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1183 | EXPECT_EQ(gfx::Rect(10, 0, 40, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1184 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1185 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1186 | this->LeaveContributingSurface(child2, &occlusion); |
| 1187 | this->VisitLayer(layer1, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1188 | this->EnterContributingSurface(child1, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1189 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1190 | // layer2's occlusion in the target space of layer1. |
| 1191 | EXPECT_EQ(gfx::Rect(30, 0, 40, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1192 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1193 | // layer1's occlusion. |
| 1194 | EXPECT_EQ(gfx::Rect(0, 0, 40, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1195 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1196 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1197 | this->LeaveContributingSurface(child1, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1198 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1199 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1200 | // The occlusion from from layer1 and layer2 is merged. |
| 1201 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1202 | EXPECT_EQ(gfx::Rect(10, 0, 70, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1203 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1204 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1205 | }; |
| 1206 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1207 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOverlappingSurfaceSiblings); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1208 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1209 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1210 | class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms |
| 1211 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1212 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1213 | explicit OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1214 | bool opaque_layers) |
| 1215 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1216 | void RunMyTest() { |
| 1217 | gfx::Transform child1_transform; |
| 1218 | child1_transform.Translate(250.0, 250.0); |
| 1219 | child1_transform.Rotate(-90.0); |
| 1220 | child1_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1221 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1222 | gfx::Transform child2_transform; |
| 1223 | child2_transform.Translate(250.0, 250.0); |
| 1224 | child2_transform.Rotate(90.0); |
| 1225 | child2_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1226 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1227 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1228 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 1229 | parent->SetMasksToBounds(true); |
| 1230 | typename Types::LayerType* child1 = this->CreateSurface( |
| 1231 | parent, child1_transform, gfx::PointF(30.f, 20.f), gfx::Size(10, 10)); |
| 1232 | typename Types::LayerType* child2 = |
| 1233 | this->CreateDrawingSurface(parent, |
| 1234 | child2_transform, |
| 1235 | gfx::PointF(20.f, 40.f), |
| 1236 | gfx::Size(10, 10), |
| 1237 | false); |
| 1238 | typename Types::ContentLayerType* layer1 = |
| 1239 | this->CreateDrawingLayer(child1, |
| 1240 | this->identity_matrix, |
| 1241 | gfx::PointF(-10.f, -20.f), |
| 1242 | gfx::Size(510, 510), |
| 1243 | true); |
| 1244 | typename Types::ContentLayerType* layer2 = |
| 1245 | this->CreateDrawingLayer(child2, |
| 1246 | this->identity_matrix, |
| 1247 | gfx::PointF(-10.f, -10.f), |
| 1248 | gfx::Size(510, 510), |
| 1249 | true); |
| 1250 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1251 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1252 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1253 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1254 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1255 | this->VisitLayer(layer2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1256 | this->EnterLayer(child2, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1257 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1258 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1259 | occlusion.occlusion_from_outside_target().ToString()); |
| 1260 | EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), |
| 1261 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1262 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1263 | this->LeaveLayer(child2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1264 | this->EnterContributingSurface(child2, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1265 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1266 | // There is nothing above child2's surface in the z-order. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1267 | EXPECT_EQ(gfx::Rect(-10, 420, 70, 80), |
| 1268 | occlusion.UnoccludedSurfaceContentRect( |
| 1269 | child2, false, gfx::Rect(-10, 420, 70, 80))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1270 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1271 | this->LeaveContributingSurface(child2, &occlusion); |
| 1272 | this->VisitLayer(layer1, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1273 | this->EnterContributingSurface(child1, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1274 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1275 | EXPECT_EQ(gfx::Rect(420, -10, 70, 80).ToString(), |
| 1276 | occlusion.occlusion_from_outside_target().ToString()); |
| 1277 | EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(), |
| 1278 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1279 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1280 | // child2's contents will occlude child1 below it. |
[email protected] | e312aca | 2014-03-20 22:11:55 | [diff] [blame] | 1281 | EXPECT_EQ(gfx::Rect(20, 30, 80, 70).ToString(), |
| 1282 | occlusion.occlusion_on_contributing_surface_from_inside_target() |
| 1283 | .ToString()); |
| 1284 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1285 | occlusion.occlusion_on_contributing_surface_from_outside_target() |
| 1286 | .ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1287 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1288 | this->LeaveContributingSurface(child1, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1289 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1290 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1291 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1292 | occlusion.occlusion_from_outside_target().ToString()); |
| 1293 | EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), |
| 1294 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1295 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1296 | /* Justification for the above occlusion: |
| 1297 | 100 |
| 1298 | +---------------------+ |
| 1299 | |20 | layer1 |
| 1300 | 10+----------------------------------+ |
| 1301 | 100 || 30 | layer2 | |
| 1302 | |20+----------------------------------+ |
| 1303 | || | | | | |
| 1304 | || | | | | |
| 1305 | || | | | | |
| 1306 | +|-|------------------+ | | |
| 1307 | | | | | 510 |
| 1308 | | | 510 | | |
| 1309 | | | | | |
| 1310 | | | | | |
| 1311 | | | | | |
| 1312 | | | | | |
| 1313 | | | 520 | | |
| 1314 | +----------------------------------+ | |
| 1315 | | | |
| 1316 | +----------------------------------+ |
| 1317 | 510 |
| 1318 | */ |
| 1319 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1320 | }; |
| 1321 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1322 | ALL_OCCLUSIONTRACKER_TEST( |
| 1323 | OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1324 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1325 | template <class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1326 | class OcclusionTrackerTestFilters : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1327 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1328 | explicit OcclusionTrackerTestFilters(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1329 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1330 | void RunMyTest() { |
| 1331 | gfx::Transform layer_transform; |
| 1332 | layer_transform.Translate(250.0, 250.0); |
| 1333 | layer_transform.Rotate(90.0); |
| 1334 | layer_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1335 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1336 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1337 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 1338 | parent->SetMasksToBounds(true); |
| 1339 | typename Types::ContentLayerType* blur_layer = |
| 1340 | this->CreateDrawingLayer(parent, |
| 1341 | layer_transform, |
| 1342 | gfx::PointF(30.f, 30.f), |
| 1343 | gfx::Size(500, 500), |
| 1344 | true); |
| 1345 | typename Types::ContentLayerType* opaque_layer = |
| 1346 | this->CreateDrawingLayer(parent, |
| 1347 | layer_transform, |
| 1348 | gfx::PointF(30.f, 30.f), |
| 1349 | gfx::Size(500, 500), |
| 1350 | true); |
| 1351 | typename Types::ContentLayerType* opacity_layer = |
| 1352 | this->CreateDrawingLayer(parent, |
| 1353 | layer_transform, |
| 1354 | gfx::PointF(30.f, 30.f), |
| 1355 | gfx::Size(500, 500), |
| 1356 | true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1357 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 1358 | FilterOperations filters; |
| 1359 | filters.Append(FilterOperation::CreateBlurFilter(10.f)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1360 | blur_layer->SetFilters(filters); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1361 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 1362 | filters.Clear(); |
| 1363 | filters.Append(FilterOperation::CreateGrayscaleFilter(0.5f)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1364 | opaque_layer->SetFilters(filters); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1365 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 1366 | filters.Clear(); |
| 1367 | filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1368 | opacity_layer->SetFilters(filters); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1369 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1370 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1371 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1372 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1373 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1374 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1375 | // Opacity layer won't contribute to occlusion. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1376 | this->VisitLayer(opacity_layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1377 | this->EnterContributingSurface(opacity_layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1378 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1379 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1380 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1381 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1382 | // And has nothing to contribute to its parent surface. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1383 | this->LeaveContributingSurface(opacity_layer, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1384 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1385 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1386 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1387 | // Opaque layer will contribute to occlusion. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1388 | this->VisitLayer(opaque_layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1389 | this->EnterContributingSurface(opaque_layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1390 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1391 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1392 | EXPECT_EQ(gfx::Rect(0, 430, 70, 70).ToString(), |
| 1393 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1394 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1395 | // And it gets translated to the parent surface. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1396 | this->LeaveContributingSurface(opaque_layer, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1397 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1398 | EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
| 1399 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1400 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1401 | // The blur layer needs to throw away any occlusion from outside its |
| 1402 | // subtree. |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1403 | this->EnterLayer(blur_layer, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1404 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1405 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1406 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1407 | // And it won't contribute to occlusion. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1408 | this->LeaveLayer(blur_layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1409 | this->EnterContributingSurface(blur_layer, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1410 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1411 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1412 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1413 | // But the opaque layer's occlusion is preserved on the parent. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1414 | this->LeaveContributingSurface(blur_layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1415 | this->EnterLayer(parent, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1416 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1417 | EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
| 1418 | occlusion.occlusion_from_inside_target().ToString()); |
| 1419 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1420 | }; |
| 1421 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1422 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFilters); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1423 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1424 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1425 | class OcclusionTrackerTestReplicaDoesOcclude |
| 1426 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1427 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1428 | explicit OcclusionTrackerTestReplicaDoesOcclude(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1429 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1430 | void RunMyTest() { |
| 1431 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1432 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 200)); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1433 | typename Types::LayerType* surface = this->CreateDrawingSurface( |
| 1434 | parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 50), true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1435 | this->CreateReplicaLayer( |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1436 | surface, this->identity_matrix, gfx::PointF(0.f, 50.f), gfx::Size()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1437 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1438 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1439 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1440 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1441 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1442 | this->VisitLayer(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1443 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1444 | EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 1445 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1446 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1447 | this->VisitContributingSurface(surface, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1448 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1449 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1450 | // The surface and replica should both be occluding the parent. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1451 | EXPECT_EQ(gfx::Rect(50, 100).ToString(), |
| 1452 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1453 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1454 | }; |
| 1455 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1456 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaDoesOcclude); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1457 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1458 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1459 | class OcclusionTrackerTestReplicaWithClipping |
| 1460 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1461 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1462 | explicit OcclusionTrackerTestReplicaWithClipping(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1463 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1464 | void RunMyTest() { |
| 1465 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1466 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 170)); |
| 1467 | parent->SetMasksToBounds(true); |
| 1468 | typename Types::LayerType* surface = |
| 1469 | this->CreateDrawingSurface(parent, |
| 1470 | this->identity_matrix, |
| 1471 | gfx::PointF(0.f, 100.f), |
| 1472 | gfx::Size(50, 50), |
| 1473 | true); |
| 1474 | this->CreateReplicaLayer( |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1475 | surface, this->identity_matrix, gfx::PointF(0.f, 50.f), gfx::Size()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1476 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1477 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1478 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1479 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1480 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1481 | this->VisitLayer(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1482 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1483 | // The surface layer's occlusion in its own space. |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1484 | EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 1485 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1486 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1487 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1488 | this->VisitContributingSurface(surface, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1489 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1490 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1491 | // The surface and replica should both be occluding the parent, the |
| 1492 | // replica's occlusion is clipped by the parent. |
| 1493 | EXPECT_EQ(gfx::Rect(0, 100, 50, 70).ToString(), |
| 1494 | occlusion.occlusion_from_inside_target().ToString()); |
| 1495 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1496 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1497 | }; |
| 1498 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1499 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithClipping); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1500 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1501 | template <class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1502 | class OcclusionTrackerTestReplicaWithMask : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1503 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1504 | explicit OcclusionTrackerTestReplicaWithMask(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1505 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1506 | void RunMyTest() { |
| 1507 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1508 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 200)); |
| 1509 | typename Types::LayerType* surface = |
| 1510 | this->CreateDrawingSurface(parent, |
| 1511 | this->identity_matrix, |
| 1512 | gfx::PointF(0.f, 100.f), |
| 1513 | gfx::Size(50, 50), |
| 1514 | true); |
| 1515 | typename Types::LayerType* replica = this->CreateReplicaLayer( |
| 1516 | surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size()); |
| 1517 | this->CreateMaskLayer(replica, gfx::Size(10, 10)); |
| 1518 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1519 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1520 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1521 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1522 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1523 | this->VisitLayer(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1524 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1525 | EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 1526 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1527 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1528 | this->VisitContributingSurface(surface, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1529 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1530 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1531 | // The replica should not be occluding the parent, since it has a mask |
| 1532 | // applied to it. |
| 1533 | EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), |
| 1534 | occlusion.occlusion_from_inside_target().ToString()); |
| 1535 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1536 | }; |
| 1537 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1538 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithMask); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1539 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1540 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1541 | class OcclusionTrackerTestOpaqueContentsRegionEmpty |
| 1542 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1543 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1544 | explicit OcclusionTrackerTestOpaqueContentsRegionEmpty(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1545 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1546 | void RunMyTest() { |
| 1547 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1548 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1549 | typename Types::ContentLayerType* layer = |
| 1550 | this->CreateDrawingSurface(parent, |
| 1551 | this->identity_matrix, |
| 1552 | gfx::PointF(), |
| 1553 | gfx::Size(200, 200), |
| 1554 | false); |
| 1555 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1556 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1557 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1558 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1559 | this->EnterLayer(layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1560 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1561 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1562 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1563 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1564 | this->LeaveLayer(layer, &occlusion); |
| 1565 | this->VisitContributingSurface(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1566 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1567 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1568 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1569 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1570 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1571 | }; |
| 1572 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1573 | MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1574 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1575 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1576 | class OcclusionTrackerTestOpaqueContentsRegionNonEmpty |
| 1577 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1578 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1579 | explicit OcclusionTrackerTestOpaqueContentsRegionNonEmpty(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1580 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1581 | void RunMyTest() { |
| 1582 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1583 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1584 | typename Types::ContentLayerType* layer = |
| 1585 | this->CreateDrawingLayer(parent, |
| 1586 | this->identity_matrix, |
| 1587 | gfx::PointF(100.f, 100.f), |
| 1588 | gfx::Size(200, 200), |
| 1589 | false); |
| 1590 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1591 | { |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1592 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1593 | gfx::Rect(0, 0, 1000, 1000)); |
| 1594 | layer->SetOpaqueContentsRect(gfx::Rect(0, 0, 100, 100)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1595 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1596 | this->ResetLayerIterator(); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1597 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1598 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1599 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1600 | EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), |
| 1601 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1602 | } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1603 | { |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1604 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1605 | gfx::Rect(0, 0, 1000, 1000)); |
| 1606 | layer->SetOpaqueContentsRect(gfx::Rect(20, 20, 180, 180)); |
| 1607 | |
| 1608 | this->ResetLayerIterator(); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1609 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1610 | this->EnterLayer(parent, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1611 | |
| 1612 | EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(), |
| 1613 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1614 | } |
| 1615 | { |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1616 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1617 | gfx::Rect(0, 0, 1000, 1000)); |
| 1618 | layer->SetOpaqueContentsRect(gfx::Rect(150, 150, 100, 100)); |
| 1619 | |
| 1620 | this->ResetLayerIterator(); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1621 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1622 | this->EnterLayer(parent, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1623 | |
| 1624 | EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(), |
| 1625 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1626 | } |
| 1627 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1628 | }; |
| 1629 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1630 | MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionNonEmpty); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1631 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1632 | template <class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1633 | class OcclusionTrackerTest3dTransform : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1634 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1635 | explicit OcclusionTrackerTest3dTransform(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1636 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1637 | void RunMyTest() { |
| 1638 | gfx::Transform transform; |
| 1639 | transform.RotateAboutYAxis(30.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1640 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1641 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1642 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1643 | typename Types::LayerType* container = this->CreateLayer( |
| 1644 | parent, this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1645 | typename Types::ContentLayerType* layer = |
| 1646 | this->CreateDrawingLayer(container, |
| 1647 | transform, |
| 1648 | gfx::PointF(100.f, 100.f), |
| 1649 | gfx::Size(200, 200), |
| 1650 | true); |
| 1651 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1652 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1653 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1654 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1655 | this->EnterLayer(layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1656 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1657 | // The layer is rotated in 3d but without preserving 3d, so it only gets |
| 1658 | // resized. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1659 | EXPECT_EQ( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1660 | gfx::Rect(0, 0, 200, 200), |
| 1661 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); |
| 1662 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1663 | }; |
| 1664 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1665 | MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTest3dTransform); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1666 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1667 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1668 | class OcclusionTrackerTestUnsorted3dLayers |
| 1669 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1670 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1671 | explicit OcclusionTrackerTestUnsorted3dLayers(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1672 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1673 | void RunMyTest() { |
| 1674 | // Currently, The main thread layer iterator does not iterate over 3d items |
| 1675 | // in sorted order, because layer sorting is not performed on the main |
| 1676 | // thread. Because of this, the occlusion tracker cannot assume that a 3d |
| 1677 | // layer occludes other layers that have not yet been iterated over. For |
| 1678 | // now, the expected behavior is that a 3d layer simply does not add any |
| 1679 | // occlusion to the occlusion tracker. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1680 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1681 | gfx::Transform translation_to_front; |
| 1682 | translation_to_front.Translate3d(0.0, 0.0, -10.0); |
| 1683 | gfx::Transform translation_to_back; |
| 1684 | translation_to_front.Translate3d(0.0, 0.0, -100.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1685 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1686 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1687 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1688 | typename Types::ContentLayerType* child1 = this->CreateDrawingLayer( |
| 1689 | parent, translation_to_back, gfx::PointF(), gfx::Size(100, 100), true); |
| 1690 | typename Types::ContentLayerType* child2 = |
| 1691 | this->CreateDrawingLayer(parent, |
| 1692 | translation_to_front, |
| 1693 | gfx::PointF(50.f, 50.f), |
| 1694 | gfx::Size(100, 100), |
| 1695 | true); |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 1696 | parent->SetShouldFlattenTransform(false); |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 1697 | parent->Set3dSortingContextId(1); |
| 1698 | child1->Set3dSortingContextId(1); |
| 1699 | child2->Set3dSortingContextId(1); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1700 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1701 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1702 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1703 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1704 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1705 | this->VisitLayer(child2, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1706 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1707 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1708 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1709 | this->VisitLayer(child1, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1710 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1711 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| 1712 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1713 | }; |
| 1714 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1715 | // This test will have different layer ordering on the impl thread; the test |
| 1716 | // will only work on the main thread. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1717 | MAIN_THREAD_TEST(OcclusionTrackerTestUnsorted3dLayers); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1718 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1719 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1720 | class OcclusionTrackerTestPerspectiveTransform |
| 1721 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1722 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1723 | explicit OcclusionTrackerTestPerspectiveTransform(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1724 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1725 | void RunMyTest() { |
| 1726 | gfx::Transform transform; |
| 1727 | transform.Translate(150.0, 150.0); |
| 1728 | transform.ApplyPerspectiveDepth(400.0); |
| 1729 | transform.RotateAboutXAxis(-30.0); |
| 1730 | transform.Translate(-150.0, -150.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1731 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1732 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1733 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1734 | typename Types::LayerType* container = this->CreateLayer( |
| 1735 | parent, this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1736 | typename Types::ContentLayerType* layer = |
| 1737 | this->CreateDrawingLayer(container, |
| 1738 | transform, |
| 1739 | gfx::PointF(100.f, 100.f), |
| 1740 | gfx::Size(200, 200), |
| 1741 | true); |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 1742 | container->SetShouldFlattenTransform(false); |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 1743 | container->Set3dSortingContextId(1); |
| 1744 | layer->Set3dSortingContextId(1); |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 1745 | layer->SetShouldFlattenTransform(false); |
| 1746 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1747 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1748 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1749 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1750 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1751 | this->EnterLayer(layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1752 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1753 | EXPECT_EQ( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1754 | gfx::Rect(0, 0, 200, 200), |
| 1755 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); |
| 1756 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1757 | }; |
| 1758 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1759 | // This test requires accumulating occlusion of 3d layers, which are skipped by |
| 1760 | // the occlusion tracker on the main thread. So this test should run on the impl |
| 1761 | // thread. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1762 | IMPL_THREAD_TEST(OcclusionTrackerTestPerspectiveTransform); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1763 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1764 | class OcclusionTrackerTestPerspectiveTransformBehindCamera |
| 1765 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1766 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1767 | explicit OcclusionTrackerTestPerspectiveTransformBehindCamera( |
| 1768 | bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1769 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1770 | void RunMyTest() { |
| 1771 | // This test is based on the platform/chromium/compositing/3d-corners.html |
| 1772 | // layout test. |
| 1773 | gfx::Transform transform; |
| 1774 | transform.Translate(250.0, 50.0); |
| 1775 | transform.ApplyPerspectiveDepth(10.0); |
| 1776 | transform.Translate(-250.0, -50.0); |
| 1777 | transform.Translate(250.0, 50.0); |
| 1778 | transform.RotateAboutXAxis(-167.0); |
| 1779 | transform.Translate(-250.0, -50.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1780 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1781 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1782 | this->identity_matrix, gfx::PointF(), gfx::Size(500, 100)); |
| 1783 | typename Types::LayerType* container = this->CreateLayer( |
| 1784 | parent, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500)); |
| 1785 | typename Types::ContentLayerType* layer = this->CreateDrawingLayer( |
| 1786 | container, transform, gfx::PointF(), gfx::Size(500, 500), true); |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 1787 | container->SetShouldFlattenTransform(false); |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 1788 | container->Set3dSortingContextId(1); |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 1789 | layer->SetShouldFlattenTransform(false); |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 1790 | layer->Set3dSortingContextId(1); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1791 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1792 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1793 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1794 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1795 | this->EnterLayer(layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1796 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1797 | // The bottom 11 pixel rows of this layer remain visible inside the |
| 1798 | // container, after translation to the target surface. When translated back, |
| 1799 | // this will include many more pixels but must include at least the bottom |
| 1800 | // 11 rows. |
| 1801 | EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
[email protected] | cfc2d2d | 2013-10-04 23:26:45 | [diff] [blame] | 1802 | layer, gfx::Rect(0, 26, 500, 474)). |
| 1803 | Contains(gfx::Rect(0, 489, 500, 11))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1804 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1805 | }; |
| 1806 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1807 | // This test requires accumulating occlusion of 3d layers, which are skipped by |
| 1808 | // the occlusion tracker on the main thread. So this test should run on the impl |
| 1809 | // thread. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1810 | IMPL_THREAD_TEST(OcclusionTrackerTestPerspectiveTransformBehindCamera); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1811 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1812 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1813 | class OcclusionTrackerTestLayerBehindCameraDoesNotOcclude |
| 1814 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1815 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1816 | explicit OcclusionTrackerTestLayerBehindCameraDoesNotOcclude( |
| 1817 | bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1818 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1819 | void RunMyTest() { |
| 1820 | gfx::Transform transform; |
| 1821 | transform.Translate(50.0, 50.0); |
| 1822 | transform.ApplyPerspectiveDepth(100.0); |
| 1823 | transform.Translate3d(0.0, 0.0, 110.0); |
| 1824 | transform.Translate(-50.0, -50.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1825 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1826 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1827 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 1828 | typename Types::ContentLayerType* layer = this->CreateDrawingLayer( |
| 1829 | parent, transform, gfx::PointF(), gfx::Size(100, 100), true); |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 1830 | parent->SetShouldFlattenTransform(false); |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 1831 | parent->Set3dSortingContextId(1); |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 1832 | layer->SetShouldFlattenTransform(false); |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 1833 | layer->Set3dSortingContextId(1); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1834 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1835 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1836 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1837 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1838 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1839 | // The |layer| is entirely behind the camera and should not occlude. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1840 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1841 | this->EnterLayer(parent, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1842 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| 1843 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1844 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1845 | }; |
| 1846 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1847 | // This test requires accumulating occlusion of 3d layers, which are skipped by |
| 1848 | // the occlusion tracker on the main thread. So this test should run on the impl |
| 1849 | // thread. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1850 | IMPL_THREAD_TEST(OcclusionTrackerTestLayerBehindCameraDoesNotOcclude); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1851 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1852 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1853 | class OcclusionTrackerTestLargePixelsOccludeInsideClipRect |
| 1854 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1855 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1856 | explicit OcclusionTrackerTestLargePixelsOccludeInsideClipRect( |
| 1857 | bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1858 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1859 | void RunMyTest() { |
| 1860 | gfx::Transform transform; |
| 1861 | transform.Translate(50.0, 50.0); |
| 1862 | transform.ApplyPerspectiveDepth(100.0); |
| 1863 | transform.Translate3d(0.0, 0.0, 99.0); |
| 1864 | transform.Translate(-50.0, -50.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1865 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1866 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1867 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 1868 | parent->SetMasksToBounds(true); |
| 1869 | typename Types::ContentLayerType* layer = this->CreateDrawingLayer( |
| 1870 | parent, transform, gfx::PointF(), gfx::Size(100, 100), true); |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 1871 | parent->SetShouldFlattenTransform(false); |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 1872 | parent->Set3dSortingContextId(1); |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 1873 | layer->SetShouldFlattenTransform(false); |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 1874 | layer->Set3dSortingContextId(1); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1875 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1876 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1877 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1878 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1879 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1880 | // This is very close to the camera, so pixels in its visible_content_rect() |
| 1881 | // will actually go outside of the layer's clip rect. Ensure that those |
| 1882 | // pixels don't occlude things outside the clip rect. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1883 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1884 | this->EnterLayer(parent, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1885 | EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 1886 | occlusion.occlusion_from_inside_target().ToString()); |
| 1887 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1888 | occlusion.occlusion_from_outside_target().ToString()); |
| 1889 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1890 | }; |
| 1891 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1892 | // This test requires accumulating occlusion of 3d layers, which are skipped by |
| 1893 | // the occlusion tracker on the main thread. So this test should run on the impl |
| 1894 | // thread. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1895 | IMPL_THREAD_TEST(OcclusionTrackerTestLargePixelsOccludeInsideClipRect); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1896 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1897 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1898 | class OcclusionTrackerTestAnimationOpacity1OnMainThread |
| 1899 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1900 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1901 | explicit OcclusionTrackerTestAnimationOpacity1OnMainThread(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1902 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1903 | void RunMyTest() { |
| 1904 | // parent |
| 1905 | // +--layer |
| 1906 | // +--surface |
| 1907 | // | +--surface_child |
| 1908 | // | +--surface_child2 |
| 1909 | // +--parent2 |
| 1910 | // +--topmost |
[email protected] | c8d7155 | 2013-01-22 03:43:02 | [diff] [blame] | 1911 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1912 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1913 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1914 | typename Types::ContentLayerType* layer = |
| 1915 | this->CreateDrawingLayer(parent, |
| 1916 | this->identity_matrix, |
| 1917 | gfx::PointF(), |
| 1918 | gfx::Size(300, 300), |
| 1919 | true); |
| 1920 | typename Types::ContentLayerType* surface = |
| 1921 | this->CreateDrawingSurface(parent, |
| 1922 | this->identity_matrix, |
| 1923 | gfx::PointF(), |
| 1924 | gfx::Size(300, 300), |
| 1925 | true); |
| 1926 | typename Types::ContentLayerType* surface_child = |
| 1927 | this->CreateDrawingLayer(surface, |
| 1928 | this->identity_matrix, |
| 1929 | gfx::PointF(), |
| 1930 | gfx::Size(200, 300), |
| 1931 | true); |
| 1932 | typename Types::ContentLayerType* surface_child2 = |
| 1933 | this->CreateDrawingLayer(surface, |
| 1934 | this->identity_matrix, |
| 1935 | gfx::PointF(), |
| 1936 | gfx::Size(100, 300), |
| 1937 | true); |
| 1938 | typename Types::ContentLayerType* parent2 = |
| 1939 | this->CreateDrawingLayer(parent, |
| 1940 | this->identity_matrix, |
| 1941 | gfx::PointF(), |
| 1942 | gfx::Size(300, 300), |
| 1943 | false); |
| 1944 | typename Types::ContentLayerType* topmost = |
| 1945 | this->CreateDrawingLayer(parent, |
| 1946 | this->identity_matrix, |
| 1947 | gfx::PointF(250.f, 0.f), |
| 1948 | gfx::Size(50, 300), |
| 1949 | true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1950 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1951 | AddOpacityTransitionToController( |
| 1952 | layer->layer_animation_controller(), 10.0, 0.f, 1.f, false); |
| 1953 | AddOpacityTransitionToController( |
| 1954 | surface->layer_animation_controller(), 10.0, 0.f, 1.f, false); |
| 1955 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1956 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1957 | EXPECT_TRUE(layer->draw_opacity_is_animating()); |
| 1958 | EXPECT_FALSE(surface->draw_opacity_is_animating()); |
| 1959 | EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1960 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 1961 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1962 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1963 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1964 | this->VisitLayer(topmost, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1965 | this->EnterLayer(parent2, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1966 | // This occlusion will affect all surfaces. |
| 1967 | EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 1968 | occlusion.occlusion_from_inside_target().ToString()); |
| 1969 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1970 | occlusion.occlusion_from_outside_target().ToString()); |
| 1971 | EXPECT_EQ(gfx::Rect(0, 0, 250, 300).ToString(), |
| 1972 | occlusion.UnoccludedLayerContentRect( |
| 1973 | parent2, gfx::Rect(0, 0, 300, 300)).ToString()); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1974 | this->LeaveLayer(parent2, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1975 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1976 | this->VisitLayer(surface_child2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1977 | this->EnterLayer(surface_child, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1978 | EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), |
| 1979 | occlusion.occlusion_from_inside_target().ToString()); |
| 1980 | EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 1981 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1982 | EXPECT_EQ(gfx::Rect(100, 0, 100, 300), |
| 1983 | occlusion.UnoccludedLayerContentRect(surface_child, |
| 1984 | gfx::Rect(0, 0, 200, 300))); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1985 | this->LeaveLayer(surface_child, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1986 | this->EnterLayer(surface, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1987 | EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), |
| 1988 | occlusion.occlusion_from_inside_target().ToString()); |
| 1989 | EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 1990 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 1991 | EXPECT_EQ(gfx::Rect(200, 0, 50, 300), |
| 1992 | occlusion.UnoccludedLayerContentRect(surface, |
| 1993 | gfx::Rect(0, 0, 300, 300))); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1994 | this->LeaveLayer(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1995 | |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1996 | this->EnterContributingSurface(surface, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1997 | // Occlusion within the surface is lost when leaving the animating surface. |
| 1998 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1999 | occlusion.occlusion_from_inside_target().ToString()); |
| 2000 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2001 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2002 | EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| 2003 | occlusion.UnoccludedSurfaceContentRect( |
| 2004 | surface, false, gfx::Rect(0, 0, 300, 300))); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2005 | this->LeaveContributingSurface(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2006 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2007 | // Occlusion from outside the animating surface still exists. |
| 2008 | EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2009 | occlusion.occlusion_from_inside_target().ToString()); |
| 2010 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2011 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | c8d7155 | 2013-01-22 03:43:02 | [diff] [blame] | 2012 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2013 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2014 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2015 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2016 | // Occlusion is not added for the animating |layer|. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2017 | EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| 2018 | occlusion.UnoccludedLayerContentRect(parent, |
| 2019 | gfx::Rect(0, 0, 300, 300))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2020 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2021 | }; |
| 2022 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 2023 | MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity1OnMainThread); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2024 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2025 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2026 | class OcclusionTrackerTestAnimationOpacity0OnMainThread |
| 2027 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2028 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2029 | explicit OcclusionTrackerTestAnimationOpacity0OnMainThread(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2030 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2031 | void RunMyTest() { |
| 2032 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2033 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 2034 | typename Types::ContentLayerType* layer = |
| 2035 | this->CreateDrawingLayer(parent, |
| 2036 | this->identity_matrix, |
| 2037 | gfx::PointF(), |
| 2038 | gfx::Size(300, 300), |
| 2039 | true); |
| 2040 | typename Types::ContentLayerType* surface = |
| 2041 | this->CreateDrawingSurface(parent, |
| 2042 | this->identity_matrix, |
| 2043 | gfx::PointF(), |
| 2044 | gfx::Size(300, 300), |
| 2045 | true); |
| 2046 | typename Types::ContentLayerType* surface_child = |
| 2047 | this->CreateDrawingLayer(surface, |
| 2048 | this->identity_matrix, |
| 2049 | gfx::PointF(), |
| 2050 | gfx::Size(200, 300), |
| 2051 | true); |
| 2052 | typename Types::ContentLayerType* surface_child2 = |
| 2053 | this->CreateDrawingLayer(surface, |
| 2054 | this->identity_matrix, |
| 2055 | gfx::PointF(), |
| 2056 | gfx::Size(100, 300), |
| 2057 | true); |
| 2058 | typename Types::ContentLayerType* parent2 = |
| 2059 | this->CreateDrawingLayer(parent, |
| 2060 | this->identity_matrix, |
| 2061 | gfx::PointF(), |
| 2062 | gfx::Size(300, 300), |
| 2063 | false); |
| 2064 | typename Types::ContentLayerType* topmost = |
| 2065 | this->CreateDrawingLayer(parent, |
| 2066 | this->identity_matrix, |
| 2067 | gfx::PointF(250.f, 0.f), |
| 2068 | gfx::Size(50, 300), |
| 2069 | true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2070 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2071 | AddOpacityTransitionToController( |
| 2072 | layer->layer_animation_controller(), 10.0, 1.f, 0.f, false); |
| 2073 | AddOpacityTransitionToController( |
| 2074 | surface->layer_animation_controller(), 10.0, 1.f, 0.f, false); |
| 2075 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2076 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2077 | EXPECT_TRUE(layer->draw_opacity_is_animating()); |
| 2078 | EXPECT_FALSE(surface->draw_opacity_is_animating()); |
| 2079 | EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2080 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 2081 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2082 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2083 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2084 | this->VisitLayer(topmost, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2085 | this->EnterLayer(parent2, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2086 | // This occlusion will affect all surfaces. |
| 2087 | EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2088 | occlusion.occlusion_from_inside_target().ToString()); |
| 2089 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2090 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2091 | EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| 2092 | occlusion.UnoccludedLayerContentRect(parent, |
| 2093 | gfx::Rect(0, 0, 300, 300))); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2094 | this->LeaveLayer(parent2, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2095 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2096 | this->VisitLayer(surface_child2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2097 | this->EnterLayer(surface_child, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2098 | EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), |
| 2099 | occlusion.occlusion_from_inside_target().ToString()); |
| 2100 | EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2101 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2102 | EXPECT_EQ(gfx::Rect(100, 0, 100, 300), |
| 2103 | occlusion.UnoccludedLayerContentRect(surface_child, |
| 2104 | gfx::Rect(0, 0, 200, 300))); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2105 | this->LeaveLayer(surface_child, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2106 | this->EnterLayer(surface, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2107 | EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), |
| 2108 | occlusion.occlusion_from_inside_target().ToString()); |
| 2109 | EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2110 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2111 | EXPECT_EQ(gfx::Rect(200, 0, 50, 300), |
| 2112 | occlusion.UnoccludedLayerContentRect(surface, |
| 2113 | gfx::Rect(0, 0, 300, 300))); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2114 | this->LeaveLayer(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2115 | |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2116 | this->EnterContributingSurface(surface, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2117 | // Occlusion within the surface is lost when leaving the animating surface. |
| 2118 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2119 | occlusion.occlusion_from_inside_target().ToString()); |
| 2120 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2121 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2122 | EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| 2123 | occlusion.UnoccludedSurfaceContentRect( |
| 2124 | surface, false, gfx::Rect(0, 0, 300, 300))); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2125 | this->LeaveContributingSurface(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2126 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2127 | // Occlusion from outside the animating surface still exists. |
| 2128 | EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2129 | occlusion.occlusion_from_inside_target().ToString()); |
| 2130 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2131 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | c8d7155 | 2013-01-22 03:43:02 | [diff] [blame] | 2132 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2133 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2134 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2135 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2136 | // Occlusion is not added for the animating |layer|. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2137 | EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| 2138 | occlusion.UnoccludedLayerContentRect(parent, |
| 2139 | gfx::Rect(0, 0, 300, 300))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2140 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2141 | }; |
| 2142 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 2143 | MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity0OnMainThread); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2144 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2145 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2146 | class OcclusionTrackerTestAnimationTranslateOnMainThread |
| 2147 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2148 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2149 | explicit OcclusionTrackerTestAnimationTranslateOnMainThread( |
| 2150 | bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2151 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2152 | void RunMyTest() { |
| 2153 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2154 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 2155 | typename Types::ContentLayerType* layer = |
| 2156 | this->CreateDrawingLayer(parent, |
| 2157 | this->identity_matrix, |
| 2158 | gfx::PointF(), |
| 2159 | gfx::Size(300, 300), |
| 2160 | true); |
| 2161 | typename Types::ContentLayerType* surface = |
| 2162 | this->CreateDrawingSurface(parent, |
| 2163 | this->identity_matrix, |
| 2164 | gfx::PointF(), |
| 2165 | gfx::Size(300, 300), |
| 2166 | true); |
| 2167 | typename Types::ContentLayerType* surface_child = |
| 2168 | this->CreateDrawingLayer(surface, |
| 2169 | this->identity_matrix, |
| 2170 | gfx::PointF(), |
| 2171 | gfx::Size(200, 300), |
| 2172 | true); |
| 2173 | typename Types::ContentLayerType* surface_child2 = |
| 2174 | this->CreateDrawingLayer(surface, |
| 2175 | this->identity_matrix, |
| 2176 | gfx::PointF(), |
| 2177 | gfx::Size(100, 300), |
| 2178 | true); |
| 2179 | typename Types::ContentLayerType* surface2 = this->CreateDrawingSurface( |
| 2180 | parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 300), true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2181 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2182 | AddAnimatedTransformToController( |
| 2183 | layer->layer_animation_controller(), 10.0, 30, 0); |
| 2184 | AddAnimatedTransformToController( |
| 2185 | surface->layer_animation_controller(), 10.0, 30, 0); |
| 2186 | AddAnimatedTransformToController( |
| 2187 | surface_child->layer_animation_controller(), 10.0, 30, 0); |
| 2188 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2189 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2190 | EXPECT_TRUE(layer->draw_transform_is_animating()); |
| 2191 | EXPECT_TRUE(layer->screen_space_transform_is_animating()); |
| 2192 | EXPECT_TRUE( |
| 2193 | surface->render_surface()->target_surface_transforms_are_animating()); |
| 2194 | EXPECT_TRUE( |
| 2195 | surface->render_surface()->screen_space_transforms_are_animating()); |
| 2196 | // The surface owning layer doesn't animate against its own surface. |
| 2197 | EXPECT_FALSE(surface->draw_transform_is_animating()); |
| 2198 | EXPECT_TRUE(surface->screen_space_transform_is_animating()); |
| 2199 | EXPECT_TRUE(surface_child->draw_transform_is_animating()); |
| 2200 | EXPECT_TRUE(surface_child->screen_space_transform_is_animating()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2201 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 2202 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2203 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2204 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2205 | this->VisitLayer(surface2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2206 | this->EnterContributingSurface(surface2, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2207 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2208 | EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), |
| 2209 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2210 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2211 | this->LeaveContributingSurface(surface2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2212 | this->EnterLayer(surface_child2, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2213 | // surface_child2 is moving in screen space but not relative to its target, |
| 2214 | // so occlusion should happen in its target space only. It also means that |
| 2215 | // things occluding from outside the target (e.g. surface2) cannot occlude |
| 2216 | // this layer. |
| 2217 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2218 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | 7d6d6c9 | 2014-03-06 01:18:50 | [diff] [blame] | 2219 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2220 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2221 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2222 | this->LeaveLayer(surface_child2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2223 | this->EnterLayer(surface_child, &occlusion); |
[email protected] | 7d6d6c9 | 2014-03-06 01:18:50 | [diff] [blame] | 2224 | // surface_child2 added to the occlusion since it is not moving relative |
| 2225 | // to its target. |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2226 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2227 | occlusion.occlusion_from_outside_target().ToString()); |
| 2228 | EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), |
| 2229 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2230 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2231 | this->LeaveLayer(surface_child, &occlusion); |
[email protected] | 7d6d6c9 | 2014-03-06 01:18:50 | [diff] [blame] | 2232 | // surface_child is moving relative to its target, so it does not add |
| 2233 | // occlusion. |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2234 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2235 | occlusion.occlusion_from_outside_target().ToString()); |
| 2236 | EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), |
| 2237 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 7d6d6c9 | 2014-03-06 01:18:50 | [diff] [blame] | 2238 | |
| 2239 | this->EnterLayer(surface, &occlusion); |
| 2240 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2241 | occlusion.occlusion_from_outside_target().ToString()); |
| 2242 | EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), |
| 2243 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2244 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2245 | this->LeaveLayer(surface, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2246 | // The surface's owning layer is moving in screen space but not relative to |
[email protected] | 7d6d6c9 | 2014-03-06 01:18:50 | [diff] [blame] | 2247 | // its target, so it adds to the occlusion. |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2248 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2249 | occlusion.occlusion_from_outside_target().ToString()); |
| 2250 | EXPECT_EQ(gfx::Rect(0, 0, 300, 300).ToString(), |
| 2251 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2252 | |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2253 | this->EnterContributingSurface(surface, &occlusion); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2254 | this->LeaveContributingSurface(surface, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2255 | // The |surface| is moving in the screen and in its target, so all occlusion |
[email protected] | 7d6d6c9 | 2014-03-06 01:18:50 | [diff] [blame] | 2256 | // within the surface is lost when leaving it. Only the |surface2| occlusion |
| 2257 | // is left. |
| 2258 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2259 | occlusion.occlusion_from_outside_target().ToString()); |
| 2260 | EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), |
| 2261 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2262 | |
[email protected] | 7d6d6c9 | 2014-03-06 01:18:50 | [diff] [blame] | 2263 | this->VisitLayer(layer, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2264 | // The |layer| is animating in the screen and in its target, so no occlusion |
| 2265 | // is added. |
[email protected] | 7d6d6c9 | 2014-03-06 01:18:50 | [diff] [blame] | 2266 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2267 | occlusion.occlusion_from_outside_target().ToString()); |
| 2268 | EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), |
| 2269 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2270 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2271 | }; |
| 2272 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 2273 | MAIN_THREAD_TEST(OcclusionTrackerTestAnimationTranslateOnMainThread); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2274 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2275 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2276 | class OcclusionTrackerTestSurfaceOcclusionTranslatesToParent |
| 2277 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2278 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2279 | explicit OcclusionTrackerTestSurfaceOcclusionTranslatesToParent( |
| 2280 | bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2281 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2282 | void RunMyTest() { |
| 2283 | gfx::Transform surface_transform; |
| 2284 | surface_transform.Translate(300.0, 300.0); |
| 2285 | surface_transform.Scale(2.0, 2.0); |
| 2286 | surface_transform.Translate(-150.0, -150.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2287 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2288 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2289 | this->identity_matrix, gfx::PointF(), gfx::Size(500, 500)); |
| 2290 | typename Types::ContentLayerType* surface = this->CreateDrawingSurface( |
| 2291 | parent, surface_transform, gfx::PointF(), gfx::Size(300, 300), false); |
| 2292 | typename Types::ContentLayerType* surface2 = |
| 2293 | this->CreateDrawingSurface(parent, |
| 2294 | this->identity_matrix, |
| 2295 | gfx::PointF(50.f, 50.f), |
| 2296 | gfx::Size(300, 300), |
| 2297 | false); |
| 2298 | surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200)); |
| 2299 | surface2->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200)); |
| 2300 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2301 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 2302 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2303 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2304 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2305 | this->VisitLayer(surface2, &occlusion); |
| 2306 | this->VisitContributingSurface(surface2, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2307 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2308 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2309 | occlusion.occlusion_from_outside_target().ToString()); |
| 2310 | EXPECT_EQ(gfx::Rect(50, 50, 200, 200).ToString(), |
| 2311 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2312 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2313 | // Clear any stored occlusion. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2314 | occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| 2315 | occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2316 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2317 | this->VisitLayer(surface, &occlusion); |
| 2318 | this->VisitContributingSurface(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2319 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2320 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2321 | occlusion.occlusion_from_outside_target().ToString()); |
| 2322 | EXPECT_EQ(gfx::Rect(0, 0, 400, 400).ToString(), |
| 2323 | occlusion.occlusion_from_inside_target().ToString()); |
| 2324 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2325 | }; |
| 2326 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2327 | MAIN_AND_IMPL_THREAD_TEST( |
| 2328 | OcclusionTrackerTestSurfaceOcclusionTranslatesToParent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2329 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2330 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2331 | class OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping |
| 2332 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2333 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2334 | explicit OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping( |
| 2335 | bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2336 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2337 | void RunMyTest() { |
| 2338 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2339 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 2340 | parent->SetMasksToBounds(true); |
| 2341 | typename Types::ContentLayerType* surface = |
| 2342 | this->CreateDrawingSurface(parent, |
| 2343 | this->identity_matrix, |
| 2344 | gfx::PointF(), |
| 2345 | gfx::Size(500, 300), |
| 2346 | false); |
| 2347 | surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 400, 200)); |
| 2348 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2349 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 2350 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2351 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2352 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2353 | this->VisitLayer(surface, &occlusion); |
| 2354 | this->VisitContributingSurface(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2355 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2356 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2357 | occlusion.occlusion_from_outside_target().ToString()); |
| 2358 | EXPECT_EQ(gfx::Rect(0, 0, 300, 200).ToString(), |
| 2359 | occlusion.occlusion_from_inside_target().ToString()); |
| 2360 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2361 | }; |
| 2362 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2363 | MAIN_AND_IMPL_THREAD_TEST( |
| 2364 | OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2365 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2366 | template <class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 2367 | class OcclusionTrackerTestReplicaOccluded : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2368 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2369 | explicit OcclusionTrackerTestReplicaOccluded(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2370 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2371 | void RunMyTest() { |
| 2372 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2373 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 200)); |
| 2374 | typename Types::LayerType* surface = |
| 2375 | this->CreateDrawingSurface(parent, |
| 2376 | this->identity_matrix, |
| 2377 | gfx::PointF(), |
| 2378 | gfx::Size(100, 100), |
| 2379 | true); |
| 2380 | this->CreateReplicaLayer(surface, |
| 2381 | this->identity_matrix, |
| 2382 | gfx::PointF(0.f, 100.f), |
| 2383 | gfx::Size(100, 100)); |
| 2384 | typename Types::LayerType* topmost = |
| 2385 | this->CreateDrawingLayer(parent, |
| 2386 | this->identity_matrix, |
| 2387 | gfx::PointF(0.f, 100.f), |
| 2388 | gfx::Size(100, 100), |
| 2389 | true); |
| 2390 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2391 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 2392 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2393 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2394 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2395 | // |topmost| occludes the replica, but not the surface itself. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2396 | this->VisitLayer(topmost, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2397 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2398 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2399 | occlusion.occlusion_from_outside_target().ToString()); |
| 2400 | EXPECT_EQ(gfx::Rect(0, 100, 100, 100).ToString(), |
| 2401 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2402 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2403 | this->VisitLayer(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2404 | |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 2405 | // Render target with replica ignores occlusion from outside. |
| 2406 | EXPECT_EQ(gfx::Rect().ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2407 | occlusion.occlusion_from_outside_target().ToString()); |
| 2408 | EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 2409 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2410 | |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2411 | this->EnterContributingSurface(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2412 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2413 | // Surface is not occluded so it shouldn't think it is. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2414 | EXPECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 2415 | occlusion.UnoccludedSurfaceContentRect( |
| 2416 | surface, false, gfx::Rect(0, 0, 100, 100))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2417 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2418 | }; |
| 2419 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 2420 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2421 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2422 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2423 | class OcclusionTrackerTestSurfaceWithReplicaUnoccluded |
| 2424 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2425 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2426 | explicit OcclusionTrackerTestSurfaceWithReplicaUnoccluded(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2427 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2428 | void RunMyTest() { |
| 2429 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2430 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 200)); |
| 2431 | typename Types::LayerType* surface = |
| 2432 | this->CreateDrawingSurface(parent, |
| 2433 | this->identity_matrix, |
| 2434 | gfx::PointF(), |
| 2435 | gfx::Size(100, 100), |
| 2436 | true); |
| 2437 | this->CreateReplicaLayer(surface, |
| 2438 | this->identity_matrix, |
| 2439 | gfx::PointF(0.f, 100.f), |
| 2440 | gfx::Size(100, 100)); |
| 2441 | typename Types::LayerType* topmost = |
| 2442 | this->CreateDrawingLayer(parent, |
| 2443 | this->identity_matrix, |
| 2444 | gfx::PointF(), |
| 2445 | gfx::Size(100, 110), |
| 2446 | true); |
| 2447 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2448 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 2449 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2450 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2451 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2452 | // |topmost| occludes the surface, but not the entire surface's replica. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2453 | this->VisitLayer(topmost, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2454 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2455 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2456 | occlusion.occlusion_from_outside_target().ToString()); |
| 2457 | EXPECT_EQ(gfx::Rect(0, 0, 100, 110).ToString(), |
| 2458 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2459 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2460 | this->VisitLayer(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2461 | |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 2462 | // Render target with replica ignores occlusion from outside. |
| 2463 | EXPECT_EQ(gfx::Rect().ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2464 | occlusion.occlusion_from_outside_target().ToString()); |
| 2465 | EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 2466 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2467 | |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2468 | this->EnterContributingSurface(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2469 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2470 | // Surface is occluded, but only the top 10px of the replica. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2471 | EXPECT_EQ(gfx::Rect(0, 0, 0, 0), |
| 2472 | occlusion.UnoccludedSurfaceContentRect( |
| 2473 | surface, false, gfx::Rect(0, 0, 100, 100))); |
| 2474 | EXPECT_EQ(gfx::Rect(0, 10, 100, 90), |
| 2475 | occlusion.UnoccludedSurfaceContentRect( |
| 2476 | surface, true, gfx::Rect(0, 0, 100, 100))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2477 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2478 | }; |
| 2479 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 2480 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithReplicaUnoccluded); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2481 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2482 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2483 | class OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently |
| 2484 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2485 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2486 | explicit OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently( |
| 2487 | bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2488 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2489 | void RunMyTest() { |
| 2490 | typename Types::ContentLayerType* parent = this->CreateRoot( |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2491 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 100)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2492 | typename Types::LayerType* surface = |
| 2493 | this->CreateDrawingSurface(parent, |
| 2494 | this->identity_matrix, |
| 2495 | gfx::PointF(), |
| 2496 | gfx::Size(100, 100), |
| 2497 | true); |
| 2498 | this->CreateReplicaLayer(surface, |
| 2499 | this->identity_matrix, |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2500 | gfx::PointF(100.f, 0.f), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2501 | gfx::Size(100, 100)); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2502 | typename Types::LayerType* over_surface = |
| 2503 | this->CreateDrawingLayer(parent, |
| 2504 | this->identity_matrix, |
| 2505 | gfx::PointF(60.f, 0.f), |
| 2506 | gfx::Size(40, 100), |
| 2507 | true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2508 | typename Types::LayerType* over_replica = |
| 2509 | this->CreateDrawingLayer(parent, |
| 2510 | this->identity_matrix, |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2511 | gfx::PointF(100.f, 0.f), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2512 | gfx::Size(50, 100), |
| 2513 | true); |
| 2514 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2515 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 2516 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2517 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2518 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2519 | // These occlude the surface and replica differently, so we can test each |
| 2520 | // one. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2521 | this->VisitLayer(over_replica, &occlusion); |
| 2522 | this->VisitLayer(over_surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2523 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2524 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2525 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2526 | EXPECT_EQ(gfx::Rect(60, 0, 90, 100).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2527 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2528 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2529 | this->VisitLayer(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2530 | |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 2531 | // Render target with replica ignores occlusion from outside. |
| 2532 | EXPECT_EQ(gfx::Rect().ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2533 | occlusion.occlusion_from_outside_target().ToString()); |
| 2534 | EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 2535 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2536 | |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2537 | this->EnterContributingSurface(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2538 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2539 | // Surface and replica are occluded different amounts. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2540 | EXPECT_EQ(gfx::Rect(0, 0, 60, 100), |
| 2541 | occlusion.UnoccludedSurfaceContentRect( |
| 2542 | surface, false, gfx::Rect(0, 0, 100, 100))); |
| 2543 | EXPECT_EQ(gfx::Rect(50, 0, 50, 100), |
| 2544 | occlusion.UnoccludedSurfaceContentRect( |
| 2545 | surface, true, gfx::Rect(0, 0, 100, 100))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2546 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2547 | }; |
| 2548 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2549 | ALL_OCCLUSIONTRACKER_TEST( |
| 2550 | OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2551 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2552 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2553 | class OcclusionTrackerTestSurfaceChildOfSurface |
| 2554 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2555 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2556 | explicit OcclusionTrackerTestSurfaceChildOfSurface(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2557 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2558 | void RunMyTest() { |
| 2559 | // This test verifies that the surface cliprect does not end up empty and |
| 2560 | // clip away the entire unoccluded rect. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2561 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2562 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2563 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 200)); |
| 2564 | typename Types::LayerType* surface = |
| 2565 | this->CreateDrawingSurface(parent, |
| 2566 | this->identity_matrix, |
| 2567 | gfx::PointF(), |
| 2568 | gfx::Size(100, 100), |
| 2569 | true); |
| 2570 | typename Types::LayerType* surface_child = |
| 2571 | this->CreateDrawingSurface(surface, |
| 2572 | this->identity_matrix, |
| 2573 | gfx::PointF(0.f, 10.f), |
| 2574 | gfx::Size(100, 50), |
| 2575 | true); |
| 2576 | typename Types::LayerType* topmost = this->CreateDrawingLayer( |
| 2577 | parent, this->identity_matrix, gfx::PointF(), gfx::Size(100, 50), true); |
| 2578 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2579 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 2580 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2581 | gfx::Rect(-100, -100, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2582 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2583 | // |topmost| occludes everything partially so we know occlusion is happening |
| 2584 | // at all. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2585 | this->VisitLayer(topmost, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2586 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2587 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2588 | occlusion.occlusion_from_outside_target().ToString()); |
| 2589 | EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
| 2590 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2591 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2592 | this->VisitLayer(surface_child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2593 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2594 | // surface_child increases the occlusion in the screen by a narrow sliver. |
| 2595 | EXPECT_EQ(gfx::Rect(0, -10, 100, 50).ToString(), |
| 2596 | occlusion.occlusion_from_outside_target().ToString()); |
| 2597 | // In its own surface, surface_child is at 0,0 as is its occlusion. |
| 2598 | EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
| 2599 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2600 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2601 | // The root layer always has a clip rect. So the parent of |surface| has a |
| 2602 | // clip rect. However, the owning layer for |surface| does not mask to |
| 2603 | // bounds, so it doesn't have a clip rect of its own. Thus the parent of |
| 2604 | // |surface_child| exercises different code paths as its parent does not |
| 2605 | // have a clip rect. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2606 | |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2607 | this->EnterContributingSurface(surface_child, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2608 | // The surface_child's parent does not have a clip rect as it owns a render |
| 2609 | // surface. Make sure the unoccluded rect does not get clipped away |
| 2610 | // inappropriately. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2611 | EXPECT_EQ(gfx::Rect(0, 40, 100, 10), |
| 2612 | occlusion.UnoccludedSurfaceContentRect( |
| 2613 | surface_child, false, gfx::Rect(0, 0, 100, 50))); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2614 | this->LeaveContributingSurface(surface_child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2615 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2616 | // When the surface_child's occlusion is transformed up to its parent, make |
| 2617 | // sure it is not clipped away inappropriately also. |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2618 | this->EnterLayer(surface, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2619 | EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
| 2620 | occlusion.occlusion_from_outside_target().ToString()); |
| 2621 | EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(), |
| 2622 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2623 | this->LeaveLayer(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2624 | |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 2625 | this->EnterContributingSurface(surface, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2626 | // The surface's parent does have a clip rect as it is the root layer. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2627 | EXPECT_EQ(gfx::Rect(0, 50, 100, 50), |
| 2628 | occlusion.UnoccludedSurfaceContentRect( |
| 2629 | surface, false, gfx::Rect(0, 0, 100, 100))); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2630 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2631 | }; |
| 2632 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 2633 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2634 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2635 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2636 | class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter |
| 2637 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2638 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2639 | explicit OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2640 | bool opaque_layers) |
| 2641 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2642 | void RunMyTest() { |
| 2643 | gfx::Transform scale_by_half; |
| 2644 | scale_by_half.Scale(0.5, 0.5); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2645 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 2646 | FilterOperations filters; |
| 2647 | filters.Append(FilterOperation::CreateBlurFilter(10.f)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2648 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2649 | // Save the distance of influence for the blur effect. |
| 2650 | int outset_top, outset_right, outset_bottom, outset_left; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 2651 | filters.GetOutsets( |
| 2652 | &outset_top, &outset_right, &outset_bottom, &outset_left); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2653 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2654 | enum Direction { |
| 2655 | LEFT, |
| 2656 | RIGHT, |
| 2657 | TOP, |
| 2658 | BOTTOM, |
| 2659 | LAST_DIRECTION = BOTTOM, |
| 2660 | }; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2661 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2662 | for (int i = 0; i <= LAST_DIRECTION; ++i) { |
| 2663 | SCOPED_TRACE(i); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2664 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2665 | // Make a 50x50 filtered surface that is adjacent to occluding layers |
| 2666 | // which are above it in the z-order in various configurations. The |
| 2667 | // surface is scaled to test that the pixel moving is done in the target |
| 2668 | // space, where the background filter is applied. |
| 2669 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2670 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| 2671 | typename Types::LayerType* filtered_surface = |
| 2672 | this->CreateDrawingLayer(parent, |
| 2673 | scale_by_half, |
| 2674 | gfx::PointF(50.f, 50.f), |
| 2675 | gfx::Size(100, 100), |
| 2676 | false); |
| 2677 | filtered_surface->SetBackgroundFilters(filters); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2678 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2679 | gfx::Rect occlusion_rect; |
| 2680 | switch (i) { |
| 2681 | case LEFT: |
| 2682 | occlusion_rect = gfx::Rect(0, 0, 50, 200); |
| 2683 | break; |
| 2684 | case RIGHT: |
| 2685 | occlusion_rect = gfx::Rect(100, 0, 50, 200); |
| 2686 | break; |
| 2687 | case TOP: |
| 2688 | occlusion_rect = gfx::Rect(0, 0, 200, 50); |
| 2689 | break; |
| 2690 | case BOTTOM: |
| 2691 | occlusion_rect = gfx::Rect(0, 100, 200, 50); |
| 2692 | break; |
| 2693 | } |
[email protected] | ac7c7f5 | 2012-11-08 06:26:50 | [diff] [blame] | 2694 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2695 | typename Types::LayerType* occluding_layer = |
| 2696 | this->CreateDrawingLayer(parent, |
| 2697 | this->identity_matrix, |
| 2698 | occlusion_rect.origin(), |
| 2699 | occlusion_rect.size(), |
| 2700 | true); |
| 2701 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2702 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2703 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 2704 | gfx::Rect(0, 0, 200, 200)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2705 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2706 | // This layer occludes pixels directly beside the filtered_surface. |
| 2707 | // Because filtered surface blends pixels in a radius, it will need to see |
| 2708 | // some of the pixels (up to radius far) underneath the occluding layers. |
| 2709 | this->VisitLayer(occluding_layer, &occlusion); |
[email protected] | ccb1c9a | 2012-12-17 03:53:19 | [diff] [blame] | 2710 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2711 | EXPECT_EQ(occlusion_rect.ToString(), |
| 2712 | occlusion.occlusion_from_inside_target().ToString()); |
| 2713 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2714 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2715 | this->VisitLayer(filtered_surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2716 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2717 | // The occlusion is used fully inside the surface. |
| 2718 | gfx::Rect occlusion_inside_surface = |
| 2719 | occlusion_rect - gfx::Vector2d(50, 50); |
| 2720 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| 2721 | EXPECT_EQ(occlusion_inside_surface.ToString(), |
| 2722 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | ac7c7f5 | 2012-11-08 06:26:50 | [diff] [blame] | 2723 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2724 | // The surface has a background blur, so it needs pixels that are |
| 2725 | // currently considered occluded in order to be drawn. So the pixels it |
| 2726 | // needs should be removed some the occluded area so that when we get to |
| 2727 | // the parent they are drawn. |
| 2728 | this->VisitContributingSurface(filtered_surface, &occlusion); |
| 2729 | this->EnterLayer(parent, &occlusion); |
[email protected] | ac7c7f5 | 2012-11-08 06:26:50 | [diff] [blame] | 2730 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2731 | gfx::Rect expected_occlusion = occlusion_rect; |
| 2732 | switch (i) { |
| 2733 | case LEFT: |
| 2734 | expected_occlusion.Inset(0, 0, outset_right, 0); |
| 2735 | break; |
| 2736 | case RIGHT: |
| 2737 | expected_occlusion.Inset(outset_right, 0, 0, 0); |
| 2738 | break; |
| 2739 | case TOP: |
| 2740 | expected_occlusion.Inset(0, 0, 0, outset_right); |
| 2741 | break; |
| 2742 | case BOTTOM: |
| 2743 | expected_occlusion.Inset(0, outset_right, 0, 0); |
| 2744 | break; |
| 2745 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2746 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2747 | EXPECT_EQ(expected_occlusion.ToString(), |
| 2748 | occlusion.occlusion_from_inside_target().ToString()); |
| 2749 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2750 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2751 | this->DestroyLayers(); |
| 2752 | } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2753 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2754 | }; |
| 2755 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2756 | ALL_OCCLUSIONTRACKER_TEST( |
| 2757 | OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2758 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2759 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2760 | class OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice |
| 2761 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2762 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2763 | explicit OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2764 | bool opaque_layers) |
| 2765 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2766 | void RunMyTest() { |
| 2767 | gfx::Transform scale_by_half; |
| 2768 | scale_by_half.Scale(0.5, 0.5); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2769 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2770 | // Makes two surfaces that completely cover |parent|. The occlusion both |
| 2771 | // above and below the filters will be reduced by each of them. |
| 2772 | typename Types::ContentLayerType* root = this->CreateRoot( |
| 2773 | this->identity_matrix, gfx::PointF(), gfx::Size(75, 75)); |
| 2774 | typename Types::LayerType* parent = this->CreateSurface( |
| 2775 | root, scale_by_half, gfx::PointF(), gfx::Size(150, 150)); |
| 2776 | parent->SetMasksToBounds(true); |
| 2777 | typename Types::LayerType* filtered_surface1 = this->CreateDrawingLayer( |
| 2778 | parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false); |
| 2779 | typename Types::LayerType* filtered_surface2 = this->CreateDrawingLayer( |
| 2780 | parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false); |
| 2781 | typename Types::LayerType* occluding_layer_above = |
| 2782 | this->CreateDrawingLayer(parent, |
| 2783 | this->identity_matrix, |
| 2784 | gfx::PointF(100.f, 100.f), |
| 2785 | gfx::Size(50, 50), |
| 2786 | true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2787 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2788 | // Filters make the layers own surfaces. |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 2789 | FilterOperations filters; |
| 2790 | filters.Append(FilterOperation::CreateBlurFilter(1.f)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2791 | filtered_surface1->SetBackgroundFilters(filters); |
| 2792 | filtered_surface2->SetBackgroundFilters(filters); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2793 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2794 | // Save the distance of influence for the blur effect. |
| 2795 | int outset_top, outset_right, outset_bottom, outset_left; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 2796 | filters.GetOutsets( |
| 2797 | &outset_top, &outset_right, &outset_bottom, &outset_left); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2798 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2799 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2800 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 2801 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2802 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2803 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2804 | this->VisitLayer(occluding_layer_above, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2805 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2806 | occlusion.occlusion_from_outside_target().ToString()); |
| 2807 | EXPECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2).ToString(), |
| 2808 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2809 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2810 | this->VisitLayer(filtered_surface2, &occlusion); |
| 2811 | this->VisitContributingSurface(filtered_surface2, &occlusion); |
| 2812 | this->VisitLayer(filtered_surface1, &occlusion); |
| 2813 | this->VisitContributingSurface(filtered_surface1, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2814 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2815 | // Test expectations in the target. |
| 2816 | gfx::Rect expected_occlusion = |
| 2817 | gfx::Rect(100 / 2 + outset_right * 2, |
| 2818 | 100 / 2 + outset_bottom * 2, |
| 2819 | 50 / 2 - (outset_left + outset_right) * 2, |
| 2820 | 50 / 2 - (outset_top + outset_bottom) * 2); |
| 2821 | EXPECT_EQ(expected_occlusion.ToString(), |
| 2822 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2823 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2824 | // Test expectations in the screen are the same as in the target, as the |
| 2825 | // render surface is 1:1 with the screen. |
| 2826 | EXPECT_EQ(expected_occlusion.ToString(), |
| 2827 | occlusion.occlusion_from_outside_target().ToString()); |
| 2828 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2829 | }; |
| 2830 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2831 | ALL_OCCLUSIONTRACKER_TEST( |
| 2832 | OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2833 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2834 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2835 | class OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter |
| 2836 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2837 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2838 | explicit OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2839 | bool opaque_layers) |
| 2840 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2841 | void RunMyTest() { |
| 2842 | gfx::Transform scale_by_half; |
| 2843 | scale_by_half.Scale(0.5, 0.5); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2844 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2845 | // Make a surface and its replica, each 50x50, with a smaller 30x30 layer |
| 2846 | // centered below each. The surface is scaled to test that the pixel moving |
| 2847 | // is done in the target space, where the background filter is applied, but |
| 2848 | // the surface appears at 50, 50 and the replica at 200, 50. |
| 2849 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2850 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 150)); |
| 2851 | typename Types::LayerType* behind_surface_layer = |
| 2852 | this->CreateDrawingLayer(parent, |
| 2853 | this->identity_matrix, |
| 2854 | gfx::PointF(60.f, 60.f), |
| 2855 | gfx::Size(30, 30), |
| 2856 | true); |
| 2857 | typename Types::LayerType* behind_replica_layer = |
| 2858 | this->CreateDrawingLayer(parent, |
| 2859 | this->identity_matrix, |
| 2860 | gfx::PointF(210.f, 60.f), |
| 2861 | gfx::Size(30, 30), |
| 2862 | true); |
| 2863 | typename Types::LayerType* filtered_surface = |
| 2864 | this->CreateDrawingLayer(parent, |
| 2865 | scale_by_half, |
| 2866 | gfx::PointF(50.f, 50.f), |
| 2867 | gfx::Size(100, 100), |
| 2868 | false); |
| 2869 | this->CreateReplicaLayer(filtered_surface, |
| 2870 | this->identity_matrix, |
| 2871 | gfx::PointF(300.f, 0.f), |
| 2872 | gfx::Size()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2873 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2874 | // Filters make the layer own a surface. |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 2875 | FilterOperations filters; |
| 2876 | filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2877 | filtered_surface->SetBackgroundFilters(filters); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2878 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2879 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2880 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 2881 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2882 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2883 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2884 | // The surface has a background blur, so it blurs non-opaque pixels below |
| 2885 | // it. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2886 | this->VisitLayer(filtered_surface, &occlusion); |
| 2887 | this->VisitContributingSurface(filtered_surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2888 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2889 | this->VisitLayer(behind_replica_layer, &occlusion); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2890 | |
| 2891 | // The layers behind the surface are not blurred, and their occlusion does |
| 2892 | // not change, until we leave the surface. So it should not be modified by |
| 2893 | // the filter here. |
| 2894 | gfx::Rect occlusion_behind_replica = gfx::Rect(210, 60, 30, 30); |
| 2895 | EXPECT_EQ(occlusion_behind_replica.ToString(), |
| 2896 | occlusion.occlusion_from_inside_target().ToString()); |
| 2897 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 2898 | |
| 2899 | // Clear the occlusion so the |behind_surface_layer| can add its occlusion |
| 2900 | // without existing occlusion interfering. |
| 2901 | occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| 2902 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2903 | this->VisitLayer(behind_surface_layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2904 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2905 | // The layers behind the surface are not blurred, and their occlusion does |
| 2906 | // not change, until we leave the surface. So it should not be modified by |
| 2907 | // the filter here. |
| 2908 | gfx::Rect occlusion_behind_surface = gfx::Rect(60, 60, 30, 30); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2909 | EXPECT_EQ(occlusion_behind_surface.ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2910 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 2911 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2912 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2913 | }; |
| 2914 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2915 | ALL_OCCLUSIONTRACKER_TEST( |
| 2916 | OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2917 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2918 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2919 | class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded |
| 2920 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2921 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2922 | explicit OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2923 | bool opaque_layers) |
| 2924 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2925 | void RunMyTest() { |
| 2926 | gfx::Transform scale_by_half; |
| 2927 | scale_by_half.Scale(0.5, 0.5); |
| 2928 | |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 2929 | // Make a 50x50 filtered surface that is completely occluded by an opaque |
| 2930 | // layer which is above it in the z-order. The surface is |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2931 | // scaled to test that the pixel moving is done in the target space, where |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 2932 | // the background filter is applied, but the surface appears at 50, 50. |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2933 | typename Types::ContentLayerType* parent = this->CreateRoot( |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 2934 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 150)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2935 | typename Types::LayerType* filtered_surface = |
| 2936 | this->CreateDrawingLayer(parent, |
| 2937 | scale_by_half, |
| 2938 | gfx::PointF(50.f, 50.f), |
| 2939 | gfx::Size(100, 100), |
| 2940 | false); |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 2941 | typename Types::LayerType* occluding_layer = |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2942 | this->CreateDrawingLayer(parent, |
| 2943 | this->identity_matrix, |
| 2944 | gfx::PointF(50.f, 50.f), |
| 2945 | gfx::Size(50, 50), |
| 2946 | true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2947 | |
| 2948 | // Filters make the layer own a surface. |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 2949 | FilterOperations filters; |
| 2950 | filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2951 | filtered_surface->SetBackgroundFilters(filters); |
| 2952 | |
| 2953 | this->CalcDrawEtc(parent); |
| 2954 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 2955 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2956 | gfx::Rect(0, 0, 1000, 1000)); |
| 2957 | |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 2958 | this->VisitLayer(occluding_layer, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2959 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2960 | this->VisitLayer(filtered_surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2961 | { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2962 | // The layers above the filtered surface occlude from outside. |
| 2963 | gfx::Rect occlusion_above_surface = gfx::Rect(0, 0, 50, 50); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2964 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2965 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2966 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 2967 | EXPECT_EQ(occlusion_above_surface.ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2968 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2969 | } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2970 | |
| 2971 | // The surface has a background blur, so it blurs non-opaque pixels below |
| 2972 | // it. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 2973 | this->VisitContributingSurface(filtered_surface, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2974 | { |
| 2975 | // The filter is completely occluded, so it should not blur anything and |
| 2976 | // reduce any occlusion. |
| 2977 | gfx::Rect occlusion_above_surface = gfx::Rect(50, 50, 50, 50); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2978 | |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 2979 | EXPECT_EQ(occlusion_above_surface.ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2980 | occlusion.occlusion_from_inside_target().ToString()); |
| 2981 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2982 | occlusion.occlusion_from_outside_target().ToString()); |
| 2983 | } |
| 2984 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2985 | }; |
| 2986 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2987 | ALL_OCCLUSIONTRACKER_TEST( |
| 2988 | OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2989 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2990 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2991 | class OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded |
| 2992 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2993 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 2994 | explicit |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 2995 | OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded( |
| 2996 | bool opaque_layers) |
| 2997 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2998 | void RunMyTest() { |
| 2999 | gfx::Transform scale_by_half; |
| 3000 | scale_by_half.Scale(0.5, 0.5); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3001 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3002 | // Make a surface and its replica, each 50x50, that are partially occluded |
| 3003 | // by opaque layers which are above them in the z-order. The surface is |
| 3004 | // scaled to test that the pixel moving is done in the target space, where |
| 3005 | // the background filter is applied, but the surface appears at 50, 50 and |
| 3006 | // the replica at 200, 50. |
| 3007 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 3008 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 150)); |
| 3009 | typename Types::LayerType* filtered_surface = |
| 3010 | this->CreateDrawingLayer(parent, |
| 3011 | scale_by_half, |
| 3012 | gfx::PointF(50.f, 50.f), |
| 3013 | gfx::Size(100, 100), |
| 3014 | false); |
| 3015 | this->CreateReplicaLayer(filtered_surface, |
| 3016 | this->identity_matrix, |
| 3017 | gfx::PointF(300.f, 0.f), |
| 3018 | gfx::Size()); |
| 3019 | typename Types::LayerType* above_surface_layer = |
| 3020 | this->CreateDrawingLayer(parent, |
| 3021 | this->identity_matrix, |
| 3022 | gfx::PointF(70.f, 50.f), |
| 3023 | gfx::Size(30, 50), |
| 3024 | true); |
| 3025 | typename Types::LayerType* above_replica_layer = |
| 3026 | this->CreateDrawingLayer(parent, |
| 3027 | this->identity_matrix, |
| 3028 | gfx::PointF(200.f, 50.f), |
| 3029 | gfx::Size(30, 50), |
| 3030 | true); |
| 3031 | typename Types::LayerType* beside_surface_layer = |
| 3032 | this->CreateDrawingLayer(parent, |
| 3033 | this->identity_matrix, |
| 3034 | gfx::PointF(90.f, 40.f), |
| 3035 | gfx::Size(10, 10), |
| 3036 | true); |
| 3037 | typename Types::LayerType* beside_replica_layer = |
| 3038 | this->CreateDrawingLayer(parent, |
| 3039 | this->identity_matrix, |
| 3040 | gfx::PointF(200.f, 40.f), |
| 3041 | gfx::Size(10, 10), |
| 3042 | true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3043 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3044 | // Filters make the layer own a surface. |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 3045 | FilterOperations filters; |
| 3046 | filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3047 | filtered_surface->SetBackgroundFilters(filters); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3048 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3049 | // Save the distance of influence for the blur effect. |
| 3050 | int outset_top, outset_right, outset_bottom, outset_left; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 3051 | filters.GetOutsets( |
| 3052 | &outset_top, &outset_right, &outset_bottom, &outset_left); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3053 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3054 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3055 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 3056 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3057 | gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3058 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 3059 | this->VisitLayer(beside_replica_layer, &occlusion); |
| 3060 | this->VisitLayer(beside_surface_layer, &occlusion); |
| 3061 | this->VisitLayer(above_replica_layer, &occlusion); |
| 3062 | this->VisitLayer(above_surface_layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3063 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3064 | // The surface has a background blur, so it blurs non-opaque pixels below |
| 3065 | // it. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 3066 | this->VisitLayer(filtered_surface, &occlusion); |
| 3067 | this->VisitContributingSurface(filtered_surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3068 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3069 | // The filter in the surface and replica are partially unoccluded. Only the |
| 3070 | // unoccluded parts should reduce occlusion. This means it will push back |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 3071 | // the occlusion that touches the unoccluded part (occlusion_above___), but |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3072 | // it will not touch occlusion_beside____ since that is not beside the |
| 3073 | // unoccluded part of the surface, even though it is beside the occluded |
| 3074 | // part of the surface. |
| 3075 | gfx::Rect occlusion_above_surface = |
| 3076 | gfx::Rect(70 + outset_right, 50, 30 - outset_right, 50); |
| 3077 | gfx::Rect occlusion_above_replica = |
| 3078 | gfx::Rect(200, 50, 30 - outset_left, 50); |
| 3079 | gfx::Rect occlusion_beside_surface = gfx::Rect(90, 40, 10, 10); |
| 3080 | gfx::Rect occlusion_beside_replica = gfx::Rect(200, 40, 10, 10); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3081 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 3082 | SimpleEnclosedRegion expected_occlusion; |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3083 | expected_occlusion.Union(occlusion_beside_replica); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 3084 | expected_occlusion.Union(occlusion_beside_surface); |
| 3085 | expected_occlusion.Union(occlusion_above_replica); |
| 3086 | expected_occlusion.Union(occlusion_above_surface); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3087 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 3088 | EXPECT_EQ(expected_occlusion.ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3089 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 3090 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3091 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 3092 | const SimpleEnclosedRegion& actual_occlusion = |
| 3093 | occlusion.occlusion_from_inside_target(); |
| 3094 | for (size_t i = 0; i < expected_occlusion.GetRegionComplexity(); ++i) { |
| 3095 | ASSERT_LT(i, actual_occlusion.GetRegionComplexity()); |
| 3096 | EXPECT_EQ(expected_occlusion.GetRect(i), actual_occlusion.GetRect(i)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3097 | } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3098 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3099 | }; |
| 3100 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3101 | ALL_OCCLUSIONTRACKER_TEST( |
| 3102 | OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3103 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3104 | template <class Types> |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 3105 | class OcclusionTrackerTestMinimumTrackingSize |
| 3106 | : public OcclusionTrackerTest<Types> { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3107 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 3108 | explicit OcclusionTrackerTestMinimumTrackingSize(bool opaque_layers) |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3109 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 3110 | void RunMyTest() { |
| 3111 | gfx::Size tracking_size(100, 100); |
| 3112 | gfx::Size below_tracking_size(99, 99); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3113 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3114 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 3115 | this->identity_matrix, gfx::PointF(), gfx::Size(400, 400)); |
| 3116 | typename Types::LayerType* large = this->CreateDrawingLayer( |
| 3117 | parent, this->identity_matrix, gfx::PointF(), tracking_size, true); |
| 3118 | typename Types::LayerType* small = |
| 3119 | this->CreateDrawingLayer(parent, |
| 3120 | this->identity_matrix, |
| 3121 | gfx::PointF(), |
| 3122 | below_tracking_size, |
| 3123 | true); |
| 3124 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3125 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 3126 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3127 | gfx::Rect(0, 0, 1000, 1000)); |
| 3128 | occlusion.set_minimum_tracking_size(tracking_size); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3129 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3130 | // The small layer is not tracked because it is too small. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 3131 | this->VisitLayer(small, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3132 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3133 | EXPECT_EQ(gfx::Rect().ToString(), |
| 3134 | occlusion.occlusion_from_outside_target().ToString()); |
| 3135 | EXPECT_EQ(gfx::Rect().ToString(), |
| 3136 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3137 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3138 | // The large layer is tracked as it is large enough. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 3139 | this->VisitLayer(large, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3140 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3141 | EXPECT_EQ(gfx::Rect().ToString(), |
| 3142 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | 2c7c670 | 2013-03-26 03:14:05 | [diff] [blame] | 3143 | EXPECT_EQ(gfx::Rect(tracking_size).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3144 | occlusion.occlusion_from_inside_target().ToString()); |
| 3145 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3146 | }; |
| 3147 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 3148 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestMinimumTrackingSize); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3149 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 3150 | template <class Types> |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 3151 | class OcclusionTrackerTestScaledLayerIsClipped |
| 3152 | : public OcclusionTrackerTest<Types> { |
| 3153 | protected: |
| 3154 | explicit OcclusionTrackerTestScaledLayerIsClipped(bool opaque_layers) |
| 3155 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 3156 | void RunMyTest() { |
| 3157 | gfx::Transform scale_transform; |
| 3158 | scale_transform.Scale(512.0, 512.0); |
| 3159 | |
| 3160 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 3161 | this->identity_matrix, gfx::PointF(), gfx::Size(400, 400)); |
| 3162 | typename Types::LayerType* clip = this->CreateLayer(parent, |
| 3163 | this->identity_matrix, |
| 3164 | gfx::PointF(10.f, 10.f), |
| 3165 | gfx::Size(50, 50)); |
| 3166 | clip->SetMasksToBounds(true); |
| 3167 | typename Types::LayerType* scale = this->CreateLayer( |
| 3168 | clip, scale_transform, gfx::PointF(), gfx::Size(1, 1)); |
| 3169 | typename Types::LayerType* scaled = this->CreateDrawingLayer( |
| 3170 | scale, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500), true); |
| 3171 | this->CalcDrawEtc(parent); |
| 3172 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 3173 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 3174 | gfx::Rect(0, 0, 1000, 1000)); |
| 3175 | |
| 3176 | this->VisitLayer(scaled, &occlusion); |
| 3177 | |
| 3178 | EXPECT_EQ(gfx::Rect().ToString(), |
| 3179 | occlusion.occlusion_from_outside_target().ToString()); |
| 3180 | EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
| 3181 | occlusion.occlusion_from_inside_target().ToString()); |
| 3182 | } |
| 3183 | }; |
| 3184 | |
| 3185 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerIsClipped) |
| 3186 | |
| 3187 | template <class Types> |
| 3188 | class OcclusionTrackerTestScaledLayerInSurfaceIsClipped |
| 3189 | : public OcclusionTrackerTest<Types> { |
| 3190 | protected: |
| 3191 | explicit OcclusionTrackerTestScaledLayerInSurfaceIsClipped(bool opaque_layers) |
| 3192 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 3193 | void RunMyTest() { |
| 3194 | gfx::Transform scale_transform; |
| 3195 | scale_transform.Scale(512.0, 512.0); |
| 3196 | |
| 3197 | typename Types::ContentLayerType* parent = this->CreateRoot( |
| 3198 | this->identity_matrix, gfx::PointF(), gfx::Size(400, 400)); |
| 3199 | typename Types::LayerType* clip = this->CreateLayer(parent, |
| 3200 | this->identity_matrix, |
| 3201 | gfx::PointF(10.f, 10.f), |
| 3202 | gfx::Size(50, 50)); |
| 3203 | clip->SetMasksToBounds(true); |
| 3204 | typename Types::LayerType* surface = this->CreateDrawingSurface( |
| 3205 | clip, this->identity_matrix, gfx::PointF(), gfx::Size(400, 30), false); |
| 3206 | typename Types::LayerType* scale = this->CreateLayer( |
| 3207 | surface, scale_transform, gfx::PointF(), gfx::Size(1, 1)); |
| 3208 | typename Types::LayerType* scaled = this->CreateDrawingLayer( |
| 3209 | scale, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500), true); |
| 3210 | this->CalcDrawEtc(parent); |
| 3211 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 3212 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 3213 | gfx::Rect(0, 0, 1000, 1000)); |
| 3214 | |
| 3215 | this->VisitLayer(scaled, &occlusion); |
| 3216 | this->VisitLayer(surface, &occlusion); |
| 3217 | this->VisitContributingSurface(surface, &occlusion); |
| 3218 | |
| 3219 | EXPECT_EQ(gfx::Rect().ToString(), |
| 3220 | occlusion.occlusion_from_outside_target().ToString()); |
| 3221 | EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
| 3222 | occlusion.occlusion_from_inside_target().ToString()); |
| 3223 | } |
| 3224 | }; |
| 3225 | |
| 3226 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerInSurfaceIsClipped) |
| 3227 | |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 3228 | template <class Types> |
| 3229 | class OcclusionTrackerTestCopyRequestDoesOcclude |
| 3230 | : public OcclusionTrackerTest<Types> { |
| 3231 | protected: |
| 3232 | explicit OcclusionTrackerTestCopyRequestDoesOcclude(bool opaque_layers) |
| 3233 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 3234 | void RunMyTest() { |
| 3235 | typename Types::ContentLayerType* root = this->CreateRoot( |
| 3236 | this->identity_matrix, gfx::Point(), gfx::Size(400, 400)); |
| 3237 | typename Types::ContentLayerType* parent = this->CreateDrawingLayer( |
| 3238 | root, this->identity_matrix, gfx::Point(), gfx::Size(400, 400), true); |
| 3239 | typename Types::LayerType* copy = this->CreateLayer(parent, |
| 3240 | this->identity_matrix, |
| 3241 | gfx::Point(100, 0), |
| 3242 | gfx::Size(200, 400)); |
| 3243 | this->AddCopyRequest(copy); |
| 3244 | typename Types::LayerType* copy_child = this->CreateDrawingLayer( |
| 3245 | copy, |
| 3246 | this->identity_matrix, |
| 3247 | gfx::PointF(), |
| 3248 | gfx::Size(200, 400), |
| 3249 | true); |
| 3250 | this->CalcDrawEtc(root); |
| 3251 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 3252 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 3253 | gfx::Rect(0, 0, 1000, 1000)); |
| 3254 | |
| 3255 | this->VisitLayer(copy_child, &occlusion); |
| 3256 | EXPECT_EQ(gfx::Rect().ToString(), |
| 3257 | occlusion.occlusion_from_outside_target().ToString()); |
| 3258 | EXPECT_EQ(gfx::Rect(200, 400).ToString(), |
| 3259 | occlusion.occlusion_from_inside_target().ToString()); |
| 3260 | |
| 3261 | // CopyRequests cause the layer to own a surface. |
| 3262 | this->VisitContributingSurface(copy, &occlusion); |
| 3263 | |
| 3264 | // The occlusion from the copy should be kept. |
| 3265 | EXPECT_EQ(gfx::Rect().ToString(), |
| 3266 | occlusion.occlusion_from_outside_target().ToString()); |
| 3267 | EXPECT_EQ(gfx::Rect(100, 0, 200, 400).ToString(), |
| 3268 | occlusion.occlusion_from_inside_target().ToString()); |
| 3269 | } |
| 3270 | }; |
| 3271 | |
| 3272 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestCopyRequestDoesOcclude) |
| 3273 | |
| 3274 | template <class Types> |
| 3275 | class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude |
| 3276 | : public OcclusionTrackerTest<Types> { |
| 3277 | protected: |
| 3278 | explicit OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude( |
| 3279 | bool opaque_layers) |
| 3280 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 3281 | void RunMyTest() { |
| 3282 | typename Types::ContentLayerType* root = this->CreateRoot( |
| 3283 | this->identity_matrix, gfx::Point(), gfx::Size(400, 400)); |
| 3284 | typename Types::ContentLayerType* parent = this->CreateDrawingLayer( |
| 3285 | root, this->identity_matrix, gfx::Point(), gfx::Size(400, 400), true); |
| 3286 | typename Types::LayerType* hide = this->CreateLayer( |
| 3287 | parent, this->identity_matrix, gfx::Point(), gfx::Size()); |
| 3288 | typename Types::LayerType* copy = this->CreateLayer( |
| 3289 | hide, this->identity_matrix, gfx::Point(100, 0), gfx::Size(200, 400)); |
| 3290 | this->AddCopyRequest(copy); |
| 3291 | typename Types::LayerType* copy_child = this->CreateDrawingLayer( |
| 3292 | copy, this->identity_matrix, gfx::PointF(), gfx::Size(200, 400), true); |
| 3293 | |
| 3294 | // The |copy| layer is hidden but since it is being copied, it will be |
| 3295 | // drawn. |
| 3296 | hide->SetHideLayerAndSubtree(true); |
| 3297 | |
| 3298 | this->CalcDrawEtc(root); |
| 3299 | |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 3300 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 3301 | gfx::Rect(0, 0, 1000, 1000)); |
| 3302 | |
| 3303 | this->VisitLayer(copy_child, &occlusion); |
| 3304 | EXPECT_EQ(gfx::Rect().ToString(), |
| 3305 | occlusion.occlusion_from_outside_target().ToString()); |
| 3306 | EXPECT_EQ(gfx::Rect(200, 400).ToString(), |
| 3307 | occlusion.occlusion_from_inside_target().ToString()); |
| 3308 | |
| 3309 | // CopyRequests cause the layer to own a surface. |
| 3310 | this->VisitContributingSurface(copy, &occlusion); |
| 3311 | |
| 3312 | // The occlusion from the copy should be dropped since it is hidden. |
| 3313 | EXPECT_EQ(gfx::Rect().ToString(), |
| 3314 | occlusion.occlusion_from_outside_target().ToString()); |
| 3315 | EXPECT_EQ(gfx::Rect().ToString(), |
| 3316 | occlusion.occlusion_from_inside_target().ToString()); |
| 3317 | } |
| 3318 | }; |
| 3319 | |
| 3320 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude) |
| 3321 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 3322 | template <class Types> |
| 3323 | class OcclusionTrackerTestOccludedLayer : public OcclusionTrackerTest<Types> { |
| 3324 | protected: |
| 3325 | explicit OcclusionTrackerTestOccludedLayer(bool opaque_layers) |
| 3326 | : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 3327 | void RunMyTest() { |
| 3328 | gfx::Transform translate; |
| 3329 | translate.Translate(10.0, 20.0); |
| 3330 | typename Types::ContentLayerType* root = this->CreateRoot( |
| 3331 | this->identity_matrix, gfx::Point(), gfx::Size(200, 200)); |
| 3332 | typename Types::LayerType* surface = this->CreateSurface( |
| 3333 | root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200)); |
| 3334 | typename Types::LayerType* layer = this->CreateDrawingLayer( |
| 3335 | surface, translate, gfx::Point(), gfx::Size(200, 200), false); |
| 3336 | typename Types::ContentLayerType* outside_layer = this->CreateDrawingLayer( |
| 3337 | root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200), false); |
| 3338 | this->CalcDrawEtc(root); |
| 3339 | |
| 3340 | TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 3341 | gfx::Rect(0, 0, 200, 200)); |
| 3342 | this->VisitLayer(outside_layer, &occlusion); |
| 3343 | this->EnterLayer(layer, &occlusion); |
| 3344 | |
| 3345 | // No occlusion, is not occluded. |
| 3346 | occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| 3347 | occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| 3348 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100))); |
| 3349 | |
| 3350 | // Partial occlusion from outside, is not occluded. |
| 3351 | occlusion.set_occlusion_from_outside_target( |
| 3352 | SimpleEnclosedRegion(50, 50, 100, 100)); |
| 3353 | occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| 3354 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); |
| 3355 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); |
| 3356 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); |
| 3357 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); |
| 3358 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); |
| 3359 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); |
| 3360 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); |
| 3361 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); |
| 3362 | |
| 3363 | // Full occlusion from outside, is occluded. |
| 3364 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); |
| 3365 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); |
| 3366 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); |
| 3367 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); |
| 3368 | |
| 3369 | // Partial occlusion from inside, is not occluded. |
| 3370 | occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| 3371 | occlusion.set_occlusion_from_inside_target( |
| 3372 | SimpleEnclosedRegion(50, 50, 100, 100)); |
| 3373 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); |
| 3374 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); |
| 3375 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); |
| 3376 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); |
| 3377 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); |
| 3378 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); |
| 3379 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); |
| 3380 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); |
| 3381 | |
| 3382 | // Full occlusion from inside, is occluded. |
| 3383 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); |
| 3384 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); |
| 3385 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); |
| 3386 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); |
| 3387 | |
| 3388 | // Partial occlusion from both, is not occluded. |
| 3389 | occlusion.set_occlusion_from_outside_target( |
| 3390 | SimpleEnclosedRegion(50, 50, 100, 50)); |
| 3391 | occlusion.set_occlusion_from_inside_target( |
| 3392 | SimpleEnclosedRegion(50, 100, 100, 50)); |
| 3393 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); |
| 3394 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); |
| 3395 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); |
| 3396 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); |
| 3397 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); |
| 3398 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); |
| 3399 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); |
| 3400 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); |
| 3401 | |
| 3402 | // Full occlusion from both, is occluded. |
| 3403 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); |
| 3404 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); |
| 3405 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); |
| 3406 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); |
| 3407 | } |
| 3408 | }; |
| 3409 | |
| 3410 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOccludedLayer) |
| 3411 | |
[email protected] | ba56574 | 2012-11-10 09:29:48 | [diff] [blame] | 3412 | } // namespace |
| 3413 | } // namespace cc |