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