[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 | |
| 5 | #include "config.h" |
| 6 | |
[email protected] | 55a124d0 | 2012-10-22 03:07:13 | [diff] [blame] | 7 | #include "cc/occlusion_tracker.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 8 | |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 9 | #include "CCLayerAnimationController.h" |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 10 | #include "CCLayerImpl.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 11 | #include "CCLayerTreeHostCommon.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 12 | #include "Region.h" |
[email protected] | a8461d8 | 2012-10-16 21:11:14 | [diff] [blame] | 13 | #include "cc/layer.h" |
[email protected] | 55a124d0 | 2012-10-22 03:07:13 | [diff] [blame] | 14 | #include "cc/math_util.h" |
| 15 | #include "cc/overdraw_metrics.h" |
[email protected] | 4456eee2 | 2012-10-19 18:16:38 | [diff] [blame] | 16 | #include "cc/single_thread_proxy.h" |
[email protected] | 101441ce | 2012-10-16 01:45:03 | [diff] [blame] | 17 | #include "cc/test/animation_test_common.h" |
| 18 | #include "cc/test/geometry_test_utils.h" |
| 19 | #include "cc/test/occlusion_tracker_test_common.h" |
[email protected] | 7f0c53db | 2012-10-02 00:23:18 | [diff] [blame] | 20 | #include "testing/gmock/include/gmock/gmock.h" |
| 21 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 22 | #include <public/WebFilterOperation.h> |
| 23 | #include <public/WebFilterOperations.h> |
| 24 | #include <public/WebTransformationMatrix.h> |
| 25 | |
[email protected] | 9c88e56 | 2012-09-14 22:21:30 | [diff] [blame] | 26 | using namespace cc; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 27 | using namespace WebKit; |
| 28 | using namespace WebKitTests; |
| 29 | |
| 30 | namespace { |
| 31 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 32 | class TestContentLayer : public Layer { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 33 | public: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 34 | TestContentLayer() |
| 35 | : Layer() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 36 | , m_overrideOpaqueContentsRect(false) |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | virtual bool drawsContent() const OVERRIDE { return true; } |
| 41 | virtual Region visibleContentOpaqueRegion() const OVERRIDE |
| 42 | { |
| 43 | if (m_overrideOpaqueContentsRect) |
| 44 | return intersection(m_opaqueContentsRect, visibleContentRect()); |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 45 | return Layer::visibleContentOpaqueRegion(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 46 | } |
| 47 | void setOpaqueContentsRect(const IntRect& opaqueContentsRect) |
| 48 | { |
| 49 | m_overrideOpaqueContentsRect = true; |
| 50 | m_opaqueContentsRect = opaqueContentsRect; |
| 51 | } |
| 52 | |
| 53 | private: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 54 | virtual ~TestContentLayer() |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 55 | { |
| 56 | } |
| 57 | |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 58 | bool m_overrideOpaqueContentsRect; |
| 59 | IntRect m_opaqueContentsRect; |
| 60 | }; |
| 61 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 62 | class TestContentLayerImpl : public LayerImpl { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 63 | public: |
| 64 | TestContentLayerImpl(int id) |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 65 | : LayerImpl(id) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 66 | , m_overrideOpaqueContentsRect(false) |
| 67 | { |
| 68 | setDrawsContent(true); |
| 69 | } |
| 70 | |
| 71 | virtual Region visibleContentOpaqueRegion() const OVERRIDE |
| 72 | { |
| 73 | if (m_overrideOpaqueContentsRect) |
| 74 | return intersection(m_opaqueContentsRect, visibleContentRect()); |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 75 | return LayerImpl::visibleContentOpaqueRegion(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 76 | } |
| 77 | void setOpaqueContentsRect(const IntRect& opaqueContentsRect) |
| 78 | { |
| 79 | m_overrideOpaqueContentsRect = true; |
| 80 | m_opaqueContentsRect = opaqueContentsRect; |
| 81 | } |
| 82 | |
| 83 | private: |
| 84 | bool m_overrideOpaqueContentsRect; |
| 85 | IntRect m_opaqueContentsRect; |
| 86 | }; |
| 87 | |
| 88 | template<typename LayerType, typename RenderSurfaceType> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 89 | class TestOcclusionTrackerWithClip : public TestOcclusionTrackerBase<LayerType, RenderSurfaceType> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 90 | public: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 91 | TestOcclusionTrackerWithClip(IntRect viewportRect, bool recordMetricsForFrame = false) |
| 92 | : TestOcclusionTrackerBase<LayerType, RenderSurfaceType>(viewportRect, recordMetricsForFrame) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 93 | , m_overrideLayerClipRect(false) |
| 94 | { |
| 95 | } |
| 96 | |
| 97 | void setLayerClipRect(const IntRect& rect) { m_overrideLayerClipRect = true; m_layerClipRect = rect;} |
| 98 | void useDefaultLayerClipRect() { m_overrideLayerClipRect = false; } |
| 99 | |
| 100 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 101 | virtual IntRect layerClipRectInTarget(const LayerType* layer) const { return m_overrideLayerClipRect ? m_layerClipRect : OcclusionTrackerBase<LayerType, RenderSurfaceType>::layerClipRectInTarget(layer); } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 102 | |
| 103 | private: |
| 104 | bool m_overrideLayerClipRect; |
| 105 | IntRect m_layerClipRect; |
| 106 | }; |
| 107 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 108 | struct OcclusionTrackerTestMainThreadTypes { |
| 109 | typedef Layer LayerType; |
| 110 | typedef RenderSurface RenderSurfaceType; |
| 111 | typedef TestContentLayer ContentLayerType; |
| 112 | typedef scoped_refptr<Layer> LayerPtrType; |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 113 | typedef scoped_refptr<ContentLayerType> ContentLayerPtrType; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 114 | typedef LayerIterator<Layer, std::vector<scoped_refptr<Layer> >, RenderSurface, LayerIteratorActions::FrontToBack> TestLayerIterator; |
| 115 | typedef OcclusionTracker OcclusionTrackerType; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 116 | |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 117 | static LayerPtrType createLayer() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 118 | { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 119 | return Layer::create(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 120 | } |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 121 | static ContentLayerPtrType createContentLayer() { return make_scoped_refptr(new ContentLayerType()); } |
| 122 | |
| 123 | static LayerPtrType passLayerPtr(ContentLayerPtrType& layer) |
| 124 | { |
| 125 | return layer.release(); |
| 126 | } |
| 127 | |
| 128 | static LayerPtrType passLayerPtr(LayerPtrType& layer) |
| 129 | { |
| 130 | return layer.release(); |
| 131 | } |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 132 | |
| 133 | static void destroyLayer(LayerPtrType& layer) |
| 134 | { |
| 135 | layer = NULL; |
| 136 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 137 | }; |
| 138 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 139 | struct OcclusionTrackerTestImplThreadTypes { |
| 140 | typedef LayerImpl LayerType; |
| 141 | typedef RenderSurfaceImpl RenderSurfaceType; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 142 | typedef TestContentLayerImpl ContentLayerType; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 143 | typedef scoped_ptr<LayerImpl> LayerPtrType; |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 144 | typedef scoped_ptr<ContentLayerType> ContentLayerPtrType; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 145 | typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> TestLayerIterator; |
| 146 | typedef OcclusionTrackerImpl OcclusionTrackerType; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 147 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 148 | static LayerPtrType createLayer() { return LayerImpl::create(nextLayerImplId++); } |
| 149 | static ContentLayerPtrType createContentLayer() { return make_scoped_ptr(new ContentLayerType(nextLayerImplId++)); } |
| 150 | static int nextLayerImplId; |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 151 | |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 152 | static LayerPtrType passLayerPtr(LayerPtrType& layer) |
| 153 | { |
| 154 | return layer.Pass(); |
| 155 | } |
| 156 | |
| 157 | static LayerPtrType passLayerPtr(ContentLayerPtrType& layer) |
| 158 | { |
| 159 | return layer.PassAs<LayerType>(); |
| 160 | } |
| 161 | |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 162 | static void destroyLayer(LayerPtrType& layer) |
| 163 | { |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 164 | layer.reset(); |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 165 | } |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 166 | }; |
| 167 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 168 | int OcclusionTrackerTestImplThreadTypes::nextLayerImplId = 1; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 169 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 170 | template<typename Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 171 | class OcclusionTrackerTest : public testing::Test { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 172 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 173 | OcclusionTrackerTest(bool opaqueLayers) |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 174 | : m_opaqueLayers(opaqueLayers) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 175 | { } |
| 176 | |
| 177 | virtual void runMyTest() = 0; |
| 178 | |
| 179 | virtual void TearDown() |
| 180 | { |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 181 | Types::destroyLayer(m_root); |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 182 | m_renderSurfaceLayerList.clear(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 183 | m_renderSurfaceLayerListImpl.clear(); |
| 184 | m_replicaLayers.clear(); |
| 185 | m_maskLayers.clear(); |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 186 | LayerTreeHost::setNeedsFilterContext(false); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | typename Types::ContentLayerType* createRoot(const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds) |
| 190 | { |
| 191 | typename Types::ContentLayerPtrType layer(Types::createContentLayer()); |
| 192 | typename Types::ContentLayerType* layerPtr = layer.get(); |
| 193 | setProperties(layerPtr, transform, position, bounds); |
| 194 | |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 195 | DCHECK(!m_root); |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 196 | m_root = Types::passLayerPtr(layer); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 197 | return layerPtr; |
| 198 | } |
| 199 | |
| 200 | typename Types::LayerType* createLayer(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds) |
| 201 | { |
| 202 | typename Types::LayerPtrType layer(Types::createLayer()); |
| 203 | typename Types::LayerType* layerPtr = layer.get(); |
| 204 | setProperties(layerPtr, transform, position, bounds); |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 205 | parent->addChild(Types::passLayerPtr(layer)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 206 | return layerPtr; |
| 207 | } |
| 208 | |
| 209 | typename Types::LayerType* createSurface(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds) |
| 210 | { |
| 211 | typename Types::LayerType* layer = createLayer(parent, transform, position, bounds); |
| 212 | WebFilterOperations filters; |
| 213 | filters.append(WebFilterOperation::createGrayscaleFilter(0.5)); |
| 214 | layer->setFilters(filters); |
| 215 | return layer; |
| 216 | } |
| 217 | |
| 218 | typename Types::ContentLayerType* createDrawingLayer(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds, bool opaque) |
| 219 | { |
| 220 | typename Types::ContentLayerPtrType layer(Types::createContentLayer()); |
| 221 | typename Types::ContentLayerType* layerPtr = layer.get(); |
| 222 | setProperties(layerPtr, transform, position, bounds); |
| 223 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 224 | if (m_opaqueLayers) |
[email protected] | 048634c | 2012-10-02 22:33:14 | [diff] [blame] | 225 | layerPtr->setContentsOpaque(opaque); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 226 | else { |
[email protected] | 048634c | 2012-10-02 22:33:14 | [diff] [blame] | 227 | layerPtr->setContentsOpaque(false); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 228 | if (opaque) |
| 229 | layerPtr->setOpaqueContentsRect(IntRect(IntPoint(), bounds)); |
| 230 | else |
| 231 | layerPtr->setOpaqueContentsRect(IntRect()); |
| 232 | } |
| 233 | |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 234 | parent->addChild(Types::passLayerPtr(layer)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 235 | return layerPtr; |
| 236 | } |
| 237 | |
| 238 | typename Types::LayerType* createReplicaLayer(typename Types::LayerType* owningLayer, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds) |
| 239 | { |
| 240 | typename Types::ContentLayerPtrType layer(Types::createContentLayer()); |
| 241 | typename Types::ContentLayerType* layerPtr = layer.get(); |
| 242 | setProperties(layerPtr, transform, position, bounds); |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 243 | setReplica(owningLayer, Types::passLayerPtr(layer)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 244 | return layerPtr; |
| 245 | } |
| 246 | |
| 247 | typename Types::LayerType* createMaskLayer(typename Types::LayerType* owningLayer, const IntSize& bounds) |
| 248 | { |
| 249 | typename Types::ContentLayerPtrType layer(Types::createContentLayer()); |
| 250 | typename Types::ContentLayerType* layerPtr = layer.get(); |
| 251 | setProperties(layerPtr, identityMatrix, FloatPoint(), bounds); |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 252 | setMask(owningLayer, Types::passLayerPtr(layer)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 253 | return layerPtr; |
| 254 | } |
| 255 | |
| 256 | typename Types::ContentLayerType* createDrawingSurface(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds, bool opaque) |
| 257 | { |
| 258 | typename Types::ContentLayerType* layer = createDrawingLayer(parent, transform, position, bounds, opaque); |
| 259 | WebFilterOperations filters; |
| 260 | filters.append(WebFilterOperation::createGrayscaleFilter(0.5)); |
| 261 | layer->setFilters(filters); |
| 262 | return layer; |
| 263 | } |
| 264 | |
| 265 | void calcDrawEtc(TestContentLayerImpl* root) |
| 266 | { |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 267 | DCHECK(root == m_root.get()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 268 | int dummyMaxTextureSize = 512; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 269 | LayerSorter layerSorter; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 270 | |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 271 | DCHECK(!root->renderSurface()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 272 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 273 | LayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, &layerSorter, dummyMaxTextureSize, m_renderSurfaceLayerListImpl); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 274 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 275 | m_layerIterator = m_layerIteratorBegin = Types::TestLayerIterator::begin(&m_renderSurfaceLayerListImpl); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 276 | } |
| 277 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 278 | void calcDrawEtc(TestContentLayer* root) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 279 | { |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 280 | DCHECK(root == m_root.get()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 281 | int dummyMaxTextureSize = 512; |
| 282 | |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 283 | DCHECK(!root->renderSurface()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 284 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 285 | LayerTreeHostCommon::calculateDrawTransforms(root, root->bounds(), 1, dummyMaxTextureSize, m_renderSurfaceLayerList); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 286 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 287 | m_layerIterator = m_layerIteratorBegin = Types::TestLayerIterator::begin(&m_renderSurfaceLayerList); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | void enterLayer(typename Types::LayerType* layer, typename Types::OcclusionTrackerType& occlusion) |
| 291 | { |
| 292 | ASSERT_EQ(layer, *m_layerIterator); |
| 293 | ASSERT_TRUE(m_layerIterator.representsItself()); |
| 294 | occlusion.enterLayer(m_layerIterator); |
| 295 | } |
| 296 | |
| 297 | void leaveLayer(typename Types::LayerType* layer, typename Types::OcclusionTrackerType& occlusion) |
| 298 | { |
| 299 | ASSERT_EQ(layer, *m_layerIterator); |
| 300 | ASSERT_TRUE(m_layerIterator.representsItself()); |
| 301 | occlusion.leaveLayer(m_layerIterator); |
| 302 | ++m_layerIterator; |
| 303 | } |
| 304 | |
| 305 | void visitLayer(typename Types::LayerType* layer, typename Types::OcclusionTrackerType& occlusion) |
| 306 | { |
| 307 | enterLayer(layer, occlusion); |
| 308 | leaveLayer(layer, occlusion); |
| 309 | } |
| 310 | |
| 311 | void enterContributingSurface(typename Types::LayerType* layer, typename Types::OcclusionTrackerType& occlusion) |
| 312 | { |
| 313 | ASSERT_EQ(layer, *m_layerIterator); |
| 314 | ASSERT_TRUE(m_layerIterator.representsTargetRenderSurface()); |
| 315 | occlusion.enterLayer(m_layerIterator); |
| 316 | occlusion.leaveLayer(m_layerIterator); |
| 317 | ++m_layerIterator; |
| 318 | ASSERT_TRUE(m_layerIterator.representsContributingRenderSurface()); |
| 319 | occlusion.enterLayer(m_layerIterator); |
| 320 | } |
| 321 | |
| 322 | void leaveContributingSurface(typename Types::LayerType* layer, typename Types::OcclusionTrackerType& occlusion) |
| 323 | { |
| 324 | ASSERT_EQ(layer, *m_layerIterator); |
| 325 | ASSERT_TRUE(m_layerIterator.representsContributingRenderSurface()); |
| 326 | occlusion.leaveLayer(m_layerIterator); |
| 327 | ++m_layerIterator; |
| 328 | } |
| 329 | |
| 330 | void visitContributingSurface(typename Types::LayerType* layer, typename Types::OcclusionTrackerType& occlusion) |
| 331 | { |
| 332 | enterContributingSurface(layer, occlusion); |
| 333 | leaveContributingSurface(layer, occlusion); |
| 334 | } |
| 335 | |
| 336 | void resetLayerIterator() |
| 337 | { |
| 338 | m_layerIterator = m_layerIteratorBegin; |
| 339 | } |
| 340 | |
| 341 | const WebTransformationMatrix identityMatrix; |
| 342 | |
| 343 | private: |
| 344 | void setBaseProperties(typename Types::LayerType* layer, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds) |
| 345 | { |
| 346 | layer->setTransform(transform); |
| 347 | layer->setSublayerTransform(WebTransformationMatrix()); |
| 348 | layer->setAnchorPoint(FloatPoint(0, 0)); |
| 349 | layer->setPosition(position); |
| 350 | layer->setBounds(bounds); |
| 351 | } |
| 352 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 353 | void setProperties(Layer* layer, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 354 | { |
| 355 | setBaseProperties(layer, transform, position, bounds); |
| 356 | } |
| 357 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 358 | void setProperties(LayerImpl* layer, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 359 | { |
| 360 | setBaseProperties(layer, transform, position, bounds); |
| 361 | |
| 362 | layer->setContentBounds(layer->bounds()); |
| 363 | } |
| 364 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 365 | void setReplica(Layer* owningLayer, scoped_refptr<Layer> layer) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 366 | { |
| 367 | owningLayer->setReplicaLayer(layer.get()); |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 368 | m_replicaLayers.push_back(layer); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 369 | } |
| 370 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 371 | void setReplica(LayerImpl* owningLayer, scoped_ptr<LayerImpl> layer) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 372 | { |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 373 | owningLayer->setReplicaLayer(layer.Pass()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 374 | } |
| 375 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 376 | void setMask(Layer* owningLayer, scoped_refptr<Layer> layer) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 377 | { |
| 378 | owningLayer->setMaskLayer(layer.get()); |
[email protected] | d58499a | 2012-10-09 22:27:47 | [diff] [blame] | 379 | m_maskLayers.push_back(layer); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 380 | } |
| 381 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 382 | void setMask(LayerImpl* owningLayer, scoped_ptr<LayerImpl> layer) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 383 | { |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 384 | owningLayer->setMaskLayer(layer.Pass()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 385 | } |
| 386 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 387 | bool m_opaqueLayers; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 388 | // These hold ownership of the layers for the duration of the test. |
| 389 | typename Types::LayerPtrType m_root; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 390 | std::vector<scoped_refptr<Layer> > m_renderSurfaceLayerList; |
| 391 | std::vector<LayerImpl*> m_renderSurfaceLayerListImpl; |
| 392 | typename Types::TestLayerIterator m_layerIteratorBegin; |
| 393 | typename Types::TestLayerIterator m_layerIterator; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 394 | typename Types::LayerType* m_lastLayerVisited; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 395 | std::vector<scoped_refptr<Layer> > m_replicaLayers; |
| 396 | std::vector<scoped_refptr<Layer> > m_maskLayers; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 397 | }; |
| 398 | |
| 399 | #define RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \ |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 400 | class ClassName##MainThreadOpaqueLayers : public ClassName<OcclusionTrackerTestMainThreadTypes> { \ |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 401 | public: \ |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 402 | ClassName##MainThreadOpaqueLayers() : ClassName<OcclusionTrackerTestMainThreadTypes>(true) { } \ |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 403 | }; \ |
| 404 | TEST_F(ClassName##MainThreadOpaqueLayers, runTest) { runMyTest(); } |
| 405 | #define RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName) \ |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 406 | class ClassName##MainThreadOpaquePaints : public ClassName<OcclusionTrackerTestMainThreadTypes> { \ |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 407 | public: \ |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 408 | ClassName##MainThreadOpaquePaints() : ClassName<OcclusionTrackerTestMainThreadTypes>(false) { } \ |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 409 | }; \ |
| 410 | TEST_F(ClassName##MainThreadOpaquePaints, runTest) { runMyTest(); } |
| 411 | |
| 412 | #define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 413 | class ClassName##ImplThreadOpaqueLayers : public ClassName<OcclusionTrackerTestImplThreadTypes> { \ |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 414 | DebugScopedSetImplThread impl; \ |
| 415 | public: \ |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 416 | ClassName##ImplThreadOpaqueLayers() : ClassName<OcclusionTrackerTestImplThreadTypes>(true) { } \ |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 417 | }; \ |
| 418 | TEST_F(ClassName##ImplThreadOpaqueLayers, runTest) { runMyTest(); } |
| 419 | #define RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName) \ |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 420 | class ClassName##ImplThreadOpaquePaints : public ClassName<OcclusionTrackerTestImplThreadTypes> { \ |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 421 | DebugScopedSetImplThread impl; \ |
| 422 | public: \ |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 423 | ClassName##ImplThreadOpaquePaints() : ClassName<OcclusionTrackerTestImplThreadTypes>(false) { } \ |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 424 | }; \ |
| 425 | TEST_F(ClassName##ImplThreadOpaquePaints, runTest) { runMyTest(); } |
| 426 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 427 | #define ALL_OCCLUSIONTRACKER_TEST(ClassName) \ |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 428 | RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \ |
| 429 | RUN_TEST_MAIN_THREAD_OPAQUE_PAINTS(ClassName) \ |
| 430 | RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) \ |
| 431 | RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName) |
| 432 | |
| 433 | #define MAIN_THREAD_TEST(ClassName) \ |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 434 | RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 435 | |
| 436 | #define IMPL_THREAD_TEST(ClassName) \ |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 437 | RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 438 | |
| 439 | #define MAIN_AND_IMPL_THREAD_TEST(ClassName) \ |
| 440 | RUN_TEST_MAIN_THREAD_OPAQUE_LAYERS(ClassName) \ |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 441 | RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 442 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 443 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 444 | class OcclusionTrackerTestIdentityTransforms : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 445 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 446 | OcclusionTrackerTestIdentityTransforms(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 447 | |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 448 | void runMyTest() |
| 449 | { |
| 450 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
| 451 | typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(30, 30), IntSize(500, 500), true); |
| 452 | this->calcDrawEtc(parent); |
| 453 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 454 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 455 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 456 | |
| 457 | this->visitLayer(layer, occlusion); |
| 458 | this->enterLayer(parent, occlusion); |
| 459 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 460 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 461 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 462 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 463 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 464 | |
| 465 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 30, 70, 70))); |
| 466 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 30, 70, 70))); |
| 467 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 29, 70, 70))); |
| 468 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(31, 30, 70, 70))); |
| 469 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 31, 70, 70))); |
| 470 | |
| 471 | occlusion.useDefaultLayerClipRect(); |
| 472 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 30, 70, 70))); |
| 473 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 30, 70, 70))); |
| 474 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 29, 70, 70))); |
| 475 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(31, 30, 70, 70))); |
| 476 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 31, 70, 70))); |
| 477 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 478 | |
| 479 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 30, 70, 70)).isEmpty()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 480 | EXPECT_RECT_EQ(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 30, 70, 70))); |
| 481 | EXPECT_RECT_EQ(IntRect(29, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 29, 70, 70))); |
| 482 | EXPECT_RECT_EQ(IntRect(30, 29, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 70, 70))); |
| 483 | EXPECT_RECT_EQ(IntRect(31, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 29, 70, 70))); |
| 484 | EXPECT_RECT_EQ(IntRect(100, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 30, 70, 70))); |
| 485 | EXPECT_RECT_EQ(IntRect(31, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 31, 70, 70))); |
| 486 | EXPECT_RECT_EQ(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 31, 70, 70))); |
| 487 | EXPECT_RECT_EQ(IntRect(29, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 31, 70, 70))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 488 | } |
| 489 | }; |
| 490 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 491 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestIdentityTransforms); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 492 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 493 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 494 | class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 495 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 496 | OcclusionTrackerTestRotatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 497 | void runMyTest() |
| 498 | { |
| 499 | WebTransformationMatrix layerTransform; |
| 500 | layerTransform.translate(250, 250); |
| 501 | layerTransform.rotate(90); |
| 502 | layerTransform.translate(-250, -250); |
| 503 | |
| 504 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
| 505 | typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, layerTransform, FloatPoint(30, 30), IntSize(500, 500), true); |
| 506 | this->calcDrawEtc(parent); |
| 507 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 508 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 509 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 510 | |
| 511 | this->visitLayer(layer, occlusion); |
| 512 | this->enterLayer(parent, occlusion); |
| 513 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 514 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 515 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 516 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 517 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 518 | |
| 519 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 30, 70, 70))); |
| 520 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 30, 70, 70))); |
| 521 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 29, 70, 70))); |
| 522 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(31, 30, 70, 70))); |
| 523 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 31, 70, 70))); |
| 524 | |
| 525 | occlusion.useDefaultLayerClipRect(); |
| 526 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 30, 70, 70))); |
| 527 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 30, 70, 70))); |
| 528 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 29, 70, 70))); |
| 529 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(31, 30, 70, 70))); |
| 530 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 31, 70, 70))); |
| 531 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 532 | |
| 533 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 30, 70, 70)).isEmpty()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 534 | EXPECT_RECT_EQ(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 30, 70, 70))); |
| 535 | EXPECT_RECT_EQ(IntRect(29, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 29, 70, 70))); |
| 536 | EXPECT_RECT_EQ(IntRect(30, 29, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 70, 70))); |
| 537 | EXPECT_RECT_EQ(IntRect(31, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 29, 70, 70))); |
| 538 | EXPECT_RECT_EQ(IntRect(100, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 30, 70, 70))); |
| 539 | EXPECT_RECT_EQ(IntRect(31, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 31, 70, 70))); |
| 540 | EXPECT_RECT_EQ(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 31, 70, 70))); |
| 541 | EXPECT_RECT_EQ(IntRect(29, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 31, 70, 70))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 542 | } |
| 543 | }; |
| 544 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 545 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestRotatedChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 546 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 547 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 548 | class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 549 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 550 | OcclusionTrackerTestTranslatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 551 | void runMyTest() |
| 552 | { |
| 553 | WebTransformationMatrix layerTransform; |
| 554 | layerTransform.translate(20, 20); |
| 555 | |
| 556 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
| 557 | typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, layerTransform, FloatPoint(30, 30), IntSize(500, 500), true); |
| 558 | this->calcDrawEtc(parent); |
| 559 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 560 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 561 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 562 | |
| 563 | this->visitLayer(layer, occlusion); |
| 564 | this->enterLayer(parent, occlusion); |
| 565 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 566 | EXPECT_RECT_EQ(IntRect(50, 50, 50, 50), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 567 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 568 | EXPECT_RECT_EQ(IntRect(50, 50, 50, 50), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 569 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 570 | |
| 571 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(50, 50, 50, 50))); |
| 572 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(49, 50, 50, 50))); |
| 573 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(50, 49, 50, 50))); |
| 574 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(51, 50, 50, 50))); |
| 575 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(50, 51, 50, 50))); |
| 576 | |
| 577 | occlusion.useDefaultLayerClipRect(); |
| 578 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(50, 50, 50, 50))); |
| 579 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(49, 50, 50, 50))); |
| 580 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(50, 49, 50, 50))); |
| 581 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(51, 50, 50, 50))); |
| 582 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(50, 51, 50, 50))); |
| 583 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 584 | |
| 585 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(50, 50, 50, 50)).isEmpty()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 586 | EXPECT_RECT_EQ(IntRect(49, 50, 1, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 50, 50, 50))); |
| 587 | EXPECT_RECT_EQ(IntRect(49, 49, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 49, 50, 50))); |
| 588 | EXPECT_RECT_EQ(IntRect(50, 49, 50, 1), occlusion.unoccludedContentRect(parent, IntRect(50, 49, 50, 50))); |
| 589 | EXPECT_RECT_EQ(IntRect(51, 49, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(51, 49, 50, 50))); |
| 590 | EXPECT_RECT_EQ(IntRect(100, 50, 1, 50), occlusion.unoccludedContentRect(parent, IntRect(51, 50, 50, 50))); |
| 591 | EXPECT_RECT_EQ(IntRect(51, 51, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(51, 51, 50, 50))); |
| 592 | EXPECT_RECT_EQ(IntRect(50, 100, 50, 1), occlusion.unoccludedContentRect(parent, IntRect(50, 51, 50, 50))); |
| 593 | EXPECT_RECT_EQ(IntRect(49, 51, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 51, 50, 50))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 594 | |
| 595 | occlusion.useDefaultLayerClipRect(); |
| 596 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(50, 50, 50, 50)).isEmpty()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 597 | EXPECT_RECT_EQ(IntRect(49, 50, 1, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 50, 50, 50))); |
| 598 | EXPECT_RECT_EQ(IntRect(49, 49, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 49, 50, 50))); |
| 599 | EXPECT_RECT_EQ(IntRect(50, 49, 50, 1), occlusion.unoccludedContentRect(parent, IntRect(50, 49, 50, 50))); |
| 600 | EXPECT_RECT_EQ(IntRect(51, 49, 49, 1), occlusion.unoccludedContentRect(parent, IntRect(51, 49, 50, 50))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 601 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(51, 50, 50, 50)).isEmpty()); |
| 602 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(51, 51, 50, 50)).isEmpty()); |
| 603 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(50, 51, 50, 50)).isEmpty()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 604 | EXPECT_RECT_EQ(IntRect(49, 51, 1, 49), occlusion.unoccludedContentRect(parent, IntRect(49, 51, 50, 50))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 605 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 606 | } |
| 607 | }; |
| 608 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 609 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestTranslatedChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 610 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 611 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 612 | class OcclusionTrackerTestChildInRotatedChild : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 613 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 614 | OcclusionTrackerTestChildInRotatedChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 615 | void runMyTest() |
| 616 | { |
| 617 | WebTransformationMatrix childTransform; |
| 618 | childTransform.translate(250, 250); |
| 619 | childTransform.rotate(90); |
| 620 | childTransform.translate(-250, -250); |
| 621 | |
| 622 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
[email protected] | 23bbb41 | 2012-08-30 20:03:38 | [diff] [blame] | 623 | parent->setMasksToBounds(true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 624 | typename Types::LayerType* child = this->createLayer(parent, childTransform, FloatPoint(30, 30), IntSize(500, 500)); |
| 625 | child->setMasksToBounds(true); |
| 626 | typename Types::ContentLayerType* layer = this->createDrawingLayer(child, this->identityMatrix, FloatPoint(10, 10), IntSize(500, 500), true); |
| 627 | this->calcDrawEtc(parent); |
| 628 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 629 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 630 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 631 | |
| 632 | this->visitLayer(layer, occlusion); |
| 633 | this->enterContributingSurface(child, occlusion); |
| 634 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 635 | EXPECT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 636 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 637 | EXPECT_RECT_EQ(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 638 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 639 | |
| 640 | this->leaveContributingSurface(child, occlusion); |
| 641 | this->enterLayer(parent, occlusion); |
| 642 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 643 | EXPECT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 644 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 645 | EXPECT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 646 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 647 | |
| 648 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 40, 70, 60))); |
| 649 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 40, 70, 60))); |
| 650 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 39, 70, 60))); |
| 651 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(31, 40, 70, 60))); |
| 652 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 41, 70, 60))); |
| 653 | |
| 654 | occlusion.useDefaultLayerClipRect(); |
| 655 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 40, 70, 60))); |
| 656 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 40, 70, 60))); |
| 657 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 39, 70, 60))); |
| 658 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(31, 40, 70, 60))); |
| 659 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 41, 70, 60))); |
| 660 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 661 | |
| 662 | |
| 663 | /* Justification for the above occlusion from |layer|: |
| 664 | 100 |
| 665 | +---------------------+ +---------------------+ |
| 666 | | | | |30 Visible region of |layer|: ///// |
| 667 | | 30 | rotate(90) | | |
| 668 | | 30 + ---------------------------------+ | +---------------------------------+ |
| 669 | 100 | | 10 | | ==> | | |10 | |
| 670 | | |10+---------------------------------+ | +---------------------------------+ | |
| 671 | | | | | | | | | |///////////////| 420 | | |
| 672 | | | | | | | | | |///////////////|60 | | |
| 673 | | | | | | | | | |///////////////| | | |
| 674 | +----|--|-------------+ | | +--|--|---------------+ | | |
| 675 | | | | | 20|10| 70 | | |
| 676 | | | | | | | | | |
| 677 | | | | |500 | | | | |
| 678 | | | | | | | | | |
| 679 | | | | | | | | | |
| 680 | | | | | | | | | |
| 681 | | | | | | | |10| |
| 682 | +--|-------------------------------+ | | +------------------------------|--+ |
| 683 | | | | 490 | |
| 684 | +---------------------------------+ +---------------------------------+ |
| 685 | 500 500 |
| 686 | */ |
| 687 | } |
| 688 | }; |
| 689 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 690 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestChildInRotatedChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 691 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 692 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 693 | class OcclusionTrackerTestVisitTargetTwoTimes : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 694 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 695 | OcclusionTrackerTestVisitTargetTwoTimes(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 696 | void runMyTest() |
| 697 | { |
| 698 | WebTransformationMatrix childTransform; |
| 699 | childTransform.translate(250, 250); |
| 700 | childTransform.rotate(90); |
| 701 | childTransform.translate(-250, -250); |
| 702 | |
| 703 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
[email protected] | 23bbb41 | 2012-08-30 20:03:38 | [diff] [blame] | 704 | parent->setMasksToBounds(true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 705 | typename Types::LayerType* child = this->createLayer(parent, childTransform, FloatPoint(30, 30), IntSize(500, 500)); |
| 706 | child->setMasksToBounds(true); |
| 707 | typename Types::ContentLayerType* layer = this->createDrawingLayer(child, this->identityMatrix, FloatPoint(10, 10), IntSize(500, 500), true); |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 708 | // |child2| makes |parent|'s surface get considered by OcclusionTracker first, instead of |child|'s. This exercises different code in |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 709 | // leaveToTargetRenderSurface, as the target surface has already been seen. |
| 710 | typename Types::ContentLayerType* child2 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(30, 30), IntSize(60, 20), true); |
| 711 | this->calcDrawEtc(parent); |
| 712 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 713 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 714 | occlusion.setLayerClipRect(IntRect(-10, -10, 1000, 1000)); |
| 715 | |
| 716 | this->visitLayer(child2, occlusion); |
| 717 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 718 | EXPECT_RECT_EQ(IntRect(30, 30, 60, 20), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 719 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 720 | EXPECT_RECT_EQ(IntRect(30, 30, 60, 20), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 721 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 722 | |
| 723 | this->visitLayer(layer, occlusion); |
| 724 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 725 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 726 | EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 727 | EXPECT_RECT_EQ(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 728 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 729 | |
| 730 | this->enterContributingSurface(child, occlusion); |
| 731 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 732 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 733 | EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 734 | EXPECT_RECT_EQ(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 735 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 736 | |
| 737 | // Occlusion in |child2| should get merged with the |child| surface we are leaving now. |
| 738 | this->leaveContributingSurface(child, occlusion); |
| 739 | this->enterLayer(parent, occlusion); |
| 740 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 741 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 742 | EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 743 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 744 | EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); |
| 745 | |
| 746 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 30, 70, 70))); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 747 | EXPECT_RECT_EQ(IntRect(90, 30, 10, 10), occlusion.unoccludedContentRect(parent, IntRect(30, 30, 70, 70))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 748 | |
| 749 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 30, 60, 10))); |
| 750 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 30, 60, 10))); |
| 751 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 29, 60, 10))); |
| 752 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(31, 30, 60, 10))); |
| 753 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 31, 60, 10))); |
| 754 | |
| 755 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 40, 70, 60))); |
| 756 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 40, 70, 60))); |
| 757 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 39, 70, 60))); |
| 758 | |
| 759 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 30, 60, 10)).isEmpty()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 760 | EXPECT_RECT_EQ(IntRect(29, 30, 1, 10), occlusion.unoccludedContentRect(parent, IntRect(29, 30, 60, 10))); |
| 761 | EXPECT_RECT_EQ(IntRect(30, 29, 60, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 60, 10))); |
| 762 | EXPECT_RECT_EQ(IntRect(90, 30, 1, 10), occlusion.unoccludedContentRect(parent, IntRect(31, 30, 60, 10))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 763 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 31, 60, 10)).isEmpty()); |
| 764 | |
| 765 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 40, 70, 60)).isEmpty()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 766 | EXPECT_RECT_EQ(IntRect(29, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(29, 40, 70, 60))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 767 | // This rect is mostly occluded by |child2|. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 768 | EXPECT_RECT_EQ(IntRect(90, 39, 10, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 39, 70, 60))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 769 | // This rect extends past top/right ends of |child2|. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 770 | EXPECT_RECT_EQ(IntRect(30, 29, 70, 11), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 70, 70))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 771 | // This rect extends past left/right ends of |child2|. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 772 | EXPECT_RECT_EQ(IntRect(20, 39, 80, 60), occlusion.unoccludedContentRect(parent, IntRect(20, 39, 80, 60))); |
| 773 | EXPECT_RECT_EQ(IntRect(100, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(31, 40, 70, 60))); |
| 774 | EXPECT_RECT_EQ(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 41, 70, 60))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 775 | |
| 776 | /* Justification for the above occlusion from |layer|: |
| 777 | 100 |
| 778 | +---------------------+ +---------------------+ |
| 779 | | | | |30 Visible region of |layer|: ///// |
| 780 | | 30 | rotate(90) | 30 60 | |child2|: \\\\\ |
| 781 | | 30 + ------------+--------------------+ | 30 +------------+--------------------+ |
| 782 | 100 | | 10 | | | ==> | |\\\\\\\\\\\\| |10 | |
| 783 | | |10+----------|----------------------+ | +--|\\\\\\\\\\\\|-----------------+ | |
| 784 | | + ------------+ | | | | | +------------+//| 420 | | |
| 785 | | | | | | | | | |///////////////|60 | | |
| 786 | | | | | | | | | |///////////////| | | |
| 787 | +----|--|-------------+ | | +--|--|---------------+ | | |
| 788 | | | | | 20|10| 70 | | |
| 789 | | | | | | | | | |
| 790 | | | | |500 | | | | |
| 791 | | | | | | | | | |
| 792 | | | | | | | | | |
| 793 | | | | | | | | | |
| 794 | | | | | | | |10| |
| 795 | +--|-------------------------------+ | | +------------------------------|--+ |
| 796 | | | | 490 | |
| 797 | +---------------------------------+ +---------------------------------+ |
| 798 | 500 500 |
| 799 | */ |
| 800 | } |
| 801 | }; |
| 802 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 803 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestVisitTargetTwoTimes); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 804 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 805 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 806 | class OcclusionTrackerTestSurfaceRotatedOffAxis : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 807 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 808 | OcclusionTrackerTestSurfaceRotatedOffAxis(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 809 | void runMyTest() |
| 810 | { |
| 811 | WebTransformationMatrix childTransform; |
| 812 | childTransform.translate(250, 250); |
| 813 | childTransform.rotate(95); |
| 814 | childTransform.translate(-250, -250); |
| 815 | |
| 816 | WebTransformationMatrix layerTransform; |
| 817 | layerTransform.translate(10, 10); |
| 818 | |
| 819 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
| 820 | typename Types::LayerType* child = this->createLayer(parent, childTransform, FloatPoint(30, 30), IntSize(500, 500)); |
| 821 | child->setMasksToBounds(true); |
| 822 | typename Types::ContentLayerType* layer = this->createDrawingLayer(child, layerTransform, FloatPoint(0, 0), IntSize(500, 500), true); |
| 823 | this->calcDrawEtc(parent); |
| 824 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 825 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 826 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 827 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 828 | IntRect clippedLayerInChild = MathUtil::mapClippedRect(layerTransform, layer->visibleContentRect()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 829 | |
| 830 | this->visitLayer(layer, occlusion); |
| 831 | this->enterContributingSurface(child, occlusion); |
| 832 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 833 | EXPECT_RECT_EQ(IntRect(), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 834 | EXPECT_EQ(0u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 835 | EXPECT_RECT_EQ(clippedLayerInChild, occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 836 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 837 | |
| 838 | EXPECT_TRUE(occlusion.occluded(child, clippedLayerInChild)); |
| 839 | EXPECT_TRUE(occlusion.unoccludedContentRect(child, clippedLayerInChild).isEmpty()); |
| 840 | clippedLayerInChild.move(-1, 0); |
| 841 | EXPECT_FALSE(occlusion.occluded(child, clippedLayerInChild)); |
| 842 | EXPECT_FALSE(occlusion.unoccludedContentRect(child, clippedLayerInChild).isEmpty()); |
| 843 | clippedLayerInChild.move(1, 0); |
| 844 | clippedLayerInChild.move(1, 0); |
| 845 | EXPECT_FALSE(occlusion.occluded(child, clippedLayerInChild)); |
| 846 | EXPECT_FALSE(occlusion.unoccludedContentRect(child, clippedLayerInChild).isEmpty()); |
| 847 | clippedLayerInChild.move(-1, 0); |
| 848 | clippedLayerInChild.move(0, -1); |
| 849 | EXPECT_FALSE(occlusion.occluded(child, clippedLayerInChild)); |
| 850 | EXPECT_FALSE(occlusion.unoccludedContentRect(child, clippedLayerInChild).isEmpty()); |
| 851 | clippedLayerInChild.move(0, 1); |
| 852 | clippedLayerInChild.move(0, 1); |
| 853 | EXPECT_FALSE(occlusion.occluded(child, clippedLayerInChild)); |
| 854 | EXPECT_FALSE(occlusion.unoccludedContentRect(child, clippedLayerInChild).isEmpty()); |
| 855 | clippedLayerInChild.move(0, -1); |
| 856 | |
| 857 | this->leaveContributingSurface(child, occlusion); |
| 858 | this->enterLayer(parent, occlusion); |
| 859 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 860 | EXPECT_RECT_EQ(IntRect(), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 861 | EXPECT_EQ(0u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 862 | EXPECT_RECT_EQ(IntRect(), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 863 | EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size()); |
| 864 | |
| 865 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(75, 55, 1, 1))); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 866 | EXPECT_RECT_EQ(IntRect(75, 55, 1, 1), occlusion.unoccludedContentRect(parent, IntRect(75, 55, 1, 1))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 867 | } |
| 868 | }; |
| 869 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 870 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceRotatedOffAxis); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 871 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 872 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 873 | class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 874 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 875 | OcclusionTrackerTestSurfaceWithTwoOpaqueChildren(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 876 | void runMyTest() |
| 877 | { |
| 878 | WebTransformationMatrix childTransform; |
| 879 | childTransform.translate(250, 250); |
| 880 | childTransform.rotate(90); |
| 881 | childTransform.translate(-250, -250); |
| 882 | |
| 883 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
[email protected] | 23bbb41 | 2012-08-30 20:03:38 | [diff] [blame] | 884 | parent->setMasksToBounds(true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 885 | typename Types::LayerType* child = this->createLayer(parent, childTransform, FloatPoint(30, 30), IntSize(500, 500)); |
| 886 | child->setMasksToBounds(true); |
| 887 | typename Types::ContentLayerType* layer1 = this->createDrawingLayer(child, this->identityMatrix, FloatPoint(10, 10), IntSize(500, 500), true); |
| 888 | typename Types::ContentLayerType* layer2 = this->createDrawingLayer(child, this->identityMatrix, FloatPoint(10, 450), IntSize(500, 60), true); |
| 889 | this->calcDrawEtc(parent); |
| 890 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 891 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 892 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 893 | |
| 894 | this->visitLayer(layer2, occlusion); |
| 895 | this->visitLayer(layer1, occlusion); |
| 896 | this->enterContributingSurface(child, occlusion); |
| 897 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 898 | EXPECT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 899 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 900 | EXPECT_RECT_EQ(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 901 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 902 | |
| 903 | EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 430, 60, 70))); |
| 904 | EXPECT_FALSE(occlusion.occluded(child, IntRect(9, 430, 60, 70))); |
| 905 | EXPECT_FALSE(occlusion.occluded(child, IntRect(10, 429, 60, 70))); |
| 906 | EXPECT_FALSE(occlusion.occluded(child, IntRect(11, 430, 60, 70))); |
| 907 | EXPECT_FALSE(occlusion.occluded(child, IntRect(10, 431, 60, 70))); |
| 908 | |
| 909 | EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(10, 430, 60, 70)).isEmpty()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 910 | EXPECT_RECT_EQ(IntRect(9, 430, 1, 70), occlusion.unoccludedContentRect(child, IntRect(9, 430, 60, 70))); |
| 911 | EXPECT_RECT_EQ(IntRect(10, 429, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 429, 60, 70))); |
| 912 | EXPECT_RECT_EQ(IntRect(70, 430, 1, 70), occlusion.unoccludedContentRect(child, IntRect(11, 430, 60, 70))); |
| 913 | EXPECT_RECT_EQ(IntRect(10, 500, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 431, 60, 70))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 914 | |
| 915 | this->leaveContributingSurface(child, occlusion); |
| 916 | this->enterLayer(parent, occlusion); |
| 917 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 918 | EXPECT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 919 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 920 | EXPECT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 921 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 922 | |
| 923 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 40, 70, 60))); |
| 924 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 40, 70, 60))); |
| 925 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 39, 70, 60))); |
| 926 | |
| 927 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 40, 70, 60)).isEmpty()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 928 | EXPECT_RECT_EQ(IntRect(29, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(29, 40, 70, 60))); |
| 929 | EXPECT_RECT_EQ(IntRect(30, 39, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 39, 70, 60))); |
| 930 | EXPECT_RECT_EQ(IntRect(100, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(31, 40, 70, 60))); |
| 931 | EXPECT_RECT_EQ(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 41, 70, 60))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 932 | |
| 933 | /* Justification for the above occlusion from |layer1| and |layer2|: |
| 934 | |
| 935 | +---------------------+ |
| 936 | | |30 Visible region of |layer1|: ///// |
| 937 | | | Visible region of |layer2|: \\\\\ |
| 938 | | +---------------------------------+ |
| 939 | | | |10 | |
| 940 | | +---------------+-----------------+ | |
| 941 | | | |\\\\\\\\\\\\|//| 420 | | |
| 942 | | | |\\\\\\\\\\\\|//|60 | | |
| 943 | | | |\\\\\\\\\\\\|//| | | |
| 944 | +--|--|------------|--+ | | |
| 945 | 20|10| 70 | | | |
| 946 | | | | | | |
| 947 | | | | | | |
| 948 | | | | | | |
| 949 | | | | | | |
| 950 | | | | | | |
| 951 | | | | |10| |
| 952 | | +------------|-----------------|--+ |
| 953 | | | 490 | |
| 954 | +---------------+-----------------+ |
| 955 | 60 440 |
| 956 | */ |
| 957 | } |
| 958 | }; |
| 959 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 960 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithTwoOpaqueChildren); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 961 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 962 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 963 | class OcclusionTrackerTestOverlappingSurfaceSiblings : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 964 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 965 | OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 966 | void runMyTest() |
| 967 | { |
| 968 | WebTransformationMatrix childTransform; |
| 969 | childTransform.translate(250, 250); |
| 970 | childTransform.rotate(90); |
| 971 | childTransform.translate(-250, -250); |
| 972 | |
| 973 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
[email protected] | 23bbb41 | 2012-08-30 20:03:38 | [diff] [blame] | 974 | parent->setMasksToBounds(true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 975 | typename Types::LayerType* child1 = this->createSurface(parent, childTransform, FloatPoint(30, 30), IntSize(10, 10)); |
| 976 | typename Types::LayerType* child2 = this->createSurface(parent, childTransform, FloatPoint(20, 40), IntSize(10, 10)); |
| 977 | typename Types::ContentLayerType* layer1 = this->createDrawingLayer(child1, this->identityMatrix, FloatPoint(-10, -10), IntSize(510, 510), true); |
| 978 | typename Types::ContentLayerType* layer2 = this->createDrawingLayer(child2, this->identityMatrix, FloatPoint(-10, -10), IntSize(510, 510), true); |
| 979 | this->calcDrawEtc(parent); |
| 980 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 981 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 982 | occlusion.setLayerClipRect(IntRect(-20, -20, 1000, 1000)); |
| 983 | |
| 984 | this->visitLayer(layer2, occlusion); |
| 985 | this->enterContributingSurface(child2, occlusion); |
| 986 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 987 | EXPECT_RECT_EQ(IntRect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 988 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 989 | EXPECT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 990 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 991 | |
| 992 | EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 420, 70, 80))); |
| 993 | EXPECT_FALSE(occlusion.occluded(child2, IntRect(-11, 420, 70, 80))); |
| 994 | EXPECT_FALSE(occlusion.occluded(child2, IntRect(-10, 419, 70, 80))); |
| 995 | EXPECT_FALSE(occlusion.occluded(child2, IntRect(-10, 420, 71, 80))); |
| 996 | EXPECT_FALSE(occlusion.occluded(child2, IntRect(-10, 420, 70, 81))); |
| 997 | |
| 998 | occlusion.useDefaultLayerClipRect(); |
| 999 | EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 420, 70, 80))); |
| 1000 | EXPECT_TRUE(occlusion.occluded(child2, IntRect(-11, 420, 70, 80))); |
| 1001 | EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 419, 70, 80))); |
| 1002 | EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 420, 71, 80))); |
| 1003 | EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 420, 70, 81))); |
| 1004 | occlusion.setLayerClipRect(IntRect(-20, -20, 1000, 1000)); |
| 1005 | |
| 1006 | // There is nothing above child2's surface in the z-order. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1007 | EXPECT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.unoccludedContributingSurfaceContentRect(child2, false, IntRect(-10, 420, 70, 80))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1008 | |
| 1009 | this->leaveContributingSurface(child2, occlusion); |
| 1010 | this->visitLayer(layer1, occlusion); |
| 1011 | this->enterContributingSurface(child1, occlusion); |
| 1012 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1013 | EXPECT_RECT_EQ(IntRect(20, 20, 80, 80), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1014 | EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1015 | EXPECT_RECT_EQ(IntRect(-10, 430, 80, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1016 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1017 | |
| 1018 | EXPECT_TRUE(occlusion.occluded(child1, IntRect(-10, 430, 80, 70))); |
| 1019 | EXPECT_FALSE(occlusion.occluded(child1, IntRect(-11, 430, 80, 70))); |
| 1020 | EXPECT_FALSE(occlusion.occluded(child1, IntRect(-10, 429, 80, 70))); |
| 1021 | EXPECT_FALSE(occlusion.occluded(child1, IntRect(-10, 430, 81, 70))); |
| 1022 | EXPECT_FALSE(occlusion.occluded(child1, IntRect(-10, 430, 80, 71))); |
| 1023 | |
| 1024 | // child2's contents will occlude child1 below it. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1025 | EXPECT_RECT_EQ(IntRect(-10, 430, 10, 70), occlusion.unoccludedContributingSurfaceContentRect(child1, false, IntRect(-10, 430, 80, 70))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1026 | |
| 1027 | this->leaveContributingSurface(child1, occlusion); |
| 1028 | this->enterLayer(parent, occlusion); |
| 1029 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1030 | EXPECT_RECT_EQ(IntRect(20, 20, 80, 80), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1031 | EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1032 | EXPECT_RECT_EQ(IntRect(20, 20, 80, 80), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1033 | EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1034 | |
| 1035 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(20, 20, 80, 80))); |
| 1036 | |
| 1037 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 20, 70, 80))); |
| 1038 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 20, 70, 80))); |
| 1039 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 19, 70, 80))); |
| 1040 | |
| 1041 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(20, 30, 80, 70))); |
| 1042 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(19, 30, 80, 70))); |
| 1043 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(20, 29, 80, 70))); |
| 1044 | |
| 1045 | /* Justification for the above occlusion: |
| 1046 | 100 |
| 1047 | +---------------------+ |
| 1048 | | 20 | layer1 |
| 1049 | | 30+ ---------------------------------+ |
| 1050 | 100 | 30| | layer2 | |
| 1051 | |20+----------------------------------+ | |
| 1052 | | | | | | | |
| 1053 | | | | | | | |
| 1054 | | | | | | | |
| 1055 | +--|-|----------------+ | | |
| 1056 | | | | | 510 |
| 1057 | | | | | |
| 1058 | | | | | |
| 1059 | | | | | |
| 1060 | | | | | |
| 1061 | | | | | |
| 1062 | | | | | |
| 1063 | | +--------------------------------|-+ |
| 1064 | | | |
| 1065 | +----------------------------------+ |
| 1066 | 510 |
| 1067 | */ |
| 1068 | } |
| 1069 | }; |
| 1070 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1071 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOverlappingSurfaceSiblings); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1072 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1073 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1074 | class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1075 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1076 | OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1077 | void runMyTest() |
| 1078 | { |
| 1079 | WebTransformationMatrix child1Transform; |
| 1080 | child1Transform.translate(250, 250); |
| 1081 | child1Transform.rotate(-90); |
| 1082 | child1Transform.translate(-250, -250); |
| 1083 | |
| 1084 | WebTransformationMatrix child2Transform; |
| 1085 | child2Transform.translate(250, 250); |
| 1086 | child2Transform.rotate(90); |
| 1087 | child2Transform.translate(-250, -250); |
| 1088 | |
| 1089 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
[email protected] | 23bbb41 | 2012-08-30 20:03:38 | [diff] [blame] | 1090 | parent->setMasksToBounds(true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1091 | typename Types::LayerType* child1 = this->createSurface(parent, child1Transform, FloatPoint(30, 20), IntSize(10, 10)); |
| 1092 | typename Types::LayerType* child2 = this->createDrawingSurface(parent, child2Transform, FloatPoint(20, 40), IntSize(10, 10), false); |
| 1093 | typename Types::ContentLayerType* layer1 = this->createDrawingLayer(child1, this->identityMatrix, FloatPoint(-10, -20), IntSize(510, 510), true); |
| 1094 | typename Types::ContentLayerType* layer2 = this->createDrawingLayer(child2, this->identityMatrix, FloatPoint(-10, -10), IntSize(510, 510), true); |
| 1095 | this->calcDrawEtc(parent); |
| 1096 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1097 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1098 | occlusion.setLayerClipRect(IntRect(-30, -30, 1000, 1000)); |
| 1099 | |
| 1100 | this->visitLayer(layer2, occlusion); |
| 1101 | this->enterLayer(child2, occlusion); |
| 1102 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1103 | EXPECT_RECT_EQ(IntRect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1104 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1105 | EXPECT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1106 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1107 | |
| 1108 | EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 420, 70, 80))); |
| 1109 | EXPECT_FALSE(occlusion.occluded(child2, IntRect(-11, 420, 70, 80))); |
| 1110 | EXPECT_FALSE(occlusion.occluded(child2, IntRect(-10, 419, 70, 80))); |
| 1111 | EXPECT_FALSE(occlusion.occluded(child2, IntRect(-10, 420, 71, 80))); |
| 1112 | EXPECT_FALSE(occlusion.occluded(child2, IntRect(-10, 420, 70, 81))); |
| 1113 | |
| 1114 | this->leaveLayer(child2, occlusion); |
| 1115 | this->enterContributingSurface(child2, occlusion); |
| 1116 | |
| 1117 | // There is nothing above child2's surface in the z-order. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1118 | EXPECT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.unoccludedContributingSurfaceContentRect(child2, false, IntRect(-10, 420, 70, 80))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1119 | |
| 1120 | this->leaveContributingSurface(child2, occlusion); |
| 1121 | this->visitLayer(layer1, occlusion); |
| 1122 | this->enterContributingSurface(child1, occlusion); |
| 1123 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1124 | EXPECT_RECT_EQ(IntRect(10, 20, 90, 80), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1125 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1126 | EXPECT_RECT_EQ(IntRect(420, -20, 80, 90), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1127 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1128 | |
| 1129 | EXPECT_TRUE(occlusion.occluded(child1, IntRect(420, -20, 80, 90))); |
| 1130 | EXPECT_FALSE(occlusion.occluded(child1, IntRect(419, -20, 80, 90))); |
| 1131 | EXPECT_FALSE(occlusion.occluded(child1, IntRect(420, -21, 80, 90))); |
| 1132 | EXPECT_FALSE(occlusion.occluded(child1, IntRect(420, -19, 80, 90))); |
| 1133 | EXPECT_FALSE(occlusion.occluded(child1, IntRect(421, -20, 80, 90))); |
| 1134 | |
| 1135 | // child2's contents will occlude child1 below it. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1136 | EXPECT_RECT_EQ(IntRect(420, -20, 80, 90), occlusion.unoccludedContributingSurfaceContentRect(child1, false, IntRect(420, -20, 80, 90))); |
| 1137 | EXPECT_RECT_EQ(IntRect(490, -10, 10, 80), occlusion.unoccludedContributingSurfaceContentRect(child1, false, IntRect(420, -10, 80, 90))); |
| 1138 | EXPECT_RECT_EQ(IntRect(420, -20, 70, 10), occlusion.unoccludedContributingSurfaceContentRect(child1, false, IntRect(420, -20, 70, 90))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1139 | |
| 1140 | this->leaveContributingSurface(child1, occlusion); |
| 1141 | this->enterLayer(parent, occlusion); |
| 1142 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1143 | EXPECT_RECT_EQ(IntRect(10, 20, 90, 80), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1144 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1145 | EXPECT_RECT_EQ(IntRect(10, 20, 90, 80), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1146 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1147 | |
| 1148 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(10, 20, 90, 80))); |
| 1149 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(9, 20, 90, 80))); |
| 1150 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(10, 19, 90, 80))); |
| 1151 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(11, 20, 90, 80))); |
| 1152 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(10, 21, 90, 80))); |
| 1153 | |
| 1154 | /* Justification for the above occlusion: |
| 1155 | 100 |
| 1156 | +---------------------+ |
| 1157 | |20 | layer1 |
| 1158 | 10+----------------------------------+ |
| 1159 | 100 || 30 | layer2 | |
| 1160 | |20+----------------------------------+ |
| 1161 | || | | | | |
| 1162 | || | | | | |
| 1163 | || | | | | |
| 1164 | +|-|------------------+ | | |
| 1165 | | | | | 510 |
| 1166 | | | 510 | | |
| 1167 | | | | | |
| 1168 | | | | | |
| 1169 | | | | | |
| 1170 | | | | | |
| 1171 | | | 520 | | |
| 1172 | +----------------------------------+ | |
| 1173 | | | |
| 1174 | +----------------------------------+ |
| 1175 | 510 |
| 1176 | */ |
| 1177 | } |
| 1178 | }; |
| 1179 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1180 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1181 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1182 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1183 | class OcclusionTrackerTestFilters : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1184 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1185 | OcclusionTrackerTestFilters(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1186 | void runMyTest() |
| 1187 | { |
| 1188 | WebTransformationMatrix layerTransform; |
| 1189 | layerTransform.translate(250, 250); |
| 1190 | layerTransform.rotate(90); |
| 1191 | layerTransform.translate(-250, -250); |
| 1192 | |
| 1193 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
[email protected] | 23bbb41 | 2012-08-30 20:03:38 | [diff] [blame] | 1194 | parent->setMasksToBounds(true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1195 | typename Types::ContentLayerType* blurLayer = this->createDrawingLayer(parent, layerTransform, FloatPoint(30, 30), IntSize(500, 500), true); |
| 1196 | typename Types::ContentLayerType* opaqueLayer = this->createDrawingLayer(parent, layerTransform, FloatPoint(30, 30), IntSize(500, 500), true); |
| 1197 | typename Types::ContentLayerType* opacityLayer = this->createDrawingLayer(parent, layerTransform, FloatPoint(30, 30), IntSize(500, 500), true); |
| 1198 | |
| 1199 | WebFilterOperations filters; |
| 1200 | filters.append(WebFilterOperation::createBlurFilter(10)); |
| 1201 | blurLayer->setFilters(filters); |
| 1202 | |
| 1203 | filters.clear(); |
| 1204 | filters.append(WebFilterOperation::createGrayscaleFilter(0.5)); |
| 1205 | opaqueLayer->setFilters(filters); |
| 1206 | |
| 1207 | filters.clear(); |
| 1208 | filters.append(WebFilterOperation::createOpacityFilter(0.5)); |
| 1209 | opacityLayer->setFilters(filters); |
| 1210 | |
| 1211 | this->calcDrawEtc(parent); |
| 1212 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1213 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1214 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 1215 | |
| 1216 | // Opacity layer won't contribute to occlusion. |
| 1217 | this->visitLayer(opacityLayer, occlusion); |
| 1218 | this->enterContributingSurface(opacityLayer, occlusion); |
| 1219 | |
| 1220 | EXPECT_TRUE(occlusion.occlusionInScreenSpace().isEmpty()); |
| 1221 | EXPECT_TRUE(occlusion.occlusionInTargetSurface().isEmpty()); |
| 1222 | |
| 1223 | // And has nothing to contribute to its parent surface. |
| 1224 | this->leaveContributingSurface(opacityLayer, occlusion); |
| 1225 | EXPECT_TRUE(occlusion.occlusionInScreenSpace().isEmpty()); |
| 1226 | EXPECT_TRUE(occlusion.occlusionInTargetSurface().isEmpty()); |
| 1227 | |
| 1228 | // Opaque layer will contribute to occlusion. |
| 1229 | this->visitLayer(opaqueLayer, occlusion); |
| 1230 | this->enterContributingSurface(opaqueLayer, occlusion); |
| 1231 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1232 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1233 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1234 | EXPECT_RECT_EQ(IntRect(0, 430, 70, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1235 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1236 | |
| 1237 | // And it gets translated to the parent surface. |
| 1238 | this->leaveContributingSurface(opaqueLayer, occlusion); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1239 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1240 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1241 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1242 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1243 | |
| 1244 | // The blur layer needs to throw away any occlusion from outside its subtree. |
| 1245 | this->enterLayer(blurLayer, occlusion); |
| 1246 | EXPECT_TRUE(occlusion.occlusionInScreenSpace().isEmpty()); |
| 1247 | EXPECT_TRUE(occlusion.occlusionInTargetSurface().isEmpty()); |
| 1248 | |
| 1249 | // And it won't contribute to occlusion. |
| 1250 | this->leaveLayer(blurLayer, occlusion); |
| 1251 | this->enterContributingSurface(blurLayer, occlusion); |
| 1252 | EXPECT_TRUE(occlusion.occlusionInScreenSpace().isEmpty()); |
| 1253 | EXPECT_TRUE(occlusion.occlusionInTargetSurface().isEmpty()); |
| 1254 | |
| 1255 | // But the opaque layer's occlusion is preserved on the parent. |
| 1256 | this->leaveContributingSurface(blurLayer, occlusion); |
| 1257 | this->enterLayer(parent, occlusion); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1258 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1259 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1260 | EXPECT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1261 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1262 | } |
| 1263 | }; |
| 1264 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1265 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFilters); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1266 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1267 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1268 | class OcclusionTrackerTestReplicaDoesOcclude : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1269 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1270 | OcclusionTrackerTestReplicaDoesOcclude(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1271 | void runMyTest() |
| 1272 | { |
| 1273 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 200)); |
| 1274 | typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 100), IntSize(50, 50), true); |
| 1275 | this->createReplicaLayer(surface, this->identityMatrix, FloatPoint(50, 50), IntSize()); |
| 1276 | this->calcDrawEtc(parent); |
| 1277 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1278 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1279 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 1280 | |
| 1281 | this->visitLayer(surface, occlusion); |
| 1282 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1283 | EXPECT_RECT_EQ(IntRect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1284 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1285 | EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1286 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1287 | |
| 1288 | this->visitContributingSurface(surface, occlusion); |
| 1289 | this->enterLayer(parent, occlusion); |
| 1290 | |
| 1291 | // The surface and replica should both be occluding the parent. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1292 | EXPECT_RECT_EQ(IntRect(0, 100, 100, 100), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1293 | EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1294 | } |
| 1295 | }; |
| 1296 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1297 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaDoesOcclude); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1298 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1299 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1300 | class OcclusionTrackerTestReplicaWithClipping : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1301 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1302 | OcclusionTrackerTestReplicaWithClipping(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1303 | void runMyTest() |
| 1304 | { |
| 1305 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 170)); |
[email protected] | 23bbb41 | 2012-08-30 20:03:38 | [diff] [blame] | 1306 | parent->setMasksToBounds(true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1307 | typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 100), IntSize(50, 50), true); |
| 1308 | this->createReplicaLayer(surface, this->identityMatrix, FloatPoint(50, 50), IntSize()); |
| 1309 | this->calcDrawEtc(parent); |
| 1310 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1311 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1312 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 1313 | |
| 1314 | this->visitLayer(surface, occlusion); |
| 1315 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1316 | EXPECT_RECT_EQ(IntRect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1317 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1318 | EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1319 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1320 | |
| 1321 | this->visitContributingSurface(surface, occlusion); |
| 1322 | this->enterLayer(parent, occlusion); |
| 1323 | |
| 1324 | // The surface and replica should both be occluding the parent. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1325 | EXPECT_RECT_EQ(IntRect(0, 100, 100, 70), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1326 | EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1327 | } |
| 1328 | }; |
| 1329 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1330 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithClipping); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1331 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1332 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1333 | class OcclusionTrackerTestReplicaWithMask : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1334 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1335 | OcclusionTrackerTestReplicaWithMask(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1336 | void runMyTest() |
| 1337 | { |
| 1338 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 200)); |
| 1339 | typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 100), IntSize(50, 50), true); |
| 1340 | typename Types::LayerType* replica = this->createReplicaLayer(surface, this->identityMatrix, FloatPoint(50, 50), IntSize()); |
| 1341 | this->createMaskLayer(replica, IntSize(10, 10)); |
| 1342 | this->calcDrawEtc(parent); |
| 1343 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1344 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1345 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 1346 | |
| 1347 | this->visitLayer(surface, occlusion); |
| 1348 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1349 | EXPECT_RECT_EQ(IntRect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1350 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1351 | EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1352 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1353 | |
| 1354 | this->visitContributingSurface(surface, occlusion); |
| 1355 | this->enterLayer(parent, occlusion); |
| 1356 | |
| 1357 | // The replica should not be occluding the parent, since it has a mask applied to it. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1358 | EXPECT_RECT_EQ(IntRect(0, 100, 50, 50), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1359 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1360 | } |
| 1361 | }; |
| 1362 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1363 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithMask); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1364 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1365 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1366 | class OcclusionTrackerTestLayerClipRectOutsideChild : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1367 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1368 | OcclusionTrackerTestLayerClipRectOutsideChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1369 | void runMyTest() |
| 1370 | { |
| 1371 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1372 | typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true); |
| 1373 | this->calcDrawEtc(parent); |
| 1374 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1375 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1376 | occlusion.setLayerClipRect(IntRect(200, 100, 100, 100)); |
| 1377 | |
| 1378 | this->enterLayer(layer, occlusion); |
| 1379 | |
| 1380 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 0, 100, 100))); |
| 1381 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 0, 100, 100))); |
| 1382 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 100, 100, 100))); |
| 1383 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 100, 100, 100))); |
| 1384 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(200, 100, 100, 100))); |
| 1385 | |
| 1386 | occlusion.useDefaultLayerClipRect(); |
| 1387 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(200, 100, 100, 100))); |
| 1388 | occlusion.setLayerClipRect(IntRect(200, 100, 100, 100)); |
| 1389 | |
| 1390 | this->leaveLayer(layer, occlusion); |
| 1391 | this->visitContributingSurface(layer, occlusion); |
| 1392 | this->enterLayer(parent, occlusion); |
| 1393 | |
| 1394 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 0, 100, 100))); |
| 1395 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1396 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 0, 100, 100))); |
| 1397 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1398 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 100, 100, 100))); |
| 1399 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 0, 100, 100))); |
| 1400 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 200, 100, 100))); |
| 1401 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 200, 100, 100))); |
| 1402 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 200, 100, 100))); |
| 1403 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1404 | EXPECT_RECT_EQ(IntRect(200, 100, 100, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1405 | } |
| 1406 | }; |
| 1407 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1408 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestLayerClipRectOutsideChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1409 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1410 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1411 | class OcclusionTrackerTestViewportRectOutsideChild : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1412 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1413 | OcclusionTrackerTestViewportRectOutsideChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1414 | void runMyTest() |
| 1415 | { |
| 1416 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1417 | typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true); |
| 1418 | this->calcDrawEtc(parent); |
| 1419 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1420 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(200, 100, 100, 100)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1421 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 1422 | |
| 1423 | this->enterLayer(layer, occlusion); |
| 1424 | |
| 1425 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 0, 100, 100))); |
| 1426 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 0, 100, 100))); |
| 1427 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 100, 100, 100))); |
| 1428 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 100, 100, 100))); |
| 1429 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(200, 100, 100, 100))); |
| 1430 | |
| 1431 | occlusion.useDefaultLayerClipRect(); |
| 1432 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(200, 100, 100, 100))); |
| 1433 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 1434 | |
| 1435 | this->leaveLayer(layer, occlusion); |
| 1436 | this->visitContributingSurface(layer, occlusion); |
| 1437 | this->enterLayer(parent, occlusion); |
| 1438 | |
| 1439 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 0, 100, 100))); |
| 1440 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1441 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 0, 100, 100))); |
| 1442 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1443 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 100, 100, 100))); |
| 1444 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 0, 100, 100))); |
| 1445 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 200, 100, 100))); |
| 1446 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 200, 100, 100))); |
| 1447 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 200, 100, 100))); |
| 1448 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1449 | EXPECT_RECT_EQ(IntRect(200, 100, 100, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1450 | } |
| 1451 | }; |
| 1452 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1453 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestViewportRectOutsideChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1454 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1455 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1456 | class OcclusionTrackerTestLayerClipRectOverChild : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1457 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1458 | OcclusionTrackerTestLayerClipRectOverChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1459 | void runMyTest() |
| 1460 | { |
| 1461 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1462 | typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true); |
| 1463 | this->calcDrawEtc(parent); |
| 1464 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1465 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1466 | occlusion.setLayerClipRect(IntRect(100, 100, 100, 100)); |
| 1467 | |
| 1468 | this->enterLayer(layer, occlusion); |
| 1469 | |
| 1470 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 0, 100, 100))); |
| 1471 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 100, 100, 100))); |
| 1472 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 0, 100, 100))); |
| 1473 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(100, 100, 100, 100))); |
| 1474 | |
| 1475 | this->leaveLayer(layer, occlusion); |
| 1476 | this->visitContributingSurface(layer, occlusion); |
| 1477 | this->enterLayer(parent, occlusion); |
| 1478 | |
| 1479 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 0, 100, 100))); |
| 1480 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1481 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 0, 100, 100))); |
| 1482 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 100, 100, 100))); |
| 1483 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 100, 100, 100))); |
| 1484 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 0, 100, 100))); |
| 1485 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 200, 100, 100))); |
| 1486 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 200, 100, 100))); |
| 1487 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 200, 100, 100))); |
| 1488 | |
| 1489 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)).isEmpty()); |
| 1490 | } |
| 1491 | }; |
| 1492 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1493 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestLayerClipRectOverChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1494 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1495 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1496 | class OcclusionTrackerTestViewportRectOverChild : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1497 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1498 | OcclusionTrackerTestViewportRectOverChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1499 | void runMyTest() |
| 1500 | { |
| 1501 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1502 | typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true); |
| 1503 | this->calcDrawEtc(parent); |
| 1504 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1505 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(100, 100, 100, 100)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1506 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 1507 | |
| 1508 | this->enterLayer(layer, occlusion); |
| 1509 | |
| 1510 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 0, 100, 100))); |
| 1511 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 100, 100, 100))); |
| 1512 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 0, 100, 100))); |
| 1513 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(100, 100, 100, 100))); |
| 1514 | |
| 1515 | this->leaveLayer(layer, occlusion); |
| 1516 | this->visitContributingSurface(layer, occlusion); |
| 1517 | this->enterLayer(parent, occlusion); |
| 1518 | |
| 1519 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 0, 100, 100))); |
| 1520 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1521 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 0, 100, 100))); |
| 1522 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 100, 100, 100))); |
| 1523 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 100, 100, 100))); |
| 1524 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 0, 100, 100))); |
| 1525 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 200, 100, 100))); |
| 1526 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 200, 100, 100))); |
| 1527 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 200, 100, 100))); |
| 1528 | |
| 1529 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)).isEmpty()); |
| 1530 | } |
| 1531 | }; |
| 1532 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1533 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestViewportRectOverChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1534 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1535 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1536 | class OcclusionTrackerTestLayerClipRectPartlyOverChild : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1537 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1538 | OcclusionTrackerTestLayerClipRectPartlyOverChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1539 | void runMyTest() |
| 1540 | { |
| 1541 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1542 | typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true); |
| 1543 | this->calcDrawEtc(parent); |
| 1544 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1545 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1546 | occlusion.setLayerClipRect(IntRect(50, 50, 200, 200)); |
| 1547 | |
| 1548 | this->enterLayer(layer, occlusion); |
| 1549 | |
| 1550 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(0, 0, 100, 100))); |
| 1551 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(0, 100, 100, 100))); |
| 1552 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(100, 0, 100, 100))); |
| 1553 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(100, 100, 100, 100))); |
| 1554 | |
| 1555 | this->leaveLayer(layer, occlusion); |
| 1556 | this->visitContributingSurface(layer, occlusion); |
| 1557 | this->enterLayer(parent, occlusion); |
| 1558 | |
| 1559 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 0, 100, 100))); |
| 1560 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1561 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 0, 100, 100))); |
| 1562 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 100, 100, 100))); |
| 1563 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 100, 100, 100))); |
| 1564 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 0, 100, 100))); |
| 1565 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(0, 200, 100, 100))); |
| 1566 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(100, 200, 100, 100))); |
| 1567 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 200, 100, 100))); |
| 1568 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1569 | EXPECT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300))); |
| 1570 | EXPECT_RECT_EQ(IntRect(200, 50, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 100))); |
| 1571 | EXPECT_RECT_EQ(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 100, 300, 100))); |
| 1572 | EXPECT_RECT_EQ(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(200, 100, 100, 100))); |
| 1573 | EXPECT_RECT_EQ(IntRect(100, 200, 100, 50), occlusion.unoccludedContentRect(parent, IntRect(100, 200, 100, 100))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1574 | } |
| 1575 | }; |
| 1576 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1577 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestLayerClipRectPartlyOverChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1578 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1579 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1580 | class OcclusionTrackerTestViewportRectPartlyOverChild : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1581 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1582 | OcclusionTrackerTestViewportRectPartlyOverChild(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1583 | void runMyTest() |
| 1584 | { |
| 1585 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1586 | typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true); |
| 1587 | this->calcDrawEtc(parent); |
| 1588 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1589 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(50, 50, 200, 200)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1590 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 1591 | |
| 1592 | this->enterLayer(layer, occlusion); |
| 1593 | |
| 1594 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(0, 0, 100, 100))); |
| 1595 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(0, 100, 100, 100))); |
| 1596 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(100, 0, 100, 100))); |
| 1597 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(100, 100, 100, 100))); |
| 1598 | |
| 1599 | this->leaveLayer(layer, occlusion); |
| 1600 | this->visitContributingSurface(layer, occlusion); |
| 1601 | this->enterLayer(parent, occlusion); |
| 1602 | |
| 1603 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 0, 100, 100))); |
| 1604 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1605 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 0, 100, 100))); |
| 1606 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 100, 100, 100))); |
| 1607 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 100, 100, 100))); |
| 1608 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 0, 100, 100))); |
| 1609 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(0, 200, 100, 100))); |
| 1610 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(100, 200, 100, 100))); |
| 1611 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 200, 100, 100))); |
| 1612 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1613 | EXPECT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300))); |
| 1614 | EXPECT_RECT_EQ(IntRect(200, 50, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 100))); |
| 1615 | EXPECT_RECT_EQ(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 100, 300, 100))); |
| 1616 | EXPECT_RECT_EQ(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(200, 100, 100, 100))); |
| 1617 | EXPECT_RECT_EQ(IntRect(100, 200, 100, 50), occlusion.unoccludedContentRect(parent, IntRect(100, 200, 100, 100))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1618 | } |
| 1619 | }; |
| 1620 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1621 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestViewportRectPartlyOverChild); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1622 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1623 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1624 | class OcclusionTrackerTestLayerClipRectOverNothing : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1625 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1626 | OcclusionTrackerTestLayerClipRectOverNothing(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1627 | void runMyTest() |
| 1628 | { |
| 1629 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1630 | typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true); |
| 1631 | this->calcDrawEtc(parent); |
| 1632 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1633 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1634 | occlusion.setLayerClipRect(IntRect(500, 500, 100, 100)); |
| 1635 | |
| 1636 | this->enterLayer(layer, occlusion); |
| 1637 | |
| 1638 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 0, 100, 100))); |
| 1639 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 100, 100, 100))); |
| 1640 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 0, 100, 100))); |
| 1641 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 100, 100, 100))); |
| 1642 | |
| 1643 | this->leaveLayer(layer, occlusion); |
| 1644 | this->visitContributingSurface(layer, occlusion); |
| 1645 | this->enterLayer(parent, occlusion); |
| 1646 | |
| 1647 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 0, 100, 100))); |
| 1648 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1649 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 0, 100, 100))); |
| 1650 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 100, 100, 100))); |
| 1651 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 100, 100, 100))); |
| 1652 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 0, 100, 100))); |
| 1653 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 200, 100, 100))); |
| 1654 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 200, 100, 100))); |
| 1655 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 200, 100, 100))); |
| 1656 | |
| 1657 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)).isEmpty()); |
| 1658 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 100)).isEmpty()); |
| 1659 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(0, 100, 300, 100)).isEmpty()); |
| 1660 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(200, 100, 100, 100)).isEmpty()); |
| 1661 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(100, 200, 100, 100)).isEmpty()); |
| 1662 | } |
| 1663 | }; |
| 1664 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1665 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestLayerClipRectOverNothing); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1666 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1667 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1668 | class OcclusionTrackerTestViewportRectOverNothing : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1669 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1670 | OcclusionTrackerTestViewportRectOverNothing(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1671 | void runMyTest() |
| 1672 | { |
| 1673 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1674 | typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true); |
| 1675 | this->calcDrawEtc(parent); |
| 1676 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1677 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(500, 500, 100, 100)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1678 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 1679 | |
| 1680 | this->enterLayer(layer, occlusion); |
| 1681 | |
| 1682 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 0, 100, 100))); |
| 1683 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(0, 100, 100, 100))); |
| 1684 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 0, 100, 100))); |
| 1685 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(100, 100, 100, 100))); |
| 1686 | |
| 1687 | this->leaveLayer(layer, occlusion); |
| 1688 | this->visitContributingSurface(layer, occlusion); |
| 1689 | this->enterLayer(parent, occlusion); |
| 1690 | |
| 1691 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 0, 100, 100))); |
| 1692 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1693 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 0, 100, 100))); |
| 1694 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 100, 100, 100))); |
| 1695 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 100, 100, 100))); |
| 1696 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 0, 100, 100))); |
| 1697 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(0, 200, 100, 100))); |
| 1698 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 200, 100, 100))); |
| 1699 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 200, 100, 100))); |
| 1700 | |
| 1701 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)).isEmpty()); |
| 1702 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 100)).isEmpty()); |
| 1703 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(0, 100, 300, 100)).isEmpty()); |
| 1704 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(200, 100, 100, 100)).isEmpty()); |
| 1705 | EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(100, 200, 100, 100)).isEmpty()); |
| 1706 | } |
| 1707 | }; |
| 1708 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1709 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestViewportRectOverNothing); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1710 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1711 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1712 | class OcclusionTrackerTestLayerClipRectForLayerOffOrigin : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1713 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1714 | OcclusionTrackerTestLayerClipRectForLayerOffOrigin(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1715 | void runMyTest() |
| 1716 | { |
| 1717 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1718 | typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), true); |
| 1719 | this->calcDrawEtc(parent); |
| 1720 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1721 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1722 | this->enterLayer(layer, occlusion); |
| 1723 | |
| 1724 | // This layer is translated when drawn into its target. So if the clip rect given from the target surface |
| 1725 | // is not in that target space, then after translating these query rects into the target, they will fall outside |
| 1726 | // the clip and be considered occluded. |
| 1727 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(0, 0, 100, 100))); |
| 1728 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(0, 100, 100, 100))); |
| 1729 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(100, 0, 100, 100))); |
| 1730 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(100, 100, 100, 100))); |
| 1731 | } |
| 1732 | }; |
| 1733 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1734 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestLayerClipRectForLayerOffOrigin); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1735 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1736 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1737 | class OcclusionTrackerTestOpaqueContentsRegionEmpty : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1738 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1739 | OcclusionTrackerTestOpaqueContentsRegionEmpty(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1740 | void runMyTest() |
| 1741 | { |
| 1742 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1743 | typename Types::ContentLayerType* layer = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 200), false); |
| 1744 | this->calcDrawEtc(parent); |
| 1745 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1746 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1747 | this->enterLayer(layer, occlusion); |
| 1748 | |
| 1749 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(0, 0, 100, 100))); |
| 1750 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(100, 0, 100, 100))); |
| 1751 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(0, 100, 100, 100))); |
| 1752 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(100, 100, 100, 100))); |
| 1753 | |
| 1754 | // Occluded since its outside the surface bounds. |
| 1755 | EXPECT_TRUE(occlusion.occluded(layer, IntRect(200, 100, 100, 100))); |
| 1756 | |
| 1757 | // Test without any clip rect. |
| 1758 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 1759 | EXPECT_FALSE(occlusion.occluded(layer, IntRect(200, 100, 100, 100))); |
| 1760 | occlusion.useDefaultLayerClipRect(); |
| 1761 | |
| 1762 | this->leaveLayer(layer, occlusion); |
| 1763 | this->visitContributingSurface(layer, occlusion); |
| 1764 | this->enterLayer(parent, occlusion); |
| 1765 | |
| 1766 | EXPECT_TRUE(occlusion.occlusionInScreenSpace().bounds().isEmpty()); |
| 1767 | EXPECT_EQ(0u, occlusion.occlusionInScreenSpace().rects().size()); |
| 1768 | } |
| 1769 | }; |
| 1770 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1771 | MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1772 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1773 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1774 | class OcclusionTrackerTestOpaqueContentsRegionNonEmpty : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1775 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1776 | OcclusionTrackerTestOpaqueContentsRegionNonEmpty(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1777 | void runMyTest() |
| 1778 | { |
| 1779 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1780 | typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(100, 100), IntSize(200, 200), false); |
| 1781 | this->calcDrawEtc(parent); |
| 1782 | |
| 1783 | { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1784 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1785 | layer->setOpaqueContentsRect(IntRect(0, 0, 100, 100)); |
| 1786 | |
| 1787 | this->resetLayerIterator(); |
| 1788 | this->visitLayer(layer, occlusion); |
| 1789 | this->enterLayer(parent, occlusion); |
| 1790 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1791 | EXPECT_RECT_EQ(IntRect(100, 100, 100, 100), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1792 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
| 1793 | |
| 1794 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1795 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 100, 100, 100))); |
| 1796 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 200, 100, 100))); |
| 1797 | } |
| 1798 | |
| 1799 | { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1800 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1801 | layer->setOpaqueContentsRect(IntRect(20, 20, 180, 180)); |
| 1802 | |
| 1803 | this->resetLayerIterator(); |
| 1804 | this->visitLayer(layer, occlusion); |
| 1805 | this->enterLayer(parent, occlusion); |
| 1806 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1807 | EXPECT_RECT_EQ(IntRect(120, 120, 180, 180), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1808 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
| 1809 | |
| 1810 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1811 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(100, 100, 100, 100))); |
| 1812 | EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 200, 100, 100))); |
| 1813 | } |
| 1814 | |
| 1815 | { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1816 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1817 | layer->setOpaqueContentsRect(IntRect(150, 150, 100, 100)); |
| 1818 | |
| 1819 | this->resetLayerIterator(); |
| 1820 | this->visitLayer(layer, occlusion); |
| 1821 | this->enterLayer(parent, occlusion); |
| 1822 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1823 | EXPECT_RECT_EQ(IntRect(250, 250, 50, 50), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1824 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
| 1825 | |
| 1826 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(0, 100, 100, 100))); |
| 1827 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(100, 100, 100, 100))); |
| 1828 | EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 200, 100, 100))); |
| 1829 | } |
| 1830 | } |
| 1831 | }; |
| 1832 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1833 | MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionNonEmpty); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1834 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1835 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1836 | class OcclusionTrackerTest3dTransform : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1837 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1838 | OcclusionTrackerTest3dTransform(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1839 | void runMyTest() |
| 1840 | { |
| 1841 | WebTransformationMatrix transform; |
| 1842 | transform.rotate3d(0, 30, 0); |
| 1843 | |
| 1844 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1845 | typename Types::LayerType* container = this->createLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1846 | typename Types::ContentLayerType* layer = this->createDrawingLayer(container, transform, FloatPoint(100, 100), IntSize(200, 200), true); |
| 1847 | this->calcDrawEtc(parent); |
| 1848 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1849 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1850 | this->enterLayer(layer, occlusion); |
| 1851 | |
| 1852 | // The layer is rotated in 3d but without preserving 3d, so it only gets resized. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1853 | EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), occlusion.unoccludedContentRect(layer, IntRect(0, 0, 200, 200))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1854 | } |
| 1855 | }; |
| 1856 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1857 | MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTest3dTransform); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1858 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1859 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1860 | class OcclusionTrackerTestUnsorted3dLayers : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1861 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1862 | OcclusionTrackerTestUnsorted3dLayers(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1863 | void runMyTest() |
| 1864 | { |
| 1865 | // Currently, the main thread layer iterator does not iterate over 3d items in |
| 1866 | // sorted order, because layer sorting is not performed on the main thread. |
| 1867 | // Because of this, the occlusion tracker cannot assume that a 3d layer occludes |
| 1868 | // other layers that have not yet been iterated over. For now, the expected |
| 1869 | // behavior is that a 3d layer simply does not add any occlusion to the occlusion |
| 1870 | // tracker. |
| 1871 | |
| 1872 | WebTransformationMatrix translationToFront; |
| 1873 | translationToFront.translate3d(0, 0, -10); |
| 1874 | WebTransformationMatrix translationToBack; |
| 1875 | translationToFront.translate3d(0, 0, -100); |
| 1876 | |
| 1877 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1878 | typename Types::ContentLayerType* child1 = this->createDrawingLayer(parent, translationToBack, FloatPoint(0, 0), IntSize(100, 100), true); |
| 1879 | typename Types::ContentLayerType* child2 = this->createDrawingLayer(parent, translationToFront, FloatPoint(50, 50), IntSize(100, 100), true); |
| 1880 | parent->setPreserves3D(true); |
| 1881 | |
| 1882 | this->calcDrawEtc(parent); |
| 1883 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1884 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1885 | this->visitLayer(child2, occlusion); |
| 1886 | EXPECT_TRUE(occlusion.occlusionInScreenSpace().isEmpty()); |
| 1887 | EXPECT_TRUE(occlusion.occlusionInTargetSurface().isEmpty()); |
| 1888 | |
| 1889 | this->visitLayer(child1, occlusion); |
| 1890 | EXPECT_TRUE(occlusion.occlusionInScreenSpace().isEmpty()); |
| 1891 | EXPECT_TRUE(occlusion.occlusionInTargetSurface().isEmpty()); |
| 1892 | } |
| 1893 | }; |
| 1894 | |
| 1895 | // This test will have different layer ordering on the impl thread; the test will only work on the main thread. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1896 | MAIN_THREAD_TEST(OcclusionTrackerTestUnsorted3dLayers); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1897 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1898 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1899 | class OcclusionTrackerTestPerspectiveTransform : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1900 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1901 | OcclusionTrackerTestPerspectiveTransform(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1902 | void runMyTest() |
| 1903 | { |
| 1904 | WebTransformationMatrix transform; |
| 1905 | transform.translate(150, 150); |
| 1906 | transform.applyPerspective(400); |
| 1907 | transform.rotate3d(1, 0, 0, -30); |
| 1908 | transform.translate(-150, -150); |
| 1909 | |
| 1910 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1911 | typename Types::LayerType* container = this->createLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 1912 | typename Types::ContentLayerType* layer = this->createDrawingLayer(container, transform, FloatPoint(100, 100), IntSize(200, 200), true); |
| 1913 | container->setPreserves3D(true); |
| 1914 | layer->setPreserves3D(true); |
| 1915 | this->calcDrawEtc(parent); |
| 1916 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1917 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1918 | this->enterLayer(layer, occlusion); |
| 1919 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 1920 | EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), occlusion.unoccludedContentRect(layer, IntRect(0, 0, 200, 200))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1921 | } |
| 1922 | }; |
| 1923 | |
| 1924 | // This test requires accumulating occlusion of 3d layers, which are skipped by the occlusion tracker on the main thread. So this test should run on the impl thread. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1925 | IMPL_THREAD_TEST(OcclusionTrackerTestPerspectiveTransform); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1926 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1927 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1928 | class OcclusionTrackerTestPerspectiveTransformBehindCamera : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1929 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1930 | OcclusionTrackerTestPerspectiveTransformBehindCamera(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1931 | void runMyTest() |
| 1932 | { |
| 1933 | // This test is based on the platform/chromium/compositing/3d-corners.html layout test. |
| 1934 | WebTransformationMatrix transform; |
| 1935 | transform.translate(250, 50); |
| 1936 | transform.applyPerspective(10); |
| 1937 | transform.translate(-250, -50); |
| 1938 | transform.translate(250, 50); |
| 1939 | transform.rotate3d(1, 0, 0, -167); |
| 1940 | transform.translate(-250, -50); |
| 1941 | |
| 1942 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(500, 100)); |
| 1943 | typename Types::LayerType* container = this->createLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(500, 500)); |
| 1944 | typename Types::ContentLayerType* layer = this->createDrawingLayer(container, transform, FloatPoint(0, 0), IntSize(500, 500), true); |
| 1945 | container->setPreserves3D(true); |
| 1946 | layer->setPreserves3D(true); |
| 1947 | this->calcDrawEtc(parent); |
| 1948 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1949 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1950 | this->enterLayer(layer, occlusion); |
| 1951 | |
| 1952 | // The bottom 11 pixel rows of this layer remain visible inside the container, after translation to the target surface. When translated back, |
| 1953 | // this will include many more pixels but must include at least the bottom 11 rows. |
| 1954 | EXPECT_TRUE(occlusion.unoccludedContentRect(layer, IntRect(0, 0, 500, 500)).contains(IntRect(0, 489, 500, 11))); |
| 1955 | } |
| 1956 | }; |
| 1957 | |
| 1958 | // This test requires accumulating occlusion of 3d layers, which are skipped by the occlusion tracker on the main thread. So this test should run on the impl thread. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1959 | IMPL_THREAD_TEST(OcclusionTrackerTestPerspectiveTransformBehindCamera); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1960 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1961 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1962 | class OcclusionTrackerTestLayerBehindCameraDoesNotOcclude : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1963 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1964 | OcclusionTrackerTestLayerBehindCameraDoesNotOcclude(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1965 | void runMyTest() |
| 1966 | { |
| 1967 | WebTransformationMatrix transform; |
| 1968 | transform.translate(50, 50); |
| 1969 | transform.applyPerspective(100); |
| 1970 | transform.translate3d(0, 0, 110); |
| 1971 | transform.translate(-50, -50); |
| 1972 | |
| 1973 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
| 1974 | typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, transform, FloatPoint(0, 0), IntSize(100, 100), true); |
| 1975 | parent->setPreserves3D(true); |
| 1976 | layer->setPreserves3D(true); |
| 1977 | this->calcDrawEtc(parent); |
| 1978 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1979 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1980 | |
| 1981 | // The |layer| is entirely behind the camera and should not occlude. |
| 1982 | this->visitLayer(layer, occlusion); |
| 1983 | this->enterLayer(parent, occlusion); |
| 1984 | EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size()); |
| 1985 | EXPECT_EQ(0u, occlusion.occlusionInScreenSpace().rects().size()); |
| 1986 | } |
| 1987 | }; |
| 1988 | |
| 1989 | // This test requires accumulating occlusion of 3d layers, which are skipped by the occlusion tracker on the main thread. So this test should run on the impl thread. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1990 | IMPL_THREAD_TEST(OcclusionTrackerTestLayerBehindCameraDoesNotOcclude); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1991 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 1992 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1993 | class OcclusionTrackerTestLargePixelsOccludeInsideClipRect : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1994 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 1995 | OcclusionTrackerTestLargePixelsOccludeInsideClipRect(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 1996 | void runMyTest() |
| 1997 | { |
| 1998 | WebTransformationMatrix transform; |
| 1999 | transform.translate(50, 50); |
| 2000 | transform.applyPerspective(100); |
| 2001 | transform.translate3d(0, 0, 99); |
| 2002 | transform.translate(-50, -50); |
| 2003 | |
| 2004 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100)); |
[email protected] | 23bbb41 | 2012-08-30 20:03:38 | [diff] [blame] | 2005 | parent->setMasksToBounds(true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2006 | typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, transform, FloatPoint(0, 0), IntSize(100, 100), true); |
| 2007 | parent->setPreserves3D(true); |
| 2008 | layer->setPreserves3D(true); |
| 2009 | this->calcDrawEtc(parent); |
| 2010 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2011 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2012 | |
| 2013 | // This is very close to the camera, so pixels in its visibleContentRect will actually go outside of the layer's clipRect. |
| 2014 | // Ensure that those pixels don't occlude things outside the clipRect. |
| 2015 | this->visitLayer(layer, occlusion); |
| 2016 | this->enterLayer(parent, occlusion); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2017 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2018 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2019 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2020 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
| 2021 | } |
| 2022 | }; |
| 2023 | |
| 2024 | // This test requires accumulating occlusion of 3d layers, which are skipped by the occlusion tracker on the main thread. So this test should run on the impl thread. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2025 | IMPL_THREAD_TEST(OcclusionTrackerTestLargePixelsOccludeInsideClipRect); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2026 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2027 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2028 | class OcclusionTrackerTestAnimationOpacity1OnMainThread : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2029 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2030 | OcclusionTrackerTestAnimationOpacity1OnMainThread(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2031 | void runMyTest() |
| 2032 | { |
| 2033 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 2034 | typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300), true); |
| 2035 | typename Types::ContentLayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300), true); |
| 2036 | typename Types::ContentLayerType* surfaceChild = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 300), true); |
| 2037 | typename Types::ContentLayerType* surfaceChild2 = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true); |
| 2038 | typename Types::ContentLayerType* parent2 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false); |
| 2039 | typename Types::ContentLayerType* topmost = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(250, 0), IntSize(50, 300), true); |
| 2040 | |
| 2041 | addOpacityTransitionToController(*layer->layerAnimationController(), 10, 0, 1, false); |
| 2042 | addOpacityTransitionToController(*surface->layerAnimationController(), 10, 0, 1, false); |
| 2043 | this->calcDrawEtc(parent); |
| 2044 | |
| 2045 | EXPECT_TRUE(layer->drawOpacityIsAnimating()); |
| 2046 | EXPECT_FALSE(surface->drawOpacityIsAnimating()); |
| 2047 | EXPECT_TRUE(surface->renderSurface()->drawOpacityIsAnimating()); |
| 2048 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2049 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2050 | |
| 2051 | this->visitLayer(topmost, occlusion); |
| 2052 | this->enterLayer(parent2, occlusion); |
| 2053 | // This occlusion will affect all surfaces. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2054 | EXPECT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent2, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2055 | this->leaveLayer(parent2, occlusion); |
| 2056 | |
| 2057 | this->visitLayer(surfaceChild2, occlusion); |
| 2058 | this->enterLayer(surfaceChild, occlusion); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2059 | EXPECT_RECT_EQ(IntRect(100, 0, 100, 300), occlusion.unoccludedContentRect(surfaceChild, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2060 | this->leaveLayer(surfaceChild, occlusion); |
| 2061 | this->enterLayer(surface, occlusion); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2062 | EXPECT_RECT_EQ(IntRect(200, 0, 50, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2063 | this->leaveLayer(surface, occlusion); |
| 2064 | |
| 2065 | this->enterContributingSurface(surface, occlusion); |
| 2066 | // Occlusion within the surface is lost when leaving the animating surface. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2067 | EXPECT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2068 | this->leaveContributingSurface(surface, occlusion); |
| 2069 | |
| 2070 | this->visitLayer(layer, occlusion); |
| 2071 | this->enterLayer(parent, occlusion); |
| 2072 | |
| 2073 | // Occlusion is not added for the animating |layer|. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2074 | EXPECT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2075 | } |
| 2076 | }; |
| 2077 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2078 | MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity1OnMainThread); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2079 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2080 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2081 | class OcclusionTrackerTestAnimationOpacity0OnMainThread : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2082 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2083 | OcclusionTrackerTestAnimationOpacity0OnMainThread(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2084 | void runMyTest() |
| 2085 | { |
| 2086 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 2087 | typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300), true); |
| 2088 | typename Types::ContentLayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300), true); |
| 2089 | typename Types::ContentLayerType* surfaceChild = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 300), true); |
| 2090 | typename Types::ContentLayerType* surfaceChild2 = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true); |
| 2091 | typename Types::ContentLayerType* parent2 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300), false); |
| 2092 | typename Types::ContentLayerType* topmost = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(250, 0), IntSize(50, 300), true); |
| 2093 | |
| 2094 | addOpacityTransitionToController(*layer->layerAnimationController(), 10, 1, 0, false); |
| 2095 | addOpacityTransitionToController(*surface->layerAnimationController(), 10, 1, 0, false); |
| 2096 | this->calcDrawEtc(parent); |
| 2097 | |
| 2098 | EXPECT_TRUE(layer->drawOpacityIsAnimating()); |
| 2099 | EXPECT_FALSE(surface->drawOpacityIsAnimating()); |
| 2100 | EXPECT_TRUE(surface->renderSurface()->drawOpacityIsAnimating()); |
| 2101 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2102 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2103 | |
| 2104 | this->visitLayer(topmost, occlusion); |
| 2105 | this->enterLayer(parent2, occlusion); |
| 2106 | // This occlusion will affect all surfaces. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2107 | EXPECT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2108 | this->leaveLayer(parent2, occlusion); |
| 2109 | |
| 2110 | this->visitLayer(surfaceChild2, occlusion); |
| 2111 | this->enterLayer(surfaceChild, occlusion); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2112 | EXPECT_RECT_EQ(IntRect(100, 0, 100, 300), occlusion.unoccludedContentRect(surfaceChild, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2113 | this->leaveLayer(surfaceChild, occlusion); |
| 2114 | this->enterLayer(surface, occlusion); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2115 | EXPECT_RECT_EQ(IntRect(200, 0, 50, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2116 | this->leaveLayer(surface, occlusion); |
| 2117 | |
| 2118 | this->enterContributingSurface(surface, occlusion); |
| 2119 | // Occlusion within the surface is lost when leaving the animating surface. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2120 | EXPECT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2121 | this->leaveContributingSurface(surface, occlusion); |
| 2122 | |
| 2123 | this->visitLayer(layer, occlusion); |
| 2124 | this->enterLayer(parent, occlusion); |
| 2125 | |
| 2126 | // Occlusion is not added for the animating |layer|. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2127 | EXPECT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2128 | } |
| 2129 | }; |
| 2130 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2131 | MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity0OnMainThread); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2132 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2133 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2134 | class OcclusionTrackerTestAnimationTranslateOnMainThread : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2135 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2136 | OcclusionTrackerTestAnimationTranslateOnMainThread(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2137 | void runMyTest() |
| 2138 | { |
| 2139 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
| 2140 | typename Types::ContentLayerType* layer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300), true); |
| 2141 | typename Types::ContentLayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300), true); |
| 2142 | typename Types::ContentLayerType* surfaceChild = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(200, 300), true); |
| 2143 | typename Types::ContentLayerType* surfaceChild2 = this->createDrawingLayer(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true); |
| 2144 | typename Types::ContentLayerType* surface2 = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(50, 300), true); |
| 2145 | |
| 2146 | addAnimatedTransformToController(*layer->layerAnimationController(), 10, 30, 0); |
| 2147 | addAnimatedTransformToController(*surface->layerAnimationController(), 10, 30, 0); |
| 2148 | addAnimatedTransformToController(*surfaceChild->layerAnimationController(), 10, 30, 0); |
| 2149 | this->calcDrawEtc(parent); |
| 2150 | |
| 2151 | EXPECT_TRUE(layer->drawTransformIsAnimating()); |
| 2152 | EXPECT_TRUE(layer->screenSpaceTransformIsAnimating()); |
| 2153 | EXPECT_TRUE(surface->renderSurface()->targetSurfaceTransformsAreAnimating()); |
| 2154 | EXPECT_TRUE(surface->renderSurface()->screenSpaceTransformsAreAnimating()); |
| 2155 | // The surface owning layer doesn't animate against its own surface. |
| 2156 | EXPECT_FALSE(surface->drawTransformIsAnimating()); |
| 2157 | EXPECT_TRUE(surface->screenSpaceTransformIsAnimating()); |
| 2158 | EXPECT_TRUE(surfaceChild->drawTransformIsAnimating()); |
| 2159 | EXPECT_TRUE(surfaceChild->screenSpaceTransformIsAnimating()); |
| 2160 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2161 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2162 | |
| 2163 | this->visitLayer(surface2, occlusion); |
| 2164 | this->enterContributingSurface(surface2, occlusion); |
| 2165 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2166 | EXPECT_RECT_EQ(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2167 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
| 2168 | |
| 2169 | this->leaveContributingSurface(surface2, occlusion); |
| 2170 | this->enterLayer(surfaceChild2, occlusion); |
| 2171 | |
| 2172 | // surfaceChild2 is moving in screen space but not relative to its target, so occlusion should happen in its target space only. |
| 2173 | // It also means that things occluding in screen space (e.g. surface2) cannot occlude this layer. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2174 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 300), occlusion.unoccludedContentRect(surfaceChild2, IntRect(0, 0, 100, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2175 | EXPECT_FALSE(occlusion.occluded(surfaceChild, IntRect(0, 0, 50, 300))); |
| 2176 | |
| 2177 | this->leaveLayer(surfaceChild2, occlusion); |
| 2178 | this->enterLayer(surfaceChild, occlusion); |
| 2179 | EXPECT_FALSE(occlusion.occluded(surfaceChild, IntRect(0, 0, 100, 300))); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2180 | EXPECT_RECT_EQ(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2181 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2182 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 300), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2183 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2184 | EXPECT_RECT_EQ(IntRect(100, 0, 200, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2185 | |
| 2186 | // The surfaceChild is occluded by the surfaceChild2, but is moving relative its target and the screen, so it |
| 2187 | // can't be occluded. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2188 | EXPECT_RECT_EQ(IntRect(0, 0, 200, 300), occlusion.unoccludedContentRect(surfaceChild, IntRect(0, 0, 200, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2189 | EXPECT_FALSE(occlusion.occluded(surfaceChild, IntRect(0, 0, 50, 300))); |
| 2190 | |
| 2191 | this->leaveLayer(surfaceChild, occlusion); |
| 2192 | this->enterLayer(surface, occlusion); |
| 2193 | // The surfaceChild is moving in screen space but not relative to its target, so occlusion should happen in its target space only. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2194 | EXPECT_RECT_EQ(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2195 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2196 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 300), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2197 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2198 | EXPECT_RECT_EQ(IntRect(100, 0, 200, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2199 | |
| 2200 | this->leaveLayer(surface, occlusion); |
| 2201 | // The surface's owning layer is moving in screen space but not relative to its target, so occlusion should happen in its target space only. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2202 | EXPECT_RECT_EQ(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2203 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2204 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 300), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2205 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2206 | EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2207 | |
| 2208 | this->enterContributingSurface(surface, occlusion); |
| 2209 | // The contributing |surface| is animating so it can't be occluded. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2210 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 300), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2211 | this->leaveContributingSurface(surface, occlusion); |
| 2212 | |
| 2213 | this->enterLayer(layer, occlusion); |
| 2214 | // The |surface| is moving in the screen and in its target, so all occlusion within the surface is lost when leaving it. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2215 | EXPECT_RECT_EQ(IntRect(50, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2216 | this->leaveLayer(layer, occlusion); |
| 2217 | |
| 2218 | this->enterLayer(parent, occlusion); |
| 2219 | // The |layer| is animating in the screen and in its target, so no occlusion is added. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2220 | EXPECT_RECT_EQ(IntRect(50, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2221 | } |
| 2222 | }; |
| 2223 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2224 | MAIN_THREAD_TEST(OcclusionTrackerTestAnimationTranslateOnMainThread); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2225 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2226 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2227 | class OcclusionTrackerTestSurfaceOcclusionTranslatesToParent : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2228 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2229 | OcclusionTrackerTestSurfaceOcclusionTranslatesToParent(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2230 | void runMyTest() |
| 2231 | { |
| 2232 | WebTransformationMatrix surfaceTransform; |
| 2233 | surfaceTransform.translate(300, 300); |
| 2234 | surfaceTransform.scale(2); |
| 2235 | surfaceTransform.translate(-150, -150); |
| 2236 | |
| 2237 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(500, 500)); |
| 2238 | typename Types::ContentLayerType* surface = this->createDrawingSurface(parent, surfaceTransform, FloatPoint(0, 0), IntSize(300, 300), false); |
| 2239 | typename Types::ContentLayerType* surface2 = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(50, 50), IntSize(300, 300), false); |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 2240 | surface->setOpaqueContentsRect(IntRect(0, 0, 200, 200)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2241 | surface2->setOpaqueContentsRect(IntRect(0, 0, 200, 200)); |
| 2242 | this->calcDrawEtc(parent); |
| 2243 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2244 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2245 | |
| 2246 | this->visitLayer(surface2, occlusion); |
| 2247 | this->visitContributingSurface(surface2, occlusion); |
| 2248 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2249 | EXPECT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2250 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2251 | EXPECT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2252 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2253 | |
| 2254 | // Clear any stored occlusion. |
| 2255 | occlusion.setOcclusionInScreenSpace(Region()); |
| 2256 | occlusion.setOcclusionInTargetSurface(Region()); |
| 2257 | |
| 2258 | this->visitLayer(surface, occlusion); |
| 2259 | this->visitContributingSurface(surface, occlusion); |
| 2260 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2261 | EXPECT_RECT_EQ(IntRect(0, 0, 400, 400), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2262 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2263 | EXPECT_RECT_EQ(IntRect(0, 0, 400, 400), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2264 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2265 | } |
| 2266 | }; |
| 2267 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2268 | MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestSurfaceOcclusionTranslatesToParent); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2269 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2270 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2271 | class OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2272 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2273 | OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2274 | void runMyTest() |
| 2275 | { |
| 2276 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300)); |
[email protected] | 23bbb41 | 2012-08-30 20:03:38 | [diff] [blame] | 2277 | parent->setMasksToBounds(true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2278 | typename Types::ContentLayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(500, 300), false); |
| 2279 | surface->setOpaqueContentsRect(IntRect(0, 0, 400, 200)); |
| 2280 | this->calcDrawEtc(parent); |
| 2281 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2282 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2283 | |
| 2284 | this->visitLayer(surface, occlusion); |
| 2285 | this->visitContributingSurface(surface, occlusion); |
| 2286 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2287 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 200), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2288 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2289 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 200), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2290 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2291 | } |
| 2292 | }; |
| 2293 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2294 | MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2295 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2296 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2297 | class OcclusionTrackerTestReplicaOccluded : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2298 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2299 | OcclusionTrackerTestReplicaOccluded(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2300 | void runMyTest() |
| 2301 | { |
| 2302 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 200)); |
| 2303 | typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100), true); |
| 2304 | this->createReplicaLayer(surface, this->identityMatrix, FloatPoint(0, 100), IntSize(100, 100)); |
| 2305 | typename Types::LayerType* topmost = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 100), IntSize(100, 100), true); |
| 2306 | this->calcDrawEtc(parent); |
| 2307 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2308 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2309 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 2310 | |
| 2311 | // |topmost| occludes the replica, but not the surface itself. |
| 2312 | this->visitLayer(topmost, occlusion); |
| 2313 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2314 | EXPECT_RECT_EQ(IntRect(0, 100, 100, 100), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2315 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2316 | EXPECT_RECT_EQ(IntRect(0, 100, 100, 100), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2317 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2318 | |
| 2319 | this->visitLayer(surface, occlusion); |
| 2320 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2321 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 200), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2322 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2323 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2324 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2325 | |
| 2326 | this->enterContributingSurface(surface, occlusion); |
| 2327 | |
| 2328 | // Surface is not occluded so it shouldn't think it is. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2329 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 100))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2330 | } |
| 2331 | }; |
| 2332 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2333 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2334 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2335 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2336 | class OcclusionTrackerTestSurfaceWithReplicaUnoccluded : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2337 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2338 | OcclusionTrackerTestSurfaceWithReplicaUnoccluded(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2339 | void runMyTest() |
| 2340 | { |
| 2341 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 200)); |
| 2342 | typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100), true); |
| 2343 | this->createReplicaLayer(surface, this->identityMatrix, FloatPoint(0, 100), IntSize(100, 100)); |
| 2344 | typename Types::LayerType* topmost = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 110), true); |
| 2345 | this->calcDrawEtc(parent); |
| 2346 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2347 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2348 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 2349 | |
| 2350 | // |topmost| occludes the surface, but not the entire surface's replica. |
| 2351 | this->visitLayer(topmost, occlusion); |
| 2352 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2353 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 110), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2354 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2355 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 110), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2356 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2357 | |
| 2358 | this->visitLayer(surface, occlusion); |
| 2359 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2360 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 110), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2361 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2362 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2363 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2364 | |
| 2365 | this->enterContributingSurface(surface, occlusion); |
| 2366 | |
| 2367 | // Surface is occluded, but only the top 10px of the replica. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2368 | EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 100))); |
| 2369 | EXPECT_RECT_EQ(IntRect(0, 10, 100, 90), occlusion.unoccludedContributingSurfaceContentRect(surface, true, IntRect(0, 0, 100, 100))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2370 | } |
| 2371 | }; |
| 2372 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2373 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithReplicaUnoccluded); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2374 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2375 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2376 | class OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2377 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2378 | OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2379 | void runMyTest() |
| 2380 | { |
| 2381 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 200)); |
| 2382 | typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100), true); |
| 2383 | this->createReplicaLayer(surface, this->identityMatrix, FloatPoint(0, 100), IntSize(100, 100)); |
| 2384 | typename Types::LayerType* overSurface = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(40, 100), true); |
| 2385 | typename Types::LayerType* overReplica = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 100), IntSize(50, 100), true); |
| 2386 | this->calcDrawEtc(parent); |
| 2387 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2388 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2389 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 2390 | |
| 2391 | // These occlude the surface and replica differently, so we can test each one. |
| 2392 | this->visitLayer(overReplica, occlusion); |
| 2393 | this->visitLayer(overSurface, occlusion); |
| 2394 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2395 | EXPECT_RECT_EQ(IntRect(0, 0, 50, 200), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2396 | EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2397 | EXPECT_RECT_EQ(IntRect(0, 0, 50, 200), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2398 | EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2399 | |
| 2400 | this->visitLayer(surface, occlusion); |
| 2401 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2402 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 200), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2403 | EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2404 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2405 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2406 | |
| 2407 | this->enterContributingSurface(surface, occlusion); |
| 2408 | |
| 2409 | // Surface and replica are occluded different amounts. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2410 | EXPECT_RECT_EQ(IntRect(40, 0, 60, 100), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 100))); |
| 2411 | EXPECT_RECT_EQ(IntRect(50, 0, 50, 100), occlusion.unoccludedContributingSurfaceContentRect(surface, true, IntRect(0, 0, 100, 100))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2412 | } |
| 2413 | }; |
| 2414 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2415 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2416 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2417 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2418 | class OcclusionTrackerTestSurfaceChildOfSurface : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2419 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2420 | OcclusionTrackerTestSurfaceChildOfSurface(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2421 | void runMyTest() |
| 2422 | { |
| 2423 | // This test verifies that the surface cliprect does not end up empty and clip away the entire unoccluded rect. |
| 2424 | |
| 2425 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 200)); |
| 2426 | typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100), true); |
| 2427 | typename Types::LayerType* surfaceChild = this->createDrawingSurface(surface, this->identityMatrix, FloatPoint(0, 10), IntSize(100, 50), true); |
| 2428 | typename Types::LayerType* topmost = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 50), true); |
| 2429 | this->calcDrawEtc(parent); |
| 2430 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2431 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(-100, -100, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2432 | |
| 2433 | // |topmost| occludes everything partially so we know occlusion is happening at all. |
| 2434 | this->visitLayer(topmost, occlusion); |
| 2435 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2436 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 50), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2437 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2438 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 50), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2439 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2440 | |
| 2441 | this->visitLayer(surfaceChild, occlusion); |
| 2442 | |
| 2443 | // surfaceChild increases the occlusion in the screen by a narrow sliver. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2444 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 60), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2445 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
| 2446 | // In its own surface, surfaceChild is at 0,0 as is its occlusion. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2447 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 50), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2448 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2449 | |
| 2450 | // The root layer always has a clipRect. So the parent of |surface| has a clipRect. However, the owning layer for |surface| does not |
| 2451 | // mask to bounds, so it doesn't have a clipRect of its own. Thus the parent of |surfaceChild| exercises different code paths |
| 2452 | // as its parent does not have a clipRect. |
| 2453 | |
| 2454 | this->enterContributingSurface(surfaceChild, occlusion); |
| 2455 | // The surfaceChild's parent does not have a clipRect as it owns a render surface. Make sure the unoccluded rect |
| 2456 | // does not get clipped away inappropriately. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2457 | EXPECT_RECT_EQ(IntRect(0, 40, 100, 10), occlusion.unoccludedContributingSurfaceContentRect(surfaceChild, false, IntRect(0, 0, 100, 50))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2458 | this->leaveContributingSurface(surfaceChild, occlusion); |
| 2459 | |
| 2460 | // When the surfaceChild's occlusion is transformed up to its parent, make sure it is not clipped away inappropriately also. |
| 2461 | this->enterLayer(surface, occlusion); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2462 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 60), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2463 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2464 | EXPECT_RECT_EQ(IntRect(0, 10, 100, 50), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2465 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2466 | this->leaveLayer(surface, occlusion); |
| 2467 | |
| 2468 | this->enterContributingSurface(surface, occlusion); |
| 2469 | // The surface's parent does have a clipRect as it is the root layer. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2470 | EXPECT_RECT_EQ(IntRect(0, 50, 100, 50), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 100))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2471 | } |
| 2472 | }; |
| 2473 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2474 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2475 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2476 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2477 | class OcclusionTrackerTestTopmostSurfaceIsClippedToViewport : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2478 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2479 | OcclusionTrackerTestTopmostSurfaceIsClippedToViewport(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2480 | void runMyTest() |
| 2481 | { |
| 2482 | // This test verifies that the top-most surface is considered occluded outside of its target's clipRect and outside the viewport rect. |
| 2483 | |
| 2484 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 200)); |
| 2485 | typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true); |
| 2486 | this->calcDrawEtc(parent); |
| 2487 | |
| 2488 | { |
| 2489 | // Make a viewport rect that is larger than the root layer. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2490 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2491 | |
| 2492 | this->visitLayer(surface, occlusion); |
| 2493 | |
| 2494 | // The root layer always has a clipRect. So the parent of |surface| has a clipRect giving the surface itself a clipRect. |
| 2495 | this->enterContributingSurface(surface, occlusion); |
| 2496 | // Make sure the parent's clipRect clips the unoccluded region of the child surface. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2497 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 200), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2498 | } |
| 2499 | this->resetLayerIterator(); |
| 2500 | { |
| 2501 | // Make a viewport rect that is smaller than the root layer. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2502 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 100, 100)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2503 | |
| 2504 | this->visitLayer(surface, occlusion); |
| 2505 | |
| 2506 | // The root layer always has a clipRect. So the parent of |surface| has a clipRect giving the surface itself a clipRect. |
| 2507 | this->enterContributingSurface(surface, occlusion); |
| 2508 | // Make sure the viewport rect clips the unoccluded region of the child surface. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2509 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 300))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2510 | } |
| 2511 | } |
| 2512 | }; |
| 2513 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2514 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestTopmostSurfaceIsClippedToViewport); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2515 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2516 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2517 | class OcclusionTrackerTestSurfaceChildOfClippingSurface : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2518 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2519 | OcclusionTrackerTestSurfaceChildOfClippingSurface(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2520 | void runMyTest() |
| 2521 | { |
| 2522 | // This test verifies that the surface cliprect does not end up empty and clip away the entire unoccluded rect. |
| 2523 | |
| 2524 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(80, 200)); |
[email protected] | 23bbb41 | 2012-08-30 20:03:38 | [diff] [blame] | 2525 | parent->setMasksToBounds(true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2526 | typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100), true); |
| 2527 | typename Types::LayerType* surfaceChild = this->createDrawingSurface(surface, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100), false); |
| 2528 | typename Types::LayerType* topmost = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 50), true); |
| 2529 | this->calcDrawEtc(parent); |
| 2530 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2531 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2532 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 2533 | |
| 2534 | // |topmost| occludes everything partially so we know occlusion is happening at all. |
| 2535 | this->visitLayer(topmost, occlusion); |
| 2536 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2537 | EXPECT_RECT_EQ(IntRect(0, 0, 80, 50), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2538 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2539 | EXPECT_RECT_EQ(IntRect(0, 0, 80, 50), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2540 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2541 | |
| 2542 | // surfaceChild is not opaque and does not occlude, so we have a non-empty unoccluded area on surface. |
| 2543 | this->visitLayer(surfaceChild, occlusion); |
| 2544 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2545 | EXPECT_RECT_EQ(IntRect(0, 0, 80, 50), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2546 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2547 | EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2548 | EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2549 | |
| 2550 | // The root layer always has a clipRect. So the parent of |surface| has a clipRect. However, the owning layer for |surface| does not |
| 2551 | // mask to bounds, so it doesn't have a clipRect of its own. Thus the parent of |surfaceChild| exercises different code paths |
| 2552 | // as its parent does not have a clipRect. |
| 2553 | |
| 2554 | this->enterContributingSurface(surfaceChild, occlusion); |
| 2555 | // The surfaceChild's parent does not have a clipRect as it owns a render surface. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2556 | EXPECT_RECT_EQ(IntRect(0, 50, 80, 50), occlusion.unoccludedContributingSurfaceContentRect(surfaceChild, false, IntRect(0, 0, 100, 100))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2557 | this->leaveContributingSurface(surfaceChild, occlusion); |
| 2558 | |
| 2559 | this->visitLayer(surface, occlusion); |
| 2560 | this->enterContributingSurface(surface, occlusion); |
| 2561 | // The surface's parent does have a clipRect as it is the root layer. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2562 | EXPECT_RECT_EQ(IntRect(0, 50, 80, 50), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 100))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2563 | } |
| 2564 | }; |
| 2565 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2566 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfClippingSurface); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2567 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2568 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2569 | class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2570 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2571 | OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2572 | void runMyTest() |
| 2573 | { |
| 2574 | WebTransformationMatrix scaleByHalf; |
| 2575 | scaleByHalf.scale(0.5); |
| 2576 | |
| 2577 | // Make a surface and its replica, each 50x50, that are completely surrounded by opaque layers which are above them in the z-order. |
| 2578 | // The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface |
| 2579 | // appears at 50, 50 and the replica at 200, 50. |
| 2580 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 150)); |
| 2581 | typename Types::LayerType* filteredSurface = this->createDrawingLayer(parent, scaleByHalf, FloatPoint(50, 50), IntSize(100, 100), false); |
| 2582 | this->createReplicaLayer(filteredSurface, this->identityMatrix, FloatPoint(300, 0), IntSize()); |
| 2583 | typename Types::LayerType* occludingLayer1 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 50), true); |
| 2584 | typename Types::LayerType* occludingLayer2 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 100), IntSize(300, 50), true); |
| 2585 | typename Types::LayerType* occludingLayer3 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 50), IntSize(50, 50), true); |
| 2586 | typename Types::LayerType* occludingLayer4 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(100, 50), IntSize(100, 50), true); |
| 2587 | typename Types::LayerType* occludingLayer5 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(250, 50), IntSize(50, 50), true); |
| 2588 | |
| 2589 | // Filters make the layer own a surface. |
| 2590 | WebFilterOperations filters; |
| 2591 | filters.append(WebFilterOperation::createBlurFilter(10)); |
| 2592 | filteredSurface->setBackgroundFilters(filters); |
| 2593 | |
| 2594 | // Save the distance of influence for the blur effect. |
| 2595 | int outsetTop, outsetRight, outsetBottom, outsetLeft; |
| 2596 | filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); |
| 2597 | |
| 2598 | this->calcDrawEtc(parent); |
| 2599 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2600 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2601 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 2602 | |
| 2603 | // These layers occlude pixels directly beside the filteredSurface. Because filtered surface blends pixels in a radius, it will |
| 2604 | // need to see some of the pixels (up to radius far) underneath the occludingLayers. |
| 2605 | this->visitLayer(occludingLayer5, occlusion); |
| 2606 | this->visitLayer(occludingLayer4, occlusion); |
| 2607 | this->visitLayer(occludingLayer3, occlusion); |
| 2608 | this->visitLayer(occludingLayer2, occlusion); |
| 2609 | this->visitLayer(occludingLayer1, occlusion); |
| 2610 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2611 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2612 | EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2613 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2614 | EXPECT_EQ(5u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2615 | |
| 2616 | // Everything outside the surface/replica is occluded but the surface/replica itself is not. |
| 2617 | this->enterLayer(filteredSurface, occlusion); |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 2618 | EXPECT_RECT_EQ(IntRect(1, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(1, 0, 100, 100))); |
| 2619 | EXPECT_RECT_EQ(IntRect(0, 1, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, 1, 100, 100))); |
| 2620 | EXPECT_RECT_EQ(IntRect(0, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(-1, 0, 100, 100))); |
| 2621 | EXPECT_RECT_EQ(IntRect(0, 0, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, -1, 100, 100))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2622 | |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 2623 | EXPECT_RECT_EQ(IntRect(300 + 1, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 1, 0, 100, 100))); |
| 2624 | EXPECT_RECT_EQ(IntRect(300 + 0, 1, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 0, 1, 100, 100))); |
| 2625 | EXPECT_RECT_EQ(IntRect(300 + 0, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 - 1, 0, 100, 100))); |
| 2626 | EXPECT_RECT_EQ(IntRect(300 + 0, 0, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 0, -1, 100, 100))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2627 | this->leaveLayer(filteredSurface, occlusion); |
| 2628 | |
| 2629 | // The filtered layer/replica does not occlude. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2630 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2631 | EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2632 | EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2633 | EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2634 | |
| 2635 | // The surface has a background blur, so it needs pixels that are currently considered occluded in order to be drawn. So the pixels |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 2636 | // it needs should be removed some the occluded area so that when we get to the parent they are drawn. |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2637 | this->visitContributingSurface(filteredSurface, occlusion); |
| 2638 | |
| 2639 | this->enterLayer(parent, occlusion); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2640 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2641 | EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2642 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2643 | EXPECT_EQ(5u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2644 | |
| 2645 | IntRect outsetRect; |
| 2646 | IntRect testRect; |
| 2647 | |
| 2648 | // Nothing in the blur outsets for the filteredSurface is occluded. |
| 2649 | outsetRect = IntRect(50 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom); |
| 2650 | testRect = outsetRect; |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2651 | EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2652 | |
| 2653 | // Stuff outside the blur outsets is still occluded though. |
| 2654 | testRect = outsetRect; |
| 2655 | testRect.expand(1, 0); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2656 | EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2657 | testRect = outsetRect; |
| 2658 | testRect.expand(0, 1); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2659 | EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2660 | testRect = outsetRect; |
| 2661 | testRect.move(-1, 0); |
| 2662 | testRect.expand(1, 0); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2663 | EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2664 | testRect = outsetRect; |
| 2665 | testRect.move(0, -1); |
| 2666 | testRect.expand(0, 1); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2667 | EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2668 | |
| 2669 | // Nothing in the blur outsets for the filteredSurface's replica is occluded. |
| 2670 | outsetRect = IntRect(200 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom); |
| 2671 | testRect = outsetRect; |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2672 | EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2673 | |
| 2674 | // Stuff outside the blur outsets is still occluded though. |
| 2675 | testRect = outsetRect; |
| 2676 | testRect.expand(1, 0); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2677 | EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2678 | testRect = outsetRect; |
| 2679 | testRect.expand(0, 1); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2680 | EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2681 | testRect = outsetRect; |
| 2682 | testRect.move(-1, 0); |
| 2683 | testRect.expand(1, 0); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2684 | EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2685 | testRect = outsetRect; |
| 2686 | testRect.move(0, -1); |
| 2687 | testRect.expand(0, 1); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2688 | EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2689 | } |
| 2690 | }; |
| 2691 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2692 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2693 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2694 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2695 | class OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2696 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2697 | OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2698 | void runMyTest() |
| 2699 | { |
| 2700 | WebTransformationMatrix scaleByHalf; |
| 2701 | scaleByHalf.scale(0.5); |
| 2702 | |
| 2703 | // Makes two surfaces that completely cover |parent|. The occlusion both above and below the filters will be reduced by each of them. |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 2704 | typename Types::ContentLayerType* root = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(75, 75)); |
| 2705 | typename Types::LayerType* parent = this->createSurface(root, scaleByHalf, FloatPoint(0, 0), IntSize(150, 150)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2706 | parent->setMasksToBounds(true); |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 2707 | typename Types::LayerType* filteredSurface1 = this->createDrawingLayer(parent, scaleByHalf, FloatPoint(0, 0), IntSize(300, 300), false); |
| 2708 | typename Types::LayerType* filteredSurface2 = this->createDrawingLayer(parent, scaleByHalf, FloatPoint(0, 0), IntSize(300, 300), false); |
| 2709 | typename Types::LayerType* occludingLayerAbove = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(100, 100), IntSize(50, 50), true); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2710 | |
| 2711 | // Filters make the layers own surfaces. |
| 2712 | WebFilterOperations filters; |
| 2713 | filters.append(WebFilterOperation::createBlurFilter(3)); |
| 2714 | filteredSurface1->setBackgroundFilters(filters); |
| 2715 | filteredSurface2->setBackgroundFilters(filters); |
| 2716 | |
| 2717 | // Save the distance of influence for the blur effect. |
| 2718 | int outsetTop, outsetRight, outsetBottom, outsetLeft; |
| 2719 | filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); |
| 2720 | |
| 2721 | this->calcDrawEtc(root); |
| 2722 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2723 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2724 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 2725 | |
| 2726 | this->visitLayer(occludingLayerAbove, occlusion); |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 2727 | EXPECT_RECT_EQ(IntRect(100 / 2, 100 / 2, 50 / 2, 50 / 2), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2728 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 2729 | EXPECT_RECT_EQ(IntRect(100, 100, 50, 50), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2730 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2731 | |
| 2732 | this->visitLayer(filteredSurface2, occlusion); |
| 2733 | this->visitContributingSurface(filteredSurface2, occlusion); |
| 2734 | this->visitLayer(filteredSurface1, occlusion); |
| 2735 | this->visitContributingSurface(filteredSurface1, occlusion); |
| 2736 | |
| 2737 | ASSERT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
| 2738 | ASSERT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2739 | |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 2740 | // Test expectations in the target. |
| 2741 | IntRect expectedOcclusion = IntRect(100 + outsetRight * 2, 100 + outsetBottom * 2, 50 - (outsetLeft + outsetRight) * 2, 50 - (outsetTop + outsetBottom) * 2); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2742 | EXPECT_RECT_EQ(expectedOcclusion, occlusion.occlusionInTargetSurface().rects()[0]); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2743 | |
[email protected] | f3922f2 | 2012-10-12 09:20:38 | [diff] [blame] | 2744 | // Test expectations in the screen. Take the ceiling of half of the outsets. |
| 2745 | outsetTop = (outsetTop + 1) / 2; |
| 2746 | outsetRight = (outsetRight + 1) / 2; |
| 2747 | outsetBottom = (outsetBottom + 1) / 2; |
| 2748 | outsetLeft = (outsetLeft + 1) / 2; |
| 2749 | expectedOcclusion = IntRect(100 / 2 + outsetRight * 2, 100 / 2 + outsetBottom * 2, 50 / 2 - (outsetLeft + outsetRight) * 2, 50 /2 - (outsetTop + outsetBottom) * 2); |
| 2750 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2751 | EXPECT_RECT_EQ(expectedOcclusion, occlusion.occlusionInScreenSpace().rects()[0]); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2752 | } |
| 2753 | }; |
| 2754 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2755 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2756 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2757 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2758 | class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilterWithClip : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2759 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2760 | OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilterWithClip(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2761 | void runMyTest() |
| 2762 | { |
| 2763 | // Make a surface and its replica, each 50x50, that are completely surrounded by opaque layers which are above them in the z-order. |
| 2764 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 150)); |
| 2765 | // We stick the filtered surface inside a clipping surface so that we can make sure the clip is honored when exposing pixels for |
| 2766 | // the background filter. |
| 2767 | typename Types::LayerType* clippingSurface = this->createSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 70)); |
| 2768 | clippingSurface->setMasksToBounds(true); |
| 2769 | typename Types::LayerType* filteredSurface = this->createDrawingLayer(clippingSurface, this->identityMatrix, FloatPoint(50, 50), IntSize(50, 50), false); |
| 2770 | this->createReplicaLayer(filteredSurface, this->identityMatrix, FloatPoint(150, 0), IntSize()); |
| 2771 | typename Types::LayerType* occludingLayer1 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(300, 50), true); |
| 2772 | typename Types::LayerType* occludingLayer2 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 100), IntSize(300, 50), true); |
| 2773 | typename Types::LayerType* occludingLayer3 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 50), IntSize(50, 50), true); |
| 2774 | typename Types::LayerType* occludingLayer4 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(100, 50), IntSize(100, 50), true); |
| 2775 | typename Types::LayerType* occludingLayer5 = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(250, 50), IntSize(50, 50), true); |
| 2776 | |
| 2777 | // Filters make the layer own a surface. This filter is large enough that it goes outside the bottom of the clippingSurface. |
| 2778 | WebFilterOperations filters; |
| 2779 | filters.append(WebFilterOperation::createBlurFilter(12)); |
| 2780 | filteredSurface->setBackgroundFilters(filters); |
| 2781 | |
| 2782 | // Save the distance of influence for the blur effect. |
| 2783 | int outsetTop, outsetRight, outsetBottom, outsetLeft; |
| 2784 | filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); |
| 2785 | |
| 2786 | this->calcDrawEtc(parent); |
| 2787 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2788 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2789 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 2790 | |
| 2791 | // These layers occlude pixels directly beside the filteredSurface. Because filtered surface blends pixels in a radius, it will |
| 2792 | // need to see some of the pixels (up to radius far) underneath the occludingLayers. |
| 2793 | this->visitLayer(occludingLayer5, occlusion); |
| 2794 | this->visitLayer(occludingLayer4, occlusion); |
| 2795 | this->visitLayer(occludingLayer3, occlusion); |
| 2796 | this->visitLayer(occludingLayer2, occlusion); |
| 2797 | this->visitLayer(occludingLayer1, occlusion); |
| 2798 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2799 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2800 | EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2801 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2802 | EXPECT_EQ(5u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2803 | |
| 2804 | // Everything outside the surface/replica is occluded but the surface/replica itself is not. |
| 2805 | this->enterLayer(filteredSurface, occlusion); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2806 | EXPECT_RECT_EQ(IntRect(1, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(1, 0, 50, 50))); |
| 2807 | EXPECT_RECT_EQ(IntRect(0, 1, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, 1, 50, 50))); |
| 2808 | EXPECT_RECT_EQ(IntRect(0, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(-1, 0, 50, 50))); |
| 2809 | EXPECT_RECT_EQ(IntRect(0, 0, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, -1, 50, 50))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2810 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2811 | EXPECT_RECT_EQ(IntRect(150 + 1, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 1, 0, 50, 50))); |
| 2812 | EXPECT_RECT_EQ(IntRect(150 + 0, 1, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 0, 1, 50, 50))); |
| 2813 | EXPECT_RECT_EQ(IntRect(150 + 0, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 - 1, 0, 50, 50))); |
| 2814 | EXPECT_RECT_EQ(IntRect(150 + 0, 0, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 0, -1, 50, 50))); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2815 | this->leaveLayer(filteredSurface, occlusion); |
| 2816 | |
| 2817 | // The filtered layer/replica does not occlude. |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2818 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2819 | EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2820 | EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2821 | EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2822 | |
| 2823 | // The surface has a background blur, so it needs pixels that are currently considered occluded in order to be drawn. So the pixels |
| 2824 | // it needs should be removed some the occluded area so that when we get to the parent they are drawn. |
| 2825 | this->visitContributingSurface(filteredSurface, occlusion); |
| 2826 | |
| 2827 | this->enterContributingSurface(clippingSurface, occlusion); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2828 | EXPECT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2829 | EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size()); |
| 2830 | |
| 2831 | IntRect outsetRect; |
| 2832 | IntRect clippedOutsetRect; |
| 2833 | IntRect testRect; |
| 2834 | |
| 2835 | // Nothing in the (clipped) blur outsets for the filteredSurface is occluded. |
| 2836 | outsetRect = IntRect(50 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom); |
| 2837 | clippedOutsetRect = intersection(outsetRect, IntRect(0 - outsetLeft, 0 - outsetTop, 300 + outsetLeft + outsetRight, 70 + outsetTop + outsetBottom)); |
| 2838 | testRect = outsetRect; |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2839 | EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2840 | |
| 2841 | // Stuff outside the (clipped) blur outsets is still occluded though. |
| 2842 | testRect = outsetRect; |
| 2843 | testRect.expand(1, 0); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2844 | EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2845 | testRect = outsetRect; |
| 2846 | testRect.expand(0, 1); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2847 | EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2848 | testRect = outsetRect; |
| 2849 | testRect.move(-1, 0); |
| 2850 | testRect.expand(1, 0); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2851 | EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2852 | testRect = outsetRect; |
| 2853 | testRect.move(0, -1); |
| 2854 | testRect.expand(0, 1); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2855 | EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2856 | |
| 2857 | // Nothing in the (clipped) blur outsets for the filteredSurface's replica is occluded. |
| 2858 | outsetRect = IntRect(200 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom); |
| 2859 | clippedOutsetRect = intersection(outsetRect, IntRect(0 - outsetLeft, 0 - outsetTop, 300 + outsetLeft + outsetRight, 70 + outsetTop + outsetBottom)); |
| 2860 | testRect = outsetRect; |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2861 | EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2862 | |
| 2863 | // Stuff outside the (clipped) blur outsets is still occluded though. |
| 2864 | testRect = outsetRect; |
| 2865 | testRect.expand(1, 0); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2866 | EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2867 | testRect = outsetRect; |
| 2868 | testRect.expand(0, 1); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2869 | EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2870 | testRect = outsetRect; |
| 2871 | testRect.move(-1, 0); |
| 2872 | testRect.expand(1, 0); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2873 | EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2874 | testRect = outsetRect; |
| 2875 | testRect.move(0, -1); |
| 2876 | testRect.expand(0, 1); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2877 | EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2878 | } |
| 2879 | }; |
| 2880 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2881 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilterWithClip); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2882 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2883 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2884 | class OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2885 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2886 | OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2887 | void runMyTest() |
| 2888 | { |
| 2889 | WebTransformationMatrix scaleByHalf; |
| 2890 | scaleByHalf.scale(0.5); |
| 2891 | |
| 2892 | // Make a surface and its replica, each 50x50, with a smaller 30x30 layer centered below each. |
| 2893 | // The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface |
| 2894 | // appears at 50, 50 and the replica at 200, 50. |
| 2895 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 150)); |
| 2896 | typename Types::LayerType* behindSurfaceLayer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(60, 60), IntSize(30, 30), true); |
| 2897 | typename Types::LayerType* behindReplicaLayer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(210, 60), IntSize(30, 30), true); |
| 2898 | typename Types::LayerType* filteredSurface = this->createDrawingLayer(parent, scaleByHalf, FloatPoint(50, 50), IntSize(100, 100), false); |
| 2899 | this->createReplicaLayer(filteredSurface, this->identityMatrix, FloatPoint(300, 0), IntSize()); |
| 2900 | |
| 2901 | // Filters make the layer own a surface. |
| 2902 | WebFilterOperations filters; |
| 2903 | filters.append(WebFilterOperation::createBlurFilter(3)); |
| 2904 | filteredSurface->setBackgroundFilters(filters); |
| 2905 | |
| 2906 | this->calcDrawEtc(parent); |
| 2907 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2908 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2909 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 2910 | |
| 2911 | // The surface has a background blur, so it blurs non-opaque pixels below it. |
| 2912 | this->visitLayer(filteredSurface, occlusion); |
| 2913 | this->visitContributingSurface(filteredSurface, occlusion); |
| 2914 | |
| 2915 | this->visitLayer(behindReplicaLayer, occlusion); |
| 2916 | this->visitLayer(behindSurfaceLayer, occlusion); |
| 2917 | |
| 2918 | // The layers behind the surface are not blurred, and their occlusion does not change, until we leave the surface. |
| 2919 | // So it should not be modified by the filter here. |
| 2920 | IntRect occlusionBehindSurface = IntRect(60, 60, 30, 30); |
| 2921 | IntRect occlusionBehindReplica = IntRect(210, 60, 30, 30); |
| 2922 | |
| 2923 | IntRect expectedOpaqueBounds = unionRect(occlusionBehindSurface, occlusionBehindReplica); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2924 | EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2925 | EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2926 | EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2927 | EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2928 | } |
| 2929 | }; |
| 2930 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2931 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2932 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2933 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2934 | class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2935 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2936 | OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2937 | void runMyTest() |
| 2938 | { |
| 2939 | WebTransformationMatrix scaleByHalf; |
| 2940 | scaleByHalf.scale(0.5); |
| 2941 | |
| 2942 | // Make a surface and its replica, each 50x50, that are completely occluded by opaque layers which are above them in the z-order. |
| 2943 | // The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface |
| 2944 | // appears at 50, 50 and the replica at 200, 50. |
| 2945 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 150)); |
| 2946 | typename Types::LayerType* filteredSurface = this->createDrawingLayer(parent, scaleByHalf, FloatPoint(50, 50), IntSize(100, 100), false); |
| 2947 | this->createReplicaLayer(filteredSurface, this->identityMatrix, FloatPoint(300, 0), IntSize()); |
| 2948 | typename Types::LayerType* aboveSurfaceLayer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(50, 50), IntSize(50, 50), true); |
| 2949 | typename Types::LayerType* aboveReplicaLayer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(200, 50), IntSize(50, 50), true); |
| 2950 | |
| 2951 | // Filters make the layer own a surface. |
| 2952 | WebFilterOperations filters; |
| 2953 | filters.append(WebFilterOperation::createBlurFilter(3)); |
| 2954 | filteredSurface->setBackgroundFilters(filters); |
| 2955 | |
| 2956 | this->calcDrawEtc(parent); |
| 2957 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2958 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2959 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 2960 | |
| 2961 | this->visitLayer(aboveReplicaLayer, occlusion); |
| 2962 | this->visitLayer(aboveSurfaceLayer, occlusion); |
| 2963 | |
| 2964 | // The surface has a background blur, so it blurs non-opaque pixels below it. |
| 2965 | this->visitLayer(filteredSurface, occlusion); |
| 2966 | this->visitContributingSurface(filteredSurface, occlusion); |
| 2967 | |
| 2968 | // The filter is completely occluded, so it should not blur anything and reduce any occlusion. |
| 2969 | IntRect occlusionAboveSurface = IntRect(50, 50, 50, 50); |
| 2970 | IntRect occlusionAboveReplica = IntRect(200, 50, 50, 50); |
| 2971 | |
| 2972 | IntRect expectedOpaqueBounds = unionRect(occlusionAboveSurface, occlusionAboveReplica); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2973 | EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2974 | EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 2975 | EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2976 | EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); |
| 2977 | } |
| 2978 | }; |
| 2979 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2980 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2981 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 2982 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2983 | class OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2984 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 2985 | OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 2986 | void runMyTest() |
| 2987 | { |
| 2988 | WebTransformationMatrix scaleByHalf; |
| 2989 | scaleByHalf.scale(0.5); |
| 2990 | |
| 2991 | // Make a surface and its replica, each 50x50, that are partially occluded by opaque layers which are above them in the z-order. |
| 2992 | // The surface is scaled to test that the pixel moving is done in the target space, where the background filter is applied, but the surface |
| 2993 | // appears at 50, 50 and the replica at 200, 50. |
| 2994 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 150)); |
| 2995 | typename Types::LayerType* filteredSurface = this->createDrawingLayer(parent, scaleByHalf, FloatPoint(50, 50), IntSize(100, 100), false); |
| 2996 | this->createReplicaLayer(filteredSurface, this->identityMatrix, FloatPoint(300, 0), IntSize()); |
| 2997 | typename Types::LayerType* aboveSurfaceLayer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(70, 50), IntSize(30, 50), true); |
| 2998 | typename Types::LayerType* aboveReplicaLayer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(200, 50), IntSize(30, 50), true); |
| 2999 | typename Types::LayerType* besideSurfaceLayer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(90, 40), IntSize(10, 10), true); |
| 3000 | typename Types::LayerType* besideReplicaLayer = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(200, 40), IntSize(10, 10), true); |
| 3001 | |
| 3002 | // Filters make the layer own a surface. |
| 3003 | WebFilterOperations filters; |
| 3004 | filters.append(WebFilterOperation::createBlurFilter(3)); |
| 3005 | filteredSurface->setBackgroundFilters(filters); |
| 3006 | |
| 3007 | // Save the distance of influence for the blur effect. |
| 3008 | int outsetTop, outsetRight, outsetBottom, outsetLeft; |
| 3009 | filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); |
| 3010 | |
| 3011 | this->calcDrawEtc(parent); |
| 3012 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 3013 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3014 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 3015 | |
| 3016 | this->visitLayer(besideReplicaLayer, occlusion); |
| 3017 | this->visitLayer(besideSurfaceLayer, occlusion); |
| 3018 | this->visitLayer(aboveReplicaLayer, occlusion); |
| 3019 | this->visitLayer(aboveSurfaceLayer, occlusion); |
| 3020 | |
| 3021 | // The surface has a background blur, so it blurs non-opaque pixels below it. |
| 3022 | this->visitLayer(filteredSurface, occlusion); |
| 3023 | this->visitContributingSurface(filteredSurface, occlusion); |
| 3024 | |
| 3025 | // The filter in the surface and replica are partially unoccluded. Only the unoccluded parts should reduce occlusion. |
| 3026 | // This means it will push back the occlusion that touches the unoccluded part (occlusionAbove___), but it will not |
| 3027 | // touch occlusionBeside____ since that is not beside the unoccluded part of the surface, even though it is beside |
| 3028 | // the occluded part of the surface. |
| 3029 | IntRect occlusionAboveSurface = IntRect(70 + outsetRight, 50, 30 - outsetRight, 50); |
| 3030 | IntRect occlusionAboveReplica = IntRect(200, 50, 30 - outsetLeft, 50); |
| 3031 | IntRect occlusionBesideSurface = IntRect(90, 40, 10, 10); |
| 3032 | IntRect occlusionBesideReplica = IntRect(200, 40, 10, 10); |
| 3033 | |
| 3034 | Region expectedOcclusion; |
| 3035 | expectedOcclusion.unite(occlusionAboveSurface); |
| 3036 | expectedOcclusion.unite(occlusionAboveReplica); |
| 3037 | expectedOcclusion.unite(occlusionBesideSurface); |
| 3038 | expectedOcclusion.unite(occlusionBesideReplica); |
| 3039 | |
| 3040 | ASSERT_EQ(expectedOcclusion.rects().size(), occlusion.occlusionInTargetSurface().rects().size()); |
| 3041 | ASSERT_EQ(expectedOcclusion.rects().size(), occlusion.occlusionInScreenSpace().rects().size()); |
| 3042 | |
| 3043 | for (size_t i = 0; i < expectedOcclusion.rects().size(); ++i) { |
| 3044 | IntRect expectedRect = expectedOcclusion.rects()[i]; |
| 3045 | IntRect screenRect = occlusion.occlusionInScreenSpace().rects()[i]; |
| 3046 | IntRect targetRect = occlusion.occlusionInTargetSurface().rects()[i]; |
| 3047 | EXPECT_EQ(expectedRect, screenRect); |
| 3048 | EXPECT_EQ(expectedRect, targetRect); |
| 3049 | } |
| 3050 | } |
| 3051 | }; |
| 3052 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 3053 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3054 | |
[email protected] | ece1d95 | 2012-10-18 21:26:07 | [diff] [blame] | 3055 | template<class Types> |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 3056 | class OcclusionTrackerTestMinimumTrackingSize : public OcclusionTrackerTest<Types> { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3057 | protected: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 3058 | OcclusionTrackerTestMinimumTrackingSize(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3059 | void runMyTest() |
| 3060 | { |
| 3061 | IntSize trackingSize(100, 100); |
| 3062 | IntSize belowTrackingSize(99, 99); |
| 3063 | |
| 3064 | typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(400, 400)); |
| 3065 | typename Types::LayerType* large = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), trackingSize, true); |
| 3066 | typename Types::LayerType* small = this->createDrawingLayer(parent, this->identityMatrix, FloatPoint(0, 0), belowTrackingSize, true); |
| 3067 | this->calcDrawEtc(parent); |
| 3068 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 3069 | TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3070 | occlusion.setLayerClipRect(IntRect(0, 0, 1000, 1000)); |
| 3071 | occlusion.setMinimumTrackingSize(trackingSize); |
| 3072 | |
| 3073 | // The small layer is not tracked because it is too small. |
| 3074 | this->visitLayer(small, occlusion); |
| 3075 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 3076 | EXPECT_RECT_EQ(IntRect(), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3077 | EXPECT_EQ(0u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 3078 | EXPECT_RECT_EQ(IntRect(), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3079 | EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size()); |
| 3080 | |
| 3081 | // The large layer is tracked as it is large enough. |
| 3082 | this->visitLayer(large, occlusion); |
| 3083 | |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 3084 | EXPECT_RECT_EQ(IntRect(IntPoint(), trackingSize), occlusion.occlusionInScreenSpace().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3085 | EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); |
[email protected] | 022cbf16 | 2012-09-01 01:15:17 | [diff] [blame] | 3086 | EXPECT_RECT_EQ(IntRect(IntPoint(), trackingSize), occlusion.occlusionInTargetSurface().bounds()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3087 | EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); |
| 3088 | } |
| 3089 | }; |
| 3090 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame^] | 3091 | ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestMinimumTrackingSize); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 3092 | |
| 3093 | } // namespace |