[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 | |
avi | 02a4d17 | 2015-12-21 06:14:36 | [diff] [blame] | 7 | #include <stddef.h> |
| 8 | |
loyso | 2cb3f32f | 2016-11-08 07:08:34 | [diff] [blame] | 9 | #include "cc/animation/animation_host.h" |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 10 | #include "cc/base/math_util.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 11 | #include "cc/layers/layer.h" |
| 12 | #include "cc/layers/layer_impl.h" |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 13 | #include "cc/output/copy_output_request.h" |
| 14 | #include "cc/output/copy_output_result.h" |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 15 | #include "cc/output/filter_operation.h" |
| 16 | #include "cc/output/filter_operations.h" |
[email protected] | 101441ce | 2012-10-16 01:45:03 | [diff] [blame] | 17 | #include "cc/test/animation_test_common.h" |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 18 | #include "cc/test/fake_impl_task_runner_provider.h" |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 19 | #include "cc/test/fake_layer_tree_host.h" |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 20 | #include "cc/test/fake_layer_tree_host_impl.h" |
[email protected] | 101441ce | 2012-10-16 01:45:03 | [diff] [blame] | 21 | #include "cc/test/geometry_test_utils.h" |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 22 | #include "cc/test/test_occlusion_tracker.h" |
danakj | cf61058 | 2015-06-16 22:48:56 | [diff] [blame] | 23 | #include "cc/test/test_task_graph_runner.h" |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 24 | #include "cc/trees/layer_tree_host_common.h" |
| 25 | #include "cc/trees/single_thread_proxy.h" |
[email protected] | 7f0c53db | 2012-10-02 00:23:18 | [diff] [blame] | 26 | #include "testing/gmock/include/gmock/gmock.h" |
| 27 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 28 | #include "ui/gfx/transform.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 29 | |
[email protected] | ba56574 | 2012-11-10 09:29:48 | [diff] [blame] | 30 | namespace cc { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 31 | namespace { |
| 32 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 33 | class TestContentLayerImpl : public LayerImpl { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 34 | public: |
| 35 | TestContentLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 36 | : LayerImpl(tree_impl, id), override_opaque_contents_rect_(false) { |
| 37 | SetDrawsContent(true); |
| 38 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 39 | |
danakj | 64767d90 | 2015-06-19 00:10:43 | [diff] [blame] | 40 | SimpleEnclosedRegion VisibleOpaqueRegion() const override { |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 41 | if (override_opaque_contents_rect_) { |
| 42 | return SimpleEnclosedRegion( |
danakj | 64767d90 | 2015-06-19 00:10:43 | [diff] [blame] | 43 | gfx::IntersectRects(opaque_contents_rect_, visible_layer_rect())); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 44 | } |
danakj | 64767d90 | 2015-06-19 00:10:43 | [diff] [blame] | 45 | return LayerImpl::VisibleOpaqueRegion(); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 46 | } |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 47 | void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 48 | override_opaque_contents_rect_ = true; |
| 49 | opaque_contents_rect_ = opaque_contents_rect; |
| 50 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 51 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 52 | private: |
| 53 | bool override_opaque_contents_rect_; |
| 54 | gfx::Rect opaque_contents_rect_; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 55 | }; |
| 56 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 57 | class TestOcclusionTrackerWithClip : public TestOcclusionTracker { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 58 | public: |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 59 | explicit TestOcclusionTrackerWithClip(const gfx::Rect& viewport_rect) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 60 | : TestOcclusionTracker(viewport_rect) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 61 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 62 | bool OccludedLayer(const LayerImpl* layer, |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 63 | const gfx::Rect& content_rect) const { |
danakj | 64767d90 | 2015-06-19 00:10:43 | [diff] [blame] | 64 | DCHECK(layer->visible_layer_rect().Contains(content_rect)); |
ajuma | d9432e3 | 2015-11-30 19:43:44 | [diff] [blame] | 65 | return this->GetCurrentOcclusionForLayer(layer->DrawTransform()) |
vmpstr | 01a5bf35 | 2014-09-17 22:57:31 | [diff] [blame] | 66 | .IsOccluded(content_rect); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 67 | } |
[email protected] | fbc29332 | 2013-10-01 05:07:15 | [diff] [blame] | 68 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 69 | // Gives an unoccluded sub-rect of |content_rect| in the content space of the |
vmpstr | 5b88d99 | 2014-09-18 23:25:04 | [diff] [blame] | 70 | // layer. Simple wrapper around GetUnoccludedContentRect. |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 71 | gfx::Rect UnoccludedLayerContentRect(const LayerImpl* layer, |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 72 | const gfx::Rect& content_rect) const { |
danakj | 64767d90 | 2015-06-19 00:10:43 | [diff] [blame] | 73 | DCHECK(layer->visible_layer_rect().Contains(content_rect)); |
ajuma | d9432e3 | 2015-11-30 19:43:44 | [diff] [blame] | 74 | return this->GetCurrentOcclusionForLayer(layer->DrawTransform()) |
vmpstr | 5b88d99 | 2014-09-18 23:25:04 | [diff] [blame] | 75 | .GetUnoccludedContentRect(content_rect); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 76 | } |
[email protected] | e312aca | 2014-03-20 22:11:55 | [diff] [blame] | 77 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 78 | gfx::Rect UnoccludedSurfaceContentRect(const LayerImpl* layer, |
[email protected] | e312aca | 2014-03-20 22:11:55 | [diff] [blame] | 79 | const gfx::Rect& content_rect) const { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 80 | RenderSurfaceImpl* surface = layer->render_surface(); |
danakj | 206a581 | 2015-02-11 02:07:08 | [diff] [blame] | 81 | return this->GetCurrentOcclusionForContributingSurface( |
| 82 | surface->draw_transform()) |
| 83 | .GetUnoccludedContentRect(content_rect); |
[email protected] | e312aca | 2014-03-20 22:11:55 | [diff] [blame] | 84 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 85 | }; |
| 86 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 87 | class OcclusionTrackerTest : public testing::Test { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 88 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 89 | explicit OcclusionTrackerTest(bool opaque_layers) |
enne | 2097cab | 2014-09-25 20:16:31 | [diff] [blame] | 90 | : opaque_layers_(opaque_layers), |
loyso | 2cb3f32f | 2016-11-08 07:08:34 | [diff] [blame] | 91 | animation_host_(AnimationHost::CreateForTesting(ThreadInstance::MAIN)), |
| 92 | host_(FakeLayerTreeHost::Create(&client_, |
| 93 | &task_graph_runner_, |
| 94 | animation_host_.get())), |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 95 | next_layer_impl_id_(1) {} |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 96 | |
| 97 | virtual void RunMyTest() = 0; |
| 98 | |
danakj | aeb9506 | 2014-11-14 01:35:36 | [diff] [blame] | 99 | void TearDown() override { DestroyLayers(); } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 100 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 101 | TestContentLayerImpl* CreateRoot(const gfx::Transform& transform, |
| 102 | const gfx::PointF& position, |
| 103 | const gfx::Size& bounds) { |
| 104 | LayerTreeImpl* tree = host_->host_impl()->active_tree(); |
| 105 | int id = next_layer_impl_id_++; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 106 | std::unique_ptr<TestContentLayerImpl> layer( |
| 107 | new TestContentLayerImpl(tree, id)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 108 | TestContentLayerImpl* layer_ptr = layer.get(); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 109 | SetProperties(layer_ptr, transform, position, bounds); |
| 110 | |
jaydasika | bf1875a | 2016-06-28 03:39:59 | [diff] [blame] | 111 | host_->host_impl()->active_tree()->SetRootLayerForTesting(std::move(layer)); |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 112 | |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 113 | layer_ptr->test_properties()->force_render_surface = true; |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 114 | SetRootLayerOnMainThread(layer_ptr); |
| 115 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 116 | return layer_ptr; |
| 117 | } |
| 118 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 119 | LayerImpl* CreateLayer(LayerImpl* parent, |
| 120 | const gfx::Transform& transform, |
| 121 | const gfx::PointF& position, |
| 122 | const gfx::Size& bounds) { |
| 123 | LayerTreeImpl* tree = host_->host_impl()->active_tree(); |
| 124 | int id = next_layer_impl_id_++; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 125 | std::unique_ptr<LayerImpl> layer = LayerImpl::Create(tree, id); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 126 | LayerImpl* layer_ptr = layer.get(); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 127 | SetProperties(layer_ptr, transform, position, bounds); |
jaydasika | 89f7b5a | 2016-06-22 02:08:39 | [diff] [blame] | 128 | parent->test_properties()->AddChild(std::move(layer)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 129 | return layer_ptr; |
| 130 | } |
| 131 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 132 | LayerImpl* CreateSurface(LayerImpl* parent, |
| 133 | const gfx::Transform& transform, |
| 134 | const gfx::PointF& position, |
| 135 | const gfx::Size& bounds) { |
| 136 | LayerImpl* layer = CreateLayer(parent, transform, position, bounds); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 137 | layer->test_properties()->force_render_surface = true; |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 138 | return layer; |
| 139 | } |
| 140 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 141 | TestContentLayerImpl* CreateDrawingLayer(LayerImpl* parent, |
| 142 | const gfx::Transform& transform, |
| 143 | const gfx::PointF& position, |
| 144 | const gfx::Size& bounds, |
| 145 | bool opaque) { |
| 146 | LayerTreeImpl* tree = host_->host_impl()->active_tree(); |
| 147 | int id = next_layer_impl_id_++; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 148 | std::unique_ptr<TestContentLayerImpl> layer( |
| 149 | new TestContentLayerImpl(tree, id)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 150 | TestContentLayerImpl* layer_ptr = layer.get(); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 151 | SetProperties(layer_ptr, transform, position, bounds); |
| 152 | |
| 153 | if (opaque_layers_) { |
| 154 | layer_ptr->SetContentsOpaque(opaque); |
| 155 | } else { |
| 156 | layer_ptr->SetContentsOpaque(false); |
| 157 | if (opaque) |
[email protected] | 2c7c670 | 2013-03-26 03:14:05 | [diff] [blame] | 158 | layer_ptr->SetOpaqueContentsRect(gfx::Rect(bounds)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 159 | else |
| 160 | layer_ptr->SetOpaqueContentsRect(gfx::Rect()); |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 161 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 162 | |
jaydasika | 89f7b5a | 2016-06-22 02:08:39 | [diff] [blame] | 163 | parent->test_properties()->AddChild(std::move(layer)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 164 | return layer_ptr; |
| 165 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 166 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 167 | LayerImpl* CreateMaskLayer(LayerImpl* owning_layer, const gfx::Size& bounds) { |
| 168 | LayerTreeImpl* tree = host_->host_impl()->active_tree(); |
| 169 | int id = next_layer_impl_id_++; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 170 | std::unique_ptr<TestContentLayerImpl> layer( |
| 171 | new TestContentLayerImpl(tree, id)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 172 | TestContentLayerImpl* layer_ptr = layer.get(); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 173 | SetProperties(layer_ptr, identity_matrix, gfx::PointF(), bounds); |
danakj | a04855a | 2015-11-18 20:39:10 | [diff] [blame] | 174 | SetMask(owning_layer, std::move(layer)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 175 | return layer_ptr; |
| 176 | } |
[email protected] | 586d51ed | 2012-12-07 20:31:45 | [diff] [blame] | 177 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 178 | TestContentLayerImpl* CreateDrawingSurface(LayerImpl* parent, |
| 179 | const gfx::Transform& transform, |
| 180 | const gfx::PointF& position, |
| 181 | const gfx::Size& bounds, |
| 182 | bool opaque) { |
| 183 | TestContentLayerImpl* layer = |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 184 | CreateDrawingLayer(parent, transform, position, bounds, opaque); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 185 | layer->test_properties()->force_render_surface = true; |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 186 | return layer; |
| 187 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 188 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 189 | void DestroyLayers() { |
jaydasika | bf1875a | 2016-06-28 03:39:59 | [diff] [blame] | 190 | host_->host_impl()->active_tree()->SetRootLayerForTesting(nullptr); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 191 | render_surface_layer_list_impl_.clear(); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 192 | mask_layers_.clear(); |
| 193 | ResetLayerIterator(); |
| 194 | } |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 195 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 196 | void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 197 | |
| 198 | void AddCopyRequest(Layer* layer) { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 199 | layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
| 200 | base::Bind(&OcclusionTrackerTest::CopyOutputCallback, |
| 201 | base::Unretained(this)))); |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | void AddCopyRequest(LayerImpl* layer) { |
ajuma | e6f541b | 2016-05-31 16:50:50 | [diff] [blame] | 205 | layer->test_properties()->copy_requests.push_back( |
| 206 | CopyOutputRequest::CreateBitmapRequest( |
| 207 | base::Bind(&OcclusionTrackerTest::CopyOutputCallback, |
| 208 | base::Unretained(this)))); |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 209 | } |
| 210 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 211 | void CalcDrawEtc(TestContentLayerImpl* root) { |
jaydasika | bf1875a | 2016-06-28 03:39:59 | [diff] [blame] | 212 | root->layer_tree_impl()->BuildLayerListForTesting(); |
| 213 | DCHECK(root == root->layer_tree_impl()->root_layer_for_testing()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 214 | |
enne | d8d1c5cb | 2015-06-16 19:09:35 | [diff] [blame] | 215 | // These occlusion tests attach and detach layers in multiple |
| 216 | // iterations, so rebuild property trees every time. |
| 217 | root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 218 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 219 | FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); |
enne | d8d1c5cb | 2015-06-16 19:09:35 | [diff] [blame] | 220 | |
[email protected] | 7aad55f | 2013-07-26 11:25:53 | [diff] [blame] | 221 | LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
ajuma | 0adb590 | 2016-04-28 16:32:38 | [diff] [blame] | 222 | root, root->bounds(), &render_surface_layer_list_impl_); |
[email protected] | 7aad55f | 2013-07-26 11:25:53 | [diff] [blame] | 223 | inputs.can_adjust_raster_scales = true; |
sunxd | b365de0 | 2016-04-28 20:32:57 | [diff] [blame] | 224 | LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 225 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 226 | layer_iterator_ = layer_iterator_begin_ = |
enne | 389d1a1 | 2015-06-18 20:40:51 | [diff] [blame] | 227 | LayerIterator::Begin(&render_surface_layer_list_impl_); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 228 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 229 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 230 | void EnterLayer(LayerImpl* layer, OcclusionTracker* occlusion) { |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 231 | ASSERT_EQ(*layer_iterator_, layer); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 232 | ASSERT_TRUE(layer_iterator_.represents_itself()); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 233 | occlusion->EnterLayer(layer_iterator_); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 234 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 235 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 236 | void LeaveLayer(LayerImpl* layer, OcclusionTracker* occlusion) { |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 237 | ASSERT_EQ(*layer_iterator_, layer); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 238 | ASSERT_TRUE(layer_iterator_.represents_itself()); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 239 | occlusion->LeaveLayer(layer_iterator_); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 240 | ++layer_iterator_; |
| 241 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 242 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 243 | void VisitLayer(LayerImpl* layer, OcclusionTracker* occlusion) { |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 244 | EnterLayer(layer, occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 245 | LeaveLayer(layer, occlusion); |
| 246 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 247 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 248 | void EnterContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) { |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 249 | ASSERT_EQ(*layer_iterator_, layer); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 250 | ASSERT_TRUE(layer_iterator_.represents_target_render_surface()); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 251 | occlusion->EnterLayer(layer_iterator_); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 252 | occlusion->LeaveLayer(layer_iterator_); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 253 | ++layer_iterator_; |
| 254 | ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 255 | occlusion->EnterLayer(layer_iterator_); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 256 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 257 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 258 | void LeaveContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) { |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 259 | ASSERT_EQ(*layer_iterator_, layer); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 260 | ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 261 | occlusion->LeaveLayer(layer_iterator_); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 262 | ++layer_iterator_; |
| 263 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 264 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 265 | void VisitContributingSurface(LayerImpl* layer, OcclusionTracker* occlusion) { |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 266 | EnterContributingSurface(layer, occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 267 | LeaveContributingSurface(layer, occlusion); |
| 268 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 269 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 270 | void ResetLayerIterator() { layer_iterator_ = layer_iterator_begin_; } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 271 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 272 | const gfx::Transform identity_matrix; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 273 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 274 | private: |
[email protected] | d600df7d | 2013-08-03 02:34:28 | [diff] [blame] | 275 | void SetRootLayerOnMainThread(Layer* root) { |
| 276 | host_->SetRootLayer(scoped_refptr<Layer>(root)); |
| 277 | } |
| 278 | |
| 279 | void SetRootLayerOnMainThread(LayerImpl* root) {} |
| 280 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 281 | void SetProperties(LayerImpl* layer, |
| 282 | const gfx::Transform& transform, |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 283 | const gfx::PointF& position, |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 284 | const gfx::Size& bounds) { |
jaydasika | 10d43fc | 2016-08-18 04:06:04 | [diff] [blame] | 285 | layer->test_properties()->transform = transform; |
danakj | 3b8b2bf | 2015-06-18 03:09:01 | [diff] [blame] | 286 | layer->SetPosition(position); |
| 287 | layer->SetBounds(bounds); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 288 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 289 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 290 | void SetMask(LayerImpl* owning_layer, std::unique_ptr<LayerImpl> layer) { |
ajuma | 1d4026a3 | 2016-06-14 13:18:50 | [diff] [blame] | 291 | owning_layer->test_properties()->SetMaskLayer(std::move(layer)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 292 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 293 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 294 | bool opaque_layers_; |
enne | 2097cab | 2014-09-25 20:16:31 | [diff] [blame] | 295 | FakeLayerTreeHostClient client_; |
danakj | cf61058 | 2015-06-16 22:48:56 | [diff] [blame] | 296 | TestTaskGraphRunner task_graph_runner_; |
loyso | 2cb3f32f | 2016-11-08 07:08:34 | [diff] [blame] | 297 | std::unique_ptr<AnimationHost> animation_host_; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 298 | std::unique_ptr<FakeLayerTreeHost> host_; |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 299 | // These hold ownership of the layers for the duration of the test. |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 300 | LayerImplList render_surface_layer_list_impl_; |
enne | 389d1a1 | 2015-06-18 20:40:51 | [diff] [blame] | 301 | LayerIterator layer_iterator_begin_; |
| 302 | LayerIterator layer_iterator_; |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 303 | LayerList mask_layers_; |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 304 | int next_layer_impl_id_; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 305 | }; |
| 306 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 307 | #define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ |
| 308 | class ClassName##ImplThreadOpaqueLayers : public ClassName { \ |
| 309 | public: /* NOLINT(whitespace/indent) */ \ |
| 310 | ClassName##ImplThreadOpaqueLayers() : ClassName(true) {} \ |
| 311 | }; \ |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 312 | TEST_F(ClassName##ImplThreadOpaqueLayers, RunTest) { RunMyTest(); } |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 313 | #define RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName) \ |
| 314 | class ClassName##ImplThreadOpaquePaints : public ClassName { \ |
| 315 | public: /* NOLINT(whitespace/indent) */ \ |
| 316 | ClassName##ImplThreadOpaquePaints() : ClassName(false) {} \ |
| 317 | }; \ |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 318 | TEST_F(ClassName##ImplThreadOpaquePaints, RunTest) { RunMyTest(); } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 319 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 320 | #define ALL_OCCLUSIONTRACKER_TEST(ClassName) \ |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 321 | RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ |
| 322 | RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 323 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 324 | class OcclusionTrackerTestIdentityTransforms : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 325 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 326 | explicit OcclusionTrackerTestIdentityTransforms(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 327 | : OcclusionTrackerTest(opaque_layers) {} |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 328 | |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 329 | void RunMyTest() override { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 330 | TestContentLayerImpl* root = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 331 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 332 | TestContentLayerImpl* parent = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 333 | root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 334 | TestContentLayerImpl* layer = this->CreateDrawingLayer( |
| 335 | parent, this->identity_matrix, gfx::PointF(30.f, 30.f), |
| 336 | gfx::Size(500, 500), true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 337 | parent->SetMasksToBounds(true); |
| 338 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 339 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 340 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 341 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 342 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 343 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 344 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 345 | EXPECT_EQ(gfx::Rect().ToString(), |
| 346 | occlusion.occlusion_from_outside_target().ToString()); |
| 347 | EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
| 348 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 349 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 350 | }; |
| 351 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 352 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestIdentityTransforms); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 353 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 354 | class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 355 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 356 | explicit OcclusionTrackerTestRotatedChild(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 357 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 358 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 359 | gfx::Transform layer_transform; |
| 360 | layer_transform.Translate(250.0, 250.0); |
| 361 | layer_transform.Rotate(90.0); |
| 362 | layer_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 363 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 364 | TestContentLayerImpl* root = this->CreateRoot( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 365 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 366 | TestContentLayerImpl* parent = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 367 | root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 368 | TestContentLayerImpl* layer = this->CreateDrawingLayer( |
| 369 | parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500), |
| 370 | true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 371 | parent->SetMasksToBounds(true); |
| 372 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 373 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 374 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 375 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 376 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 377 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 378 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 379 | EXPECT_EQ(gfx::Rect().ToString(), |
| 380 | occlusion.occlusion_from_outside_target().ToString()); |
| 381 | EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
| 382 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 383 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 384 | }; |
| 385 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 386 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestRotatedChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 387 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 388 | class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 389 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 390 | explicit OcclusionTrackerTestTranslatedChild(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 391 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 392 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 393 | gfx::Transform layer_transform; |
| 394 | layer_transform.Translate(20.0, 20.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 395 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 396 | TestContentLayerImpl* root = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 397 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 398 | TestContentLayerImpl* parent = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 399 | root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 400 | TestContentLayerImpl* layer = this->CreateDrawingLayer( |
| 401 | parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500), |
| 402 | true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 403 | parent->SetMasksToBounds(true); |
| 404 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 405 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 406 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 407 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 408 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 409 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 410 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 411 | EXPECT_EQ(gfx::Rect().ToString(), |
| 412 | occlusion.occlusion_from_outside_target().ToString()); |
| 413 | EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), |
| 414 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 415 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 416 | }; |
| 417 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 418 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestTranslatedChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 419 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 420 | class OcclusionTrackerTestChildInRotatedChild : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 421 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 422 | explicit OcclusionTrackerTestChildInRotatedChild(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 423 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 424 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 425 | gfx::Transform child_transform; |
| 426 | child_transform.Translate(250.0, 250.0); |
| 427 | child_transform.Rotate(90.0); |
| 428 | child_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 429 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 430 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 431 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 432 | parent->SetMasksToBounds(true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 433 | LayerImpl* child = this->CreateSurface( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 434 | parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500)); |
| 435 | child->SetMasksToBounds(true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 436 | TestContentLayerImpl* layer = this->CreateDrawingLayer( |
| 437 | child, this->identity_matrix, gfx::PointF(10.f, 10.f), |
| 438 | gfx::Size(500, 500), true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 439 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 440 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 441 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 442 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 443 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 444 | this->EnterContributingSurface(child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 445 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 446 | EXPECT_EQ(gfx::Rect().ToString(), |
| 447 | occlusion.occlusion_from_outside_target().ToString()); |
| 448 | EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
| 449 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 450 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 451 | this->LeaveContributingSurface(child, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 452 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 453 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 454 | EXPECT_EQ(gfx::Rect().ToString(), |
| 455 | occlusion.occlusion_from_outside_target().ToString()); |
| 456 | EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), |
| 457 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 458 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 459 | /* Justification for the above occlusion from |layer|: |
| 460 | 100 |
| 461 | +---------------------+ |
| 462 | | | |
| 463 | | 30 | rotate(90) |
| 464 | | 30 + ---------------------------------+ |
| 465 | 100 | | 10 | | ==> |
| 466 | | |10+---------------------------------+ |
| 467 | | | | | | | |
| 468 | | | | | | | |
| 469 | | | | | | | |
| 470 | +----|--|-------------+ | | |
| 471 | | | | | |
| 472 | | | | | |
| 473 | | | | |500 |
| 474 | | | | | |
| 475 | | | | | |
| 476 | | | | | |
| 477 | | | | | |
| 478 | +--|-------------------------------+ | |
| 479 | | | |
| 480 | +---------------------------------+ |
| 481 | 500 |
| 482 | |
| 483 | +---------------------+ |
| 484 | | |30 Visible region of |layer|: ///// |
| 485 | | | |
| 486 | | +---------------------------------+ |
| 487 | 100| | |10 | |
| 488 | | +---------------------------------+ | |
| 489 | | | |///////////////| 420 | | |
| 490 | | | |///////////////|60 | | |
| 491 | | | |///////////////| | | |
| 492 | +--|--|---------------+ | | |
| 493 | 20|10| 70 | | |
| 494 | | | | | |
| 495 | | | | | |
| 496 | | | | | |
| 497 | | | | | |
| 498 | | | | | |
| 499 | | | |10| |
| 500 | | +------------------------------|--+ |
| 501 | | 490 | |
| 502 | +---------------------------------+ |
| 503 | 500 |
| 504 | |
| 505 | */ |
| 506 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 507 | }; |
| 508 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 509 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestChildInRotatedChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 510 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 511 | class OcclusionTrackerTestScaledRenderSurface : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 512 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 513 | explicit OcclusionTrackerTestScaledRenderSurface(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 514 | : OcclusionTrackerTest(opaque_layers) {} |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 515 | |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 516 | void RunMyTest() override { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 517 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 518 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 519 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 520 | gfx::Transform layer1_matrix; |
| 521 | layer1_matrix.Scale(2.0, 2.0); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 522 | TestContentLayerImpl* layer1 = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 523 | parent, layer1_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 524 | layer1->test_properties()->force_render_surface = true; |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 525 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 526 | gfx::Transform layer2_matrix; |
| 527 | layer2_matrix.Translate(25.0, 25.0); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 528 | TestContentLayerImpl* layer2 = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 529 | layer1, layer2_matrix, gfx::PointF(), gfx::Size(50, 50), true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 530 | TestContentLayerImpl* occluder = this->CreateDrawingLayer( |
| 531 | parent, this->identity_matrix, gfx::PointF(100.f, 100.f), |
| 532 | gfx::Size(500, 500), true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 533 | this->CalcDrawEtc(parent); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 534 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 535 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 536 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 537 | this->VisitLayer(occluder, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 538 | this->EnterLayer(layer2, &occlusion); |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 539 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 540 | EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), |
| 541 | occlusion.occlusion_from_outside_target().ToString()); |
| 542 | EXPECT_EQ(gfx::Rect().ToString(), |
| 543 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 544 | } |
[email protected] | 710ffc0 | 2012-10-30 21:42:02 | [diff] [blame] | 545 | }; |
| 546 | |
| 547 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledRenderSurface); |
| 548 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 549 | class OcclusionTrackerTestVisitTargetTwoTimes : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 550 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 551 | explicit OcclusionTrackerTestVisitTargetTwoTimes(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 552 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 553 | void RunMyTest() override { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 554 | TestContentLayerImpl* root = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 555 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 556 | LayerImpl* surface = this->CreateSurface( |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 557 | root, this->identity_matrix, gfx::PointF(30.f, 30.f), gfx::Size()); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 558 | TestContentLayerImpl* surface_child = this->CreateDrawingLayer( |
| 559 | surface, this->identity_matrix, gfx::PointF(10.f, 10.f), |
| 560 | gfx::Size(50, 50), true); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 561 | // |top_layer| makes |root|'s surface get considered by OcclusionTracker |
| 562 | // first, instead of |surface|'s. This exercises different code in |
| 563 | // LeaveToRenderTarget, as the target surface has already been seen when |
| 564 | // leaving |surface| later. |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 565 | TestContentLayerImpl* top_layer = this->CreateDrawingLayer( |
| 566 | root, this->identity_matrix, gfx::PointF(40.f, 90.f), gfx::Size(50, 20), |
| 567 | true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 568 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 569 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 570 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 571 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 572 | this->VisitLayer(top_layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 573 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 574 | EXPECT_EQ(gfx::Rect().ToString(), |
| 575 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 576 | EXPECT_EQ(gfx::Rect(40, 90, 50, 20).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 577 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 578 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 579 | this->VisitLayer(surface_child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 580 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 581 | EXPECT_EQ(gfx::Rect(10, 60, 50, 20).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 582 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 583 | EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 584 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 585 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 586 | this->EnterContributingSurface(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 587 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 588 | EXPECT_EQ(gfx::Rect(10, 60, 50, 20).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 589 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 590 | EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 591 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 592 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 593 | // Occlusion from |top_layer| already in the root target should get merged |
| 594 | // with the occlusion from the |surface| we are leaving now. |
| 595 | this->LeaveContributingSurface(surface, &occlusion); |
| 596 | this->EnterLayer(root, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 597 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 598 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 599 | EXPECT_EQ(gfx::Rect(40, 40, 50, 70).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 600 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 601 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 602 | }; |
| 603 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 604 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestVisitTargetTwoTimes); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 605 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 606 | class OcclusionTrackerTestSurfaceRotatedOffAxis : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 607 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 608 | explicit OcclusionTrackerTestSurfaceRotatedOffAxis(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 609 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 610 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 611 | gfx::Transform child_transform; |
| 612 | child_transform.Translate(250.0, 250.0); |
| 613 | child_transform.Rotate(95.0); |
| 614 | child_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 615 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 616 | gfx::Transform layer_transform; |
| 617 | layer_transform.Translate(10.0, 10.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 618 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 619 | TestContentLayerImpl* root = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 620 | this->identity_matrix, gfx::PointF(), gfx::Size(1000, 1000)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 621 | TestContentLayerImpl* parent = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 622 | root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 623 | LayerImpl* child = this->CreateSurface( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 624 | parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 625 | TestContentLayerImpl* layer = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 626 | child, layer_transform, gfx::PointF(), gfx::Size(500, 500), true); |
| 627 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 628 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 629 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 630 | |
[email protected] | 8a82269 | 2014-02-12 17:30:55 | [diff] [blame] | 631 | gfx::Rect clipped_layer_in_child = MathUtil::MapEnclosingClippedRect( |
danakj | 64767d90 | 2015-06-19 00:10:43 | [diff] [blame] | 632 | layer_transform, layer->visible_layer_rect()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 633 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 634 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 635 | this->EnterContributingSurface(child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 636 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 637 | EXPECT_EQ(gfx::Rect().ToString(), |
| 638 | occlusion.occlusion_from_outside_target().ToString()); |
| 639 | EXPECT_EQ(clipped_layer_in_child.ToString(), |
| 640 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 641 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 642 | this->LeaveContributingSurface(child, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 643 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 644 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 645 | EXPECT_EQ(gfx::Rect().ToString(), |
| 646 | occlusion.occlusion_from_outside_target().ToString()); |
| 647 | EXPECT_EQ(gfx::Rect().ToString(), |
| 648 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 649 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 650 | }; |
| 651 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 652 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceRotatedOffAxis); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 653 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 654 | class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 655 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 656 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 657 | explicit OcclusionTrackerTestSurfaceWithTwoOpaqueChildren(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 658 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 659 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 660 | gfx::Transform child_transform; |
| 661 | child_transform.Translate(250.0, 250.0); |
| 662 | child_transform.Rotate(90.0); |
| 663 | child_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 664 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 665 | TestContentLayerImpl* root = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 666 | this->identity_matrix, gfx::PointF(), gfx::Size(1000, 1000)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 667 | TestContentLayerImpl* parent = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 668 | root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
| 669 | parent->SetMasksToBounds(true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 670 | TestContentLayerImpl* child = this->CreateDrawingSurface( |
| 671 | parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500), |
| 672 | false); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 673 | child->SetMasksToBounds(true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 674 | TestContentLayerImpl* layer1 = this->CreateDrawingLayer( |
| 675 | child, this->identity_matrix, gfx::PointF(10.f, 10.f), |
| 676 | gfx::Size(500, 500), true); |
| 677 | TestContentLayerImpl* layer2 = this->CreateDrawingLayer( |
| 678 | child, this->identity_matrix, gfx::PointF(10.f, 450.f), |
| 679 | gfx::Size(500, 60), true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 680 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 681 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 682 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 683 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 684 | this->VisitLayer(layer2, &occlusion); |
| 685 | this->VisitLayer(layer1, &occlusion); |
| 686 | this->VisitLayer(child, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 687 | this->EnterContributingSurface(child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 688 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 689 | EXPECT_EQ(gfx::Rect().ToString(), |
| 690 | occlusion.occlusion_from_outside_target().ToString()); |
| 691 | EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
| 692 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 693 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 694 | this->LeaveContributingSurface(child, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 695 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 696 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 697 | EXPECT_EQ(gfx::Rect().ToString(), |
| 698 | occlusion.occlusion_from_outside_target().ToString()); |
| 699 | EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), |
| 700 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 701 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 702 | /* Justification for the above occlusion from |layer1| and |layer2|: |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 703 | |
| 704 | +---------------------+ |
| 705 | | |30 Visible region of |layer1|: ///// |
| 706 | | | Visible region of |layer2|: \\\\\ |
| 707 | | +---------------------------------+ |
| 708 | | | |10 | |
| 709 | | +---------------+-----------------+ | |
| 710 | | | |\\\\\\\\\\\\|//| 420 | | |
| 711 | | | |\\\\\\\\\\\\|//|60 | | |
| 712 | | | |\\\\\\\\\\\\|//| | | |
| 713 | +--|--|------------|--+ | | |
| 714 | 20|10| 70 | | | |
| 715 | | | | | | |
| 716 | | | | | | |
| 717 | | | | | | |
| 718 | | | | | | |
| 719 | | | | | | |
| 720 | | | | |10| |
| 721 | | +------------|-----------------|--+ |
| 722 | | | 490 | |
| 723 | +---------------+-----------------+ |
| 724 | 60 440 |
| 725 | */ |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 726 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 727 | }; |
| 728 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 729 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithTwoOpaqueChildren); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 730 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 731 | class OcclusionTrackerTestOverlappingSurfaceSiblings |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 732 | : public OcclusionTrackerTest { |
[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 OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 735 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 736 | void RunMyTest() override { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 737 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 738 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 739 | parent->SetMasksToBounds(true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 740 | LayerImpl* child1 = this->CreateSurface( |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 741 | parent, this->identity_matrix, gfx::PointF(10.f, 0.f), gfx::Size()); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 742 | LayerImpl* child2 = this->CreateSurface( |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 743 | parent, this->identity_matrix, gfx::PointF(30.f, 0.f), gfx::Size()); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 744 | TestContentLayerImpl* layer1 = this->CreateDrawingLayer( |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 745 | child1, this->identity_matrix, gfx::PointF(), gfx::Size(40, 50), true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 746 | TestContentLayerImpl* layer2 = this->CreateDrawingLayer( |
| 747 | child2, this->identity_matrix, gfx::PointF(10.f, 0.f), |
| 748 | gfx::Size(40, 50), true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 749 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 750 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 751 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 752 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 753 | this->VisitLayer(layer2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 754 | this->EnterContributingSurface(child2, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 755 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 756 | // layer2's occlusion. |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 757 | EXPECT_EQ(gfx::Rect().ToString(), |
| 758 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 759 | EXPECT_EQ(gfx::Rect(10, 0, 40, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 760 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 761 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 762 | this->LeaveContributingSurface(child2, &occlusion); |
| 763 | this->VisitLayer(layer1, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 764 | this->EnterContributingSurface(child1, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 765 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 766 | // layer2's occlusion in the target space of layer1. |
| 767 | EXPECT_EQ(gfx::Rect(30, 0, 40, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 768 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 769 | // layer1's occlusion. |
| 770 | EXPECT_EQ(gfx::Rect(0, 0, 40, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 771 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 772 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 773 | this->LeaveContributingSurface(child1, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 774 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 775 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 776 | // The occlusion from from layer1 and layer2 is merged. |
| 777 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 778 | EXPECT_EQ(gfx::Rect(10, 0, 70, 50).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 779 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 780 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 781 | }; |
| 782 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 783 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOverlappingSurfaceSiblings); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 784 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 785 | class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 786 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 787 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 788 | explicit OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 789 | bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 790 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 791 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 792 | gfx::Transform child1_transform; |
| 793 | child1_transform.Translate(250.0, 250.0); |
| 794 | child1_transform.Rotate(-90.0); |
| 795 | child1_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 796 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 797 | gfx::Transform child2_transform; |
| 798 | child2_transform.Translate(250.0, 250.0); |
| 799 | child2_transform.Rotate(90.0); |
| 800 | child2_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 801 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 802 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 803 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 804 | parent->SetMasksToBounds(true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 805 | LayerImpl* child1 = this->CreateSurface( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 806 | parent, child1_transform, gfx::PointF(30.f, 20.f), gfx::Size(10, 10)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 807 | LayerImpl* child2 = this->CreateDrawingSurface(parent, child2_transform, |
| 808 | gfx::PointF(20.f, 40.f), |
| 809 | gfx::Size(10, 10), false); |
| 810 | TestContentLayerImpl* layer1 = this->CreateDrawingLayer( |
| 811 | child1, this->identity_matrix, gfx::PointF(-10.f, -20.f), |
| 812 | gfx::Size(510, 510), true); |
| 813 | TestContentLayerImpl* layer2 = this->CreateDrawingLayer( |
| 814 | child2, this->identity_matrix, gfx::PointF(-10.f, -10.f), |
| 815 | gfx::Size(510, 510), true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 816 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 817 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 818 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 819 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 820 | this->VisitLayer(layer2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 821 | this->EnterLayer(child2, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 822 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 823 | EXPECT_EQ(gfx::Rect().ToString(), |
| 824 | occlusion.occlusion_from_outside_target().ToString()); |
| 825 | EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), |
| 826 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 827 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 828 | this->LeaveLayer(child2, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 829 | this->EnterContributingSurface(child2, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 830 | |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 831 | EXPECT_EQ(gfx::Rect().ToString(), |
| 832 | occlusion.occlusion_from_outside_target().ToString()); |
| 833 | EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), |
| 834 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 835 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 836 | this->LeaveContributingSurface(child2, &occlusion); |
| 837 | this->VisitLayer(layer1, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 838 | this->EnterContributingSurface(child1, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 839 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 840 | EXPECT_EQ(gfx::Rect(420, -10, 70, 80).ToString(), |
| 841 | occlusion.occlusion_from_outside_target().ToString()); |
| 842 | EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(), |
| 843 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 844 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 845 | this->LeaveContributingSurface(child1, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 846 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 847 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 848 | EXPECT_EQ(gfx::Rect().ToString(), |
| 849 | occlusion.occlusion_from_outside_target().ToString()); |
| 850 | EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), |
| 851 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 852 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 853 | /* Justification for the above occlusion: |
| 854 | 100 |
| 855 | +---------------------+ |
| 856 | |20 | layer1 |
| 857 | 10+----------------------------------+ |
| 858 | 100 || 30 | layer2 | |
| 859 | |20+----------------------------------+ |
| 860 | || | | | | |
| 861 | || | | | | |
| 862 | || | | | | |
| 863 | +|-|------------------+ | | |
| 864 | | | | | 510 |
| 865 | | | 510 | | |
| 866 | | | | | |
| 867 | | | | | |
| 868 | | | | | |
| 869 | | | | | |
| 870 | | | 520 | | |
| 871 | +----------------------------------+ | |
| 872 | | | |
| 873 | +----------------------------------+ |
| 874 | 510 |
| 875 | */ |
| 876 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 877 | }; |
| 878 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 879 | ALL_OCCLUSIONTRACKER_TEST( |
| 880 | OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 881 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 882 | class OcclusionTrackerTestFilters : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 883 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 884 | explicit OcclusionTrackerTestFilters(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 885 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 886 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 887 | gfx::Transform layer_transform; |
| 888 | layer_transform.Translate(250.0, 250.0); |
| 889 | layer_transform.Rotate(90.0); |
| 890 | layer_transform.Translate(-250.0, -250.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 891 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 892 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 893 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 894 | parent->SetMasksToBounds(true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 895 | TestContentLayerImpl* blur_layer = this->CreateDrawingLayer( |
| 896 | parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500), |
| 897 | true); |
| 898 | TestContentLayerImpl* opaque_layer = this->CreateDrawingLayer( |
| 899 | parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500), |
| 900 | true); |
| 901 | TestContentLayerImpl* opacity_layer = this->CreateDrawingLayer( |
| 902 | parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500), |
| 903 | true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 904 | |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 905 | blur_layer->test_properties()->force_render_surface = true; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 906 | FilterOperations filters; |
| 907 | filters.Append(FilterOperation::CreateBlurFilter(10.f)); |
ajuma | cb2b7443 | 2016-07-21 19:11:15 | [diff] [blame] | 908 | blur_layer->test_properties()->filters = filters; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 909 | |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 910 | opaque_layer->test_properties()->force_render_surface = true; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 911 | filters.Clear(); |
| 912 | filters.Append(FilterOperation::CreateGrayscaleFilter(0.5f)); |
ajuma | cb2b7443 | 2016-07-21 19:11:15 | [diff] [blame] | 913 | opaque_layer->test_properties()->filters = filters; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 914 | |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 915 | opacity_layer->test_properties()->force_render_surface = true; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 916 | filters.Clear(); |
| 917 | filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); |
ajuma | cb2b7443 | 2016-07-21 19:11:15 | [diff] [blame] | 918 | opacity_layer->test_properties()->filters = filters; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 919 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 920 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 921 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 922 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 923 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 924 | // Opacity layer won't contribute to occlusion. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 925 | this->VisitLayer(opacity_layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 926 | this->EnterContributingSurface(opacity_layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 927 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 928 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 929 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 930 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 931 | // And has nothing to contribute to its parent surface. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 932 | this->LeaveContributingSurface(opacity_layer, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 933 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 934 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 935 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 936 | // Opaque layer will contribute to occlusion. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 937 | this->VisitLayer(opaque_layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 938 | this->EnterContributingSurface(opaque_layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 939 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 940 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 941 | EXPECT_EQ(gfx::Rect(0, 430, 70, 70).ToString(), |
| 942 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 943 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 944 | // And it gets translated to the parent surface. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 945 | this->LeaveContributingSurface(opaque_layer, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 946 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 947 | EXPECT_EQ(gfx::Rect(30, 30, 70, 70).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 | // The blur layer needs to throw away any occlusion from outside its |
| 951 | // subtree. |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 952 | this->EnterLayer(blur_layer, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 953 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 954 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 955 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 956 | // And it won't contribute to occlusion. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 957 | this->LeaveLayer(blur_layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 958 | this->EnterContributingSurface(blur_layer, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 959 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 960 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 961 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 962 | // But the opaque layer's occlusion is preserved on the parent. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 963 | this->LeaveContributingSurface(blur_layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 964 | this->EnterLayer(parent, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 965 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 966 | EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
| 967 | occlusion.occlusion_from_inside_target().ToString()); |
| 968 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 969 | }; |
| 970 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 971 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFilters); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 972 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 973 | class OcclusionTrackerTestOpaqueContentsRegionEmpty |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 974 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 975 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 976 | explicit OcclusionTrackerTestOpaqueContentsRegionEmpty(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 977 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 978 | void RunMyTest() override { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 979 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 980 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 981 | TestContentLayerImpl* layer = |
| 982 | this->CreateDrawingSurface(parent, this->identity_matrix, gfx::PointF(), |
| 983 | gfx::Size(200, 200), false); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 984 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 985 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 986 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 987 | this->EnterLayer(layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 988 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 989 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 990 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 991 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 992 | this->LeaveLayer(layer, &occlusion); |
| 993 | this->VisitContributingSurface(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 994 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 995 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 996 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 997 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 998 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 999 | }; |
| 1000 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1001 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1002 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1003 | class OcclusionTrackerTestOpaqueContentsRegionNonEmpty |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1004 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1005 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1006 | explicit OcclusionTrackerTestOpaqueContentsRegionNonEmpty(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1007 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1008 | void RunMyTest() override { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1009 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1010 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1011 | TestContentLayerImpl* layer = this->CreateDrawingLayer( |
| 1012 | parent, this->identity_matrix, gfx::PointF(100.f, 100.f), |
| 1013 | gfx::Size(200, 200), false); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1014 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1015 | { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1016 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1017 | layer->SetOpaqueContentsRect(gfx::Rect(0, 0, 100, 100)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1018 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1019 | this->ResetLayerIterator(); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1020 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1021 | this->EnterLayer(parent, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1022 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1023 | EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), |
| 1024 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1025 | } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1026 | { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1027 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1028 | layer->SetOpaqueContentsRect(gfx::Rect(20, 20, 180, 180)); |
| 1029 | |
| 1030 | this->ResetLayerIterator(); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1031 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1032 | this->EnterLayer(parent, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1033 | |
| 1034 | EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(), |
| 1035 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1036 | } |
| 1037 | { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1038 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1039 | layer->SetOpaqueContentsRect(gfx::Rect(150, 150, 100, 100)); |
| 1040 | |
| 1041 | this->ResetLayerIterator(); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1042 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1043 | this->EnterLayer(parent, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1044 | |
| 1045 | EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(), |
| 1046 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1047 | } |
| 1048 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1049 | }; |
| 1050 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1051 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOpaqueContentsRegionNonEmpty); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1052 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1053 | class OcclusionTrackerTestLayerBehindCameraDoesNotOcclude |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1054 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1055 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1056 | explicit OcclusionTrackerTestLayerBehindCameraDoesNotOcclude( |
| 1057 | bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1058 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1059 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1060 | gfx::Transform transform; |
| 1061 | transform.Translate(50.0, 50.0); |
| 1062 | transform.ApplyPerspectiveDepth(100.0); |
| 1063 | transform.Translate3d(0.0, 0.0, 110.0); |
| 1064 | transform.Translate(-50.0, -50.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1065 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1066 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1067 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1068 | TestContentLayerImpl* layer = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1069 | parent, transform, gfx::PointF(), gfx::Size(100, 100), true); |
jaydasika | ca2605e | 2016-04-23 02:52:52 | [diff] [blame] | 1070 | parent->test_properties()->should_flatten_transform = false; |
wkorman | f09921d | 2017-01-07 01:01:20 | [diff] [blame^] | 1071 | parent->test_properties()->sorting_context_id = 1; |
jaydasika | ca2605e | 2016-04-23 02:52:52 | [diff] [blame] | 1072 | layer->test_properties()->should_flatten_transform = false; |
wkorman | f09921d | 2017-01-07 01:01:20 | [diff] [blame^] | 1073 | layer->test_properties()->sorting_context_id = 1; |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1074 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1075 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1076 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1077 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1078 | // The |layer| is entirely behind the camera and should not occlude. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1079 | this->VisitLayer(layer, &occlusion); |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1080 | this->EnterLayer(parent, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1081 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| 1082 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1083 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1084 | }; |
| 1085 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1086 | class OcclusionTrackerTestSurfaceOcclusionTranslatesToParent |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1087 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1088 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1089 | explicit OcclusionTrackerTestSurfaceOcclusionTranslatesToParent( |
| 1090 | bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1091 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1092 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1093 | gfx::Transform surface_transform; |
| 1094 | surface_transform.Translate(300.0, 300.0); |
| 1095 | surface_transform.Scale(2.0, 2.0); |
| 1096 | surface_transform.Translate(-150.0, -150.0); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1097 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1098 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1099 | this->identity_matrix, gfx::PointF(), gfx::Size(500, 500)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1100 | TestContentLayerImpl* surface = this->CreateDrawingSurface( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1101 | parent, surface_transform, gfx::PointF(), gfx::Size(300, 300), false); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1102 | TestContentLayerImpl* surface2 = this->CreateDrawingSurface( |
| 1103 | parent, this->identity_matrix, gfx::PointF(50.f, 50.f), |
| 1104 | gfx::Size(300, 300), false); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1105 | surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200)); |
| 1106 | surface2->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200)); |
| 1107 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1108 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1109 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1110 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1111 | this->VisitLayer(surface2, &occlusion); |
| 1112 | this->VisitContributingSurface(surface2, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1113 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1114 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1115 | occlusion.occlusion_from_outside_target().ToString()); |
| 1116 | EXPECT_EQ(gfx::Rect(50, 50, 200, 200).ToString(), |
| 1117 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1118 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1119 | // Clear any stored occlusion. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1120 | occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| 1121 | occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1122 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1123 | this->VisitLayer(surface, &occlusion); |
| 1124 | this->VisitContributingSurface(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1125 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1126 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1127 | occlusion.occlusion_from_outside_target().ToString()); |
| 1128 | EXPECT_EQ(gfx::Rect(0, 0, 400, 400).ToString(), |
| 1129 | occlusion.occlusion_from_inside_target().ToString()); |
| 1130 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1131 | }; |
| 1132 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1133 | ALL_OCCLUSIONTRACKER_TEST( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1134 | OcclusionTrackerTestSurfaceOcclusionTranslatesToParent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1135 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1136 | class OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1137 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1138 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1139 | explicit OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping( |
| 1140 | bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1141 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1142 | void RunMyTest() override { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1143 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1144 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1145 | parent->SetMasksToBounds(true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1146 | TestContentLayerImpl* surface = |
| 1147 | this->CreateDrawingSurface(parent, this->identity_matrix, gfx::PointF(), |
| 1148 | gfx::Size(500, 300), false); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1149 | surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 400, 200)); |
| 1150 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1151 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1152 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1153 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1154 | this->VisitLayer(surface, &occlusion); |
| 1155 | this->VisitContributingSurface(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1156 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1157 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1158 | occlusion.occlusion_from_outside_target().ToString()); |
| 1159 | EXPECT_EQ(gfx::Rect(0, 0, 300, 200).ToString(), |
| 1160 | occlusion.occlusion_from_inside_target().ToString()); |
| 1161 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1162 | }; |
| 1163 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1164 | ALL_OCCLUSIONTRACKER_TEST( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1165 | OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1166 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1167 | class OcclusionTrackerTestSurfaceChildOfSurface : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1168 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1169 | explicit OcclusionTrackerTestSurfaceChildOfSurface(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1170 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1171 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1172 | // This test verifies that the surface cliprect does not end up empty and |
| 1173 | // clip away the entire unoccluded rect. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1174 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1175 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1176 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 200)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1177 | LayerImpl* surface = |
| 1178 | this->CreateDrawingSurface(parent, this->identity_matrix, gfx::PointF(), |
| 1179 | gfx::Size(100, 100), false); |
| 1180 | LayerImpl* surface_child = this->CreateDrawingSurface( |
| 1181 | surface, this->identity_matrix, gfx::PointF(0.f, 10.f), |
| 1182 | gfx::Size(100, 50), true); |
| 1183 | LayerImpl* topmost = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1184 | parent, this->identity_matrix, gfx::PointF(), gfx::Size(100, 50), true); |
| 1185 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1186 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1187 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(-100, -100, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1188 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1189 | // |topmost| occludes everything partially so we know occlusion is happening |
| 1190 | // at all. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1191 | this->VisitLayer(topmost, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1192 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1193 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1194 | occlusion.occlusion_from_outside_target().ToString()); |
| 1195 | EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
| 1196 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1197 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1198 | this->VisitLayer(surface_child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1199 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1200 | // surface_child increases the occlusion in the screen by a narrow sliver. |
| 1201 | EXPECT_EQ(gfx::Rect(0, -10, 100, 50).ToString(), |
| 1202 | occlusion.occlusion_from_outside_target().ToString()); |
| 1203 | // In its own surface, surface_child is at 0,0 as is its occlusion. |
| 1204 | EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
| 1205 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1206 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1207 | // The root layer always has a clip rect. So the parent of |surface| has a |
| 1208 | // clip rect. However, the owning layer for |surface| does not mask to |
| 1209 | // bounds, so it doesn't have a clip rect of its own. Thus the parent of |
| 1210 | // |surface_child| exercises different code paths as its parent does not |
| 1211 | // have a clip rect. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1212 | |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1213 | this->EnterContributingSurface(surface_child, &occlusion); |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 1214 | // The |surface_child| can't occlude its own surface, but occlusion from |
| 1215 | // |topmost| can. |
| 1216 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1217 | occlusion.occlusion_on_contributing_surface_from_outside_target() |
| 1218 | .ToString()); |
| 1219 | EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
| 1220 | occlusion.occlusion_on_contributing_surface_from_inside_target() |
| 1221 | .ToString()); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1222 | this->LeaveContributingSurface(surface_child, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1223 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1224 | // When the surface_child's occlusion is transformed up to its parent, make |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 1225 | // sure it is not clipped away inappropriately. |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1226 | this->EnterLayer(surface, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1227 | EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
| 1228 | occlusion.occlusion_from_outside_target().ToString()); |
| 1229 | EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(), |
| 1230 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1231 | this->LeaveLayer(surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1232 | |
[email protected] | e47b0a0a | 2013-11-18 23:26:22 | [diff] [blame] | 1233 | this->EnterContributingSurface(surface, &occlusion); |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 1234 | // The occlusion from inside |surface| can't affect the surface, but |
| 1235 | // |topmost| can. |
| 1236 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1237 | occlusion.occlusion_on_contributing_surface_from_outside_target() |
| 1238 | .ToString()); |
| 1239 | EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
| 1240 | occlusion.occlusion_on_contributing_surface_from_inside_target() |
| 1241 | .ToString()); |
| 1242 | |
| 1243 | this->LeaveContributingSurface(surface, &occlusion); |
| 1244 | this->EnterLayer(parent, &occlusion); |
| 1245 | // The occlusion in |surface| and without are merged into the parent. |
| 1246 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1247 | occlusion.occlusion_from_outside_target().ToString()); |
| 1248 | EXPECT_EQ(gfx::Rect(0, 0, 100, 60).ToString(), |
| 1249 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1250 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1251 | }; |
| 1252 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1253 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1254 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1255 | class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1256 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1257 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1258 | explicit OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1259 | bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1260 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1261 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1262 | gfx::Transform scale_by_half; |
| 1263 | scale_by_half.Scale(0.5, 0.5); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1264 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 1265 | FilterOperations filters; |
| 1266 | filters.Append(FilterOperation::CreateBlurFilter(10.f)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1267 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1268 | enum Direction { |
| 1269 | LEFT, |
| 1270 | RIGHT, |
| 1271 | TOP, |
| 1272 | BOTTOM, |
| 1273 | LAST_DIRECTION = BOTTOM, |
| 1274 | }; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1275 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1276 | for (int i = 0; i <= LAST_DIRECTION; ++i) { |
| 1277 | SCOPED_TRACE(i); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1278 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1279 | // Make a 50x50 filtered surface that is adjacent to occluding layers |
| 1280 | // which are above it in the z-order in various configurations. The |
| 1281 | // surface is scaled to test that the pixel moving is done in the target |
| 1282 | // space, where the background filter is applied. |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1283 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1284 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1285 | LayerImpl* filtered_surface = this->CreateDrawingLayer( |
| 1286 | parent, scale_by_half, gfx::PointF(50.f, 50.f), gfx::Size(100, 100), |
| 1287 | false); |
ajuma | 50bce7e | 2016-06-24 20:56:04 | [diff] [blame] | 1288 | filtered_surface->test_properties()->background_filters = filters; |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1289 | gfx::Rect occlusion_rect; |
| 1290 | switch (i) { |
| 1291 | case LEFT: |
| 1292 | occlusion_rect = gfx::Rect(0, 0, 50, 200); |
| 1293 | break; |
| 1294 | case RIGHT: |
jbroman | 19a18b1 | 2016-07-07 02:37:38 | [diff] [blame] | 1295 | // This is the right edge; filtered_surface is scaled by half. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1296 | occlusion_rect = gfx::Rect(100, 0, 50, 200); |
| 1297 | break; |
| 1298 | case TOP: |
| 1299 | occlusion_rect = gfx::Rect(0, 0, 200, 50); |
| 1300 | break; |
| 1301 | case BOTTOM: |
jbroman | 19a18b1 | 2016-07-07 02:37:38 | [diff] [blame] | 1302 | // This is the bottom edge; filtered_surface is scaled by half. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1303 | occlusion_rect = gfx::Rect(0, 100, 200, 50); |
| 1304 | break; |
| 1305 | } |
[email protected] | ac7c7f5 | 2012-11-08 06:26:50 | [diff] [blame] | 1306 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1307 | LayerImpl* occluding_layer = this->CreateDrawingLayer( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 1308 | parent, this->identity_matrix, gfx::PointF(occlusion_rect.origin()), |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1309 | occlusion_rect.size(), true); |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 1310 | occluding_layer->test_properties()->force_render_surface = false; |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1311 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1312 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1313 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1314 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1315 | // This layer occludes pixels directly beside the filtered_surface. |
| 1316 | // Because filtered surface blends pixels in a radius, it will need to see |
| 1317 | // some of the pixels (up to radius far) underneath the occluding layers. |
| 1318 | this->VisitLayer(occluding_layer, &occlusion); |
[email protected] | ccb1c9a | 2012-12-17 03:53:19 | [diff] [blame] | 1319 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1320 | EXPECT_EQ(occlusion_rect.ToString(), |
| 1321 | occlusion.occlusion_from_inside_target().ToString()); |
| 1322 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1323 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1324 | this->VisitLayer(filtered_surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1325 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1326 | // The occlusion is used fully inside the surface. |
| 1327 | gfx::Rect occlusion_inside_surface = |
| 1328 | occlusion_rect - gfx::Vector2d(50, 50); |
| 1329 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| 1330 | EXPECT_EQ(occlusion_inside_surface.ToString(), |
| 1331 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | ac7c7f5 | 2012-11-08 06:26:50 | [diff] [blame] | 1332 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1333 | // The surface has a background blur, so it needs pixels that are |
jbroman | 19a18b1 | 2016-07-07 02:37:38 | [diff] [blame] | 1334 | // currently considered occluded in order to be drawn. The pixels it |
| 1335 | // needs should be removed from the occluded area, so that they are drawn |
| 1336 | // when we get to the parent. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1337 | this->VisitContributingSurface(filtered_surface, &occlusion); |
| 1338 | this->EnterLayer(parent, &occlusion); |
[email protected] | ac7c7f5 | 2012-11-08 06:26:50 | [diff] [blame] | 1339 | |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 1340 | // The spread due to a 10px blur is 30px. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1341 | gfx::Rect expected_occlusion = occlusion_rect; |
| 1342 | switch (i) { |
| 1343 | case LEFT: |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 1344 | expected_occlusion.Inset(0, 0, 30, 0); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1345 | break; |
| 1346 | case RIGHT: |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 1347 | expected_occlusion.Inset(30, 0, 0, 0); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1348 | break; |
| 1349 | case TOP: |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 1350 | expected_occlusion.Inset(0, 0, 0, 30); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1351 | break; |
| 1352 | case BOTTOM: |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 1353 | expected_occlusion.Inset(0, 30, 0, 0); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1354 | break; |
| 1355 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1356 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1357 | EXPECT_EQ(expected_occlusion.ToString(), |
| 1358 | occlusion.occlusion_from_inside_target().ToString()); |
| 1359 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1360 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1361 | this->DestroyLayers(); |
| 1362 | } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1363 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1364 | }; |
| 1365 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1366 | ALL_OCCLUSIONTRACKER_TEST( |
| 1367 | OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1368 | |
ajuma | 97755536 | 2016-07-19 16:12:12 | [diff] [blame] | 1369 | class OcclusionTrackerTestPixelsNeededForDropShadowBackgroundFilter |
jbroman | 19a18b1 | 2016-07-07 02:37:38 | [diff] [blame] | 1370 | : public OcclusionTrackerTest { |
| 1371 | protected: |
ajuma | 97755536 | 2016-07-19 16:12:12 | [diff] [blame] | 1372 | explicit OcclusionTrackerTestPixelsNeededForDropShadowBackgroundFilter( |
jbroman | 19a18b1 | 2016-07-07 02:37:38 | [diff] [blame] | 1373 | bool opaque_layers) |
| 1374 | : OcclusionTrackerTest(opaque_layers) {} |
| 1375 | void RunMyTest() override { |
| 1376 | gfx::Transform scale_by_half; |
| 1377 | scale_by_half.Scale(0.5, 0.5); |
| 1378 | |
| 1379 | FilterOperations filters; |
| 1380 | filters.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(10, 10), |
| 1381 | 5, SK_ColorBLACK)); |
| 1382 | |
| 1383 | enum Direction { |
| 1384 | LEFT, |
| 1385 | RIGHT, |
| 1386 | TOP, |
| 1387 | BOTTOM, |
| 1388 | LAST_DIRECTION = BOTTOM, |
| 1389 | }; |
| 1390 | |
| 1391 | for (int i = 0; i <= LAST_DIRECTION; ++i) { |
| 1392 | SCOPED_TRACE(i); |
| 1393 | |
| 1394 | // Make a 50x50 filtered surface that is adjacent to occluding layers |
| 1395 | // which are above it in the z-order in various configurations. The |
| 1396 | // surface is scaled to test that the pixel moving is done in the target |
| 1397 | // space, where the background filter is applied. |
| 1398 | TestContentLayerImpl* parent = this->CreateRoot( |
| 1399 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| 1400 | LayerImpl* filtered_surface = this->CreateDrawingLayer( |
| 1401 | parent, scale_by_half, gfx::PointF(50.f, 50.f), gfx::Size(100, 100), |
| 1402 | false); |
| 1403 | filtered_surface->test_properties()->background_filters = filters; |
| 1404 | gfx::Rect occlusion_rect; |
| 1405 | switch (i) { |
| 1406 | case LEFT: |
| 1407 | occlusion_rect = gfx::Rect(0, 0, 50, 200); |
| 1408 | break; |
| 1409 | case RIGHT: |
| 1410 | // This is the right edge; filtered_surface is scaled by half. |
| 1411 | occlusion_rect = gfx::Rect(100, 0, 50, 200); |
| 1412 | break; |
| 1413 | case TOP: |
| 1414 | occlusion_rect = gfx::Rect(0, 0, 200, 50); |
| 1415 | break; |
| 1416 | case BOTTOM: |
| 1417 | // This is the bottom edge; filtered_surface is scaled by half. |
| 1418 | occlusion_rect = gfx::Rect(0, 100, 200, 50); |
| 1419 | break; |
| 1420 | } |
| 1421 | |
| 1422 | LayerImpl* occluding_layer = this->CreateDrawingLayer( |
| 1423 | parent, this->identity_matrix, gfx::PointF(occlusion_rect.origin()), |
| 1424 | occlusion_rect.size(), true); |
| 1425 | occluding_layer->test_properties()->force_render_surface = false; |
| 1426 | this->CalcDrawEtc(parent); |
| 1427 | |
| 1428 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200)); |
| 1429 | |
| 1430 | // This layer occludes pixels directly beside the filtered_surface. |
| 1431 | // Because filtered surface blends pixels in a radius, it will need to see |
| 1432 | // some of the pixels (up to radius far) underneath the occluding layers. |
| 1433 | this->VisitLayer(occluding_layer, &occlusion); |
| 1434 | |
| 1435 | EXPECT_EQ(occlusion_rect.ToString(), |
| 1436 | occlusion.occlusion_from_inside_target().ToString()); |
| 1437 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1438 | |
| 1439 | this->VisitLayer(filtered_surface, &occlusion); |
| 1440 | |
| 1441 | // The occlusion is used fully inside the surface. |
| 1442 | gfx::Rect occlusion_inside_surface = |
| 1443 | occlusion_rect - gfx::Vector2d(50, 50); |
| 1444 | EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| 1445 | EXPECT_EQ(occlusion_inside_surface.ToString(), |
| 1446 | occlusion.occlusion_from_outside_target().ToString()); |
| 1447 | |
| 1448 | // The surface has a background filter, so it needs pixels that are |
| 1449 | // currently considered occluded in order to be drawn. The pixels it |
| 1450 | // needs should be removed from the occluded area, so that they are drawn |
| 1451 | // when we get to the parent. |
| 1452 | this->VisitContributingSurface(filtered_surface, &occlusion); |
| 1453 | this->EnterLayer(parent, &occlusion); |
| 1454 | |
| 1455 | gfx::Rect expected_occlusion; |
| 1456 | switch (i) { |
| 1457 | case LEFT: |
| 1458 | // The right half of the occlusion is close enough to cast a shadow |
| 1459 | // that would be visible in the background filter. The shadow reaches |
| 1460 | // 3*5 + 10 = 25 pixels to the right. |
| 1461 | expected_occlusion = gfx::Rect(0, 0, 25, 200); |
| 1462 | break; |
| 1463 | case RIGHT: |
| 1464 | // The shadow spreads 3*5 - 10 = 5 pixels to the left, so the |
| 1465 | // occlusion must recede by 5 to account for that. |
| 1466 | expected_occlusion = gfx::Rect(105, 0, 45, 200); |
| 1467 | break; |
| 1468 | case TOP: |
| 1469 | // Similar to LEFT. |
| 1470 | expected_occlusion = gfx::Rect(0, 0, 200, 25); |
| 1471 | break; |
| 1472 | case BOTTOM: |
| 1473 | // Similar to RIGHT. |
| 1474 | expected_occlusion = gfx::Rect(0, 105, 200, 45); |
| 1475 | break; |
| 1476 | } |
| 1477 | |
| 1478 | EXPECT_EQ(expected_occlusion.ToString(), |
| 1479 | occlusion.occlusion_from_inside_target().ToString()); |
| 1480 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1481 | |
| 1482 | this->DestroyLayers(); |
| 1483 | } |
| 1484 | } |
| 1485 | }; |
| 1486 | |
| 1487 | ALL_OCCLUSIONTRACKER_TEST( |
ajuma | 97755536 | 2016-07-19 16:12:12 | [diff] [blame] | 1488 | OcclusionTrackerTestPixelsNeededForDropShadowBackgroundFilter); |
jbroman | 19a18b1 | 2016-07-07 02:37:38 | [diff] [blame] | 1489 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1490 | class OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1491 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1492 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1493 | explicit OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1494 | bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1495 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1496 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1497 | gfx::Transform scale_by_half; |
| 1498 | scale_by_half.Scale(0.5, 0.5); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1499 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1500 | // Makes two surfaces that completely cover |parent|. The occlusion both |
| 1501 | // above and below the filters will be reduced by each of them. |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1502 | TestContentLayerImpl* root = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1503 | this->identity_matrix, gfx::PointF(), gfx::Size(75, 75)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1504 | LayerImpl* parent = this->CreateSurface(root, scale_by_half, gfx::PointF(), |
| 1505 | gfx::Size(150, 150)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1506 | parent->SetMasksToBounds(true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1507 | LayerImpl* filtered_surface1 = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1508 | parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1509 | LayerImpl* filtered_surface2 = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1510 | parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1511 | LayerImpl* occluding_layer_above = this->CreateDrawingLayer( |
| 1512 | parent, this->identity_matrix, gfx::PointF(100.f, 100.f), |
| 1513 | gfx::Size(50, 50), true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1514 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1515 | // Filters make the layers own surfaces. |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 1516 | filtered_surface1->test_properties()->force_render_surface = true; |
| 1517 | filtered_surface2->test_properties()->force_render_surface = true; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 1518 | FilterOperations filters; |
| 1519 | filters.Append(FilterOperation::CreateBlurFilter(1.f)); |
ajuma | 50bce7e | 2016-06-24 20:56:04 | [diff] [blame] | 1520 | filtered_surface1->test_properties()->background_filters = filters; |
| 1521 | filtered_surface2->test_properties()->background_filters = filters; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1522 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1523 | this->CalcDrawEtc(root); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1524 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1525 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1526 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1527 | this->VisitLayer(occluding_layer_above, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1528 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1529 | occlusion.occlusion_from_outside_target().ToString()); |
| 1530 | EXPECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2).ToString(), |
| 1531 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1532 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1533 | this->VisitLayer(filtered_surface2, &occlusion); |
| 1534 | this->VisitContributingSurface(filtered_surface2, &occlusion); |
| 1535 | this->VisitLayer(filtered_surface1, &occlusion); |
| 1536 | this->VisitContributingSurface(filtered_surface1, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1537 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1538 | // Test expectations in the target. |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 1539 | int blur_outset = 3; |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1540 | gfx::Rect expected_occlusion = |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 1541 | gfx::Rect(100 / 2 + blur_outset * 2, 100 / 2 + blur_outset * 2, |
| 1542 | 50 / 2 - blur_outset * 4, 50 / 2 - blur_outset * 4); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1543 | EXPECT_EQ(expected_occlusion.ToString(), |
| 1544 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1545 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1546 | // Test expectations in the screen are the same as in the target, as the |
| 1547 | // render surface is 1:1 with the screen. |
| 1548 | EXPECT_EQ(expected_occlusion.ToString(), |
| 1549 | occlusion.occlusion_from_outside_target().ToString()); |
| 1550 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1551 | }; |
| 1552 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1553 | ALL_OCCLUSIONTRACKER_TEST( |
| 1554 | OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1555 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1556 | class OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1557 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1558 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1559 | explicit OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1560 | bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1561 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1562 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1563 | gfx::Transform scale_by_half; |
| 1564 | scale_by_half.Scale(0.5, 0.5); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1565 | |
wangxianzhu | 932d7f1 | 2016-09-30 05:47:00 | [diff] [blame] | 1566 | // Make a 50x50 surface, with a smaller 30x30 layer centered below it. |
| 1567 | // The surface is scaled to test that the pixel moving is done in the target |
| 1568 | // space, where the background filter is applied, and the surface appears at |
| 1569 | // 50, 50. |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1570 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1571 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 150)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1572 | LayerImpl* behind_surface_layer = this->CreateDrawingLayer( |
| 1573 | parent, this->identity_matrix, gfx::PointF(60.f, 60.f), |
| 1574 | gfx::Size(30, 30), true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1575 | LayerImpl* filtered_surface = |
| 1576 | this->CreateDrawingLayer(parent, scale_by_half, gfx::PointF(50.f, 50.f), |
| 1577 | gfx::Size(100, 100), false); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1578 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1579 | // Filters make the layer own a surface. |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 1580 | filtered_surface->test_properties()->force_render_surface = true; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 1581 | FilterOperations filters; |
| 1582 | filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
ajuma | 50bce7e | 2016-06-24 20:56:04 | [diff] [blame] | 1583 | filtered_surface->test_properties()->background_filters = filters; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1584 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1585 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1586 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1587 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1588 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1589 | // The surface has a background blur, so it blurs non-opaque pixels below |
| 1590 | // it. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1591 | this->VisitLayer(filtered_surface, &occlusion); |
| 1592 | this->VisitContributingSurface(filtered_surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1593 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1594 | // The layers behind the surface are not blurred, and their occlusion does |
| 1595 | // not change, until we leave the surface. So it should not be modified by |
| 1596 | // the filter here. |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1597 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1598 | |
| 1599 | // Clear the occlusion so the |behind_surface_layer| can add its occlusion |
| 1600 | // without existing occlusion interfering. |
| 1601 | occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| 1602 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1603 | this->VisitLayer(behind_surface_layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1604 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1605 | // The layers behind the surface are not blurred, and their occlusion does |
| 1606 | // not change, until we leave the surface. So it should not be modified by |
| 1607 | // the filter here. |
| 1608 | gfx::Rect occlusion_behind_surface = gfx::Rect(60, 60, 30, 30); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1609 | EXPECT_EQ(occlusion_behind_surface.ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1610 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1611 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1612 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1613 | }; |
| 1614 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1615 | ALL_OCCLUSIONTRACKER_TEST( |
| 1616 | OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1617 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1618 | class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1619 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1620 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1621 | explicit OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1622 | bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1623 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1624 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1625 | gfx::Transform scale_by_half; |
| 1626 | scale_by_half.Scale(0.5, 0.5); |
| 1627 | |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 1628 | // Make a 50x50 filtered surface that is completely occluded by an opaque |
| 1629 | // layer which is above it in the z-order. The surface is |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1630 | // scaled to test that the pixel moving is done in the target space, where |
wangxianzhu | 932d7f1 | 2016-09-30 05:47:00 | [diff] [blame] | 1631 | // the background filter is applied, and the surface appears at 50, 50. |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1632 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 1633 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 150)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1634 | LayerImpl* filtered_surface = |
| 1635 | this->CreateDrawingLayer(parent, scale_by_half, gfx::PointF(50.f, 50.f), |
| 1636 | gfx::Size(100, 100), false); |
| 1637 | LayerImpl* occluding_layer = this->CreateDrawingLayer( |
| 1638 | parent, this->identity_matrix, gfx::PointF(50.f, 50.f), |
| 1639 | gfx::Size(50, 50), true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1640 | |
| 1641 | // Filters make the layer own a surface. |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 1642 | filtered_surface->test_properties()->force_render_surface = true; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 1643 | FilterOperations filters; |
| 1644 | filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
ajuma | 50bce7e | 2016-06-24 20:56:04 | [diff] [blame] | 1645 | filtered_surface->test_properties()->background_filters = filters; |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1646 | |
| 1647 | this->CalcDrawEtc(parent); |
| 1648 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1649 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1650 | |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 1651 | this->VisitLayer(occluding_layer, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1652 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1653 | this->VisitLayer(filtered_surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1654 | { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1655 | // The layers above the filtered surface occlude from outside. |
| 1656 | gfx::Rect occlusion_above_surface = gfx::Rect(0, 0, 50, 50); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1657 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1658 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1659 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 1660 | EXPECT_EQ(occlusion_above_surface.ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1661 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1662 | } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1663 | |
| 1664 | // The surface has a background blur, so it blurs non-opaque pixels below |
| 1665 | // it. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1666 | this->VisitContributingSurface(filtered_surface, &occlusion); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1667 | { |
| 1668 | // The filter is completely occluded, so it should not blur anything and |
| 1669 | // reduce any occlusion. |
| 1670 | gfx::Rect occlusion_above_surface = gfx::Rect(50, 50, 50, 50); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1671 | |
[email protected] | 66b52e1 | 2013-11-17 15:53:18 | [diff] [blame] | 1672 | EXPECT_EQ(occlusion_above_surface.ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1673 | occlusion.occlusion_from_inside_target().ToString()); |
| 1674 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1675 | occlusion.occlusion_from_outside_target().ToString()); |
| 1676 | } |
| 1677 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1678 | }; |
| 1679 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1680 | ALL_OCCLUSIONTRACKER_TEST( |
| 1681 | OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1682 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1683 | class OcclusionTrackerTestReduceOcclusionWhenBkgdFilterIsPartiallyOccluded |
| 1684 | : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1685 | protected: |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1686 | explicit OcclusionTrackerTestReduceOcclusionWhenBkgdFilterIsPartiallyOccluded( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1687 | bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1688 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1689 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1690 | gfx::Transform scale_by_half; |
| 1691 | scale_by_half.Scale(0.5, 0.5); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1692 | |
wangxianzhu | 932d7f1 | 2016-09-30 05:47:00 | [diff] [blame] | 1693 | // Make a 50x50 surface which is partially occluded by opaque layers which |
| 1694 | // are above it in the z-order. The surface is scaled to test that the |
| 1695 | // pixel moving is done in the target space, where the background filter is |
| 1696 | // applied, but the surface appears at 50, 50. |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1697 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1698 | this->identity_matrix, gfx::PointF(), gfx::Size(300, 150)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1699 | LayerImpl* filtered_surface = |
| 1700 | this->CreateDrawingLayer(parent, scale_by_half, gfx::PointF(50.f, 50.f), |
| 1701 | gfx::Size(100, 100), false); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1702 | LayerImpl* above_surface_layer = this->CreateDrawingLayer( |
| 1703 | parent, this->identity_matrix, gfx::PointF(70.f, 50.f), |
| 1704 | gfx::Size(30, 50), true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1705 | LayerImpl* beside_surface_layer = this->CreateDrawingLayer( |
| 1706 | parent, this->identity_matrix, gfx::PointF(90.f, 40.f), |
| 1707 | gfx::Size(10, 10), true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1708 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1709 | // Filters make the layer own a surface. |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 1710 | filtered_surface->test_properties()->force_render_surface = true; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 1711 | FilterOperations filters; |
| 1712 | filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
ajuma | 50bce7e | 2016-06-24 20:56:04 | [diff] [blame] | 1713 | filtered_surface->test_properties()->background_filters = filters; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1714 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1715 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1716 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1717 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1718 | |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1719 | this->VisitLayer(beside_surface_layer, &occlusion); |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1720 | this->VisitLayer(above_surface_layer, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1721 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1722 | // The surface has a background blur, so it blurs non-opaque pixels below |
| 1723 | // it. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1724 | this->VisitLayer(filtered_surface, &occlusion); |
| 1725 | this->VisitContributingSurface(filtered_surface, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1726 | |
wangxianzhu | 932d7f1 | 2016-09-30 05:47:00 | [diff] [blame] | 1727 | // The filter in the surface is partially unoccluded. Only the unoccluded |
| 1728 | // parts should reduce occlusion. This means it will push back the |
| 1729 | // occlusion that touches the unoccluded part (occlusion_above___), but |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1730 | // it will not touch occlusion_beside____ since that is not beside the |
| 1731 | // unoccluded part of the surface, even though it is beside the occluded |
| 1732 | // part of the surface. |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 1733 | int blur_outset = 9; |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1734 | gfx::Rect occlusion_above_surface = |
jbroman | 56c1f9c | 2016-07-06 19:08:10 | [diff] [blame] | 1735 | gfx::Rect(70 + blur_outset, 50, 30 - blur_outset, 50); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1736 | gfx::Rect occlusion_beside_surface = gfx::Rect(90, 40, 10, 10); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1737 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1738 | SimpleEnclosedRegion expected_occlusion; |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1739 | expected_occlusion.Union(occlusion_beside_surface); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1740 | expected_occlusion.Union(occlusion_above_surface); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1741 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1742 | EXPECT_EQ(expected_occlusion.ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1743 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1744 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1745 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 1746 | const SimpleEnclosedRegion& actual_occlusion = |
| 1747 | occlusion.occlusion_from_inside_target(); |
| 1748 | for (size_t i = 0; i < expected_occlusion.GetRegionComplexity(); ++i) { |
| 1749 | ASSERT_LT(i, actual_occlusion.GetRegionComplexity()); |
| 1750 | EXPECT_EQ(expected_occlusion.GetRect(i), actual_occlusion.GetRect(i)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1751 | } |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1752 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1753 | }; |
| 1754 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1755 | ALL_OCCLUSIONTRACKER_TEST( |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1756 | OcclusionTrackerTestReduceOcclusionWhenBkgdFilterIsPartiallyOccluded); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1757 | |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1758 | class OcclusionTrackerTestBlendModeDoesNotOcclude |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1759 | : public OcclusionTrackerTest { |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1760 | protected: |
| 1761 | explicit OcclusionTrackerTestBlendModeDoesNotOcclude(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1762 | : OcclusionTrackerTest(opaque_layers) {} |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1763 | void RunMyTest() override { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1764 | TestContentLayerImpl* parent = this->CreateRoot( |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1765 | this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1766 | LayerImpl* blend_mode_layer = this->CreateDrawingLayer( |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1767 | parent, this->identity_matrix, gfx::PointF(0.f, 0.f), |
| 1768 | gfx::Size(100, 100), true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1769 | LayerImpl* top_layer = this->CreateDrawingLayer( |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1770 | parent, this->identity_matrix, gfx::PointF(10.f, 12.f), |
| 1771 | gfx::Size(20, 22), true); |
| 1772 | |
| 1773 | // Blend mode makes the layer own a surface. |
jaydasika | 6b5a32bf | 2016-04-22 21:56:36 | [diff] [blame] | 1774 | blend_mode_layer->test_properties()->force_render_surface = true; |
reed | cc9c70f | 2016-11-22 04:26:01 | [diff] [blame] | 1775 | blend_mode_layer->test_properties()->blend_mode = SkBlendMode::kMultiply; |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1776 | |
| 1777 | this->CalcDrawEtc(parent); |
| 1778 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1779 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1780 | |
| 1781 | this->VisitLayer(top_layer, &occlusion); |
| 1782 | // |top_layer| occludes. |
| 1783 | EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(), |
| 1784 | occlusion.occlusion_from_inside_target().ToString()); |
| 1785 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1786 | |
| 1787 | this->VisitLayer(blend_mode_layer, &occlusion); |
ajuma | 2d466aa | 2016-07-25 21:11:00 | [diff] [blame] | 1788 | // |top_layer| and |blend_mode_layer| both occlude, since the blend mode |
| 1789 | // gets applied by blend_mode_layer's render surface, not when drawing the |
| 1790 | // layer itself. |
| 1791 | EXPECT_EQ(gfx::Rect(100, 100).ToString(), |
| 1792 | occlusion.occlusion_from_inside_target().ToString()); |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1793 | EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(), |
| 1794 | occlusion.occlusion_from_outside_target().ToString()); |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1795 | |
| 1796 | this->VisitContributingSurface(blend_mode_layer, &occlusion); |
| 1797 | // |top_layer| occludes but not |blend_mode_layer|. |
| 1798 | EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(), |
| 1799 | occlusion.occlusion_from_inside_target().ToString()); |
| 1800 | EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1801 | } |
| 1802 | }; |
| 1803 | |
| 1804 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestBlendModeDoesNotOcclude); |
| 1805 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1806 | class OcclusionTrackerTestMinimumTrackingSize : public OcclusionTrackerTest { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1807 | protected: |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1808 | explicit OcclusionTrackerTestMinimumTrackingSize(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1809 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1810 | void RunMyTest() override { |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1811 | gfx::Size tracking_size(100, 100); |
| 1812 | gfx::Size below_tracking_size(99, 99); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1813 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1814 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1815 | this->identity_matrix, gfx::PointF(), gfx::Size(400, 400)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1816 | LayerImpl* large = this->CreateDrawingLayer( |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1817 | parent, this->identity_matrix, gfx::PointF(), tracking_size, true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1818 | LayerImpl* small = |
| 1819 | this->CreateDrawingLayer(parent, this->identity_matrix, gfx::PointF(), |
| 1820 | below_tracking_size, true); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1821 | this->CalcDrawEtc(parent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1822 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1823 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1824 | occlusion.set_minimum_tracking_size(tracking_size); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1825 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1826 | // The small layer is not tracked because it is too small. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1827 | this->VisitLayer(small, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1828 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1829 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1830 | occlusion.occlusion_from_outside_target().ToString()); |
| 1831 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1832 | occlusion.occlusion_from_inside_target().ToString()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1833 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1834 | // The large layer is tracked as it is large enough. |
[email protected] | d002dd0 | 2013-03-27 07:40:40 | [diff] [blame] | 1835 | this->VisitLayer(large, &occlusion); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1836 | |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1837 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1838 | occlusion.occlusion_from_outside_target().ToString()); |
[email protected] | 2c7c670 | 2013-03-26 03:14:05 | [diff] [blame] | 1839 | EXPECT_EQ(gfx::Rect(tracking_size).ToString(), |
[email protected] | a27cbde | 2013-03-23 22:01:49 | [diff] [blame] | 1840 | occlusion.occlusion_from_inside_target().ToString()); |
| 1841 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1842 | }; |
| 1843 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 1844 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestMinimumTrackingSize); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1845 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1846 | class OcclusionTrackerTestScaledLayerIsClipped : public OcclusionTrackerTest { |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1847 | protected: |
| 1848 | explicit OcclusionTrackerTestScaledLayerIsClipped(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1849 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1850 | void RunMyTest() override { |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1851 | gfx::Transform scale_transform; |
| 1852 | scale_transform.Scale(512.0, 512.0); |
| 1853 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1854 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1855 | this->identity_matrix, gfx::PointF(), gfx::Size(400, 400)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1856 | LayerImpl* clip = |
| 1857 | this->CreateLayer(parent, this->identity_matrix, |
| 1858 | gfx::PointF(10.f, 10.f), gfx::Size(50, 50)); |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1859 | clip->SetMasksToBounds(true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1860 | LayerImpl* scale = this->CreateLayer(clip, scale_transform, gfx::PointF(), |
| 1861 | gfx::Size(1, 1)); |
| 1862 | LayerImpl* scaled = this->CreateDrawingLayer( |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1863 | scale, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500), true); |
| 1864 | this->CalcDrawEtc(parent); |
| 1865 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1866 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1867 | |
| 1868 | this->VisitLayer(scaled, &occlusion); |
| 1869 | |
| 1870 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1871 | occlusion.occlusion_from_outside_target().ToString()); |
| 1872 | EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
| 1873 | occlusion.occlusion_from_inside_target().ToString()); |
| 1874 | } |
| 1875 | }; |
| 1876 | |
| 1877 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerIsClipped) |
| 1878 | |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1879 | class OcclusionTrackerTestScaledLayerInSurfaceIsClipped |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1880 | : public OcclusionTrackerTest { |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1881 | protected: |
| 1882 | explicit OcclusionTrackerTestScaledLayerInSurfaceIsClipped(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1883 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1884 | void RunMyTest() override { |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1885 | gfx::Transform scale_transform; |
| 1886 | scale_transform.Scale(512.0, 512.0); |
| 1887 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1888 | TestContentLayerImpl* parent = this->CreateRoot( |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1889 | this->identity_matrix, gfx::PointF(), gfx::Size(400, 400)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1890 | LayerImpl* clip = |
| 1891 | this->CreateLayer(parent, this->identity_matrix, |
| 1892 | gfx::PointF(10.f, 10.f), gfx::Size(50, 50)); |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1893 | clip->SetMasksToBounds(true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1894 | LayerImpl* surface = this->CreateDrawingSurface( |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1895 | clip, this->identity_matrix, gfx::PointF(), gfx::Size(400, 30), false); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1896 | LayerImpl* scale = this->CreateLayer(surface, scale_transform, |
| 1897 | gfx::PointF(), gfx::Size(1, 1)); |
| 1898 | LayerImpl* scaled = this->CreateDrawingLayer( |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1899 | scale, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500), true); |
| 1900 | this->CalcDrawEtc(parent); |
| 1901 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1902 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 1a5d9ce | 2013-04-30 01:31:09 | [diff] [blame] | 1903 | |
| 1904 | this->VisitLayer(scaled, &occlusion); |
| 1905 | this->VisitLayer(surface, &occlusion); |
| 1906 | this->VisitContributingSurface(surface, &occlusion); |
| 1907 | |
| 1908 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1909 | occlusion.occlusion_from_outside_target().ToString()); |
| 1910 | EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
| 1911 | occlusion.occlusion_from_inside_target().ToString()); |
| 1912 | } |
| 1913 | }; |
| 1914 | |
| 1915 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerInSurfaceIsClipped) |
| 1916 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1917 | class OcclusionTrackerTestCopyRequestDoesOcclude : public OcclusionTrackerTest { |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1918 | protected: |
| 1919 | explicit OcclusionTrackerTestCopyRequestDoesOcclude(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1920 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1921 | void RunMyTest() override { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1922 | TestContentLayerImpl* root = this->CreateRoot( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 1923 | this->identity_matrix, gfx::PointF(), gfx::Size(400, 400)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1924 | TestContentLayerImpl* parent = this->CreateDrawingLayer( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 1925 | root, this->identity_matrix, gfx::PointF(), gfx::Size(400, 400), true); |
| 1926 | LayerImpl* copy = |
| 1927 | this->CreateLayer(parent, this->identity_matrix, gfx::PointF(100, 0), |
| 1928 | gfx::Size(200, 400)); |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1929 | this->AddCopyRequest(copy); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1930 | LayerImpl* copy_child = this->CreateDrawingLayer( |
| 1931 | copy, this->identity_matrix, gfx::PointF(), gfx::Size(200, 400), true); |
| 1932 | LayerImpl* top_layer = |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1933 | this->CreateDrawingLayer(root, this->identity_matrix, |
| 1934 | gfx::PointF(50, 0), gfx::Size(50, 400), true); |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1935 | this->CalcDrawEtc(root); |
| 1936 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1937 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1938 | |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1939 | this->VisitLayer(top_layer, &occlusion); |
| 1940 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1941 | occlusion.occlusion_from_outside_target().ToString()); |
| 1942 | EXPECT_EQ(gfx::Rect(50, 0, 50, 400).ToString(), |
| 1943 | occlusion.occlusion_from_inside_target().ToString()); |
| 1944 | |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1945 | this->VisitLayer(copy_child, &occlusion); |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1946 | // Layers outside the copy request do not occlude. |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1947 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1948 | occlusion.occlusion_from_outside_target().ToString()); |
| 1949 | EXPECT_EQ(gfx::Rect(200, 400).ToString(), |
| 1950 | occlusion.occlusion_from_inside_target().ToString()); |
| 1951 | |
| 1952 | // CopyRequests cause the layer to own a surface. |
| 1953 | this->VisitContributingSurface(copy, &occlusion); |
| 1954 | |
| 1955 | // The occlusion from the copy should be kept. |
| 1956 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1957 | occlusion.occlusion_from_outside_target().ToString()); |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 1958 | EXPECT_EQ(gfx::Rect(50, 0, 250, 400).ToString(), |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1959 | occlusion.occlusion_from_inside_target().ToString()); |
| 1960 | } |
| 1961 | }; |
| 1962 | |
| 1963 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestCopyRequestDoesOcclude) |
| 1964 | |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1965 | class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1966 | : public OcclusionTrackerTest { |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1967 | protected: |
| 1968 | explicit OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude( |
| 1969 | bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1970 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 1971 | void RunMyTest() override { |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1972 | TestContentLayerImpl* root = this->CreateRoot( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 1973 | this->identity_matrix, gfx::PointF(), gfx::Size(400, 400)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1974 | TestContentLayerImpl* parent = this->CreateDrawingLayer( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 1975 | root, this->identity_matrix, gfx::PointF(), gfx::Size(400, 400), true); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1976 | LayerImpl* hide = this->CreateLayer(parent, this->identity_matrix, |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 1977 | gfx::PointF(), gfx::Size()); |
| 1978 | LayerImpl* copy = |
| 1979 | this->CreateLayer(hide, this->identity_matrix, gfx::PointF(100.f, 0.f), |
| 1980 | gfx::Size(200, 400)); |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1981 | this->AddCopyRequest(copy); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1982 | LayerImpl* copy_child = this->CreateDrawingLayer( |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1983 | copy, this->identity_matrix, gfx::PointF(), gfx::Size(200, 400), true); |
| 1984 | |
| 1985 | // The |copy| layer is hidden but since it is being copied, it will be |
| 1986 | // drawn. |
jaydasika | 5121caa8 | 2016-05-05 15:43:35 | [diff] [blame] | 1987 | hide->test_properties()->hide_layer_and_subtree = true; |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1988 | |
| 1989 | this->CalcDrawEtc(root); |
| 1990 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 1991 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); |
[email protected] | 5b54b97 | 2013-07-26 13:25:42 | [diff] [blame] | 1992 | |
| 1993 | this->VisitLayer(copy_child, &occlusion); |
| 1994 | EXPECT_EQ(gfx::Rect().ToString(), |
| 1995 | occlusion.occlusion_from_outside_target().ToString()); |
| 1996 | EXPECT_EQ(gfx::Rect(200, 400).ToString(), |
| 1997 | occlusion.occlusion_from_inside_target().ToString()); |
| 1998 | |
| 1999 | // CopyRequests cause the layer to own a surface. |
| 2000 | this->VisitContributingSurface(copy, &occlusion); |
| 2001 | |
| 2002 | // The occlusion from the copy should be dropped since it is hidden. |
| 2003 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2004 | occlusion.occlusion_from_outside_target().ToString()); |
| 2005 | EXPECT_EQ(gfx::Rect().ToString(), |
| 2006 | occlusion.occlusion_from_inside_target().ToString()); |
| 2007 | } |
| 2008 | }; |
| 2009 | |
| 2010 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude) |
| 2011 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2012 | class OcclusionTrackerTestOccludedLayer : public OcclusionTrackerTest { |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 2013 | protected: |
| 2014 | explicit OcclusionTrackerTestOccludedLayer(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2015 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 2016 | void RunMyTest() override { |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 2017 | gfx::Transform translate; |
| 2018 | translate.Translate(10.0, 20.0); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2019 | TestContentLayerImpl* root = this->CreateRoot( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 2020 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| 2021 | LayerImpl* surface = this->CreateSurface( |
| 2022 | root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2023 | LayerImpl* layer = this->CreateDrawingLayer( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 2024 | surface, translate, gfx::PointF(), gfx::Size(200, 200), false); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2025 | TestContentLayerImpl* outside_layer = this->CreateDrawingLayer( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 2026 | root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200), false); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 2027 | this->CalcDrawEtc(root); |
| 2028 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2029 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200)); |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 2030 | this->VisitLayer(outside_layer, &occlusion); |
| 2031 | this->EnterLayer(layer, &occlusion); |
| 2032 | |
| 2033 | // No occlusion, is not occluded. |
| 2034 | occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| 2035 | occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| 2036 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100))); |
| 2037 | |
| 2038 | // Partial occlusion from outside, is not occluded. |
| 2039 | occlusion.set_occlusion_from_outside_target( |
| 2040 | SimpleEnclosedRegion(50, 50, 100, 100)); |
| 2041 | occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| 2042 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); |
| 2043 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); |
| 2044 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); |
| 2045 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); |
| 2046 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); |
| 2047 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); |
| 2048 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); |
| 2049 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); |
| 2050 | |
| 2051 | // Full occlusion from outside, is occluded. |
| 2052 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); |
| 2053 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); |
| 2054 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); |
| 2055 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); |
| 2056 | |
| 2057 | // Partial occlusion from inside, is not occluded. |
| 2058 | occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| 2059 | occlusion.set_occlusion_from_inside_target( |
| 2060 | SimpleEnclosedRegion(50, 50, 100, 100)); |
| 2061 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); |
| 2062 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); |
| 2063 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); |
| 2064 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); |
| 2065 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); |
| 2066 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); |
| 2067 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); |
| 2068 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); |
| 2069 | |
| 2070 | // Full occlusion from inside, is occluded. |
| 2071 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); |
| 2072 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); |
| 2073 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); |
| 2074 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); |
| 2075 | |
| 2076 | // Partial occlusion from both, is not occluded. |
| 2077 | occlusion.set_occlusion_from_outside_target( |
| 2078 | SimpleEnclosedRegion(50, 50, 100, 50)); |
| 2079 | occlusion.set_occlusion_from_inside_target( |
| 2080 | SimpleEnclosedRegion(50, 100, 100, 50)); |
| 2081 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); |
| 2082 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); |
| 2083 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); |
| 2084 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); |
| 2085 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); |
| 2086 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); |
| 2087 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); |
| 2088 | EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); |
| 2089 | |
| 2090 | // Full occlusion from both, is occluded. |
| 2091 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); |
| 2092 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); |
| 2093 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); |
| 2094 | EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); |
| 2095 | } |
| 2096 | }; |
| 2097 | |
| 2098 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOccludedLayer) |
| 2099 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2100 | class OcclusionTrackerTestUnoccludedLayerQuery : public OcclusionTrackerTest { |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 2101 | protected: |
| 2102 | explicit OcclusionTrackerTestUnoccludedLayerQuery(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2103 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 2104 | void RunMyTest() override { |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 2105 | gfx::Transform translate; |
| 2106 | translate.Translate(10.0, 20.0); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2107 | TestContentLayerImpl* root = this->CreateRoot( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 2108 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| 2109 | LayerImpl* surface = this->CreateSurface( |
| 2110 | root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2111 | LayerImpl* layer = this->CreateDrawingLayer( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 2112 | surface, translate, gfx::PointF(), gfx::Size(200, 200), false); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2113 | TestContentLayerImpl* outside_layer = this->CreateDrawingLayer( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 2114 | root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200), false); |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 2115 | this->CalcDrawEtc(root); |
| 2116 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2117 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200)); |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 2118 | this->VisitLayer(outside_layer, &occlusion); |
| 2119 | this->EnterLayer(layer, &occlusion); |
| 2120 | |
| 2121 | // No occlusion, is not occluded. |
| 2122 | occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| 2123 | occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| 2124 | EXPECT_EQ(gfx::Rect(100, 100), |
| 2125 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(100, 100))); |
| 2126 | |
| 2127 | // Partial occlusion from outside. |
| 2128 | occlusion.set_occlusion_from_outside_target( |
| 2129 | SimpleEnclosedRegion(50, 50, 100, 100)); |
| 2130 | occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| 2131 | EXPECT_EQ( |
| 2132 | gfx::Rect(0, 0, 100, 100), |
| 2133 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 100, 100))); |
| 2134 | EXPECT_EQ(gfx::Rect(140, 30, 50, 100), |
| 2135 | occlusion.UnoccludedLayerContentRect( |
| 2136 | layer, gfx::Rect(90, 30, 100, 100))); |
| 2137 | EXPECT_EQ(gfx::Rect(40, 0, 100, 30), |
| 2138 | occlusion.UnoccludedLayerContentRect(layer, |
| 2139 | gfx::Rect(40, 0, 100, 100))); |
| 2140 | EXPECT_EQ(gfx::Rect(40, 130, 100, 50), |
| 2141 | occlusion.UnoccludedLayerContentRect( |
| 2142 | layer, gfx::Rect(40, 80, 100, 100))); |
| 2143 | EXPECT_EQ( |
| 2144 | gfx::Rect(0, 0, 80, 100), |
| 2145 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 80, 100))); |
| 2146 | EXPECT_EQ(gfx::Rect(90, 80, 100, 100), |
| 2147 | occlusion.UnoccludedLayerContentRect( |
| 2148 | layer, gfx::Rect(90, 80, 100, 100))); |
| 2149 | EXPECT_EQ(gfx::Rect(0, 80, 100, 100), |
| 2150 | occlusion.UnoccludedLayerContentRect(layer, |
| 2151 | gfx::Rect(0, 80, 100, 100))); |
| 2152 | EXPECT_EQ(gfx::Rect(90, 0, 100, 100), |
| 2153 | occlusion.UnoccludedLayerContentRect(layer, |
| 2154 | gfx::Rect(90, 0, 100, 100))); |
| 2155 | |
| 2156 | // Full occlusion from outside, is occluded. |
| 2157 | EXPECT_EQ(gfx::Rect(), |
| 2158 | occlusion.UnoccludedLayerContentRect( |
| 2159 | layer, gfx::Rect(40, 30, 100, 100))); |
| 2160 | EXPECT_EQ( |
| 2161 | gfx::Rect(), |
| 2162 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(40, 30, 10, 10))); |
| 2163 | EXPECT_EQ(gfx::Rect(), |
| 2164 | occlusion.UnoccludedLayerContentRect( |
| 2165 | layer, gfx::Rect(130, 120, 10, 10))); |
| 2166 | EXPECT_EQ( |
| 2167 | gfx::Rect(), |
| 2168 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(80, 70, 50, 50))); |
| 2169 | |
| 2170 | // Partial occlusion from inside, is not occluded. |
| 2171 | occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| 2172 | occlusion.set_occlusion_from_inside_target( |
| 2173 | SimpleEnclosedRegion(50, 50, 100, 100)); |
| 2174 | EXPECT_EQ( |
| 2175 | gfx::Rect(0, 0, 100, 100), |
| 2176 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 100, 100))); |
| 2177 | EXPECT_EQ(gfx::Rect(140, 30, 50, 100), |
| 2178 | occlusion.UnoccludedLayerContentRect( |
| 2179 | layer, gfx::Rect(90, 30, 100, 100))); |
| 2180 | EXPECT_EQ(gfx::Rect(40, 0, 100, 30), |
| 2181 | occlusion.UnoccludedLayerContentRect(layer, |
| 2182 | gfx::Rect(40, 0, 100, 100))); |
| 2183 | EXPECT_EQ(gfx::Rect(40, 130, 100, 50), |
| 2184 | occlusion.UnoccludedLayerContentRect( |
| 2185 | layer, gfx::Rect(40, 80, 100, 100))); |
| 2186 | EXPECT_EQ( |
| 2187 | gfx::Rect(0, 0, 80, 100), |
| 2188 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 80, 100))); |
| 2189 | EXPECT_EQ(gfx::Rect(90, 80, 100, 100), |
| 2190 | occlusion.UnoccludedLayerContentRect( |
| 2191 | layer, gfx::Rect(90, 80, 100, 100))); |
| 2192 | EXPECT_EQ(gfx::Rect(0, 80, 100, 100), |
| 2193 | occlusion.UnoccludedLayerContentRect(layer, |
| 2194 | gfx::Rect(0, 80, 100, 100))); |
| 2195 | EXPECT_EQ(gfx::Rect(90, 0, 100, 100), |
| 2196 | occlusion.UnoccludedLayerContentRect(layer, |
| 2197 | gfx::Rect(90, 0, 100, 100))); |
| 2198 | |
| 2199 | // Full occlusion from inside, is occluded. |
| 2200 | EXPECT_EQ(gfx::Rect(), |
| 2201 | occlusion.UnoccludedLayerContentRect( |
| 2202 | layer, gfx::Rect(40, 30, 100, 100))); |
| 2203 | EXPECT_EQ( |
| 2204 | gfx::Rect(), |
| 2205 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(40, 30, 10, 10))); |
| 2206 | EXPECT_EQ(gfx::Rect(), |
| 2207 | occlusion.UnoccludedLayerContentRect( |
| 2208 | layer, gfx::Rect(130, 120, 10, 10))); |
| 2209 | EXPECT_EQ( |
| 2210 | gfx::Rect(), |
| 2211 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(80, 70, 50, 50))); |
| 2212 | |
| 2213 | // Partial occlusion from both, is not occluded. |
| 2214 | occlusion.set_occlusion_from_outside_target( |
| 2215 | SimpleEnclosedRegion(50, 50, 100, 50)); |
| 2216 | occlusion.set_occlusion_from_inside_target( |
| 2217 | SimpleEnclosedRegion(50, 100, 100, 50)); |
| 2218 | EXPECT_EQ( |
| 2219 | gfx::Rect(0, 0, 100, 100), |
| 2220 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 100, 100))); |
| 2221 | // This could be (140, 30, 50, 100). But because we do a lossy subtract, |
| 2222 | // it's larger. |
| 2223 | EXPECT_EQ(gfx::Rect(90, 30, 100, 100), |
| 2224 | occlusion.UnoccludedLayerContentRect( |
| 2225 | layer, gfx::Rect(90, 30, 100, 100))); |
| 2226 | EXPECT_EQ(gfx::Rect(40, 0, 100, 30), |
| 2227 | occlusion.UnoccludedLayerContentRect(layer, |
| 2228 | gfx::Rect(40, 0, 100, 100))); |
| 2229 | EXPECT_EQ(gfx::Rect(40, 130, 100, 50), |
| 2230 | occlusion.UnoccludedLayerContentRect( |
| 2231 | layer, gfx::Rect(40, 80, 100, 100))); |
| 2232 | EXPECT_EQ( |
| 2233 | gfx::Rect(0, 0, 80, 100), |
| 2234 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 80, 100))); |
| 2235 | EXPECT_EQ(gfx::Rect(90, 80, 100, 100), |
| 2236 | occlusion.UnoccludedLayerContentRect( |
| 2237 | layer, gfx::Rect(90, 80, 100, 100))); |
| 2238 | EXPECT_EQ(gfx::Rect(0, 80, 100, 100), |
| 2239 | occlusion.UnoccludedLayerContentRect(layer, |
| 2240 | gfx::Rect(0, 80, 100, 100))); |
| 2241 | EXPECT_EQ(gfx::Rect(90, 0, 100, 100), |
| 2242 | occlusion.UnoccludedLayerContentRect(layer, |
| 2243 | gfx::Rect(90, 0, 100, 100))); |
| 2244 | |
| 2245 | // Full occlusion from both, is occluded. |
| 2246 | EXPECT_EQ(gfx::Rect(), |
| 2247 | occlusion.UnoccludedLayerContentRect( |
| 2248 | layer, gfx::Rect(40, 30, 100, 100))); |
| 2249 | EXPECT_EQ( |
| 2250 | gfx::Rect(), |
| 2251 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(40, 30, 10, 10))); |
| 2252 | EXPECT_EQ(gfx::Rect(), |
| 2253 | occlusion.UnoccludedLayerContentRect( |
| 2254 | layer, gfx::Rect(130, 120, 10, 10))); |
| 2255 | EXPECT_EQ( |
| 2256 | gfx::Rect(), |
| 2257 | occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(80, 70, 50, 50))); |
| 2258 | } |
| 2259 | }; |
| 2260 | |
| 2261 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedLayerQuery) |
| 2262 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2263 | class OcclusionTrackerTestUnoccludedSurfaceQuery : public OcclusionTrackerTest { |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 2264 | protected: |
| 2265 | explicit OcclusionTrackerTestUnoccludedSurfaceQuery(bool opaque_layers) |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2266 | : OcclusionTrackerTest(opaque_layers) {} |
dmichael | c78b093 | 2014-12-17 23:39:47 | [diff] [blame] | 2267 | void RunMyTest() override { |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 2268 | gfx::Transform translate; |
| 2269 | translate.Translate(10.0, 20.0); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2270 | TestContentLayerImpl* root = this->CreateRoot( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 2271 | this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| 2272 | LayerImpl* surface = this->CreateSurface(root, translate, gfx::PointF(), |
| 2273 | gfx::Size(200, 200)); |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2274 | LayerImpl* layer = |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 2275 | this->CreateDrawingLayer(surface, this->identity_matrix, gfx::PointF(), |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2276 | gfx::Size(200, 200), false); |
| 2277 | TestContentLayerImpl* outside_layer = this->CreateDrawingLayer( |
danakj | a2fdbc70 | 2015-10-20 23:05:24 | [diff] [blame] | 2278 | root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200), false); |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 2279 | this->CalcDrawEtc(root); |
| 2280 | |
danakj | 00f7925e | 2015-06-15 21:19:22 | [diff] [blame] | 2281 | TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200)); |
danakj | f080b5b | 2014-08-23 22:18:20 | [diff] [blame] | 2282 | this->VisitLayer(outside_layer, &occlusion); |
| 2283 | this->VisitLayer(layer, &occlusion); |
| 2284 | this->EnterContributingSurface(surface, &occlusion); |
| 2285 | |
| 2286 | // No occlusion, is not occluded. |
| 2287 | occlusion.set_occlusion_on_contributing_surface_from_outside_target( |
| 2288 | SimpleEnclosedRegion()); |
| 2289 | occlusion.set_occlusion_on_contributing_surface_from_inside_target( |
| 2290 | SimpleEnclosedRegion()); |
| 2291 | EXPECT_EQ( |
| 2292 | gfx::Rect(100, 100), |
| 2293 | occlusion.UnoccludedSurfaceContentRect(surface, gfx::Rect(100, 100))); |
| 2294 | |
| 2295 | // Partial occlusion from outside. |
| 2296 | occlusion.set_occlusion_on_contributing_surface_from_outside_target( |
| 2297 | SimpleEnclosedRegion(50, 50, 100, 100)); |
| 2298 | occlusion.set_occlusion_on_contributing_surface_from_inside_target( |
| 2299 | SimpleEnclosedRegion()); |
| 2300 | EXPECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 2301 | occlusion.UnoccludedSurfaceContentRect( |
| 2302 | surface, gfx::Rect(0, 0, 100, 100))); |
| 2303 | EXPECT_EQ(gfx::Rect(140, 30, 50, 100), |
| 2304 | occlusion.UnoccludedSurfaceContentRect( |
| 2305 | surface, gfx::Rect(90, 30, 100, 100))); |
| 2306 | EXPECT_EQ(gfx::Rect(40, 0, 100, 30), |
| 2307 | occlusion.UnoccludedSurfaceContentRect( |
| 2308 | surface, gfx::Rect(40, 0, 100, 100))); |
| 2309 | EXPECT_EQ(gfx::Rect(40, 130, 100, 50), |
| 2310 | occlusion.UnoccludedSurfaceContentRect( |
| 2311 | surface, gfx::Rect(40, 80, 100, 100))); |
| 2312 | EXPECT_EQ(gfx::Rect(0, 0, 80, 100), |
| 2313 | occlusion.UnoccludedSurfaceContentRect(surface, |
| 2314 | gfx::Rect(0, 0, 80, 100))); |
| 2315 | EXPECT_EQ(gfx::Rect(90, 80, 100, 100), |
| 2316 | occlusion.UnoccludedSurfaceContentRect( |
| 2317 | surface, gfx::Rect(90, 80, 100, 100))); |
| 2318 | EXPECT_EQ(gfx::Rect(0, 80, 100, 100), |
| 2319 | occlusion.UnoccludedSurfaceContentRect( |
| 2320 | surface, gfx::Rect(0, 80, 100, 100))); |
| 2321 | EXPECT_EQ(gfx::Rect(90, 0, 100, 100), |
| 2322 | occlusion.UnoccludedSurfaceContentRect( |
| 2323 | surface, gfx::Rect(90, 0, 100, 100))); |
| 2324 | |
| 2325 | // Full occlusion from outside, is occluded. |
| 2326 | EXPECT_EQ(gfx::Rect(), |
| 2327 | occlusion.UnoccludedSurfaceContentRect( |
| 2328 | surface, gfx::Rect(40, 30, 100, 100))); |
| 2329 | EXPECT_EQ(gfx::Rect(), |
| 2330 | occlusion.UnoccludedSurfaceContentRect( |
| 2331 | surface, gfx::Rect(40, 30, 10, 10))); |
| 2332 | EXPECT_EQ(gfx::Rect(), |
| 2333 | occlusion.UnoccludedSurfaceContentRect( |
| 2334 | surface, gfx::Rect(130, 120, 10, 10))); |
| 2335 | EXPECT_EQ(gfx::Rect(), |
| 2336 | occlusion.UnoccludedSurfaceContentRect( |
| 2337 | surface, gfx::Rect(80, 70, 50, 50))); |
| 2338 | |
| 2339 | // Partial occlusion from inside, is not occluded. |
| 2340 | occlusion.set_occlusion_on_contributing_surface_from_outside_target( |
| 2341 | SimpleEnclosedRegion()); |
| 2342 | occlusion.set_occlusion_on_contributing_surface_from_inside_target( |
| 2343 | SimpleEnclosedRegion(50, 50, 100, 100)); |
| 2344 | EXPECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 2345 | occlusion.UnoccludedSurfaceContentRect( |
| 2346 | surface, gfx::Rect(0, 0, 100, 100))); |
| 2347 | EXPECT_EQ(gfx::Rect(140, 30, 50, 100), |
| 2348 | occlusion.UnoccludedSurfaceContentRect( |
| 2349 | surface, gfx::Rect(90, 30, 100, 100))); |
| 2350 | EXPECT_EQ(gfx::Rect(40, 0, 100, 30), |
| 2351 | occlusion.UnoccludedSurfaceContentRect( |
| 2352 | surface, gfx::Rect(40, 0, 100, 100))); |
| 2353 | EXPECT_EQ(gfx::Rect(40, 130, 100, 50), |
| 2354 | occlusion.UnoccludedSurfaceContentRect( |
| 2355 | surface, gfx::Rect(40, 80, 100, 100))); |
| 2356 | EXPECT_EQ(gfx::Rect(0, 0, 80, 100), |
| 2357 | occlusion.UnoccludedSurfaceContentRect(surface, |
| 2358 | gfx::Rect(0, 0, 80, 100))); |
| 2359 | EXPECT_EQ(gfx::Rect(90, 80, 100, 100), |
| 2360 | occlusion.UnoccludedSurfaceContentRect( |
| 2361 | surface, gfx::Rect(90, 80, 100, 100))); |
| 2362 | EXPECT_EQ(gfx::Rect(0, 80, 100, 100), |
| 2363 | occlusion.UnoccludedSurfaceContentRect( |
| 2364 | surface, gfx::Rect(0, 80, 100, 100))); |
| 2365 | EXPECT_EQ(gfx::Rect(90, 0, 100, 100), |
| 2366 | occlusion.UnoccludedSurfaceContentRect( |
| 2367 | surface, gfx::Rect(90, 0, 100, 100))); |
| 2368 | |
| 2369 | // Full occlusion from inside, is occluded. |
| 2370 | EXPECT_EQ(gfx::Rect(), |
| 2371 | occlusion.UnoccludedSurfaceContentRect( |
| 2372 | surface, gfx::Rect(40, 30, 100, 100))); |
| 2373 | EXPECT_EQ(gfx::Rect(), |
| 2374 | occlusion.UnoccludedSurfaceContentRect( |
| 2375 | surface, gfx::Rect(40, 30, 10, 10))); |
| 2376 | EXPECT_EQ(gfx::Rect(), |
| 2377 | occlusion.UnoccludedSurfaceContentRect( |
| 2378 | surface, gfx::Rect(130, 120, 10, 10))); |
| 2379 | EXPECT_EQ(gfx::Rect(), |
| 2380 | occlusion.UnoccludedSurfaceContentRect( |
| 2381 | surface, gfx::Rect(80, 70, 50, 50))); |
| 2382 | |
| 2383 | // Partial occlusion from both, is not occluded. |
| 2384 | occlusion.set_occlusion_on_contributing_surface_from_outside_target( |
| 2385 | SimpleEnclosedRegion(50, 50, 100, 50)); |
| 2386 | occlusion.set_occlusion_on_contributing_surface_from_inside_target( |
| 2387 | SimpleEnclosedRegion(50, 100, 100, 50)); |
| 2388 | EXPECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 2389 | occlusion.UnoccludedSurfaceContentRect( |
| 2390 | surface, gfx::Rect(0, 0, 100, 100))); |
| 2391 | // This could be (140, 30, 50, 100). But because we do a lossy subtract, |
| 2392 | // it's larger. |
| 2393 | EXPECT_EQ(gfx::Rect(90, 30, 100, 100), |
| 2394 | occlusion.UnoccludedSurfaceContentRect( |
| 2395 | surface, gfx::Rect(90, 30, 100, 100))); |
| 2396 | EXPECT_EQ(gfx::Rect(40, 0, 100, 30), |
| 2397 | occlusion.UnoccludedSurfaceContentRect( |
| 2398 | surface, gfx::Rect(40, 0, 100, 100))); |
| 2399 | EXPECT_EQ(gfx::Rect(40, 130, 100, 50), |
| 2400 | occlusion.UnoccludedSurfaceContentRect( |
| 2401 | surface, gfx::Rect(40, 80, 100, 100))); |
| 2402 | EXPECT_EQ(gfx::Rect(0, 0, 80, 100), |
| 2403 | occlusion.UnoccludedSurfaceContentRect(surface, |
| 2404 | gfx::Rect(0, 0, 80, 100))); |
| 2405 | EXPECT_EQ(gfx::Rect(90, 80, 100, 100), |
| 2406 | occlusion.UnoccludedSurfaceContentRect( |
| 2407 | surface, gfx::Rect(90, 80, 100, 100))); |
| 2408 | EXPECT_EQ(gfx::Rect(0, 80, 100, 100), |
| 2409 | occlusion.UnoccludedSurfaceContentRect( |
| 2410 | surface, gfx::Rect(0, 80, 100, 100))); |
| 2411 | EXPECT_EQ(gfx::Rect(90, 0, 100, 100), |
| 2412 | occlusion.UnoccludedSurfaceContentRect( |
| 2413 | surface, gfx::Rect(90, 0, 100, 100))); |
| 2414 | |
| 2415 | // Full occlusion from both, is occluded. |
| 2416 | EXPECT_EQ(gfx::Rect(), |
| 2417 | occlusion.UnoccludedSurfaceContentRect( |
| 2418 | surface, gfx::Rect(40, 30, 100, 100))); |
| 2419 | EXPECT_EQ(gfx::Rect(), |
| 2420 | occlusion.UnoccludedSurfaceContentRect( |
| 2421 | surface, gfx::Rect(40, 30, 10, 10))); |
| 2422 | EXPECT_EQ(gfx::Rect(), |
| 2423 | occlusion.UnoccludedSurfaceContentRect( |
| 2424 | surface, gfx::Rect(130, 120, 10, 10))); |
| 2425 | EXPECT_EQ(gfx::Rect(), |
| 2426 | occlusion.UnoccludedSurfaceContentRect( |
| 2427 | surface, gfx::Rect(80, 70, 50, 50))); |
| 2428 | } |
| 2429 | }; |
| 2430 | |
| 2431 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) |
| 2432 | |
[email protected] | ba56574 | 2012-11-10 09:29:48 | [diff] [blame] | 2433 | } // namespace |
| 2434 | } // namespace cc |