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