Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/tiled_layer.h" | 5 #include "cc/tiled_layer.h" |
| 6 | 6 |
| 7 #include "cc/bitmap_content_layer_updater.h" | 7 #include "cc/bitmap_content_layer_updater.h" |
| 8 #include "cc/layer_painter.h" | 8 #include "cc/layer_painter.h" |
| 9 #include "cc/overdraw_metrics.h" | 9 #include "cc/overdraw_metrics.h" |
| 10 #include "cc/rendering_stats.h" | 10 #include "cc/rendering_stats.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 namespace cc { | 26 namespace cc { |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 class TestOcclusionTracker : public OcclusionTracker { | 29 class TestOcclusionTracker : public OcclusionTracker { |
| 30 public: | 30 public: |
| 31 TestOcclusionTracker() | 31 TestOcclusionTracker() |
| 32 : OcclusionTracker(gfx::Rect(0, 0, 1000, 1000), true) | 32 : OcclusionTracker(gfx::Rect(0, 0, 1000, 1000), true) |
| 33 , m_layerClipRectInTarget(gfx::Rect(0, 0, 1000, 1000)) | 33 , m_layerClipRectInTarget(gfx::Rect(0, 0, 1000, 1000)) |
| 34 { | 34 { |
| 35 // Pretend we have visited a render surface. | |
| 36 m_stack.push_back(StackObject()); | 35 m_stack.push_back(StackObject()); |
| 37 } | 36 } |
| 38 | 37 |
| 39 void setOcclusion(const Region& occlusion) { m_stack.back().occlusionInTarge t = occlusion; } | 38 void setRenderTarget(Layer* renderTarget) |
| 39 { | |
| 40 m_stack.back().target = renderTarget; | |
| 41 } | |
| 42 | |
| 43 void setOcclusion(const Region& occlusion) { m_stack.back().occlusionFromIns ideTarget = occlusion; } | |
| 40 | 44 |
| 41 protected: | 45 protected: |
| 42 virtual gfx::Rect layerClipRectInTarget(const Layer* layer) const OVERRIDE { return m_layerClipRectInTarget; } | 46 virtual gfx::Rect layerClipRectInTarget(const Layer* layer) const OVERRIDE { return m_layerClipRectInTarget; } |
| 43 | 47 |
| 44 private: | 48 private: |
| 45 gfx::Rect m_layerClipRectInTarget; | 49 gfx::Rect m_layerClipRectInTarget; |
| 46 }; | 50 }; |
| 47 | 51 |
| 48 class TiledLayerTest : public testing::Test { | 52 class TiledLayerTest : public testing::Test { |
| 49 public: | 53 public: |
| 50 TiledLayerTest() | 54 TiledLayerTest() |
| 51 : m_proxy(NULL) | 55 : m_proxy(NULL) |
| 52 , m_outputSurface(createFakeOutputSurface()) | 56 , m_outputSurface(createFakeOutputSurface()) |
| 53 , m_queue(make_scoped_ptr(new ResourceUpdateQueue)) | 57 , m_queue(make_scoped_ptr(new ResourceUpdateQueue)) |
| 54 , m_occlusion(0) | 58 , m_occlusion(0) |
| 55 { | 59 { |
| 56 } | 60 } |
| 57 | 61 |
| 58 virtual void SetUp() | 62 virtual void SetUp() |
| 59 { | 63 { |
| 60 m_layerTreeHost = LayerTreeHost::create(&m_fakeLayerImplTreeHostClient, m_settings, scoped_ptr<Thread>(NULL)); | 64 m_layerTreeHost = LayerTreeHost::create(&m_fakeLayerImplTreeHostClient, m_settings, scoped_ptr<Thread>(NULL)); |
| 61 m_proxy = m_layerTreeHost->proxy(); | 65 m_proxy = m_layerTreeHost->proxy(); |
| 62 m_resourceManager = PrioritizedResourceManager::create(m_proxy); | 66 m_resourceManager = PrioritizedResourceManager::create(m_proxy); |
| 63 m_layerTreeHost->initializeRendererIfNeeded(); | 67 m_layerTreeHost->initializeRendererIfNeeded(); |
| 68 m_layerTreeHost->setRootLayer(Layer::create()); | |
| 69 | |
| 64 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy); | 70 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy); |
| 65 m_resourceProvider = ResourceProvider::create(m_outputSurface.get()); | 71 m_resourceProvider = ResourceProvider::create(m_outputSurface.get()); |
| 66 m_hostImpl = make_scoped_ptr(new FakeLayerTreeHostImpl(m_proxy)); | 72 m_hostImpl = make_scoped_ptr(new FakeLayerTreeHostImpl(m_proxy)); |
| 67 } | 73 } |
| 68 | 74 |
| 69 virtual ~TiledLayerTest() | 75 virtual ~TiledLayerTest() |
| 70 { | 76 { |
| 71 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvide r.get()); | 77 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvide r.get()); |
| 78 | |
| 72 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy); | 79 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy); |
| 73 m_resourceProvider.reset(); | 80 m_resourceProvider.reset(); |
| 74 m_hostImpl.reset(); | 81 m_hostImpl.reset(); |
| 75 } | 82 } |
| 76 | 83 |
| 77 class ScopedFakeTiledLayerImpl { | |
| 78 public: | |
| 79 ScopedFakeTiledLayerImpl(LayerTreeImpl* treeImpl, int id) | |
| 80 { | |
| 81 m_layerImpl = new FakeTiledLayerImpl(treeImpl, id); | |
| 82 } | |
| 83 ~ScopedFakeTiledLayerImpl() | |
| 84 { | |
| 85 delete m_layerImpl; | |
| 86 } | |
| 87 FakeTiledLayerImpl* get() | |
| 88 { | |
| 89 return m_layerImpl; | |
| 90 } | |
| 91 FakeTiledLayerImpl* operator->() | |
| 92 { | |
| 93 return m_layerImpl; | |
| 94 } | |
| 95 private: | |
| 96 FakeTiledLayerImpl* m_layerImpl; | |
| 97 }; | |
| 98 void resourceManagerClearAllMemory(PrioritizedResourceManager* resourceManag er, ResourceProvider* resourceProvider) | 84 void resourceManagerClearAllMemory(PrioritizedResourceManager* resourceManag er, ResourceProvider* resourceProvider) |
| 99 { | 85 { |
| 100 { | 86 { |
| 101 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThread Blocked(m_proxy); | 87 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThread Blocked(m_proxy); |
| 102 resourceManager->clearAllMemory(resourceProvider); | 88 resourceManager->clearAllMemory(resourceProvider); |
| 103 resourceManager->reduceMemory(resourceProvider); | 89 resourceManager->reduceMemory(resourceProvider); |
| 104 } | 90 } |
| 105 resourceManager->unlinkAndClearEvictedBackings(); | 91 resourceManager->unlinkAndClearEvictedBackings(); |
| 106 } | 92 } |
| 107 void updateTextures() | 93 void updateTextures() |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 122 { | 108 { |
| 123 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy); | 109 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(m_proxy); |
| 124 layer->pushPropertiesTo(layerImpl); | 110 layer->pushPropertiesTo(layerImpl); |
| 125 } | 111 } |
| 126 void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded) | 112 void layerUpdate(FakeTiledLayer* layer, TestOcclusionTracker* occluded) |
| 127 { | 113 { |
| 128 DebugScopedSetMainThread mainThread(m_proxy); | 114 DebugScopedSetMainThread mainThread(m_proxy); |
| 129 layer->update(*m_queue.get(), occluded, m_stats); | 115 layer->update(*m_queue.get(), occluded, m_stats); |
| 130 } | 116 } |
| 131 | 117 |
| 132 bool updateAndPush(FakeTiledLayer* layer1, | 118 void calcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1) |
|
enne (OOO)
2012/12/16 19:44:25
Yay, calling calcDrawProperties.
Although, functi
danakj
2012/12/16 20:16:52
It's roughly equivilent to passing by value. I don
enne (OOO)
2012/12/16 20:53:17
Oh. I didn't realize that this was an idiom for o
| |
| 133 FakeTiledLayerImpl* layerImpl1, | 119 { |
| 134 FakeTiledLayer* layer2 = 0, | 120 scoped_refptr<FakeTiledLayer> layer2; |
| 135 FakeTiledLayerImpl* layerImpl2 = 0) | 121 calcDrawProps(layer1, layer2); |
| 122 } | |
| 123 | |
| 124 void calcDrawProps(const scoped_refptr<FakeTiledLayer>& layer1, | |
| 125 const scoped_refptr<FakeTiledLayer>& layer2) | |
| 126 { | |
| 127 if (layer1 && !layer1->parent()) | |
| 128 m_layerTreeHost->rootLayer()->addChild(layer1); | |
| 129 if (layer2 && !layer1->parent()) | |
| 130 m_layerTreeHost->rootLayer()->addChild(layer2); | |
| 131 if (m_occlusion) | |
| 132 m_occlusion->setRenderTarget(m_layerTreeHost->rootLayer()); | |
| 133 | |
| 134 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | |
| 135 LayerTreeHostCommon::calculateDrawProperties( | |
| 136 m_layerTreeHost->rootLayer(), | |
| 137 m_layerTreeHost->deviceViewportSize(), | |
| 138 m_layerTreeHost->deviceScaleFactor(), | |
| 139 1, // page_scale_factor | |
| 140 m_layerTreeHost->rendererCapabilities().maxTextureSize, | |
| 141 false, // can_use_lcd_text | |
| 142 renderSurfaceLayerList); | |
| 143 } | |
| 144 | |
| 145 bool updateAndPush(const scoped_refptr<FakeTiledLayer>& layer1, | |
| 146 const scoped_ptr<FakeTiledLayerImpl>& layerImpl1) | |
| 147 { | |
| 148 scoped_refptr<FakeTiledLayer> layer2; | |
| 149 scoped_ptr<FakeTiledLayerImpl> layerImpl2; | |
| 150 return updateAndPush(layer1, layerImpl1, layer2, layerImpl2); | |
| 151 } | |
| 152 | |
| 153 bool updateAndPush(const scoped_refptr<FakeTiledLayer>& layer1, | |
| 154 const scoped_ptr<FakeTiledLayerImpl>& layerImpl1, | |
| 155 const scoped_refptr<FakeTiledLayer>& layer2, | |
| 156 const scoped_ptr<FakeTiledLayerImpl>& layerImpl2) | |
| 136 { | 157 { |
| 137 // Get textures | 158 // Get textures |
| 138 m_resourceManager->clearPriorities(); | 159 m_resourceManager->clearPriorities(); |
| 139 if (layer1) | 160 if (layer1) |
| 140 layer1->setTexturePriorities(m_priorityCalculator); | 161 layer1->setTexturePriorities(m_priorityCalculator); |
| 141 if (layer2) | 162 if (layer2) |
| 142 layer2->setTexturePriorities(m_priorityCalculator); | 163 layer2->setTexturePriorities(m_priorityCalculator); |
| 143 m_resourceManager->prioritizeTextures(); | 164 m_resourceManager->prioritizeTextures(); |
| 144 | 165 |
| 145 // Update content | 166 // Update content |
| 146 if (layer1) | 167 if (layer1) |
| 147 layer1->update(*m_queue.get(), m_occlusion, m_stats); | 168 layer1->update(*m_queue.get(), m_occlusion, m_stats); |
| 148 if (layer2) | 169 if (layer2) |
| 149 layer2->update(*m_queue.get(), m_occlusion, m_stats); | 170 layer2->update(*m_queue.get(), m_occlusion, m_stats); |
| 150 | 171 |
| 151 bool needsUpdate = false; | 172 bool needsUpdate = false; |
| 152 if (layer1) | 173 if (layer1) |
| 153 needsUpdate |= layer1->needsIdlePaint(); | 174 needsUpdate |= layer1->needsIdlePaint(); |
| 154 if (layer2) | 175 if (layer2) |
| 155 needsUpdate |= layer2->needsIdlePaint(); | 176 needsUpdate |= layer2->needsIdlePaint(); |
| 156 | 177 |
| 157 // Update textures and push. | 178 // Update textures and push. |
| 158 updateTextures(); | 179 updateTextures(); |
| 159 if (layer1) | 180 if (layer1) |
| 160 layerPushPropertiesTo(layer1, layerImpl1); | 181 layerPushPropertiesTo(layer1.get(), layerImpl1.get()); |
| 161 if (layer2) | 182 if (layer2) |
| 162 layerPushPropertiesTo(layer2, layerImpl2); | 183 layerPushPropertiesTo(layer2.get(), layerImpl2.get()); |
| 163 | 184 |
| 164 return needsUpdate; | 185 return needsUpdate; |
| 165 } | 186 } |
| 166 | 187 |
| 167 public: | 188 public: |
| 168 Proxy* m_proxy; | 189 Proxy* m_proxy; |
| 169 LayerTreeSettings m_settings; | 190 LayerTreeSettings m_settings; |
| 170 scoped_ptr<OutputSurface> m_outputSurface; | 191 scoped_ptr<OutputSurface> m_outputSurface; |
| 171 scoped_ptr<ResourceProvider> m_resourceProvider; | 192 scoped_ptr<ResourceProvider> m_resourceProvider; |
| 172 scoped_ptr<ResourceUpdateQueue> m_queue; | 193 scoped_ptr<ResourceUpdateQueue> m_queue; |
| 173 RenderingStats m_stats; | 194 RenderingStats m_stats; |
| 174 PriorityCalculator m_priorityCalculator; | 195 PriorityCalculator m_priorityCalculator; |
| 175 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient; | 196 FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient; |
| 176 scoped_ptr<LayerTreeHost> m_layerTreeHost; | 197 scoped_ptr<LayerTreeHost> m_layerTreeHost; |
| 177 scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl; | 198 scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl; |
| 178 scoped_ptr<PrioritizedResourceManager> m_resourceManager; | 199 scoped_ptr<PrioritizedResourceManager> m_resourceManager; |
| 179 TestOcclusionTracker* m_occlusion; | 200 TestOcclusionTracker* m_occlusion; |
| 180 }; | 201 }; |
| 181 | 202 |
| 182 TEST_F(TiledLayerTest, pushDirtyTiles) | 203 TEST_F(TiledLayerTest, pushDirtyTiles) |
| 183 { | 204 { |
| 184 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 205 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 185 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 206 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 186 | 207 |
| 187 // The tile size is 100x100, so this invalidates and then paints two tiles. | 208 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 188 layer->setBounds(gfx::Size(100, 200)); | 209 layer->setBounds(gfx::Size(100, 200)); |
| 189 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 210 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 190 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 211 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
| 191 updateAndPush(layer.get(), layerImpl.get()); | 212 updateAndPush(layer, layerImpl); |
| 192 | 213 |
| 193 // We should have both tiles on the impl side. | 214 // We should have both tiles on the impl side. |
| 194 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 215 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 195 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 216 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 196 | 217 |
| 197 // Invalidates both tiles, but then only update one of them. | 218 // Invalidates both tiles, but then only update one of them. |
| 198 layer->setBounds(gfx::Size(100, 200)); | 219 layer->setBounds(gfx::Size(100, 200)); |
| 199 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 220 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
| 200 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 221 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
| 201 updateAndPush(layer.get(), layerImpl.get()); | 222 updateAndPush(layer, layerImpl); |
| 202 | 223 |
| 203 // We should only have the first tile since the other tile was invalidated b ut not painted. | 224 // We should only have the first tile since the other tile was invalidated b ut not painted. |
| 204 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 225 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 205 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 226 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 206 } | 227 } |
| 207 | 228 |
| 208 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) | 229 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) |
| 209 { | 230 { |
| 210 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 231 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 211 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 232 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 212 TestOcclusionTracker occluded; | 233 TestOcclusionTracker occluded; |
| 213 m_occlusion = &occluded; | 234 m_occlusion = &occluded; |
| 214 | 235 |
| 215 // The tile size is 100x100, so this invalidates and then paints two tiles. | 236 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 216 layer->setBounds(gfx::Size(100, 200)); | 237 layer->setBounds(gfx::Size(100, 200)); |
| 217 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 238 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 218 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 100, 200); | 239 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 100, 200); |
| 219 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 240 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
| 220 updateAndPush(layer.get(), layerImpl.get()); | 241 updateAndPush(layer, layerImpl); |
| 221 | 242 |
| 222 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 243 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 223 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1 ); | 244 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1 ); |
| 224 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 245 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 225 | 246 |
| 226 // We should have both tiles on the impl side. | 247 // We should have both tiles on the impl side. |
| 227 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 248 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 228 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 249 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 229 | 250 |
| 230 // Invalidates part of the top tile... | 251 // Invalidates part of the top tile... |
| 231 layer->invalidateContentRect(gfx::Rect(0, 0, 50, 50)); | 252 layer->invalidateContentRect(gfx::Rect(0, 0, 50, 50)); |
| 232 // ....but the area is occluded. | 253 // ....but the area is occluded. |
| 233 occluded.setOcclusion(gfx::Rect(0, 0, 50, 50)); | 254 occluded.setOcclusion(gfx::Rect(0, 0, 50, 50)); |
| 234 updateAndPush(layer.get(), layerImpl.get()); | 255 updateAndPush(layer, layerImpl); |
| 235 | 256 |
| 236 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 257 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 237 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 2500, 1); | 258 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 + 2500, 1); |
| 238 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 259 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 239 | 260 |
| 240 // We should still have both tiles, as part of the top tile is still unocclu ded. | 261 // We should still have both tiles, as part of the top tile is still unocclu ded. |
| 241 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 262 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 242 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 263 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 243 } | 264 } |
| 244 | 265 |
| 245 TEST_F(TiledLayerTest, pushDeletedTiles) | 266 TEST_F(TiledLayerTest, pushDeletedTiles) |
| 246 { | 267 { |
| 247 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 268 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 248 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 269 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 249 | 270 |
| 250 // The tile size is 100x100, so this invalidates and then paints two tiles. | 271 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 251 layer->setBounds(gfx::Size(100, 200)); | 272 layer->setBounds(gfx::Size(100, 200)); |
| 252 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 273 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 253 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 274 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
| 254 updateAndPush(layer.get(), layerImpl.get()); | 275 updateAndPush(layer, layerImpl); |
| 255 | 276 |
| 256 // We should have both tiles on the impl side. | 277 // We should have both tiles on the impl side. |
| 257 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 278 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 258 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 279 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 259 | 280 |
| 260 m_resourceManager->clearPriorities(); | 281 m_resourceManager->clearPriorities(); |
| 261 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvider.ge t()); | 282 resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvider.ge t()); |
| 262 m_resourceManager->setMaxMemoryLimitBytes(4*1024*1024); | 283 m_resourceManager->setMaxMemoryLimitBytes(4*1024*1024); |
| 263 | 284 |
| 264 // This should drop the tiles on the impl thread. | 285 // This should drop the tiles on the impl thread. |
| 265 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 286 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 266 | 287 |
| 267 // We should now have no textures on the impl thread. | 288 // We should now have no textures on the impl thread. |
| 268 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); | 289 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 269 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 290 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 270 | 291 |
| 271 // This should recreate and update one of the deleted textures. | 292 // This should recreate and update one of the deleted textures. |
| 272 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 293 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
| 273 updateAndPush(layer.get(), layerImpl.get()); | 294 updateAndPush(layer, layerImpl); |
| 274 | 295 |
| 275 // We should have one tiles on the impl side. | 296 // We should have one tiles on the impl side. |
| 276 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 297 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 277 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 298 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 278 } | 299 } |
| 279 | 300 |
| 280 TEST_F(TiledLayerTest, pushIdlePaintTiles) | 301 TEST_F(TiledLayerTest, pushIdlePaintTiles) |
| 281 { | 302 { |
| 282 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 303 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 283 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 304 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 284 | 305 |
| 285 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce nter. | 306 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce nter. |
| 286 // This paints 1 visible of the 25 invalid tiles. | 307 // This paints 1 visible of the 25 invalid tiles. |
| 287 layer->setBounds(gfx::Size(500, 500)); | 308 layer->setBounds(gfx::Size(500, 500)); |
| 288 layer->drawProperties().visible_content_rect = gfx::Rect(200, 200, 100, 100) ; | 309 layer->drawProperties().visible_content_rect = gfx::Rect(200, 200, 100, 100) ; |
| 289 layer->invalidateContentRect(gfx::Rect(0, 0, 500, 500)); | 310 layer->invalidateContentRect(gfx::Rect(0, 0, 500, 500)); |
| 290 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 311 bool needsUpdate = updateAndPush(layer, layerImpl); |
| 291 // We should need idle-painting for surrounding tiles. | 312 // We should need idle-painting for surrounding tiles. |
| 292 EXPECT_TRUE(needsUpdate); | 313 EXPECT_TRUE(needsUpdate); |
| 293 | 314 |
| 294 // We should have one tile on the impl side. | 315 // We should have one tile on the impl side. |
| 295 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(2, 2)); | 316 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(2, 2)); |
| 296 | 317 |
| 297 // For the next four updates, we should detect we still need idle painting. | 318 // For the next four updates, we should detect we still need idle painting. |
| 298 for (int i = 0; i < 4; i++) { | 319 for (int i = 0; i < 4; i++) { |
| 299 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 320 needsUpdate = updateAndPush(layer, layerImpl); |
| 300 EXPECT_TRUE(needsUpdate); | 321 EXPECT_TRUE(needsUpdate); |
| 301 } | 322 } |
| 302 | 323 |
| 303 // We should always finish painting eventually. | 324 // We should always finish painting eventually. |
| 304 for (int i = 0; i < 20; i++) | 325 for (int i = 0; i < 20; i++) |
| 305 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 326 needsUpdate = updateAndPush(layer, layerImpl); |
| 306 | 327 |
| 307 // We should have pre-painted all of the surrounding tiles. | 328 // We should have pre-painted all of the surrounding tiles. |
| 308 for (int i = 0; i < 5; i++) { | 329 for (int i = 0; i < 5; i++) { |
| 309 for (int j = 0; j < 5; j++) | 330 for (int j = 0; j < 5; j++) |
| 310 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j)); | 331 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(i, j)); |
| 311 } | 332 } |
| 312 | 333 |
| 313 EXPECT_FALSE(needsUpdate); | 334 EXPECT_FALSE(needsUpdate); |
| 314 } | 335 } |
| 315 | 336 |
| 316 TEST_F(TiledLayerTest, predictivePainting) | 337 TEST_F(TiledLayerTest, predictivePainting) |
| 317 { | 338 { |
| 318 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 339 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 319 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 340 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 320 | 341 |
| 321 // Prepainting should occur in the scroll direction first, and the | 342 // Prepainting should occur in the scroll direction first, and the |
| 322 // visible rect should be extruded only along the dominant axis. | 343 // visible rect should be extruded only along the dominant axis. |
| 323 gfx::Vector2d directions[6] = { gfx::Vector2d(-10, 0), | 344 gfx::Vector2d directions[6] = { gfx::Vector2d(-10, 0), |
| 324 gfx::Vector2d(10, 0), | 345 gfx::Vector2d(10, 0), |
| 325 gfx::Vector2d(0, -10), | 346 gfx::Vector2d(0, -10), |
| 326 gfx::Vector2d(0, 10), | 347 gfx::Vector2d(0, 10), |
| 327 gfx::Vector2d(10, 20), | 348 gfx::Vector2d(10, 20), |
| 328 gfx::Vector2d(-20, 10) }; | 349 gfx::Vector2d(-20, 10) }; |
| 329 // We should push all tiles that touch the extruded visible rect. | 350 // We should push all tiles that touch the extruded visible rect. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 347 gfx::Size contentBounds = gfx::Size(500, 500); | 368 gfx::Size contentBounds = gfx::Size(500, 500); |
| 348 gfx::Rect contentRect = gfx::Rect(0, 0, 500, 500); | 369 gfx::Rect contentRect = gfx::Rect(0, 0, 500, 500); |
| 349 gfx::Rect visibleRect = gfx::Rect(200, 200, 100, 100); | 370 gfx::Rect visibleRect = gfx::Rect(200, 200, 100, 100); |
| 350 gfx::Rect previousVisibleRect = gfx::Rect(visibleRect.origin() + directi ons[k], visibleRect.size()); | 371 gfx::Rect previousVisibleRect = gfx::Rect(visibleRect.origin() + directi ons[k], visibleRect.size()); |
| 351 gfx::Rect nextVisibleRect = gfx::Rect(visibleRect.origin() - directions[ k], visibleRect.size()); | 372 gfx::Rect nextVisibleRect = gfx::Rect(visibleRect.origin() - directions[ k], visibleRect.size()); |
| 352 | 373 |
| 353 // Setup. Use the previousVisibleRect to setup the prediction for next f rame. | 374 // Setup. Use the previousVisibleRect to setup the prediction for next f rame. |
| 354 layer->setBounds(contentBounds); | 375 layer->setBounds(contentBounds); |
| 355 layer->drawProperties().visible_content_rect = previousVisibleRect; | 376 layer->drawProperties().visible_content_rect = previousVisibleRect; |
| 356 layer->invalidateContentRect(contentRect); | 377 layer->invalidateContentRect(contentRect); |
| 357 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 378 bool needsUpdate = updateAndPush(layer, layerImpl); |
| 358 | 379 |
| 359 // Invalidate and move the visibleRect in the scroll direction. | 380 // Invalidate and move the visibleRect in the scroll direction. |
| 360 // Check that the correct tiles have been painted in the visible pass. | 381 // Check that the correct tiles have been painted in the visible pass. |
| 361 layer->invalidateContentRect(contentRect); | 382 layer->invalidateContentRect(contentRect); |
| 362 layer->drawProperties().visible_content_rect = visibleRect; | 383 layer->drawProperties().visible_content_rect = visibleRect; |
| 363 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 384 needsUpdate = updateAndPush(layer, layerImpl); |
| 364 for (int i = 0; i < 5; i++) { | 385 for (int i = 0; i < 5; i++) { |
| 365 for (int j = 0; j < 5; j++) | 386 for (int j = 0; j < 5; j++) |
| 366 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedVisible Tiles[k].Contains(i, j)); | 387 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedVisible Tiles[k].Contains(i, j)); |
| 367 } | 388 } |
| 368 | 389 |
| 369 // Move the transform in the same direction without invalidating. | 390 // Move the transform in the same direction without invalidating. |
| 370 // Check that non-visible pre-painting occured in the correct direction. | 391 // Check that non-visible pre-painting occured in the correct direction. |
| 371 // Ignore diagonal scrolls here (k > 3) as these have new visible conten t now. | 392 // Ignore diagonal scrolls here (k > 3) as these have new visible conten t now. |
| 372 if (k <= 3) { | 393 if (k <= 3) { |
| 373 layer->drawProperties().visible_content_rect = nextVisibleRect; | 394 layer->drawProperties().visible_content_rect = nextVisibleRect; |
| 374 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 395 needsUpdate = updateAndPush(layer, layerImpl); |
| 375 for (int i = 0; i < 5; i++) { | 396 for (int i = 0; i < 5; i++) { |
| 376 for (int j = 0; j < 5; j++) | 397 for (int j = 0; j < 5; j++) |
| 377 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedPre paintTiles[k].Contains(i, j)); | 398 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedPre paintTiles[k].Contains(i, j)); |
| 378 } | 399 } |
| 379 } | 400 } |
| 380 | 401 |
| 381 // We should always finish painting eventually. | 402 // We should always finish painting eventually. |
| 382 for (int i = 0; i < 20; i++) | 403 for (int i = 0; i < 20; i++) |
| 383 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 404 needsUpdate = updateAndPush(layer, layerImpl); |
| 384 EXPECT_FALSE(needsUpdate); | 405 EXPECT_FALSE(needsUpdate); |
| 385 } | 406 } |
| 386 } | 407 } |
| 387 | 408 |
| 388 TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed) | 409 TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed) |
| 389 { | 410 { |
| 390 // Start with 2mb of memory, but the test is going to try to use just more t han 1mb, so we reduce to 1mb later. | 411 // Start with 2mb of memory, but the test is going to try to use just more t han 1mb, so we reduce to 1mb later. |
| 391 m_resourceManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); | 412 m_resourceManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); |
| 392 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); | 413 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); |
| 393 ScopedFakeTiledLayerImpl layerImpl1(m_hostImpl->activeTree(), 1); | 414 scoped_ptr<FakeTiledLayerImpl> layerImpl1 = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 1)); |
| 394 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); | 415 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); |
| 395 ScopedFakeTiledLayerImpl layerImpl2(m_hostImpl->activeTree(), 2); | 416 scoped_ptr<FakeTiledLayerImpl> layerImpl2 = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 2)); |
| 396 | 417 |
| 397 // For this test we have two layers. layer1 exhausts most texture memory, le aving room for 2 more tiles from | 418 // For this test we have two layers. layer1 exhausts most texture memory, le aving room for 2 more tiles from |
| 398 // layer2, but not all three tiles. First we paint layer1, and one tile from layer2. Then when we idle paint | 419 // layer2, but not all three tiles. First we paint layer1, and one tile from layer2. Then when we idle paint |
| 399 // layer2, we will fail on the third tile of layer2, and this should not lea ve the second tile in a bad state. | 420 // layer2, we will fail on the third tile of layer2, and this should not lea ve the second tile in a bad state. |
| 400 | 421 |
| 401 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou gh for 2 tiles only in the other layer. | 422 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou gh for 2 tiles only in the other layer. |
| 402 gfx::Rect layer1Rect(0, 0, 100, 2400); | 423 gfx::Rect layer1Rect(0, 0, 100, 2400); |
| 403 | 424 |
| 404 // This requires 4*30000 bytes of memory. | 425 // This requires 4*30000 bytes of memory. |
| 405 gfx::Rect layer2Rect(0, 0, 100, 300); | 426 gfx::Rect layer2Rect(0, 0, 100, 300); |
| 406 | 427 |
| 407 // Paint a single tile in layer2 so that it will idle paint. | 428 // Paint a single tile in layer2 so that it will idle paint. |
| 408 layer1->setBounds(layer1Rect.size()); | 429 layer1->setBounds(layer1Rect.size()); |
| 409 layer1->drawProperties().visible_content_rect = layer1Rect; | 430 layer1->drawProperties().visible_content_rect = layer1Rect; |
| 410 layer2->setBounds(layer2Rect.size()); | 431 layer2->setBounds(layer2Rect.size()); |
| 411 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 432 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
| 412 bool needsUpdate = updateAndPush(layer1.get(), layerImpl1.get(), | 433 bool needsUpdate = updateAndPush(layer1, layerImpl1, |
| 413 layer2.get(), layerImpl2.get()); | 434 layer2, layerImpl2); |
| 414 // We should need idle-painting for both remaining tiles in layer2. | 435 // We should need idle-painting for both remaining tiles in layer2. |
| 415 EXPECT_TRUE(needsUpdate); | 436 EXPECT_TRUE(needsUpdate); |
| 416 | 437 |
| 417 // Reduce our memory limits to 1mb. | 438 // Reduce our memory limits to 1mb. |
| 418 m_resourceManager->setMaxMemoryLimitBytes(1024 * 1024); | 439 m_resourceManager->setMaxMemoryLimitBytes(1024 * 1024); |
| 419 | 440 |
| 420 // Now idle paint layer2. We are going to run out of memory though! | 441 // Now idle paint layer2. We are going to run out of memory though! |
| 421 // Oh well, commit the frame and push. | 442 // Oh well, commit the frame and push. |
| 422 for (int i = 0; i < 4; i++) { | 443 for (int i = 0; i < 4; i++) { |
| 423 needsUpdate = updateAndPush(layer1.get(), layerImpl1.get(), | 444 needsUpdate = updateAndPush(layer1, layerImpl1, |
| 424 layer2.get(), layerImpl2.get()); | 445 layer2, layerImpl2); |
| 425 } | 446 } |
| 426 | 447 |
| 427 // Sanity check, we should have textures for the big layer. | 448 // Sanity check, we should have textures for the big layer. |
| 428 EXPECT_TRUE(layerImpl1->hasResourceIdForTileAt(0, 0)); | 449 EXPECT_TRUE(layerImpl1->hasResourceIdForTileAt(0, 0)); |
| 429 EXPECT_TRUE(layerImpl1->hasResourceIdForTileAt(0, 23)); | 450 EXPECT_TRUE(layerImpl1->hasResourceIdForTileAt(0, 23)); |
| 430 | 451 |
| 431 // We should only have the first two tiles from layer2 since | 452 // We should only have the first two tiles from layer2 since |
| 432 // it failed to idle update the last tile. | 453 // it failed to idle update the last tile. |
| 433 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 0)); | 454 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 0)); |
| 434 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 0)); | 455 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 0)); |
| 435 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); | 456 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); |
| 436 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); | 457 EXPECT_TRUE(layerImpl2->hasResourceIdForTileAt(0, 1)); |
| 437 | 458 |
| 438 EXPECT_FALSE(needsUpdate); | 459 EXPECT_FALSE(needsUpdate); |
| 439 EXPECT_FALSE(layerImpl2->hasResourceIdForTileAt(0, 2)); | 460 EXPECT_FALSE(layerImpl2->hasResourceIdForTileAt(0, 2)); |
| 440 } | 461 } |
| 441 | 462 |
| 442 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles) | 463 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles) |
| 443 { | 464 { |
| 444 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 465 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 445 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 466 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 446 TestOcclusionTracker occluded; | 467 TestOcclusionTracker occluded; |
| 447 m_occlusion = &occluded; | 468 m_occlusion = &occluded; |
| 448 | 469 |
| 449 // The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it. | 470 // The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it. |
| 450 occluded.setOcclusion(gfx::Rect(0, 0, 100, 100)); | 471 occluded.setOcclusion(gfx::Rect(0, 0, 100, 100)); |
| 451 | 472 |
| 452 layer->setBounds(gfx::Size(100, 100)); | 473 layer->setBounds(gfx::Size(100, 100)); |
| 474 calcDrawProps(layer); | |
| 453 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 475 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
| 454 updateAndPush(layer.get(), layerImpl.get()); | 476 updateAndPush(layer, layerImpl); |
| 455 | 477 |
| 456 // We should have the prepainted tile on the impl side, but culled it during paint. | 478 // We should have the prepainted tile on the impl side, but culled it during paint. |
| 457 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 479 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 458 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); | 480 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 459 } | 481 } |
| 460 | 482 |
| 461 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) | 483 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) |
| 462 { | 484 { |
| 463 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 485 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 464 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 486 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 465 | 487 |
| 466 // The tile size is 100x100, so this invalidates and then paints two tiles. | 488 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 467 // However, during the paint, we invalidate one of the tiles. This should | 489 // However, during the paint, we invalidate one of the tiles. This should |
| 468 // not prevent the tile from being pushed. | 490 // not prevent the tile from being pushed. |
| 469 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la yer.get()); | 491 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la yer.get()); |
| 470 layer->setBounds(gfx::Size(100, 200)); | 492 layer->setBounds(gfx::Size(100, 200)); |
| 493 calcDrawProps(layer); | |
| 471 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 494 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 472 updateAndPush(layer.get(), layerImpl.get()); | 495 updateAndPush(layer, layerImpl); |
| 473 | 496 |
| 474 // We should have both tiles on the impl side. | 497 // We should have both tiles on the impl side. |
| 475 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 498 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 476 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 499 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 477 } | 500 } |
| 478 | 501 |
| 479 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) | 502 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) |
| 480 { | 503 { |
| 481 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); | 504 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); |
| 482 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); | 505 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); |
| 483 ScopedFakeTiledLayerImpl layer1Impl(m_hostImpl->activeTree(), 1); | 506 scoped_ptr<FakeTiledLayerImpl> layer1Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 1)); |
| 484 ScopedFakeTiledLayerImpl layer2Impl(m_hostImpl->activeTree(), 2); | 507 scoped_ptr<FakeTiledLayerImpl> layer2Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 2)); |
| 485 | 508 |
| 486 // Invalidate a tile on layer1, during update of layer 2. | 509 // Invalidate a tile on layer1, during update of layer 2. |
| 487 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer1.get()); | 510 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer1.get()); |
| 488 layer1->setBounds(gfx::Size(100, 200)); | 511 layer1->setBounds(gfx::Size(100, 200)); |
| 512 layer2->setBounds(gfx::Size(100, 200)); | |
| 513 calcDrawProps(layer1, layer2); | |
| 489 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 514 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 490 layer2->setBounds(gfx::Size(100, 200)); | |
| 491 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 515 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 492 updateAndPush(layer1.get(), layer1Impl.get(), | 516 updateAndPush(layer1, layer1Impl, |
| 493 layer2.get(), layer2Impl.get()); | 517 layer2, layer2Impl); |
| 494 | 518 |
| 495 // We should have both tiles on the impl side for all layers. | 519 // We should have both tiles on the impl side for all layers. |
| 496 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); | 520 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); |
| 497 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); | 521 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); |
| 498 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); | 522 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); |
| 499 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); | 523 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); |
| 500 } | 524 } |
| 501 | 525 |
| 502 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) | 526 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) |
| 503 { | 527 { |
| 504 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); | 528 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); |
| 505 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); | 529 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer (m_resourceManager.get())); |
| 506 ScopedFakeTiledLayerImpl layer1Impl(m_hostImpl->activeTree(), 1); | 530 scoped_ptr<FakeTiledLayerImpl> layer1Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 1)); |
| 507 ScopedFakeTiledLayerImpl layer2Impl(m_hostImpl->activeTree(), 2); | 531 scoped_ptr<FakeTiledLayerImpl> layer2Impl = make_scoped_ptr(new FakeTiledLay erImpl(m_hostImpl->activeTree(), 2)); |
| 508 | 532 |
| 509 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer2.get()); | 533 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l ayer2.get()); |
| 510 layer1->setBounds(gfx::Size(100, 200)); | 534 layer1->setBounds(gfx::Size(100, 200)); |
| 535 layer2->setBounds(gfx::Size(100, 200)); | |
| 536 calcDrawProps(layer1, layer2); | |
| 511 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 537 layer1->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 512 layer2->setBounds(gfx::Size(100, 200)); | |
| 513 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 538 layer2->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 514 updateAndPush(layer1.get(), layer1Impl.get(), | 539 updateAndPush(layer1, layer1Impl, |
| 515 layer2.get(), layer2Impl.get()); | 540 layer2, layer2Impl); |
| 516 | 541 |
| 517 // We should have both tiles on the impl side for all layers. | 542 // We should have both tiles on the impl side for all layers. |
| 518 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); | 543 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); |
| 519 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); | 544 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); |
| 520 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); | 545 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); |
| 521 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); | 546 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); |
| 522 } | 547 } |
| 523 | 548 |
| 524 TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately) | 549 TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately) |
| 525 { | 550 { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 538 int memoryForLayer = layerWidth * layerHeight * 4; | 563 int memoryForLayer = layerWidth * layerHeight * 4; |
| 539 layerTreeHost->setViewportSize(gfx::Size(layerWidth, layerHeight), gfx:: Size(layerWidth, layerHeight)); | 564 layerTreeHost->setViewportSize(gfx::Size(layerWidth, layerHeight), gfx:: Size(layerWidth, layerHeight)); |
| 540 | 565 |
| 541 // Use 10x5 tiles to run out of memory. | 566 // Use 10x5 tiles to run out of memory. |
| 542 if (runOutOfMemory[i]) | 567 if (runOutOfMemory[i]) |
| 543 layerWidth *= 2; | 568 layerWidth *= 2; |
| 544 | 569 |
| 545 m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer); | 570 m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer); |
| 546 | 571 |
| 547 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa yer(m_resourceManager.get())); | 572 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa yer(m_resourceManager.get())); |
| 548 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 573 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); |
| 549 | 574 |
| 550 // Full size layer with half being visible. | 575 // Full size layer with half being visible. |
| 551 gfx::Size contentBounds(layerWidth, layerHeight); | 576 gfx::Size contentBounds(layerWidth, layerHeight); |
| 552 gfx::Rect contentRect(gfx::Point(), contentBounds); | 577 gfx::Rect contentRect(gfx::Point(), contentBounds); |
| 553 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh t)); | 578 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh t)); |
| 554 | 579 |
| 555 // Pretend the layer is animating. | 580 // Pretend the layer is animating. |
| 556 layer->drawProperties().target_space_transform_is_animating = true; | 581 layer->drawProperties().target_space_transform_is_animating = true; |
| 557 layer->setBounds(contentBounds); | 582 layer->setBounds(contentBounds); |
| 558 layer->drawProperties().visible_content_rect = visibleRect; | 583 layer->drawProperties().visible_content_rect = visibleRect; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 580 for (int j = 0; j < 5; ++j) | 605 for (int j = 0; j < 5; ++j) |
| 581 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), i < 5); | 606 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), i < 5); |
| 582 } | 607 } |
| 583 } | 608 } |
| 584 } | 609 } |
| 585 } | 610 } |
| 586 | 611 |
| 587 TEST_F(TiledLayerTest, idlePaintOutOfMemory) | 612 TEST_F(TiledLayerTest, idlePaintOutOfMemory) |
| 588 { | 613 { |
| 589 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 614 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 590 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 615 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 591 | 616 |
| 592 // We have enough memory for only the visible rect, so we will run out of me mory in first idle paint. | 617 // We have enough memory for only the visible rect, so we will run out of me mory in first idle paint. |
| 593 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. | 618 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. |
| 594 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit); | 619 m_resourceManager->setMaxMemoryLimitBytes(memoryLimit); |
| 595 | 620 |
| 596 // The tile size is 100x100, so this invalidates and then paints two tiles. | 621 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 597 bool needsUpdate = false; | 622 bool needsUpdate = false; |
| 598 layer->setBounds(gfx::Size(300, 300)); | 623 layer->setBounds(gfx::Size(300, 300)); |
| 624 calcDrawProps(layer); | |
| 599 layer->drawProperties().visible_content_rect = gfx::Rect(100, 100, 100, 100) ; | 625 layer->drawProperties().visible_content_rect = gfx::Rect(100, 100, 100, 100) ; |
| 600 for (int i = 0; i < 2; i++) | 626 for (int i = 0; i < 2; i++) |
| 601 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 627 needsUpdate = updateAndPush(layer, layerImpl); |
| 602 | 628 |
| 603 // Idle-painting should see no more priority tiles for painting. | 629 // Idle-painting should see no more priority tiles for painting. |
| 604 EXPECT_FALSE(needsUpdate); | 630 EXPECT_FALSE(needsUpdate); |
| 605 | 631 |
| 606 // We should have one tile on the impl side. | 632 // We should have one tile on the impl side. |
| 607 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); | 633 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); |
| 608 } | 634 } |
| 609 | 635 |
| 610 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) | 636 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) |
| 611 { | 637 { |
| 612 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 638 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 613 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 639 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 614 | 640 |
| 615 bool animating[2] = {false, true}; | 641 bool animating[2] = {false, true}; |
| 616 for (int i = 0; i < 2; i++) { | 642 for (int i = 0; i < 2; i++) { |
| 617 // Pretend the layer is animating. | 643 // Pretend the layer is animating. |
| 618 layer->drawProperties().target_space_transform_is_animating = animating[ i]; | 644 layer->drawProperties().target_space_transform_is_animating = animating[ i]; |
| 619 | 645 |
| 620 // The layer's bounds are empty. | 646 // The layer's bounds are empty. |
| 621 // Empty layers don't paint or idle-paint. | 647 // Empty layers don't paint or idle-paint. |
| 622 layer->setBounds(gfx::Size()); | 648 layer->setBounds(gfx::Size()); |
| 649 calcDrawProps(layer); | |
| 623 layer->drawProperties().visible_content_rect = gfx::Rect(); | 650 layer->drawProperties().visible_content_rect = gfx::Rect(); |
| 624 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 651 bool needsUpdate = updateAndPush(layer, layerImpl); |
| 625 | 652 |
| 626 // Empty layers don't have tiles. | 653 // Empty layers don't have tiles. |
| 627 EXPECT_EQ(0u, layer->numPaintedTiles()); | 654 EXPECT_EQ(0u, layer->numPaintedTiles()); |
| 628 | 655 |
| 629 // Empty layers don't need prepaint. | 656 // Empty layers don't need prepaint. |
| 630 EXPECT_FALSE(needsUpdate); | 657 EXPECT_FALSE(needsUpdate); |
| 631 | 658 |
| 632 // Empty layers don't have tiles. | 659 // Empty layers don't have tiles. |
| 633 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); | 660 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 634 } | 661 } |
| 635 } | 662 } |
| 636 | 663 |
| 637 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers) | 664 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers) |
| 638 { | 665 { |
| 639 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 666 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 640 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 667 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 641 | 668 |
| 642 // Alternate between not visible and visible. | 669 // Alternate between not visible and visible. |
| 643 gfx::Rect v(0, 0, 100, 100); | 670 gfx::Rect v(0, 0, 100, 100); |
| 644 gfx::Rect nv(0, 0, 0, 0); | 671 gfx::Rect nv(0, 0, 0, 0); |
| 645 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; | 672 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; |
| 646 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals e, false }; | 673 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals e, false }; |
| 647 | 674 |
| 648 // We should not have any tiles except for when the layer was visible | 675 // We should not have any tiles except for when the layer was visible |
| 649 // or after the layer was visible and we didn't invalidate. | 676 // or after the layer was visible and we didn't invalidate. |
| 650 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr ue, true }; | 677 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr ue, true }; |
| 651 | 678 |
| 652 for (int i = 0; i < 10; i++) { | 679 for (int i = 0; i < 10; i++) { |
| 653 layer->setBounds(gfx::Size(100, 100)); | 680 layer->setBounds(gfx::Size(100, 100)); |
| 681 calcDrawProps(layer); | |
| 654 layer->drawProperties().visible_content_rect = visibleRect[i]; | 682 layer->drawProperties().visible_content_rect = visibleRect[i]; |
| 655 | 683 |
| 656 if (invalidate[i]) | 684 if (invalidate[i]) |
| 657 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 100)); | 685 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 100)); |
| 658 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 686 bool needsUpdate = updateAndPush(layer, layerImpl); |
| 659 | 687 |
| 660 // We should never signal idle paint, as we painted the entire layer | 688 // We should never signal idle paint, as we painted the entire layer |
| 661 // or the layer was not visible. | 689 // or the layer was not visible. |
| 662 EXPECT_FALSE(needsUpdate); | 690 EXPECT_FALSE(needsUpdate); |
| 663 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); | 691 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); |
| 664 } | 692 } |
| 665 } | 693 } |
| 666 | 694 |
| 667 TEST_F(TiledLayerTest, invalidateFromPrepare) | 695 TEST_F(TiledLayerTest, invalidateFromPrepare) |
| 668 { | 696 { |
| 669 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 697 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 670 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 698 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 671 | 699 |
| 672 // The tile size is 100x100, so this invalidates and then paints two tiles. | 700 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 673 layer->setBounds(gfx::Size(100, 200)); | 701 layer->setBounds(gfx::Size(100, 200)); |
| 702 calcDrawProps(layer); | |
| 674 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); | 703 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); |
| 675 updateAndPush(layer.get(), layerImpl.get()); | 704 updateAndPush(layer, layerImpl); |
| 676 | 705 |
| 677 // We should have both tiles on the impl side. | 706 // We should have both tiles on the impl side. |
| 678 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 707 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
| 679 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 708 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
| 680 | 709 |
| 681 layer->fakeLayerUpdater()->clearPrepareCount(); | 710 layer->fakeLayerUpdater()->clearPrepareCount(); |
| 682 // Invoke update again. As the layer is valid update shouldn't be invoked on | 711 // Invoke update again. As the layer is valid update shouldn't be invoked on |
| 683 // the LayerUpdater. | 712 // the LayerUpdater. |
| 684 updateAndPush(layer.get(), layerImpl.get()); | 713 updateAndPush(layer, layerImpl); |
| 685 EXPECT_EQ(0, layer->fakeLayerUpdater()->prepareCount()); | 714 EXPECT_EQ(0, layer->fakeLayerUpdater()->prepareCount()); |
| 686 | 715 |
| 687 // setRectToInvalidate triggers invalidateContentRect() being invoked from u pdate. | 716 // setRectToInvalidate triggers invalidateContentRect() being invoked from u pdate. |
| 688 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(25, 25, 50, 50), la yer.get()); | 717 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(25, 25, 50, 50), la yer.get()); |
| 689 layer->fakeLayerUpdater()->clearPrepareCount(); | 718 layer->fakeLayerUpdater()->clearPrepareCount(); |
| 690 layer->invalidateContentRect(gfx::Rect(0, 0, 50, 50)); | 719 layer->invalidateContentRect(gfx::Rect(0, 0, 50, 50)); |
| 691 updateAndPush(layer.get(), layerImpl.get()); | 720 updateAndPush(layer, layerImpl); |
| 692 EXPECT_EQ(1, layer->fakeLayerUpdater()->prepareCount()); | 721 EXPECT_EQ(1, layer->fakeLayerUpdater()->prepareCount()); |
| 693 layer->fakeLayerUpdater()->clearPrepareCount(); | 722 layer->fakeLayerUpdater()->clearPrepareCount(); |
| 694 | 723 |
| 695 // The layer should still be invalid as update invoked invalidate. | 724 // The layer should still be invalid as update invoked invalidate. |
| 696 updateAndPush(layer.get(), layerImpl.get()); // visible | 725 updateAndPush(layer, layerImpl); // visible |
| 697 EXPECT_EQ(1, layer->fakeLayerUpdater()->prepareCount()); | 726 EXPECT_EQ(1, layer->fakeLayerUpdater()->prepareCount()); |
| 698 } | 727 } |
| 699 | 728 |
| 700 TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled) | 729 TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled) |
| 701 { | 730 { |
| 702 // The updateRect (that indicates what was actually painted) should be in | 731 // The updateRect (that indicates what was actually painted) should be in |
| 703 // layer space, not the content space. | 732 // layer space, not the content space. |
| 704 scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new FakeTiledLayerWithScaledBounds(m_resourceManager.get())); | 733 scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new FakeTiledLayerWithScaledBounds(m_resourceManager.get())); |
| 705 | 734 |
| 706 gfx::Rect layerBounds(0, 0, 300, 200); | 735 gfx::Rect layerBounds(0, 0, 300, 200); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 733 layer->invalidateContentRect(partialDamage); | 762 layer->invalidateContentRect(partialDamage); |
| 734 layer->setTexturePriorities(m_priorityCalculator); | 763 layer->setTexturePriorities(m_priorityCalculator); |
| 735 m_resourceManager->prioritizeTextures(); | 764 m_resourceManager->prioritizeTextures(); |
| 736 layer->update(*m_queue.get(), 0, m_stats); | 765 layer->update(*m_queue.get(), 0, m_stats); |
| 737 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); | 766 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); |
| 738 } | 767 } |
| 739 | 768 |
| 740 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) | 769 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) |
| 741 { | 770 { |
| 742 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 771 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 743 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 772 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiledLaye rImpl(m_hostImpl->activeTree(), 1)); |
| 744 | 773 |
| 745 // Create a layer with one tile. | 774 // Create a layer with one tile. |
| 746 layer->setBounds(gfx::Size(100, 100)); | 775 layer->setBounds(gfx::Size(100, 100)); |
| 747 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 776 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
| 748 | 777 |
| 749 // Invalidate the entire layer. | 778 // Invalidate the entire layer. |
| 750 layer->setNeedsDisplay(); | 779 layer->setNeedsDisplay(); |
| 751 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect ()); | 780 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect ()); |
| 752 | 781 |
| 753 // Push the tiles to the impl side and check that there is exactly one. | 782 // Push the tiles to the impl side and check that there is exactly one. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 885 layer->drawProperties().visible_content_rect = contentRect; | 914 layer->drawProperties().visible_content_rect = contentRect; |
| 886 layer->invalidateContentRect(contentRect); | 915 layer->invalidateContentRect(contentRect); |
| 887 | 916 |
| 888 m_layerTreeHost->setRootLayer(layer); | 917 m_layerTreeHost->setRootLayer(layer); |
| 889 m_layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); | 918 m_layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); |
| 890 | 919 |
| 891 // Full update of all 6 tiles. | 920 // Full update of all 6 tiles. |
| 892 m_layerTreeHost->updateLayers( | 921 m_layerTreeHost->updateLayers( |
| 893 *m_queue.get(), std::numeric_limits<size_t>::max()); | 922 *m_queue.get(), std::numeric_limits<size_t>::max()); |
| 894 { | 923 { |
| 895 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 924 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); |
| 896 EXPECT_EQ(6, m_queue->fullUploadSize()); | 925 EXPECT_EQ(6, m_queue->fullUploadSize()); |
| 897 EXPECT_EQ(0, m_queue->partialUploadSize()); | 926 EXPECT_EQ(0, m_queue->partialUploadSize()); |
| 898 updateTextures(); | 927 updateTextures(); |
| 899 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 928 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
| 900 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 929 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 901 layer->fakeLayerUpdater()->clearUpdateCount(); | 930 layer->fakeLayerUpdater()->clearUpdateCount(); |
| 902 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 931 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 903 } | 932 } |
| 904 m_layerTreeHost->commitComplete(); | 933 m_layerTreeHost->commitComplete(); |
| 905 | 934 |
| 906 // Full update of 3 tiles and partial update of 3 tiles. | 935 // Full update of 3 tiles and partial update of 3 tiles. |
| 907 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150)); | 936 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150)); |
| 908 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::m ax()); | 937 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::m ax()); |
| 909 { | 938 { |
| 910 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 939 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); |
| 911 EXPECT_EQ(3, m_queue->fullUploadSize()); | 940 EXPECT_EQ(3, m_queue->fullUploadSize()); |
| 912 EXPECT_EQ(3, m_queue->partialUploadSize()); | 941 EXPECT_EQ(3, m_queue->partialUploadSize()); |
| 913 updateTextures(); | 942 updateTextures(); |
| 914 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 943 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
| 915 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 944 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 916 layer->fakeLayerUpdater()->clearUpdateCount(); | 945 layer->fakeLayerUpdater()->clearUpdateCount(); |
| 917 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 946 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 918 } | 947 } |
| 919 m_layerTreeHost->commitComplete(); | 948 m_layerTreeHost->commitComplete(); |
| 920 | 949 |
| 921 // Partial update of 6 tiles. | 950 // Partial update of 6 tiles. |
| 922 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); | 951 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); |
| 923 { | 952 { |
| 924 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 953 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); |
| 925 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); | 954 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); |
| 926 EXPECT_EQ(2, m_queue->fullUploadSize()); | 955 EXPECT_EQ(2, m_queue->fullUploadSize()); |
| 927 EXPECT_EQ(4, m_queue->partialUploadSize()); | 956 EXPECT_EQ(4, m_queue->partialUploadSize()); |
| 928 updateTextures(); | 957 updateTextures(); |
| 929 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 958 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
| 930 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 959 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 931 layer->fakeLayerUpdater()->clearUpdateCount(); | 960 layer->fakeLayerUpdater()->clearUpdateCount(); |
| 932 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 961 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 933 } | 962 } |
| 934 m_layerTreeHost->commitComplete(); | 963 m_layerTreeHost->commitComplete(); |
| 935 | 964 |
| 936 // Checkerboard all tiles. | 965 // Checkerboard all tiles. |
| 937 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200)); | 966 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200)); |
| 938 { | 967 { |
| 939 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 968 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); |
| 940 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 969 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 941 } | 970 } |
| 942 m_layerTreeHost->commitComplete(); | 971 m_layerTreeHost->commitComplete(); |
| 943 | 972 |
| 944 // Partial update of 6 checkerboard tiles. | 973 // Partial update of 6 checkerboard tiles. |
| 945 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); | 974 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); |
| 946 { | 975 { |
| 947 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 976 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); |
| 948 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); | 977 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); |
| 949 EXPECT_EQ(6, m_queue->fullUploadSize()); | 978 EXPECT_EQ(6, m_queue->fullUploadSize()); |
| 950 EXPECT_EQ(0, m_queue->partialUploadSize()); | 979 EXPECT_EQ(0, m_queue->partialUploadSize()); |
| 951 updateTextures(); | 980 updateTextures(); |
| 952 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 981 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
| 953 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 982 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 954 layer->fakeLayerUpdater()->clearUpdateCount(); | 983 layer->fakeLayerUpdater()->clearUpdateCount(); |
| 955 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 984 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 956 } | 985 } |
| 957 m_layerTreeHost->commitComplete(); | 986 m_layerTreeHost->commitComplete(); |
| 958 | 987 |
| 959 // Partial update of 4 tiles. | 988 // Partial update of 4 tiles. |
| 960 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100)); | 989 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100)); |
| 961 { | 990 { |
| 962 ScopedFakeTiledLayerImpl layerImpl(m_hostImpl->activeTree(), 1); | 991 scoped_ptr<FakeTiledLayerImpl> layerImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), 1)); |
| 963 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); | 992 m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t >::max()); |
| 964 EXPECT_EQ(0, m_queue->fullUploadSize()); | 993 EXPECT_EQ(0, m_queue->fullUploadSize()); |
| 965 EXPECT_EQ(4, m_queue->partialUploadSize()); | 994 EXPECT_EQ(4, m_queue->partialUploadSize()); |
| 966 updateTextures(); | 995 updateTextures(); |
| 967 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); | 996 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); |
| 968 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 997 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 969 layer->fakeLayerUpdater()->clearUpdateCount(); | 998 layer->fakeLayerUpdater()->clearUpdateCount(); |
| 970 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 999 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 971 } | 1000 } |
| 972 m_layerTreeHost->commitComplete(); | 1001 m_layerTreeHost->commitComplete(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 988 layer->setTexturePriorities(m_priorityCalculator); | 1017 layer->setTexturePriorities(m_priorityCalculator); |
| 989 m_resourceManager->prioritizeTextures(); | 1018 m_resourceManager->prioritizeTextures(); |
| 990 layer->update(*m_queue.get(), 0, m_stats); | 1019 layer->update(*m_queue.get(), 0, m_stats); |
| 991 EXPECT_EQ(2, layer->fakeLayerUpdater()->updateCount()); | 1020 EXPECT_EQ(2, layer->fakeLayerUpdater()->updateCount()); |
| 992 } | 1021 } |
| 993 | 1022 |
| 994 TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) | 1023 TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) |
| 995 { | 1024 { |
| 996 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 1025 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 997 TestOcclusionTracker occluded; | 1026 TestOcclusionTracker occluded; |
| 1027 m_occlusion = &occluded; | |
| 998 | 1028 |
| 999 // The tile size is 100x100. | 1029 // The tile size is 100x100. |
| 1000 | 1030 |
| 1001 layer->setBounds(gfx::Size(600, 600)); | 1031 layer->setBounds(gfx::Size(600, 600)); |
| 1032 calcDrawProps(layer); | |
| 1002 | 1033 |
| 1003 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); | 1034 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); |
| 1004 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye r->contentBounds()); | 1035 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye r->contentBounds()); |
| 1005 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer ->contentBounds()); | 1036 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer ->contentBounds()); |
| 1006 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1037 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
| 1007 | 1038 |
| 1008 layer->setTexturePriorities(m_priorityCalculator); | 1039 layer->setTexturePriorities(m_priorityCalculator); |
| 1009 m_resourceManager->prioritizeTextures(); | 1040 m_resourceManager->prioritizeTextures(); |
| 1010 layer->update(*m_queue.get(), &occluded, m_stats); | 1041 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1011 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); | 1042 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1038 | 1069 |
| 1039 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1070 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1040 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 + 340000 + 360000, 1); | 1071 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 + 340000 + 360000, 1); |
| 1041 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); | 1072 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1042 } | 1073 } |
| 1043 | 1074 |
| 1044 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) | 1075 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) |
| 1045 { | 1076 { |
| 1046 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 1077 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 1047 TestOcclusionTracker occluded; | 1078 TestOcclusionTracker occluded; |
| 1079 m_occlusion = &occluded; | |
| 1048 | 1080 |
| 1049 // The tile size is 100x100. | 1081 // The tile size is 100x100. |
| 1050 | 1082 |
| 1051 layer->setBounds(gfx::Size(600, 600)); | 1083 layer->setBounds(gfx::Size(600, 600)); |
| 1084 calcDrawProps(layer); | |
| 1052 | 1085 |
| 1053 // The partially occluded tiles (by the 150 occlusion height) are visible be yond the occlusion, so not culled. | 1086 // The partially occluded tiles (by the 150 occlusion height) are visible be yond the occlusion, so not culled. |
| 1054 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); | 1087 occluded.setOcclusion(gfx::Rect(200, 200, 300, 150)); |
| 1055 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); | 1088 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); |
| 1056 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 360); | 1089 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 360); |
| 1057 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1090 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
| 1058 | 1091 |
| 1059 layer->setTexturePriorities(m_priorityCalculator); | 1092 layer->setTexturePriorities(m_priorityCalculator); |
| 1060 m_resourceManager->prioritizeTextures(); | 1093 m_resourceManager->prioritizeTextures(); |
| 1061 layer->update(*m_queue.get(), &occluded, m_stats); | 1094 layer->update(*m_queue.get(), &occluded, m_stats); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1096 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1129 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1097 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 + 180000 + 180000, 1); | 1130 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 + 180000 + 180000, 1); |
| 1098 EXPECT_EQ(3 + 6 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); | 1131 EXPECT_EQ(3 + 6 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1099 | 1132 |
| 1100 } | 1133 } |
| 1101 | 1134 |
| 1102 TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) | 1135 TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) |
| 1103 { | 1136 { |
| 1104 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 1137 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 1105 TestOcclusionTracker occluded; | 1138 TestOcclusionTracker occluded; |
| 1139 m_occlusion = &occluded; | |
| 1106 | 1140 |
| 1107 // The tile size is 100x100. | 1141 // The tile size is 100x100. |
| 1108 | 1142 |
| 1109 layer->setBounds(gfx::Size(600, 600)); | 1143 layer->setBounds(gfx::Size(600, 600)); |
| 1144 calcDrawProps(layer); | |
| 1110 | 1145 |
| 1111 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); | 1146 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); |
| 1112 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); | 1147 layer->drawProperties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); |
| 1113 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 600); | 1148 layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 600, 600); |
| 1114 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1149 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
| 1115 layer->setTexturePriorities(m_priorityCalculator); | 1150 layer->setTexturePriorities(m_priorityCalculator); |
| 1116 m_resourceManager->prioritizeTextures(); | 1151 m_resourceManager->prioritizeTextures(); |
| 1117 layer->update(*m_queue.get(), &occluded, m_stats); | 1152 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1118 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); | 1153 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); |
| 1119 { | 1154 { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1134 | 1169 |
| 1135 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1170 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1136 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1); | 1171 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1); |
| 1137 EXPECT_EQ(6, occluded.overdrawMetrics().tilesCulledForUpload()); | 1172 EXPECT_EQ(6, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1138 } | 1173 } |
| 1139 | 1174 |
| 1140 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms) | 1175 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms) |
| 1141 { | 1176 { |
| 1142 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 1177 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 1143 TestOcclusionTracker occluded; | 1178 TestOcclusionTracker occluded; |
| 1179 m_occlusion = &occluded; | |
| 1144 | 1180 |
| 1145 // The tile size is 100x100. | 1181 // The tile size is 100x100. |
| 1146 | 1182 |
| 1147 // This makes sure the painting works when the occluded region (in screen sp ace) | 1183 // This makes sure the painting works when the occluded region (in screen sp ace) |
| 1148 // is transformed differently than the layer. | 1184 // is transformed differently than the layer. |
| 1149 layer->setBounds(gfx::Size(600, 600)); | 1185 layer->setBounds(gfx::Size(600, 600)); |
| 1186 calcDrawProps(layer); | |
| 1150 gfx::Transform screenTransform; | 1187 gfx::Transform screenTransform; |
| 1151 screenTransform.Scale(0.5, 0.5); | 1188 screenTransform.Scale(0.5, 0.5); |
| 1152 layer->drawProperties().screen_space_transform = screenTransform; | 1189 layer->drawProperties().screen_space_transform = screenTransform; |
| 1153 layer->drawProperties().target_space_transform = screenTransform; | 1190 layer->drawProperties().target_space_transform = screenTransform; |
| 1154 | 1191 |
| 1155 occluded.setOcclusion(gfx::Rect(100, 100, 150, 50)); | 1192 occluded.setOcclusion(gfx::Rect(100, 100, 150, 50)); |
| 1156 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye r->contentBounds()); | 1193 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye r->contentBounds()); |
| 1157 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer ->contentBounds()); | 1194 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer ->contentBounds()); |
| 1158 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1195 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
| 1159 layer->setTexturePriorities(m_priorityCalculator); | 1196 layer->setTexturePriorities(m_priorityCalculator); |
| 1160 m_resourceManager->prioritizeTextures(); | 1197 m_resourceManager->prioritizeTextures(); |
| 1161 layer->update(*m_queue.get(), &occluded, m_stats); | 1198 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1162 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); | 1199 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); |
| 1163 | 1200 |
| 1164 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1201 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1165 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1); | 1202 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000, 1); |
| 1166 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 1203 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1167 } | 1204 } |
| 1168 | 1205 |
| 1169 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) | 1206 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) |
| 1170 { | 1207 { |
| 1171 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); | 1208 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer( m_resourceManager.get())); |
| 1172 TestOcclusionTracker occluded; | 1209 TestOcclusionTracker occluded; |
| 1210 m_occlusion = &occluded; | |
| 1173 | 1211 |
| 1174 // The tile size is 100x100. | 1212 // The tile size is 100x100. |
| 1175 | 1213 |
| 1176 // This makes sure the painting works when the content space is scaled to | 1214 // This makes sure the painting works when the content space is scaled to |
| 1177 // a different layer space. In this case tiles are scaled to be 200x200 | 1215 // a different layer space. In this case tiles are scaled to be 200x200 |
| 1178 // pixels, which means none should be occluded. | 1216 // pixels, which means none should be occluded. |
| 1217 layer->setBounds(gfx::Size(600, 600)); | |
| 1218 calcDrawProps(layer); | |
| 1179 layer->setContentsScale(0.5); | 1219 layer->setContentsScale(0.5); |
| 1180 EXPECT_FLOAT_EQ(layer->contentsScaleX(), layer->contentsScaleY()); | 1220 EXPECT_FLOAT_EQ(layer->contentsScaleX(), layer->contentsScaleY()); |
| 1181 layer->setBounds(gfx::Size(600, 600)); | |
| 1182 gfx::Transform drawTransform; | 1221 gfx::Transform drawTransform; |
| 1183 double invScaleFactor = 1 / layer->contentsScaleX(); | 1222 double invScaleFactor = 1 / layer->contentsScaleX(); |
| 1184 drawTransform.Scale(invScaleFactor, invScaleFactor); | 1223 drawTransform.Scale(invScaleFactor, invScaleFactor); |
| 1185 layer->drawProperties().target_space_transform = drawTransform; | 1224 layer->drawProperties().target_space_transform = drawTransform; |
|
enne (OOO)
2012/12/16 19:44:25
If you're calling calcDrawProperties, can all this
danakj
2012/12/16 20:16:52
Yes, but then it needs to move to other properties
enne (OOO)
2012/12/16 20:53:17
Yeah, I think it breaks the encapsulation a little
| |
| 1186 layer->drawProperties().screen_space_transform = drawTransform; | 1225 layer->drawProperties().screen_space_transform = drawTransform; |
| 1187 | 1226 |
| 1188 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); | 1227 occluded.setOcclusion(gfx::Rect(200, 200, 300, 100)); |
| 1189 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye r->bounds()); | 1228 layer->drawProperties().drawable_content_rect = gfx::Rect(gfx::Point(), laye r->bounds()); |
| 1190 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer ->contentBounds()); | 1229 layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layer ->contentBounds()); |
| 1191 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1230 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
| 1192 layer->setTexturePriorities(m_priorityCalculator); | 1231 layer->setTexturePriorities(m_priorityCalculator); |
| 1193 m_resourceManager->prioritizeTextures(); | 1232 m_resourceManager->prioritizeTextures(); |
| 1194 layer->update(*m_queue.get(), &occluded, m_stats); | 1233 layer->update(*m_queue.get(), &occluded, m_stats); |
| 1195 // The content is half the size of the layer (so the number of tiles is fewe r). | 1234 // The content is half the size of the layer (so the number of tiles is fewe r). |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1432 updateTextures(); | 1471 updateTextures(); |
| 1433 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); | 1472 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); |
| 1434 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); | 1473 EXPECT_EQ(3, child->fakeLayerUpdater()->updateCount()); |
| 1435 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); | 1474 EXPECT_EQ(3, child2->fakeLayerUpdater()->updateCount()); |
| 1436 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1475 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 1437 | 1476 |
| 1438 root->fakeLayerUpdater()->clearUpdateCount(); | 1477 root->fakeLayerUpdater()->clearUpdateCount(); |
| 1439 child->fakeLayerUpdater()->clearUpdateCount(); | 1478 child->fakeLayerUpdater()->clearUpdateCount(); |
| 1440 child2->fakeLayerUpdater()->clearUpdateCount(); | 1479 child2->fakeLayerUpdater()->clearUpdateCount(); |
| 1441 | 1480 |
| 1442 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl->activeTree(), root->id()); | 1481 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL ayerImpl(m_hostImpl->activeTree(), root->id())); |
| 1443 ScopedFakeTiledLayerImpl childImpl(m_hostImpl->activeTree(), child->id() ); | 1482 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), child->id())); |
| 1444 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl->activeTree(), child2->id ()); | 1483 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile dLayerImpl(m_hostImpl->activeTree(), child2->id())); |
| 1445 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1484 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1446 layerPushPropertiesTo(child.get(), childImpl.get()); | 1485 layerPushPropertiesTo(child.get(), childImpl.get()); |
| 1447 layerPushPropertiesTo(child2.get(), child2Impl.get()); | 1486 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
| 1448 | 1487 |
| 1449 for (unsigned i = 0; i < 3; ++i) { | 1488 for (unsigned i = 0; i < 3; ++i) { |
| 1450 for (unsigned j = 0; j < 2; ++j) | 1489 for (unsigned j = 0; j < 2; ++j) |
| 1451 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); | 1490 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); |
| 1452 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0)); | 1491 EXPECT_TRUE(childImpl->hasResourceIdForTileAt(i, 0)); |
| 1453 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0)); | 1492 EXPECT_TRUE(child2Impl->hasResourceIdForTileAt(i, 0)); |
| 1454 } | 1493 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1467 updateTextures(); | 1506 updateTextures(); |
| 1468 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); | 1507 EXPECT_EQ(6, root->fakeLayerUpdater()->updateCount()); |
| 1469 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); | 1508 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); |
| 1470 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); | 1509 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); |
| 1471 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1510 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 1472 | 1511 |
| 1473 root->fakeLayerUpdater()->clearUpdateCount(); | 1512 root->fakeLayerUpdater()->clearUpdateCount(); |
| 1474 child->fakeLayerUpdater()->clearUpdateCount(); | 1513 child->fakeLayerUpdater()->clearUpdateCount(); |
| 1475 child2->fakeLayerUpdater()->clearUpdateCount(); | 1514 child2->fakeLayerUpdater()->clearUpdateCount(); |
| 1476 | 1515 |
| 1477 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl->activeTree(), root->id()); | 1516 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL ayerImpl(m_hostImpl->activeTree(), root->id())); |
| 1478 ScopedFakeTiledLayerImpl childImpl(m_hostImpl->activeTree(), child->id() ); | 1517 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), child->id())); |
| 1479 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl->activeTree(), child2->id ()); | 1518 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile dLayerImpl(m_hostImpl->activeTree(), child2->id())); |
| 1480 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1519 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1481 layerPushPropertiesTo(child.get(), childImpl.get()); | 1520 layerPushPropertiesTo(child.get(), childImpl.get()); |
| 1482 layerPushPropertiesTo(child2.get(), child2Impl.get()); | 1521 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
| 1483 | 1522 |
| 1484 for (unsigned i = 0; i < 3; ++i) { | 1523 for (unsigned i = 0; i < 3; ++i) { |
| 1485 for (unsigned j = 0; j < 2; ++j) | 1524 for (unsigned j = 0; j < 2; ++j) |
| 1486 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); | 1525 EXPECT_TRUE(rootImpl->hasResourceIdForTileAt(i, j)); |
| 1487 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); | 1526 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); |
| 1488 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); | 1527 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); |
| 1489 } | 1528 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1503 updateTextures(); | 1542 updateTextures(); |
| 1504 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); | 1543 EXPECT_EQ(0, root->fakeLayerUpdater()->updateCount()); |
| 1505 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); | 1544 EXPECT_EQ(0, child->fakeLayerUpdater()->updateCount()); |
| 1506 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); | 1545 EXPECT_EQ(0, child2->fakeLayerUpdater()->updateCount()); |
| 1507 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 1546 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
| 1508 | 1547 |
| 1509 root->fakeLayerUpdater()->clearUpdateCount(); | 1548 root->fakeLayerUpdater()->clearUpdateCount(); |
| 1510 child->fakeLayerUpdater()->clearUpdateCount(); | 1549 child->fakeLayerUpdater()->clearUpdateCount(); |
| 1511 child2->fakeLayerUpdater()->clearUpdateCount(); | 1550 child2->fakeLayerUpdater()->clearUpdateCount(); |
| 1512 | 1551 |
| 1513 ScopedFakeTiledLayerImpl rootImpl(m_hostImpl->activeTree(), root->id()); | 1552 scoped_ptr<FakeTiledLayerImpl> rootImpl = make_scoped_ptr(new FakeTiledL ayerImpl(m_hostImpl->activeTree(), root->id())); |
| 1514 ScopedFakeTiledLayerImpl childImpl(m_hostImpl->activeTree(), child->id() ); | 1553 scoped_ptr<FakeTiledLayerImpl> childImpl = make_scoped_ptr(new FakeTiled LayerImpl(m_hostImpl->activeTree(), child->id())); |
| 1515 ScopedFakeTiledLayerImpl child2Impl(m_hostImpl->activeTree(), child2->id ()); | 1554 scoped_ptr<FakeTiledLayerImpl> child2Impl = make_scoped_ptr(new FakeTile dLayerImpl(m_hostImpl->activeTree(), child2->id())); |
| 1516 layerPushPropertiesTo(root.get(), rootImpl.get()); | 1555 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1517 layerPushPropertiesTo(child.get(), childImpl.get()); | 1556 layerPushPropertiesTo(child.get(), childImpl.get()); |
| 1518 layerPushPropertiesTo(child2.get(), child2Impl.get()); | 1557 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
| 1519 | 1558 |
| 1520 for (unsigned i = 0; i < 3; ++i) { | 1559 for (unsigned i = 0; i < 3; ++i) { |
| 1521 for (unsigned j = 0; j < 2; ++j) | 1560 for (unsigned j = 0; j < 2; ++j) |
| 1522 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j)); | 1561 EXPECT_FALSE(rootImpl->hasResourceIdForTileAt(i, j)); |
| 1523 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); | 1562 EXPECT_FALSE(childImpl->hasResourceIdForTileAt(i, 0)); |
| 1524 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); | 1563 EXPECT_FALSE(child2Impl->hasResourceIdForTileAt(i, 0)); |
| 1525 } | 1564 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1626 | 1665 |
| 1627 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. | 1666 // Invalidate the entire layer in layer space. When painting, the rect given to webkit should match the layer's bounds. |
| 1628 layer->setNeedsDisplayRect(layerRect); | 1667 layer->setNeedsDisplayRect(layerRect); |
| 1629 layer->update(*m_queue.get(), 0, m_stats); | 1668 layer->update(*m_queue.get(), 0, m_stats); |
| 1630 | 1669 |
| 1631 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1670 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
| 1632 } | 1671 } |
| 1633 | 1672 |
| 1634 } // namespace | 1673 } // namespace |
| 1635 } // namespace cc | 1674 } // namespace cc |
| OLD | NEW |