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