| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "TiledLayerChromium.h" | 7 #include "TiledLayerChromium.h" |
| 8 | 8 |
| 9 #include "BitmapCanvasLayerTextureUpdater.h" | 9 #include "BitmapCanvasLayerTextureUpdater.h" |
| 10 #include "CCAnimationTestCommon.h" | 10 #include "CCAnimationTestCommon.h" |
| 11 #include "CCLayerTreeTestCommon.h" | 11 #include "CCGeometryTestUtils.h" |
| 12 #include "CCOverdrawMetrics.h" | 12 #include "CCOverdrawMetrics.h" |
| 13 #include "CCRenderingStats.h" | 13 #include "CCRenderingStats.h" |
| 14 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread | 14 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread |
| 15 #include "CCTextureUpdateController.h" | 15 #include "CCTextureUpdateController.h" |
| 16 #include "CCTiledLayerTestCommon.h" | 16 #include "CCTiledLayerTestCommon.h" |
| 17 #include "FakeCCGraphicsContext.h" | 17 #include "FakeCCGraphicsContext.h" |
| 18 #include "FakeCCLayerTreeHostClient.h" | 18 #include "FakeCCLayerTreeHostClient.h" |
| 19 #include "LayerPainterChromium.h" | 19 #include "LayerPainterChromium.h" |
| 20 #include <gtest/gtest.h> | 20 #include <gtest/gtest.h> |
| 21 #include <public/WebCompositor.h> | 21 #include <public/WebCompositor.h> |
| 22 #include <public/WebTransformationMatrix.h> | 22 #include <public/WebTransformationMatrix.h> |
| 23 | 23 |
| 24 using namespace WebCore; | 24 using namespace WebCore; |
| 25 using namespace WebKitTests; | 25 using namespace WebKitTests; |
| 26 using namespace WTF; | 26 using namespace WTF; |
| 27 using WebKit::WebTransformationMatrix; | 27 using WebKit::WebTransformationMatrix; |
| 28 | 28 |
| 29 #define EXPECT_EQ_RECT(a, b) \ | |
| 30 EXPECT_EQ(a.x(), b.x()); \ | |
| 31 EXPECT_EQ(a.y(), b.y()); \ | |
| 32 EXPECT_EQ(a.width(), b.width()); \ | |
| 33 EXPECT_EQ(a.height(), b.height()); | |
| 34 | |
| 35 namespace { | 29 namespace { |
| 36 | 30 |
| 37 class TestCCOcclusionTracker : public CCOcclusionTracker { | 31 class TestCCOcclusionTracker : public CCOcclusionTracker { |
| 38 public: | 32 public: |
| 39 TestCCOcclusionTracker() | 33 TestCCOcclusionTracker() |
| 40 : CCOcclusionTracker(IntRect(0, 0, 1000, 1000), true) | 34 : CCOcclusionTracker(IntRect(0, 0, 1000, 1000), true) |
| 41 , m_layerClipRectInTarget(IntRect(0, 0, 1000, 1000)) | 35 , m_layerClipRectInTarget(IntRect(0, 0, 1000, 1000)) |
| 42 { | 36 { |
| 43 // Pretend we have visited a render surface. | 37 // Pretend we have visited a render surface. |
| 44 m_stack.append(StackObject()); | 38 m_stack.append(StackObject()); |
| 45 } | 39 } |
| 46 | 40 |
| 47 void setOcclusion(const Region& occlusion) { m_stack.last().occlusionInScree
n = occlusion; } | 41 void setOcclusion(const Region& occlusion) { m_stack.last().occlusionInScree
n = occlusion; } |
| 48 | 42 |
| 49 protected: | 43 protected: |
| 50 virtual IntRect layerClipRectInTarget(const LayerChromium* layer) const OVER
RIDE { return m_layerClipRectInTarget; } | 44 virtual IntRect layerClipRectInTarget(const LayerChromium* layer) const OVER
RIDE { return m_layerClipRectInTarget; } |
| 51 | 45 |
| 52 private: | 46 private: |
| 53 IntRect m_layerClipRectInTarget; | 47 IntRect m_layerClipRectInTarget; |
| 54 }; | 48 }; |
| 55 | 49 |
| 56 class TiledLayerChromiumTest : public testing::Test { | 50 class TiledLayerChromiumTest : public testing::Test { |
| 57 public: | 51 public: |
| 58 TiledLayerChromiumTest() | 52 TiledLayerChromiumTest() |
| 59 : m_context(WebKit::createFakeCCGraphicsContext()) | 53 : m_context(WebKit::createFakeCCGraphicsContext()) |
| 60 , m_textureManager(CCPrioritizedTextureManager::create(60*1024*1024, 102
4, CCRenderer::ContentPool)) | 54 , m_textureManager(CCPrioritizedTextureManager::create(60*1024*1024, 102
4, CCRenderer::ContentPool)) |
| 61 , m_occlusion(0) | 55 , m_occlusion(0) |
| 62 { | 56 { |
| 63 DebugScopedSetImplThread implThread; | 57 WebKit::WebCompositor::initialize(0); |
| 58 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 64 m_resourceProvider = CCResourceProvider::create(m_context.get()); | 59 m_resourceProvider = CCResourceProvider::create(m_context.get()); |
| 65 } | 60 } |
| 66 | 61 |
| 67 virtual ~TiledLayerChromiumTest() | 62 virtual ~TiledLayerChromiumTest() |
| 68 { | 63 { |
| 69 DebugScopedSetImplThread implThread; | 64 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.
get()); |
| 70 m_resourceProvider.clear(); | 65 { |
| 66 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThread
Blocked; |
| 67 m_resourceProvider.clear(); |
| 68 } |
| 69 WebKit::WebCompositor::shutdown(); |
| 71 } | 70 } |
| 72 | 71 |
| 72 // Helper classes and functions that set the current thread to be the impl t
hread |
| 73 // before doing the action that they wrap. |
| 74 class ScopedFakeCCTiledLayerImpl { |
| 75 public: |
| 76 ScopedFakeCCTiledLayerImpl(int id) |
| 77 { |
| 78 DebugScopedSetImplThread implThread; |
| 79 m_layerImpl = new FakeCCTiledLayerImpl(id); |
| 80 } |
| 81 ~ScopedFakeCCTiledLayerImpl() |
| 82 { |
| 83 DebugScopedSetImplThread implThread; |
| 84 delete m_layerImpl; |
| 85 } |
| 86 FakeCCTiledLayerImpl* get() |
| 87 { |
| 88 return m_layerImpl; |
| 89 } |
| 90 FakeCCTiledLayerImpl* operator->() |
| 91 { |
| 92 return m_layerImpl; |
| 93 } |
| 94 private: |
| 95 FakeCCTiledLayerImpl* m_layerImpl; |
| 96 }; |
| 97 void textureManagerClearAllMemory(CCPrioritizedTextureManager* textureManage
r, CCResourceProvider* resourceProvider) |
| 98 { |
| 99 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 100 textureManager->clearAllMemory(resourceProvider); |
| 101 } |
| 73 void updateTextures(int count = 500) | 102 void updateTextures(int count = 500) |
| 74 { | 103 { |
| 104 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 75 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_c
opier, &m_uploader, &m_queue, count); | 105 CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_c
opier, &m_uploader, &m_queue, count); |
| 76 } | 106 } |
| 107 void layerPushPropertiesTo(FakeTiledLayerChromium* layer, FakeCCTiledLayerIm
pl* layerImpl) |
| 108 { |
| 109 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc
ked; |
| 110 layer->pushPropertiesTo(layerImpl); |
| 111 } |
| 112 void layerUpdate(FakeTiledLayerChromium* layer, TestCCOcclusionTracker* occl
uded) |
| 113 { |
| 114 DebugScopedSetMainThread mainThread; |
| 115 layer->update(m_queue, occluded, m_stats); |
| 116 } |
| 77 | 117 |
| 78 bool updateAndPush(FakeTiledLayerChromium* layer1, | 118 bool updateAndPush(FakeTiledLayerChromium* layer1, |
| 79 CCLayerImpl* layerImpl1, | 119 FakeCCTiledLayerImpl* layerImpl1, |
| 80 FakeTiledLayerChromium* layer2 = 0, | 120 FakeTiledLayerChromium* layer2 = 0, |
| 81 CCLayerImpl* layerImpl2 = 0) | 121 FakeCCTiledLayerImpl* layerImpl2 = 0) |
| 82 { | 122 { |
| 83 // Get textures | 123 // Get textures |
| 84 m_textureManager->clearPriorities(); | 124 m_textureManager->clearPriorities(); |
| 85 if (layer1) | 125 if (layer1) |
| 86 layer1->setTexturePriorities(m_priorityCalculator); | 126 layer1->setTexturePriorities(m_priorityCalculator); |
| 87 if (layer2) | 127 if (layer2) |
| 88 layer2->setTexturePriorities(m_priorityCalculator); | 128 layer2->setTexturePriorities(m_priorityCalculator); |
| 89 m_textureManager->prioritizeTextures(); | 129 m_textureManager->prioritizeTextures(); |
| 90 | 130 |
| 91 // Update content | 131 // Update content |
| 92 if (layer1) | 132 if (layer1) |
| 93 layer1->update(m_queue, m_occlusion, m_stats); | 133 layer1->update(m_queue, m_occlusion, m_stats); |
| 94 if (layer2) | 134 if (layer2) |
| 95 layer2->update(m_queue, m_occlusion, m_stats); | 135 layer2->update(m_queue, m_occlusion, m_stats); |
| 96 | 136 |
| 97 bool needsUpdate = false; | 137 bool needsUpdate = false; |
| 98 if (layer1) | 138 if (layer1) |
| 99 needsUpdate |= layer1->needsIdlePaint(); | 139 needsUpdate |= layer1->needsIdlePaint(); |
| 100 if (layer2) | 140 if (layer2) |
| 101 needsUpdate |= layer2->needsIdlePaint(); | 141 needsUpdate |= layer2->needsIdlePaint(); |
| 102 | 142 |
| 103 // Update textures and push. | 143 // Update textures and push. |
| 104 updateTextures(); | 144 updateTextures(); |
| 105 if (layer1) | 145 if (layer1) |
| 106 layer1->pushPropertiesTo(layerImpl1); | 146 layerPushPropertiesTo(layer1, layerImpl1); |
| 107 if (layer2) | 147 if (layer2) |
| 108 layer2->pushPropertiesTo(layerImpl2); | 148 layerPushPropertiesTo(layer2, layerImpl2); |
| 109 | 149 |
| 110 return needsUpdate; | 150 return needsUpdate; |
| 111 } | 151 } |
| 112 | 152 |
| 113 public: | 153 public: |
| 114 OwnPtr<CCGraphicsContext> m_context; | 154 OwnPtr<CCGraphicsContext> m_context; |
| 115 OwnPtr<CCResourceProvider> m_resourceProvider; | 155 OwnPtr<CCResourceProvider> m_resourceProvider; |
| 116 CCTextureUpdateQueue m_queue; | 156 CCTextureUpdateQueue m_queue; |
| 117 CCRenderingStats m_stats; | 157 CCRenderingStats m_stats; |
| 118 FakeTextureCopier m_copier; | 158 FakeTextureCopier m_copier; |
| 119 FakeTextureUploader m_uploader; | 159 FakeTextureUploader m_uploader; |
| 120 CCPriorityCalculator m_priorityCalculator; | 160 CCPriorityCalculator m_priorityCalculator; |
| 121 OwnPtr<CCPrioritizedTextureManager> m_textureManager; | 161 OwnPtr<CCPrioritizedTextureManager> m_textureManager; |
| 122 TestCCOcclusionTracker* m_occlusion; | 162 TestCCOcclusionTracker* m_occlusion; |
| 123 }; | 163 }; |
| 124 | 164 |
| 125 TEST_F(TiledLayerChromiumTest, pushDirtyTiles) | 165 TEST_F(TiledLayerChromiumTest, pushDirtyTiles) |
| 126 { | 166 { |
| 127 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 167 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 128 DebugScopedSetImplThread implThread; | 168 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 129 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))
); | |
| 130 | 169 |
| 131 // The tile size is 100x100, so this invalidates and then paints two tiles. | 170 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 132 layer->setBounds(IntSize(100, 200)); | 171 layer->setBounds(IntSize(100, 200)); |
| 133 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 172 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); |
| 134 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); | 173 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); |
| 135 updateAndPush(layer.get(), layerImpl.get()); | 174 updateAndPush(layer.get(), layerImpl.get()); |
| 136 | 175 |
| 137 // We should have both tiles on the impl side. | 176 // We should have both tiles on the impl side. |
| 138 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 177 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 139 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); | 178 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); |
| 140 | 179 |
| 141 // Invalidates both tiles, but then only update one of them. | 180 // Invalidates both tiles, but then only update one of them. |
| 142 layer->setBounds(IntSize(100, 200)); | 181 layer->setBounds(IntSize(100, 200)); |
| 143 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); | 182 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); |
| 144 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); | 183 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); |
| 145 updateAndPush(layer.get(), layerImpl.get()); | 184 updateAndPush(layer.get(), layerImpl.get()); |
| 146 | 185 |
| 147 // We should only have the first tile since the other tile was invalidated b
ut not painted. | 186 // We should only have the first tile since the other tile was invalidated b
ut not painted. |
| 148 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 187 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 149 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); | 188 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); |
| 150 } | 189 } |
| 151 | 190 |
| 152 TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles) | 191 TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles) |
| 153 { | 192 { |
| 154 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 193 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 155 DebugScopedSetImplThread implThread; | 194 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 156 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))
); | |
| 157 TestCCOcclusionTracker occluded; | 195 TestCCOcclusionTracker occluded; |
| 158 m_occlusion = &occluded; | 196 m_occlusion = &occluded; |
| 159 | 197 |
| 160 // The tile size is 100x100, so this invalidates and then paints two tiles. | 198 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 161 layer->setBounds(IntSize(100, 200)); | 199 layer->setBounds(IntSize(100, 200)); |
| 162 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 200 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); |
| 163 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); | 201 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); |
| 164 updateAndPush(layer.get(), layerImpl.get()); | 202 updateAndPush(layer.get(), layerImpl.get()); |
| 165 | 203 |
| 166 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 204 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 182 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 220 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 183 | 221 |
| 184 // We should still have both tiles, as part of the top tile is still unocclu
ded. | 222 // We should still have both tiles, as part of the top tile is still unocclu
ded. |
| 185 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 223 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 186 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); | 224 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); |
| 187 } | 225 } |
| 188 | 226 |
| 189 TEST_F(TiledLayerChromiumTest, pushDeletedTiles) | 227 TEST_F(TiledLayerChromiumTest, pushDeletedTiles) |
| 190 { | 228 { |
| 191 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 229 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 192 DebugScopedSetImplThread implThread; | 230 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 193 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))
); | |
| 194 | 231 |
| 195 // The tile size is 100x100, so this invalidates and then paints two tiles. | 232 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 196 layer->setBounds(IntSize(100, 200)); | 233 layer->setBounds(IntSize(100, 200)); |
| 197 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 234 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); |
| 198 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); | 235 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); |
| 199 updateAndPush(layer.get(), layerImpl.get()); | 236 updateAndPush(layer.get(), layerImpl.get()); |
| 200 | 237 |
| 201 // We should have both tiles on the impl side. | 238 // We should have both tiles on the impl side. |
| 202 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 239 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 203 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); | 240 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); |
| 204 | 241 |
| 205 m_textureManager->clearPriorities(); | 242 m_textureManager->clearPriorities(); |
| 206 m_textureManager->clearAllMemory(m_resourceProvider.get()); | 243 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.get(
)); |
| 207 m_textureManager->setMaxMemoryLimitBytes(4*1024*1024); | 244 m_textureManager->setMaxMemoryLimitBytes(4*1024*1024); |
| 208 | 245 |
| 209 // This should drop the tiles on the impl thread. | 246 // This should drop the tiles on the impl thread. |
| 210 layer->pushPropertiesTo(layerImpl.get()); | 247 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 211 | 248 |
| 212 // We should now have no textures on the impl thread. | 249 // We should now have no textures on the impl thread. |
| 213 EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); | 250 EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); |
| 214 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); | 251 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); |
| 215 | 252 |
| 216 // This should recreate and update one of the deleted textures. | 253 // This should recreate and update one of the deleted textures. |
| 217 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); | 254 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); |
| 218 updateAndPush(layer.get(), layerImpl.get()); | 255 updateAndPush(layer.get(), layerImpl.get()); |
| 219 | 256 |
| 220 // We should have one tiles on the impl side. | 257 // We should have one tiles on the impl side. |
| 221 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 258 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 222 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); | 259 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); |
| 223 } | 260 } |
| 224 | 261 |
| 225 TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles) | 262 TEST_F(TiledLayerChromiumTest, pushIdlePaintTiles) |
| 226 { | 263 { |
| 227 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 264 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 228 DebugScopedSetImplThread implThread; | 265 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 229 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))
); | |
| 230 | 266 |
| 231 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce
nter. | 267 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce
nter. |
| 232 // This paints 1 visible of the 25 invalid tiles. | 268 // This paints 1 visible of the 25 invalid tiles. |
| 233 layer->setBounds(IntSize(500, 500)); | 269 layer->setBounds(IntSize(500, 500)); |
| 234 layer->setVisibleContentRect(IntRect(200, 200, 100, 100)); | 270 layer->setVisibleContentRect(IntRect(200, 200, 100, 100)); |
| 235 layer->invalidateContentRect(IntRect(0, 0, 500, 500)); | 271 layer->invalidateContentRect(IntRect(0, 0, 500, 500)); |
| 236 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 272 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
| 237 // We should need idle-painting for surrounding tiles. | 273 // We should need idle-painting for surrounding tiles. |
| 238 EXPECT_TRUE(needsUpdate); | 274 EXPECT_TRUE(needsUpdate); |
| 239 | 275 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 256 // We should always finish painting eventually. | 292 // We should always finish painting eventually. |
| 257 for (int i = 0; i < 20; i++) | 293 for (int i = 0; i < 20; i++) |
| 258 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 294 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
| 259 EXPECT_FALSE(needsUpdate); | 295 EXPECT_FALSE(needsUpdate); |
| 260 } | 296 } |
| 261 | 297 |
| 262 TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed) | 298 TEST_F(TiledLayerChromiumTest, pushTilesAfterIdlePaintFailed) |
| 263 { | 299 { |
| 264 // 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. | 300 // 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. |
| 265 m_textureManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); | 301 m_textureManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); |
| 266 DebugScopedSetImplThread implThread; | |
| 267 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); | 302 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); |
| 268 OwnPtr<FakeCCTiledLayerImpl> layerImpl1(adoptPtr(new FakeCCTiledLayerImpl(1)
)); | 303 ScopedFakeCCTiledLayerImpl layerImpl1(1); |
| 269 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); | 304 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); |
| 270 OwnPtr<FakeCCTiledLayerImpl> layerImpl2(adoptPtr(new FakeCCTiledLayerImpl(2)
)); | 305 ScopedFakeCCTiledLayerImpl layerImpl2(2); |
| 271 | 306 |
| 272 // For this test we have two layers. layer1 exhausts most texture memory, le
aving room for 2 more tiles from | 307 // For this test we have two layers. layer1 exhausts most texture memory, le
aving room for 2 more tiles from |
| 273 // layer2, but not all three tiles. First we paint layer1, and one tile from
layer2. Then when we idle paint | 308 // layer2, but not all three tiles. First we paint layer1, and one tile from
layer2. Then when we idle paint |
| 274 // layer2, we will fail on the third tile of layer2, and this should not lea
ve the second tile in a bad state. | 309 // layer2, we will fail on the third tile of layer2, and this should not lea
ve the second tile in a bad state. |
| 275 | 310 |
| 276 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou
gh for 2 tiles only in the other layer. | 311 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou
gh for 2 tiles only in the other layer. |
| 277 IntRect layer1Rect(0, 0, 100, 2400); | 312 IntRect layer1Rect(0, 0, 100, 2400); |
| 278 | 313 |
| 279 // This requires 4*30000 bytes of memory. | 314 // This requires 4*30000 bytes of memory. |
| 280 IntRect layer2Rect(0, 0, 100, 300); | 315 IntRect layer2Rect(0, 0, 100, 300); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 310 EXPECT_TRUE(layerImpl2->hasTileAt(0, 1)); | 345 EXPECT_TRUE(layerImpl2->hasTileAt(0, 1)); |
| 311 EXPECT_TRUE(layerImpl2->hasTextureIdForTileAt(0, 1)); | 346 EXPECT_TRUE(layerImpl2->hasTextureIdForTileAt(0, 1)); |
| 312 | 347 |
| 313 EXPECT_FALSE(needsUpdate); | 348 EXPECT_FALSE(needsUpdate); |
| 314 EXPECT_FALSE(layerImpl2->hasTileAt(0, 2)); | 349 EXPECT_FALSE(layerImpl2->hasTileAt(0, 2)); |
| 315 } | 350 } |
| 316 | 351 |
| 317 TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles) | 352 TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles) |
| 318 { | 353 { |
| 319 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 354 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 320 DebugScopedSetImplThread implThread; | 355 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 321 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))
); | |
| 322 TestCCOcclusionTracker occluded; | 356 TestCCOcclusionTracker occluded; |
| 323 m_occlusion = &occluded; | 357 m_occlusion = &occluded; |
| 324 | 358 |
| 325 // The tile size is 100x100, so this invalidates one occluded tile, culls it
during paint, but prepaints it. | 359 // The tile size is 100x100, so this invalidates one occluded tile, culls it
during paint, but prepaints it. |
| 326 occluded.setOcclusion(IntRect(0, 0, 100, 100)); | 360 occluded.setOcclusion(IntRect(0, 0, 100, 100)); |
| 327 | 361 |
| 328 layer->setBounds(IntSize(100, 100)); | 362 layer->setBounds(IntSize(100, 100)); |
| 329 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); | 363 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); |
| 330 updateAndPush(layer.get(), layerImpl.get()); | 364 updateAndPush(layer.get(), layerImpl.get()); |
| 331 | 365 |
| 332 // We should have the prepainted tile on the impl side, but culled it during
paint. | 366 // We should have the prepainted tile on the impl side, but culled it during
paint. |
| 333 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 367 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 334 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); | 368 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 335 } | 369 } |
| 336 | 370 |
| 337 TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint) | 371 TEST_F(TiledLayerChromiumTest, pushTilesMarkedDirtyDuringPaint) |
| 338 { | 372 { |
| 339 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 373 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 340 DebugScopedSetImplThread implThread; | 374 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 341 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))
); | |
| 342 | 375 |
| 343 // The tile size is 100x100, so this invalidates and then paints two tiles. | 376 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 344 // However, during the paint, we invalidate one of the tiles. This should | 377 // However, during the paint, we invalidate one of the tiles. This should |
| 345 // not prevent the tile from being pushed. | 378 // not prevent the tile from being pushed. |
| 346 layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50
), layer.get()); | 379 layer->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50
), layer.get()); |
| 347 layer->setBounds(IntSize(100, 200)); | 380 layer->setBounds(IntSize(100, 200)); |
| 348 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 381 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); |
| 349 updateAndPush(layer.get(), layerImpl.get()); | 382 updateAndPush(layer.get(), layerImpl.get()); |
| 350 | 383 |
| 351 // We should have both tiles on the impl side. | 384 // We should have both tiles on the impl side. |
| 352 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 385 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 353 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); | 386 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); |
| 354 } | 387 } |
| 355 | 388 |
| 356 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) | 389 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) |
| 357 { | 390 { |
| 358 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); | 391 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); |
| 359 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); | 392 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); |
| 360 DebugScopedSetImplThread implThread; | 393 ScopedFakeCCTiledLayerImpl layer1Impl(1); |
| 361 OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(1)
)); | 394 ScopedFakeCCTiledLayerImpl layer2Impl(2); |
| 362 OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(2)
)); | |
| 363 | 395 |
| 364 // Invalidate a tile on layer1, during update of layer 2. | 396 // Invalidate a tile on layer1, during update of layer 2. |
| 365 layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5
0), layer1.get()); | 397 layer2->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5
0), layer1.get()); |
| 366 layer1->setBounds(IntSize(100, 200)); | 398 layer1->setBounds(IntSize(100, 200)); |
| 367 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 399 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); |
| 368 layer2->setBounds(IntSize(100, 200)); | 400 layer2->setBounds(IntSize(100, 200)); |
| 369 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 401 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); |
| 370 updateAndPush(layer1.get(), layer1Impl.get(), | 402 updateAndPush(layer1.get(), layer1Impl.get(), |
| 371 layer2.get(), layer2Impl.get()); | 403 layer2.get(), layer2Impl.get()); |
| 372 | 404 |
| 373 // We should have both tiles on the impl side for all layers. | 405 // We should have both tiles on the impl side for all layers. |
| 374 EXPECT_TRUE(layer1Impl->hasTileAt(0, 0)); | 406 EXPECT_TRUE(layer1Impl->hasTileAt(0, 0)); |
| 375 EXPECT_TRUE(layer1Impl->hasTileAt(0, 1)); | 407 EXPECT_TRUE(layer1Impl->hasTileAt(0, 1)); |
| 376 EXPECT_TRUE(layer2Impl->hasTileAt(0, 0)); | 408 EXPECT_TRUE(layer2Impl->hasTileAt(0, 0)); |
| 377 EXPECT_TRUE(layer2Impl->hasTileAt(0, 1)); | 409 EXPECT_TRUE(layer2Impl->hasTileAt(0, 1)); |
| 378 } | 410 } |
| 379 | 411 |
| 380 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLay
er) | 412 TEST_F(TiledLayerChromiumTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLay
er) |
| 381 { | 413 { |
| 382 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); | 414 RefPtr<FakeTiledLayerChromium> layer1 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); |
| 383 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); | 415 RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(
m_textureManager.get())); |
| 384 DebugScopedSetImplThread implThread; | 416 ScopedFakeCCTiledLayerImpl layer1Impl(1); |
| 385 OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(1)
)); | 417 ScopedFakeCCTiledLayerImpl layer2Impl(2); |
| 386 OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(2)
)); | |
| 387 | 418 |
| 388 layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5
0), layer2.get()); | 419 layer1->fakeLayerTextureUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 5
0), layer2.get()); |
| 389 layer1->setBounds(IntSize(100, 200)); | 420 layer1->setBounds(IntSize(100, 200)); |
| 390 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 421 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); |
| 391 layer2->setBounds(IntSize(100, 200)); | 422 layer2->setBounds(IntSize(100, 200)); |
| 392 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 423 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); |
| 393 updateAndPush(layer1.get(), layer1Impl.get(), | 424 updateAndPush(layer1.get(), layer1Impl.get(), |
| 394 layer2.get(), layer2Impl.get()); | 425 layer2.get(), layer2Impl.get()); |
| 395 | 426 |
| 396 // We should have both tiles on the impl side for all layers. | 427 // We should have both tiles on the impl side for all layers. |
| 397 EXPECT_TRUE(layer1Impl->hasTileAt(0, 0)); | 428 EXPECT_TRUE(layer1Impl->hasTileAt(0, 0)); |
| 398 EXPECT_TRUE(layer1Impl->hasTileAt(0, 1)); | 429 EXPECT_TRUE(layer1Impl->hasTileAt(0, 1)); |
| 399 EXPECT_TRUE(layer2Impl->hasTileAt(0, 0)); | 430 EXPECT_TRUE(layer2Impl->hasTileAt(0, 0)); |
| 400 EXPECT_TRUE(layer2Impl->hasTileAt(0, 1)); | 431 EXPECT_TRUE(layer2Impl->hasTileAt(0, 1)); |
| 401 } | 432 } |
| 402 | 433 |
| 403 TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately) | 434 TEST_F(TiledLayerChromiumTest, paintSmallAnimatedLayersImmediately) |
| 404 { | 435 { |
| 405 // Create a CCLayerTreeHost that has the right viewportsize, | 436 // Create a CCLayerTreeHost that has the right viewportsize, |
| 406 // so the layer is considered small enough. | 437 // so the layer is considered small enough. |
| 407 WebKit::WebCompositor::initialize(0); | |
| 408 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; | 438 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; |
| 409 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay
erTreeHostClient, CCLayerTreeSettings()); | 439 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay
erTreeHostClient, CCLayerTreeSettings()); |
| 410 | 440 |
| 411 bool runOutOfMemory[2] = {false, true}; | 441 bool runOutOfMemory[2] = {false, true}; |
| 412 for (int i = 0; i < 2; i++) { | 442 for (int i = 0; i < 2; i++) { |
| 413 // Create a layer with 4x4 tiles. | 443 // Create a layer with 4x4 tiles. |
| 414 int layerWidth = 4 * FakeTiledLayerChromium::tileSize().width(); | 444 int layerWidth = 4 * FakeTiledLayerChromium::tileSize().width(); |
| 415 int layerHeight = 4 * FakeTiledLayerChromium::tileSize().height(); | 445 int layerHeight = 4 * FakeTiledLayerChromium::tileSize().height(); |
| 416 int memoryForLayer = layerWidth * layerHeight * 4; | 446 int memoryForLayer = layerWidth * layerHeight * 4; |
| 417 IntSize viewportSize = IntSize(layerWidth, layerHeight); | 447 IntSize viewportSize = IntSize(layerWidth, layerHeight); |
| 418 ccLayerTreeHost->setViewportSize(viewportSize, viewportSize); | 448 ccLayerTreeHost->setViewportSize(viewportSize, viewportSize); |
| 419 | 449 |
| 420 // Use 8x4 tiles to run out of memory. | 450 // Use 8x4 tiles to run out of memory. |
| 421 if (runOutOfMemory[i]) | 451 if (runOutOfMemory[i]) |
| 422 layerWidth *= 2; | 452 layerWidth *= 2; |
| 423 | 453 |
| 424 m_textureManager->setMaxMemoryLimitBytes(memoryForLayer); | 454 m_textureManager->setMaxMemoryLimitBytes(memoryForLayer); |
| 425 DebugScopedSetImplThread implThread; | |
| 426 | 455 |
| 427 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromi
um(m_textureManager.get())); | 456 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromi
um(m_textureManager.get())); |
| 428 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(1))); | 457 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 429 | 458 |
| 430 // Full size layer with half being visible. | 459 // Full size layer with half being visible. |
| 431 IntSize contentBounds(layerWidth, layerHeight); | 460 IntSize contentBounds(layerWidth, layerHeight); |
| 432 IntRect contentRect(IntPoint::zero(), contentBounds); | 461 IntRect contentRect(IntPoint::zero(), contentBounds); |
| 433 IntRect visibleRect(IntPoint::zero(), IntSize(layerWidth / 2, layerHeigh
t)); | 462 IntRect visibleRect(IntPoint::zero(), IntSize(layerWidth / 2, layerHeigh
t)); |
| 434 | 463 |
| 435 // Pretend the layer is animating. | 464 // Pretend the layer is animating. |
| 436 layer->setDrawTransformIsAnimating(true); | 465 layer->setDrawTransformIsAnimating(true); |
| 437 layer->setBounds(contentBounds); | 466 layer->setBounds(contentBounds); |
| 438 layer->setVisibleContentRect(visibleRect); | 467 layer->setVisibleContentRect(visibleRect); |
| 439 layer->invalidateContentRect(contentRect); | 468 layer->invalidateContentRect(contentRect); |
| 440 layer->setLayerTreeHost(ccLayerTreeHost.get()); | 469 layer->setLayerTreeHost(ccLayerTreeHost.get()); |
| 441 | 470 |
| 442 // The layer should paint it's entire contents on the first paint | 471 // The layer should paint it's entire contents on the first paint |
| 443 // if it is close to the viewport size and has the available memory. | 472 // if it is close to the viewport size and has the available memory. |
| 444 layer->setTexturePriorities(m_priorityCalculator); | 473 layer->setTexturePriorities(m_priorityCalculator); |
| 445 m_textureManager->prioritizeTextures(); | 474 m_textureManager->prioritizeTextures(); |
| 446 layer->update(m_queue, 0, m_stats); | 475 layer->update(m_queue, 0, m_stats); |
| 447 updateTextures(); | 476 updateTextures(); |
| 448 layer->pushPropertiesTo(layerImpl.get()); | 477 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 449 | 478 |
| 450 // We should have all the tiles for the small animated layer. | 479 // We should have all the tiles for the small animated layer. |
| 451 // We should still have the visible tiles when we didn't | 480 // We should still have the visible tiles when we didn't |
| 452 // have enough memory for all the tiles. | 481 // have enough memory for all the tiles. |
| 453 if (!runOutOfMemory[i]) { | 482 if (!runOutOfMemory[i]) { |
| 454 for (int i = 0; i < 4; ++i) { | 483 for (int i = 0; i < 4; ++i) { |
| 455 for (int j = 0; j < 4; ++j) | 484 for (int j = 0; j < 4; ++j) |
| 456 EXPECT_TRUE(layerImpl->hasTileAt(i, j)); | 485 EXPECT_TRUE(layerImpl->hasTileAt(i, j)); |
| 457 } | 486 } |
| 458 } else { | 487 } else { |
| 459 for (int i = 0; i < 8; ++i) { | 488 for (int i = 0; i < 8; ++i) { |
| 460 for (int j = 0; j < 4; ++j) | 489 for (int j = 0; j < 4; ++j) |
| 461 EXPECT_EQ(layerImpl->hasTileAt(i, j), i < 4); | 490 EXPECT_EQ(layerImpl->hasTileAt(i, j), i < 4); |
| 462 } | 491 } |
| 463 } | 492 } |
| 464 } | 493 } |
| 465 ccLayerTreeHost.clear(); | 494 ccLayerTreeHost.clear(); |
| 466 WebKit::WebCompositor::shutdown(); | |
| 467 } | 495 } |
| 468 | 496 |
| 469 TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory) | 497 TEST_F(TiledLayerChromiumTest, idlePaintOutOfMemory) |
| 470 { | 498 { |
| 471 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 499 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 472 DebugScopedSetImplThread implThread; | 500 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 473 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))
); | |
| 474 | 501 |
| 475 // We have enough memory for only the visible rect, so we will run out of me
mory in first idle paint. | 502 // We have enough memory for only the visible rect, so we will run out of me
mory in first idle paint. |
| 476 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. | 503 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. |
| 477 m_textureManager->setMaxMemoryLimitBytes(memoryLimit); | 504 m_textureManager->setMaxMemoryLimitBytes(memoryLimit); |
| 478 | 505 |
| 479 // The tile size is 100x100, so this invalidates and then paints two tiles. | 506 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 480 bool needsUpdate = false; | 507 bool needsUpdate = false; |
| 481 layer->setBounds(IntSize(300, 300)); | 508 layer->setBounds(IntSize(300, 300)); |
| 482 layer->setVisibleContentRect(IntRect(100, 100, 100, 100)); | 509 layer->setVisibleContentRect(IntRect(100, 100, 100, 100)); |
| 483 for (int i = 0; i < 2; i++) | 510 for (int i = 0; i < 2; i++) |
| 484 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 511 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
| 485 | 512 |
| 486 // Idle-painting should see no more priority tiles for painting. | 513 // Idle-painting should see no more priority tiles for painting. |
| 487 EXPECT_FALSE(needsUpdate); | 514 EXPECT_FALSE(needsUpdate); |
| 488 | 515 |
| 489 // We should have one tile on the impl side. | 516 // We should have one tile on the impl side. |
| 490 EXPECT_TRUE(layerImpl->hasTileAt(1, 1)); | 517 EXPECT_TRUE(layerImpl->hasTileAt(1, 1)); |
| 491 } | 518 } |
| 492 | 519 |
| 493 TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer) | 520 TEST_F(TiledLayerChromiumTest, idlePaintZeroSizedLayer) |
| 494 { | 521 { |
| 495 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 522 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 496 DebugScopedSetImplThread implThread; | 523 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 497 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))
); | |
| 498 | 524 |
| 499 bool animating[2] = {false, true}; | 525 bool animating[2] = {false, true}; |
| 500 for (int i = 0; i < 2; i++) { | 526 for (int i = 0; i < 2; i++) { |
| 501 // Pretend the layer is animating. | 527 // Pretend the layer is animating. |
| 502 layer->setDrawTransformIsAnimating(animating[i]); | 528 layer->setDrawTransformIsAnimating(animating[i]); |
| 503 | 529 |
| 504 // The layer's bounds are empty. | 530 // The layer's bounds are empty. |
| 505 // Empty layers don't paint or idle-paint. | 531 // Empty layers don't paint or idle-paint. |
| 506 layer->setBounds(IntSize()); | 532 layer->setBounds(IntSize()); |
| 507 layer->setVisibleContentRect(IntRect()); | 533 layer->setVisibleContentRect(IntRect()); |
| 508 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 534 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
| 509 | 535 |
| 510 // Empty layers don't have tiles. | 536 // Empty layers don't have tiles. |
| 511 EXPECT_EQ(0u, layer->numPaintedTiles()); | 537 EXPECT_EQ(0u, layer->numPaintedTiles()); |
| 512 | 538 |
| 513 // Empty layers don't need prepaint. | 539 // Empty layers don't need prepaint. |
| 514 EXPECT_FALSE(needsUpdate); | 540 EXPECT_FALSE(needsUpdate); |
| 515 | 541 |
| 516 // Empty layers don't have tiles. | 542 // Empty layers don't have tiles. |
| 517 EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); | 543 EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); |
| 518 } | 544 } |
| 519 } | 545 } |
| 520 | 546 |
| 521 TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers) | 547 TEST_F(TiledLayerChromiumTest, idlePaintNonVisibleLayers) |
| 522 { | 548 { |
| 523 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 549 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 524 DebugScopedSetImplThread implThread; | 550 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 525 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))
); | |
| 526 | 551 |
| 527 // Alternate between not visible and visible. | 552 // Alternate between not visible and visible. |
| 528 IntRect v(0, 0, 100, 100); | 553 IntRect v(0, 0, 100, 100); |
| 529 IntRect nv(0, 0, 0, 0); | 554 IntRect nv(0, 0, 0, 0); |
| 530 IntRect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; | 555 IntRect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; |
| 531 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals
e, false }; | 556 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals
e, false }; |
| 532 | 557 |
| 533 // We should not have any tiles except for when the layer was visible | 558 // We should not have any tiles except for when the layer was visible |
| 534 // or after the layer was visible and we didn't invalidate. | 559 // or after the layer was visible and we didn't invalidate. |
| 535 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr
ue, true }; | 560 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr
ue, true }; |
| 536 | 561 |
| 537 for (int i = 0; i < 10; i++) { | 562 for (int i = 0; i < 10; i++) { |
| 538 layer->setBounds(IntSize(100, 100)); | 563 layer->setBounds(IntSize(100, 100)); |
| 539 layer->setVisibleContentRect(visibleRect[i]); | 564 layer->setVisibleContentRect(visibleRect[i]); |
| 540 | 565 |
| 541 if (invalidate[i]) | 566 if (invalidate[i]) |
| 542 layer->invalidateContentRect(IntRect(0, 0, 100, 100)); | 567 layer->invalidateContentRect(IntRect(0, 0, 100, 100)); |
| 543 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 568 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
| 544 | 569 |
| 545 // We should never signal idle paint, as we painted the entire layer | 570 // We should never signal idle paint, as we painted the entire layer |
| 546 // or the layer was not visible. | 571 // or the layer was not visible. |
| 547 EXPECT_FALSE(needsUpdate); | 572 EXPECT_FALSE(needsUpdate); |
| 548 EXPECT_EQ(layerImpl->hasTileAt(0, 0), haveTile[i]); | 573 EXPECT_EQ(layerImpl->hasTileAt(0, 0), haveTile[i]); |
| 549 } | 574 } |
| 550 } | 575 } |
| 551 | 576 |
| 552 TEST_F(TiledLayerChromiumTest, invalidateFromPrepare) | 577 TEST_F(TiledLayerChromiumTest, invalidateFromPrepare) |
| 553 { | 578 { |
| 554 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 579 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 555 DebugScopedSetImplThread implThread; | 580 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 556 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))
); | |
| 557 | 581 |
| 558 // The tile size is 100x100, so this invalidates and then paints two tiles. | 582 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 559 layer->setBounds(IntSize(100, 200)); | 583 layer->setBounds(IntSize(100, 200)); |
| 560 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 584 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); |
| 561 updateAndPush(layer.get(), layerImpl.get()); | 585 updateAndPush(layer.get(), layerImpl.get()); |
| 562 | 586 |
| 563 // We should have both tiles on the impl side. | 587 // We should have both tiles on the impl side. |
| 564 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 588 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 565 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); | 589 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); |
| 566 | 590 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 581 // The layer should still be invalid as update invoked invalidate. | 605 // The layer should still be invalid as update invoked invalidate. |
| 582 updateAndPush(layer.get(), layerImpl.get()); // visible | 606 updateAndPush(layer.get(), layerImpl.get()); // visible |
| 583 EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); | 607 EXPECT_EQ(1, layer->fakeLayerTextureUpdater()->prepareCount()); |
| 584 } | 608 } |
| 585 | 609 |
| 586 TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) | 610 TEST_F(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) |
| 587 { | 611 { |
| 588 // The updateRect (that indicates what was actually painted) should be in | 612 // The updateRect (that indicates what was actually painted) should be in |
| 589 // layer space, not the content space. | 613 // layer space, not the content space. |
| 590 RefPtr<FakeTiledLayerWithScaledBounds> layer = adoptRef(new FakeTiledLayerWi
thScaledBounds(m_textureManager.get())); | 614 RefPtr<FakeTiledLayerWithScaledBounds> layer = adoptRef(new FakeTiledLayerWi
thScaledBounds(m_textureManager.get())); |
| 591 DebugScopedSetImplThread implThread; | |
| 592 | 615 |
| 593 IntRect layerBounds(0, 0, 300, 200); | 616 IntRect layerBounds(0, 0, 300, 200); |
| 594 IntRect contentBounds(0, 0, 200, 250); | 617 IntRect contentBounds(0, 0, 200, 250); |
| 595 | 618 |
| 596 layer->setBounds(layerBounds.size()); | 619 layer->setBounds(layerBounds.size()); |
| 597 layer->setContentBounds(contentBounds.size()); | 620 layer->setContentBounds(contentBounds.size()); |
| 598 layer->setVisibleContentRect(contentBounds); | 621 layer->setVisibleContentRect(contentBounds); |
| 599 | 622 |
| 600 // On first update, the updateRect includes all tiles, even beyond the bound
aries of the layer. | 623 // On first update, the updateRect includes all tiles, even beyond the bound
aries of the layer. |
| 601 // However, it should still be in layer space, not content space. | 624 // However, it should still be in layer space, not content space. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 620 layer->invalidateContentRect(partialDamage); | 643 layer->invalidateContentRect(partialDamage); |
| 621 layer->setTexturePriorities(m_priorityCalculator); | 644 layer->setTexturePriorities(m_priorityCalculator); |
| 622 m_textureManager->prioritizeTextures(); | 645 m_textureManager->prioritizeTextures(); |
| 623 layer->update(m_queue, 0, m_stats); | 646 layer->update(m_queue, 0, m_stats); |
| 624 EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect()); | 647 EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect()); |
| 625 } | 648 } |
| 626 | 649 |
| 627 TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) | 650 TEST_F(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) |
| 628 { | 651 { |
| 629 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 652 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 630 DebugScopedSetImplThread implThread; | 653 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 631 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(1))
); | |
| 632 | 654 |
| 633 // Create a layer with one tile. | 655 // Create a layer with one tile. |
| 634 layer->setBounds(IntSize(100, 100)); | 656 layer->setBounds(IntSize(100, 100)); |
| 635 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); | 657 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); |
| 636 | 658 |
| 637 // Invalidate the entire layer. | 659 // Invalidate the entire layer. |
| 638 layer->setNeedsDisplay(); | 660 layer->setNeedsDisplay(); |
| 639 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect(
)); | 661 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect(
)); |
| 640 | 662 |
| 641 // Push the tiles to the impl side and check that there is exactly one. | 663 // Push the tiles to the impl side and check that there is exactly one. |
| 642 layer->setTexturePriorities(m_priorityCalculator); | 664 layer->setTexturePriorities(m_priorityCalculator); |
| 643 m_textureManager->prioritizeTextures(); | 665 m_textureManager->prioritizeTextures(); |
| 644 layer->update(m_queue, 0, m_stats); | 666 layer->update(m_queue, 0, m_stats); |
| 645 updateTextures(); | 667 updateTextures(); |
| 646 layer->pushPropertiesTo(layerImpl.get()); | 668 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 647 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 669 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 648 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); | 670 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); |
| 649 EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); | 671 EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); |
| 650 EXPECT_FALSE(layerImpl->hasTileAt(1, 1)); | 672 EXPECT_FALSE(layerImpl->hasTileAt(1, 1)); |
| 651 | 673 |
| 652 // Change the contents scale and verify that the content rectangle requiring
painting | 674 // Change the contents scale and verify that the content rectangle requiring
painting |
| 653 // is not scaled. | 675 // is not scaled. |
| 654 layer->setContentsScale(2); | 676 layer->setContentsScale(2); |
| 655 layer->setVisibleContentRect(IntRect(0, 0, 200, 200)); | 677 layer->setVisibleContentRect(IntRect(0, 0, 200, 200)); |
| 656 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect(
)); | 678 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect(
)); |
| 657 | 679 |
| 658 // The impl side should get 2x2 tiles now. | 680 // The impl side should get 2x2 tiles now. |
| 659 layer->setTexturePriorities(m_priorityCalculator); | 681 layer->setTexturePriorities(m_priorityCalculator); |
| 660 m_textureManager->prioritizeTextures(); | 682 m_textureManager->prioritizeTextures(); |
| 661 layer->update(m_queue, 0, m_stats); | 683 layer->update(m_queue, 0, m_stats); |
| 662 updateTextures(); | 684 updateTextures(); |
| 663 layer->pushPropertiesTo(layerImpl.get()); | 685 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 664 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); | 686 EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); |
| 665 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); | 687 EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); |
| 666 EXPECT_TRUE(layerImpl->hasTileAt(1, 0)); | 688 EXPECT_TRUE(layerImpl->hasTileAt(1, 0)); |
| 667 EXPECT_TRUE(layerImpl->hasTileAt(1, 1)); | 689 EXPECT_TRUE(layerImpl->hasTileAt(1, 1)); |
| 668 | 690 |
| 669 // Invalidate the entire layer again, but do not paint. All tiles should be
gone now from the | 691 // Invalidate the entire layer again, but do not paint. All tiles should be
gone now from the |
| 670 // impl side. | 692 // impl side. |
| 671 layer->setNeedsDisplay(); | 693 layer->setNeedsDisplay(); |
| 672 layer->setTexturePriorities(m_priorityCalculator); | 694 layer->setTexturePriorities(m_priorityCalculator); |
| 673 m_textureManager->prioritizeTextures(); | 695 m_textureManager->prioritizeTextures(); |
| 674 | 696 |
| 675 layer->pushPropertiesTo(layerImpl.get()); | 697 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 676 EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); | 698 EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); |
| 677 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); | 699 EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); |
| 678 EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); | 700 EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); |
| 679 EXPECT_FALSE(layerImpl->hasTileAt(1, 1)); | 701 EXPECT_FALSE(layerImpl->hasTileAt(1, 1)); |
| 680 } | 702 } |
| 681 | 703 |
| 682 TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset) | 704 TEST_F(TiledLayerChromiumTest, skipsDrawGetsReset) |
| 683 { | 705 { |
| 684 // Initialize without threading support. | |
| 685 WebKit::WebCompositor::initialize(0); | |
| 686 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; | 706 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; |
| 687 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay
erTreeHostClient, CCLayerTreeSettings()); | 707 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay
erTreeHostClient, CCLayerTreeSettings()); |
| 688 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); | 708 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); |
| 689 | 709 |
| 690 // Create two 300 x 300 tiled layers. | 710 // Create two 300 x 300 tiled layers. |
| 691 IntSize contentBounds(300, 300); | 711 IntSize contentBounds(300, 300); |
| 692 IntRect contentRect(IntPoint::zero(), contentBounds); | 712 IntRect contentRect(IntPoint::zero(), contentBounds); |
| 693 | 713 |
| 694 // We have enough memory for only one of the two layers. | 714 // We have enough memory for only one of the two layers. |
| 695 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel. | 715 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 717 EXPECT_FALSE(childLayer->skipsDraw()); | 737 EXPECT_FALSE(childLayer->skipsDraw()); |
| 718 | 738 |
| 719 ccLayerTreeHost->commitComplete(); | 739 ccLayerTreeHost->commitComplete(); |
| 720 | 740 |
| 721 // Remove the child layer. | 741 // Remove the child layer. |
| 722 rootLayer->removeAllChildren(); | 742 rootLayer->removeAllChildren(); |
| 723 | 743 |
| 724 ccLayerTreeHost->updateLayers(m_queue, memoryLimit); | 744 ccLayerTreeHost->updateLayers(m_queue, memoryLimit); |
| 725 EXPECT_FALSE(rootLayer->skipsDraw()); | 745 EXPECT_FALSE(rootLayer->skipsDraw()); |
| 726 | 746 |
| 727 ccLayerTreeHost->contentsTextureManager()->clearAllMemory(m_resourceProvider
.get()); | 747 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re
sourceProvider.get()); |
| 728 ccLayerTreeHost->setRootLayer(0); | 748 ccLayerTreeHost->setRootLayer(0); |
| 729 ccLayerTreeHost.clear(); | 749 ccLayerTreeHost.clear(); |
| 730 WebKit::WebCompositor::shutdown(); | |
| 731 } | 750 } |
| 732 | 751 |
| 733 TEST_F(TiledLayerChromiumTest, resizeToSmaller) | 752 TEST_F(TiledLayerChromiumTest, resizeToSmaller) |
| 734 { | 753 { |
| 735 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 754 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 736 | 755 |
| 737 layer->setBounds(IntSize(700, 700)); | 756 layer->setBounds(IntSize(700, 700)); |
| 738 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); | 757 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); |
| 739 layer->invalidateContentRect(IntRect(0, 0, 700, 700)); | 758 layer->invalidateContentRect(IntRect(0, 0, 700, 700)); |
| 740 | 759 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 756 layer->invalidateContentRect(IntRect(0, 0, size, size)); | 775 layer->invalidateContentRect(IntRect(0, 0, size, size)); |
| 757 | 776 |
| 758 // Ensure no crash for bounds where size * size would overflow an int. | 777 // Ensure no crash for bounds where size * size would overflow an int. |
| 759 layer->setTexturePriorities(m_priorityCalculator); | 778 layer->setTexturePriorities(m_priorityCalculator); |
| 760 m_textureManager->prioritizeTextures(); | 779 m_textureManager->prioritizeTextures(); |
| 761 layer->update(m_queue, 0, m_stats); | 780 layer->update(m_queue, 0, m_stats); |
| 762 } | 781 } |
| 763 | 782 |
| 764 TEST_F(TiledLayerChromiumTest, partialUpdates) | 783 TEST_F(TiledLayerChromiumTest, partialUpdates) |
| 765 { | 784 { |
| 766 // Initialize without threading support. | |
| 767 WebKit::WebCompositor::initialize(0); | |
| 768 | |
| 769 CCLayerTreeSettings settings; | 785 CCLayerTreeSettings settings; |
| 770 settings.maxPartialTextureUpdates = 4; | 786 settings.maxPartialTextureUpdates = 4; |
| 771 | 787 |
| 772 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; | 788 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; |
| 773 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay
erTreeHostClient, settings); | 789 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay
erTreeHostClient, settings); |
| 774 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); | 790 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); |
| 775 | 791 |
| 776 // Create one 300 x 200 tiled layer with 3 x 2 tiles. | 792 // Create one 300 x 200 tiled layer with 3 x 2 tiles. |
| 777 IntSize contentBounds(300, 200); | 793 IntSize contentBounds(300, 200); |
| 778 IntRect contentRect(IntPoint::zero(), contentBounds); | 794 IntRect contentRect(IntPoint::zero(), contentBounds); |
| 779 | 795 |
| 780 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(c
cLayerTreeHost->contentsTextureManager())); | 796 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(c
cLayerTreeHost->contentsTextureManager())); |
| 781 layer->setBounds(contentBounds); | 797 layer->setBounds(contentBounds); |
| 782 layer->setPosition(FloatPoint(0, 0)); | 798 layer->setPosition(FloatPoint(0, 0)); |
| 783 layer->setVisibleContentRect(contentRect); | 799 layer->setVisibleContentRect(contentRect); |
| 784 layer->invalidateContentRect(contentRect); | 800 layer->invalidateContentRect(contentRect); |
| 785 | 801 |
| 786 ccLayerTreeHost->setRootLayer(layer); | 802 ccLayerTreeHost->setRootLayer(layer); |
| 787 ccLayerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200)); | 803 ccLayerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200)); |
| 788 | 804 |
| 789 // Full update of all 6 tiles. | 805 // Full update of all 6 tiles. |
| 790 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); | 806 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); |
| 791 { | 807 { |
| 792 DebugScopedSetImplThread implThread; | 808 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 793 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(1))); | |
| 794 updateTextures(4); | 809 updateTextures(4); |
| 795 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 810 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); |
| 796 EXPECT_TRUE(m_queue.hasMoreUpdates()); | 811 EXPECT_TRUE(m_queue.hasMoreUpdates()); |
| 797 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 812 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 798 updateTextures(4); | 813 updateTextures(4); |
| 799 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); | 814 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); |
| 800 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 815 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 801 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 816 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 802 layer->pushPropertiesTo(layerImpl.get()); | 817 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 803 } | 818 } |
| 804 ccLayerTreeHost->commitComplete(); | 819 ccLayerTreeHost->commitComplete(); |
| 805 | 820 |
| 806 // Full update of 3 tiles and partial update of 3 tiles. | 821 // Full update of 3 tiles and partial update of 3 tiles. |
| 807 layer->invalidateContentRect(IntRect(0, 0, 300, 150)); | 822 layer->invalidateContentRect(IntRect(0, 0, 300, 150)); |
| 808 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); | 823 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); |
| 809 { | 824 { |
| 810 DebugScopedSetImplThread implThread; | 825 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 811 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(1))); | |
| 812 updateTextures(4); | 826 updateTextures(4); |
| 813 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); | 827 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); |
| 814 EXPECT_TRUE(m_queue.hasMoreUpdates()); | 828 EXPECT_TRUE(m_queue.hasMoreUpdates()); |
| 815 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 829 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 816 updateTextures(4); | 830 updateTextures(4); |
| 817 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); | 831 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); |
| 818 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 832 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 819 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 833 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 820 layer->pushPropertiesTo(layerImpl.get()); | 834 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 821 } | 835 } |
| 822 ccLayerTreeHost->commitComplete(); | 836 ccLayerTreeHost->commitComplete(); |
| 823 | 837 |
| 824 // Partial update of 6 tiles. | 838 // Partial update of 6 tiles. |
| 825 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); | 839 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); |
| 826 { | 840 { |
| 827 DebugScopedSetImplThread implThread; | 841 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 828 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(1))); | |
| 829 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); | 842 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); |
| 830 updateTextures(4); | 843 updateTextures(4); |
| 831 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); | 844 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); |
| 832 EXPECT_TRUE(m_queue.hasMoreUpdates()); | 845 EXPECT_TRUE(m_queue.hasMoreUpdates()); |
| 833 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 846 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 834 updateTextures(4); | 847 updateTextures(4); |
| 835 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 848 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); |
| 836 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 849 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 837 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 850 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 838 layer->pushPropertiesTo(layerImpl.get()); | 851 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 839 } | 852 } |
| 840 ccLayerTreeHost->commitComplete(); | 853 ccLayerTreeHost->commitComplete(); |
| 841 | 854 |
| 842 // Checkerboard all tiles. | 855 // Checkerboard all tiles. |
| 843 layer->invalidateContentRect(IntRect(0, 0, 300, 200)); | 856 layer->invalidateContentRect(IntRect(0, 0, 300, 200)); |
| 844 { | 857 { |
| 845 DebugScopedSetImplThread implThread; | 858 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 846 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(1))); | 859 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 847 layer->pushPropertiesTo(layerImpl.get()); | |
| 848 } | 860 } |
| 849 ccLayerTreeHost->commitComplete(); | 861 ccLayerTreeHost->commitComplete(); |
| 850 | 862 |
| 851 // Partial update of 6 checkerboard tiles. | 863 // Partial update of 6 checkerboard tiles. |
| 852 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); | 864 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); |
| 853 { | 865 { |
| 854 DebugScopedSetImplThread implThread; | 866 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 855 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(1))); | |
| 856 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); | 867 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); |
| 857 updateTextures(4); | 868 updateTextures(4); |
| 858 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 869 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); |
| 859 EXPECT_TRUE(m_queue.hasMoreUpdates()); | 870 EXPECT_TRUE(m_queue.hasMoreUpdates()); |
| 860 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 871 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 861 updateTextures(4); | 872 updateTextures(4); |
| 862 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); | 873 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); |
| 863 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 874 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 864 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 875 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 865 layer->pushPropertiesTo(layerImpl.get()); | 876 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 866 } | 877 } |
| 867 ccLayerTreeHost->commitComplete(); | 878 ccLayerTreeHost->commitComplete(); |
| 868 | 879 |
| 869 // Partial update of 4 tiles. | 880 // Partial update of 4 tiles. |
| 870 layer->invalidateContentRect(IntRect(50, 50, 100, 100)); | 881 layer->invalidateContentRect(IntRect(50, 50, 100, 100)); |
| 871 { | 882 { |
| 872 DebugScopedSetImplThread implThread; | 883 ScopedFakeCCTiledLayerImpl layerImpl(1); |
| 873 OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl
(1))); | |
| 874 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); | 884 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max(
)); |
| 875 updateTextures(4); | 885 updateTextures(4); |
| 876 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); | 886 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); |
| 877 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 887 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 878 layer->fakeLayerTextureUpdater()->clearUpdateCount(); | 888 layer->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 879 layer->pushPropertiesTo(layerImpl.get()); | 889 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
| 880 } | 890 } |
| 881 ccLayerTreeHost->commitComplete(); | 891 ccLayerTreeHost->commitComplete(); |
| 882 | 892 |
| 883 { | 893 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re
sourceProvider.get()); |
| 884 DebugScopedSetImplThread implThread; | |
| 885 ccLayerTreeHost->contentsTextureManager()->clearAllMemory(m_resourceProv
ider.get()); | |
| 886 } | |
| 887 ccLayerTreeHost->setRootLayer(0); | 894 ccLayerTreeHost->setRootLayer(0); |
| 888 ccLayerTreeHost.clear(); | 895 ccLayerTreeHost.clear(); |
| 889 WebKit::WebCompositor::shutdown(); | |
| 890 } | 896 } |
| 891 | 897 |
| 892 TEST_F(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion) | 898 TEST_F(TiledLayerChromiumTest, tilesPaintedWithoutOcclusion) |
| 893 { | 899 { |
| 894 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 900 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 895 | 901 |
| 896 // The tile size is 100x100, so this invalidates and then paints two tiles. | 902 // The tile size is 100x100, so this invalidates and then paints two tiles. |
| 897 layer->setBounds(IntSize(100, 200)); | 903 layer->setBounds(IntSize(100, 200)); |
| 898 layer->setDrawableContentRect(IntRect(0, 0, 100, 200)); | 904 layer->setDrawableContentRect(IntRect(0, 0, 100, 200)); |
| 899 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 905 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 | 1030 |
| 1025 occluded.setOcclusion(IntRect(200, 200, 300, 100)); | 1031 occluded.setOcclusion(IntRect(200, 200, 300, 100)); |
| 1026 layer->setDrawableContentRect(IntRect(0, 0, 600, 600)); | 1032 layer->setDrawableContentRect(IntRect(0, 0, 600, 600)); |
| 1027 layer->setVisibleContentRect(IntRect(0, 0, 600, 600)); | 1033 layer->setVisibleContentRect(IntRect(0, 0, 600, 600)); |
| 1028 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1034 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); |
| 1029 layer->setTexturePriorities(m_priorityCalculator); | 1035 layer->setTexturePriorities(m_priorityCalculator); |
| 1030 m_textureManager->prioritizeTextures(); | 1036 m_textureManager->prioritizeTextures(); |
| 1031 layer->update(m_queue, &occluded, m_stats); | 1037 layer->update(m_queue, &occluded, m_stats); |
| 1032 EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); | 1038 EXPECT_EQ(36-3, layer->fakeLayerTextureUpdater()->prepareRectCount()); |
| 1033 { | 1039 { |
| 1034 DebugScopedSetImplThread implThread; | |
| 1035 updateTextures(); | 1040 updateTextures(); |
| 1036 } | 1041 } |
| 1037 | 1042 |
| 1038 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1043 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1039 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); | 1044 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); |
| 1040 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 1045 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1041 | 1046 |
| 1042 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); | 1047 layer->fakeLayerTextureUpdater()->clearPrepareRectCount(); |
| 1043 layer->setTexturePriorities(m_priorityCalculator); | 1048 layer->setTexturePriorities(m_priorityCalculator); |
| 1044 m_textureManager->prioritizeTextures(); | 1049 m_textureManager->prioritizeTextures(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 | 1156 |
| 1152 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1157 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1153 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000 + 80000, 1); | 1158 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000 + 80000, 1); |
| 1154 EXPECT_EQ(1 + 1, occluded.overdrawMetrics().tilesCulledForUpload()); | 1159 EXPECT_EQ(1 + 1, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1155 } | 1160 } |
| 1156 | 1161 |
| 1157 TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) | 1162 TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion) |
| 1158 { | 1163 { |
| 1159 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 1164 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 1160 TestCCOcclusionTracker occluded; | 1165 TestCCOcclusionTracker occluded; |
| 1161 DebugScopedSetImplThread implThread; | |
| 1162 | 1166 |
| 1163 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. | 1167 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. |
| 1164 | 1168 |
| 1165 IntRect opaquePaintRect; | 1169 IntRect opaquePaintRect; |
| 1166 Region opaqueContents; | 1170 Region opaqueContents; |
| 1167 | 1171 |
| 1168 IntRect contentBounds = IntRect(0, 0, 100, 200); | 1172 IntRect contentBounds = IntRect(0, 0, 100, 200); |
| 1169 IntRect visibleBounds = IntRect(0, 0, 100, 150); | 1173 IntRect visibleBounds = IntRect(0, 0, 100, 150); |
| 1170 | 1174 |
| 1171 layer->setBounds(contentBounds.size()); | 1175 layer->setBounds(contentBounds.size()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1188 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1
); | 1192 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1
); |
| 1189 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1193 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1190 | 1194 |
| 1191 // visibleContentOpaqueRegion should match the visible part of what is paint
ed opaque. | 1195 // visibleContentOpaqueRegion should match the visible part of what is paint
ed opaque. |
| 1192 opaquePaintRect = IntRect(10, 10, 90, 190); | 1196 opaquePaintRect = IntRect(10, 10, 90, 190); |
| 1193 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); | 1197 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); |
| 1194 layer->invalidateContentRect(contentBounds); | 1198 layer->invalidateContentRect(contentBounds); |
| 1195 layer->update(m_queue, &occluded, m_stats); | 1199 layer->update(m_queue, &occluded, m_stats); |
| 1196 updateTextures(); | 1200 updateTextures(); |
| 1197 opaqueContents = layer->visibleContentOpaqueRegion(); | 1201 opaqueContents = layer->visibleContentOpaqueRegion(); |
| 1198 EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); | 1202 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); |
| 1199 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1203 EXPECT_EQ(1u, opaqueContents.rects().size()); |
| 1200 | 1204 |
| 1201 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); | 1205 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); |
| 1202 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1206 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
| 1203 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); | 1207 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); |
| 1204 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1208 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1205 | 1209 |
| 1206 // If we paint again without invalidating, the same stuff should be opaque. | 1210 // If we paint again without invalidating, the same stuff should be opaque. |
| 1207 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); | 1211 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); |
| 1208 layer->update(m_queue, &occluded, m_stats); | 1212 layer->update(m_queue, &occluded, m_stats); |
| 1209 updateTextures(); | 1213 updateTextures(); |
| 1210 opaqueContents = layer->visibleContentOpaqueRegion(); | 1214 opaqueContents = layer->visibleContentOpaqueRegion(); |
| 1211 EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); | 1215 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); |
| 1212 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1216 EXPECT_EQ(1u, opaqueContents.rects().size()); |
| 1213 | 1217 |
| 1214 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); | 1218 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); |
| 1215 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1219 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
| 1216 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); | 1220 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); |
| 1217 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1221 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1218 | 1222 |
| 1219 // If we repaint a non-opaque part of the tile, then it shouldn't lose its o
paque-ness. And other tiles should | 1223 // If we repaint a non-opaque part of the tile, then it shouldn't lose its o
paque-ness. And other tiles should |
| 1220 // not be affected. | 1224 // not be affected. |
| 1221 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); | 1225 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); |
| 1222 layer->invalidateContentRect(IntRect(0, 0, 1, 1)); | 1226 layer->invalidateContentRect(IntRect(0, 0, 1, 1)); |
| 1223 layer->update(m_queue, &occluded, m_stats); | 1227 layer->update(m_queue, &occluded, m_stats); |
| 1224 updateTextures(); | 1228 updateTextures(); |
| 1225 opaqueContents = layer->visibleContentOpaqueRegion(); | 1229 opaqueContents = layer->visibleContentOpaqueRegion(); |
| 1226 EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); | 1230 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); |
| 1227 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1231 EXPECT_EQ(1u, opaqueContents.rects().size()); |
| 1228 | 1232 |
| 1229 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1, 1); | 1233 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1, 1); |
| 1230 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1234 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
| 1231 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1, 1); | 1235 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1, 1); |
| 1232 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1236 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1233 | 1237 |
| 1234 // If we repaint an opaque part of the tile, then it should lose its opaque-
ness. But other tiles should still | 1238 // If we repaint an opaque part of the tile, then it should lose its opaque-
ness. But other tiles should still |
| 1235 // not be affected. | 1239 // not be affected. |
| 1236 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); | 1240 layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); |
| 1237 layer->invalidateContentRect(IntRect(10, 10, 1, 1)); | 1241 layer->invalidateContentRect(IntRect(10, 10, 1, 1)); |
| 1238 layer->update(m_queue, &occluded, m_stats); | 1242 layer->update(m_queue, &occluded, m_stats); |
| 1239 updateTextures(); | 1243 updateTextures(); |
| 1240 opaqueContents = layer->visibleContentOpaqueRegion(); | 1244 opaqueContents = layer->visibleContentOpaqueRegion(); |
| 1241 EXPECT_EQ_RECT(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqu
eContents.bounds()); | 1245 EXPECT_RECT_EQ(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqu
eContents.bounds()); |
| 1242 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1246 EXPECT_EQ(1u, opaqueContents.rects().size()); |
| 1243 | 1247 |
| 1244 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1 + 1,
1); | 1248 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1 + 1,
1); |
| 1245 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1249 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
| 1246 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1 + 1, 1); | 1250 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1 + 1, 1); |
| 1247 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1251 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1248 } | 1252 } |
| 1249 | 1253 |
| 1250 TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics) | 1254 TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics) |
| 1251 { | 1255 { |
| 1252 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); | 1256 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(m
_textureManager.get())); |
| 1253 TestCCOcclusionTracker occluded; | 1257 TestCCOcclusionTracker occluded; |
| 1254 DebugScopedSetImplThread implThread; | |
| 1255 | 1258 |
| 1256 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. | 1259 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. |
| 1257 | 1260 |
| 1258 IntRect opaquePaintRect; | 1261 IntRect opaquePaintRect; |
| 1259 Region opaqueContents; | 1262 Region opaqueContents; |
| 1260 | 1263 |
| 1261 IntRect contentBounds = IntRect(0, 0, 100, 300); | 1264 IntRect contentBounds = IntRect(0, 0, 100, 300); |
| 1262 IntRect visibleBounds = IntRect(0, 0, 100, 300); | 1265 IntRect visibleBounds = IntRect(0, 0, 100, 300); |
| 1263 | 1266 |
| 1264 layer->setBounds(contentBounds.size()); | 1267 layer->setBounds(contentBounds.size()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1295 // The middle tile was painted even though not invalidated. | 1298 // The middle tile was painted even though not invalidated. |
| 1296 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000 + 60 * 210, 1)
; | 1299 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000 + 60 * 210, 1)
; |
| 1297 // The pixels uploaded will not include the non-invalidated tile in the midd
le. | 1300 // The pixels uploaded will not include the non-invalidated tile in the midd
le. |
| 1298 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1301 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
| 1299 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000 +
1 + 100, 1); | 1302 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000 +
1 + 100, 1); |
| 1300 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1303 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
| 1301 } | 1304 } |
| 1302 | 1305 |
| 1303 TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca
ted) | 1306 TEST_F(TiledLayerChromiumTest, dontAllocateContentsWhenTargetSurfaceCantBeAlloca
ted) |
| 1304 { | 1307 { |
| 1305 // Initialize without threading support. | |
| 1306 WebKit::WebCompositor::initialize(0); | |
| 1307 | |
| 1308 // Tile size is 100x100. | 1308 // Tile size is 100x100. |
| 1309 IntRect rootRect(0, 0, 300, 200); | 1309 IntRect rootRect(0, 0, 300, 200); |
| 1310 IntRect childRect(0, 0, 300, 100); | 1310 IntRect childRect(0, 0, 300, 100); |
| 1311 IntRect child2Rect(0, 100, 300, 100); | 1311 IntRect child2Rect(0, 100, 300, 100); |
| 1312 | 1312 |
| 1313 CCLayerTreeSettings settings; | 1313 CCLayerTreeSettings settings; |
| 1314 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; | 1314 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; |
| 1315 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay
erTreeHostClient, settings); | 1315 OwnPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLay
erTreeHostClient, settings); |
| 1316 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); | 1316 ASSERT_TRUE(ccLayerTreeHost->initializeRendererIfNeeded()); |
| 1317 | 1317 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1346 | 1346 |
| 1347 ccLayerTreeHost->setRootLayer(root); | 1347 ccLayerTreeHost->setRootLayer(root); |
| 1348 ccLayerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); | 1348 ccLayerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); |
| 1349 | 1349 |
| 1350 // With a huge memory limit, all layers should update and push their texture
s. | 1350 // With a huge memory limit, all layers should update and push their texture
s. |
| 1351 root->invalidateContentRect(rootRect); | 1351 root->invalidateContentRect(rootRect); |
| 1352 child->invalidateContentRect(childRect); | 1352 child->invalidateContentRect(childRect); |
| 1353 child2->invalidateContentRect(child2Rect); | 1353 child2->invalidateContentRect(child2Rect); |
| 1354 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); | 1354 ccLayerTreeHost->updateLayers(m_queue, std::numeric_limits<size_t>::max()); |
| 1355 { | 1355 { |
| 1356 DebugScopedSetImplThread implThread; | |
| 1357 updateTextures(1000); | 1356 updateTextures(1000); |
| 1358 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); | 1357 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); |
| 1359 EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount()); | 1358 EXPECT_EQ(3, child->fakeLayerTextureUpdater()->updateCount()); |
| 1360 EXPECT_EQ(3, child2->fakeLayerTextureUpdater()->updateCount()); | 1359 EXPECT_EQ(3, child2->fakeLayerTextureUpdater()->updateCount()); |
| 1361 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 1360 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 1362 | 1361 |
| 1363 root->fakeLayerTextureUpdater()->clearUpdateCount(); | 1362 root->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1364 child->fakeLayerTextureUpdater()->clearUpdateCount(); | 1363 child->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1365 child2->fakeLayerTextureUpdater()->clearUpdateCount(); | 1364 child2->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1366 | 1365 |
| 1367 OwnPtr<FakeCCTiledLayerImpl> rootImpl(adoptPtr(new FakeCCTiledLayerImpl(
root->id()))); | 1366 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); |
| 1368 OwnPtr<FakeCCTiledLayerImpl> childImpl(adoptPtr(new FakeCCTiledLayerImpl
(child->id()))); | 1367 ScopedFakeCCTiledLayerImpl childImpl(child->id()); |
| 1369 OwnPtr<FakeCCTiledLayerImpl> child2Impl(adoptPtr(new FakeCCTiledLayerImp
l(child2->id()))); | 1368 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); |
| 1370 root->pushPropertiesTo(rootImpl.get()); | 1369 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1371 child->pushPropertiesTo(childImpl.get()); | 1370 layerPushPropertiesTo(child.get(), childImpl.get()); |
| 1372 child2->pushPropertiesTo(child2Impl.get()); | 1371 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
| 1373 | 1372 |
| 1374 for (unsigned i = 0; i < 3; ++i) { | 1373 for (unsigned i = 0; i < 3; ++i) { |
| 1375 for (unsigned j = 0; j < 2; ++j) | 1374 for (unsigned j = 0; j < 2; ++j) |
| 1376 EXPECT_TRUE(rootImpl->hasTextureIdForTileAt(i, j)); | 1375 EXPECT_TRUE(rootImpl->hasTextureIdForTileAt(i, j)); |
| 1377 EXPECT_TRUE(childImpl->hasTextureIdForTileAt(i, 0)); | 1376 EXPECT_TRUE(childImpl->hasTextureIdForTileAt(i, 0)); |
| 1378 EXPECT_TRUE(child2Impl->hasTextureIdForTileAt(i, 0)); | 1377 EXPECT_TRUE(child2Impl->hasTextureIdForTileAt(i, 0)); |
| 1379 } | 1378 } |
| 1380 } | 1379 } |
| 1381 ccLayerTreeHost->commitComplete(); | 1380 ccLayerTreeHost->commitComplete(); |
| 1382 | 1381 |
| 1383 // With a memory limit that includes only the root layer (3x2 tiles) and hal
f the surface that | 1382 // With a memory limit that includes only the root layer (3x2 tiles) and hal
f the surface that |
| 1384 // the child layers draw into, the child layers will not be allocated. If th
e surface isn't | 1383 // the child layers draw into, the child layers will not be allocated. If th
e surface isn't |
| 1385 // accounted for, then one of the children would fit within the memory limit
. | 1384 // accounted for, then one of the children would fit within the memory limit
. |
| 1386 root->invalidateContentRect(rootRect); | 1385 root->invalidateContentRect(rootRect); |
| 1387 child->invalidateContentRect(childRect); | 1386 child->invalidateContentRect(childRect); |
| 1388 child2->invalidateContentRect(child2Rect); | 1387 child2->invalidateContentRect(child2Rect); |
| 1389 ccLayerTreeHost->updateLayers(m_queue, (3 * 2 + 3 * 1) * (100 * 100) * 4); | 1388 ccLayerTreeHost->updateLayers(m_queue, (3 * 2 + 3 * 1) * (100 * 100) * 4); |
| 1390 { | 1389 { |
| 1391 DebugScopedSetImplThread implThread; | |
| 1392 updateTextures(1000); | 1390 updateTextures(1000); |
| 1393 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); | 1391 EXPECT_EQ(6, root->fakeLayerTextureUpdater()->updateCount()); |
| 1394 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); | 1392 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); |
| 1395 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); | 1393 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); |
| 1396 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 1394 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 1397 | 1395 |
| 1398 root->fakeLayerTextureUpdater()->clearUpdateCount(); | 1396 root->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1399 child->fakeLayerTextureUpdater()->clearUpdateCount(); | 1397 child->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1400 child2->fakeLayerTextureUpdater()->clearUpdateCount(); | 1398 child2->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1401 | 1399 |
| 1402 OwnPtr<FakeCCTiledLayerImpl> rootImpl(adoptPtr(new FakeCCTiledLayerImpl(
root->id()))); | 1400 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); |
| 1403 OwnPtr<FakeCCTiledLayerImpl> childImpl(adoptPtr(new FakeCCTiledLayerImpl
(child->id()))); | 1401 ScopedFakeCCTiledLayerImpl childImpl(child->id()); |
| 1404 OwnPtr<FakeCCTiledLayerImpl> child2Impl(adoptPtr(new FakeCCTiledLayerImp
l(child2->id()))); | 1402 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); |
| 1405 root->pushPropertiesTo(rootImpl.get()); | 1403 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1406 child->pushPropertiesTo(childImpl.get()); | 1404 layerPushPropertiesTo(child.get(), childImpl.get()); |
| 1407 child2->pushPropertiesTo(child2Impl.get()); | 1405 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
| 1408 | 1406 |
| 1409 for (unsigned i = 0; i < 3; ++i) { | 1407 for (unsigned i = 0; i < 3; ++i) { |
| 1410 for (unsigned j = 0; j < 2; ++j) | 1408 for (unsigned j = 0; j < 2; ++j) |
| 1411 EXPECT_TRUE(rootImpl->hasTextureIdForTileAt(i, j)); | 1409 EXPECT_TRUE(rootImpl->hasTextureIdForTileAt(i, j)); |
| 1412 EXPECT_FALSE(childImpl->hasTextureIdForTileAt(i, 0)); | 1410 EXPECT_FALSE(childImpl->hasTextureIdForTileAt(i, 0)); |
| 1413 EXPECT_FALSE(child2Impl->hasTextureIdForTileAt(i, 0)); | 1411 EXPECT_FALSE(child2Impl->hasTextureIdForTileAt(i, 0)); |
| 1414 } | 1412 } |
| 1415 } | 1413 } |
| 1416 ccLayerTreeHost->commitComplete(); | 1414 ccLayerTreeHost->commitComplete(); |
| 1417 | 1415 |
| 1418 // With a memory limit that includes only half the root layer, no contents w
ill be | 1416 // With a memory limit that includes only half the root layer, no contents w
ill be |
| 1419 // allocated. If render surface memory wasn't accounted for, there is enough
space | 1417 // allocated. If render surface memory wasn't accounted for, there is enough
space |
| 1420 // for one of the children layers, but they draw into a surface that can't b
e | 1418 // for one of the children layers, but they draw into a surface that can't b
e |
| 1421 // allocated. | 1419 // allocated. |
| 1422 root->invalidateContentRect(rootRect); | 1420 root->invalidateContentRect(rootRect); |
| 1423 child->invalidateContentRect(childRect); | 1421 child->invalidateContentRect(childRect); |
| 1424 child2->invalidateContentRect(child2Rect); | 1422 child2->invalidateContentRect(child2Rect); |
| 1425 ccLayerTreeHost->updateLayers(m_queue, (3 * 1) * (100 * 100) * 4); | 1423 ccLayerTreeHost->updateLayers(m_queue, (3 * 1) * (100 * 100) * 4); |
| 1426 { | 1424 { |
| 1427 DebugScopedSetImplThread implThread; | |
| 1428 updateTextures(1000); | 1425 updateTextures(1000); |
| 1429 EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount()); | 1426 EXPECT_EQ(0, root->fakeLayerTextureUpdater()->updateCount()); |
| 1430 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); | 1427 EXPECT_EQ(0, child->fakeLayerTextureUpdater()->updateCount()); |
| 1431 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); | 1428 EXPECT_EQ(0, child2->fakeLayerTextureUpdater()->updateCount()); |
| 1432 EXPECT_FALSE(m_queue.hasMoreUpdates()); | 1429 EXPECT_FALSE(m_queue.hasMoreUpdates()); |
| 1433 | 1430 |
| 1434 root->fakeLayerTextureUpdater()->clearUpdateCount(); | 1431 root->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1435 child->fakeLayerTextureUpdater()->clearUpdateCount(); | 1432 child->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1436 child2->fakeLayerTextureUpdater()->clearUpdateCount(); | 1433 child2->fakeLayerTextureUpdater()->clearUpdateCount(); |
| 1437 | 1434 |
| 1438 OwnPtr<FakeCCTiledLayerImpl> rootImpl(adoptPtr(new FakeCCTiledLayerImpl(
root->id()))); | 1435 ScopedFakeCCTiledLayerImpl rootImpl(root->id()); |
| 1439 OwnPtr<FakeCCTiledLayerImpl> childImpl(adoptPtr(new FakeCCTiledLayerImpl
(child->id()))); | 1436 ScopedFakeCCTiledLayerImpl childImpl(child->id()); |
| 1440 OwnPtr<FakeCCTiledLayerImpl> child2Impl(adoptPtr(new FakeCCTiledLayerImp
l(child2->id()))); | 1437 ScopedFakeCCTiledLayerImpl child2Impl(child2->id()); |
| 1441 root->pushPropertiesTo(rootImpl.get()); | 1438 layerPushPropertiesTo(root.get(), rootImpl.get()); |
| 1442 child->pushPropertiesTo(childImpl.get()); | 1439 layerPushPropertiesTo(child.get(), childImpl.get()); |
| 1443 child2->pushPropertiesTo(child2Impl.get()); | 1440 layerPushPropertiesTo(child2.get(), child2Impl.get()); |
| 1444 | 1441 |
| 1445 for (unsigned i = 0; i < 3; ++i) { | 1442 for (unsigned i = 0; i < 3; ++i) { |
| 1446 for (unsigned j = 0; j < 2; ++j) | 1443 for (unsigned j = 0; j < 2; ++j) |
| 1447 EXPECT_FALSE(rootImpl->hasTextureIdForTileAt(i, j)); | 1444 EXPECT_FALSE(rootImpl->hasTextureIdForTileAt(i, j)); |
| 1448 EXPECT_FALSE(childImpl->hasTextureIdForTileAt(i, 0)); | 1445 EXPECT_FALSE(childImpl->hasTextureIdForTileAt(i, 0)); |
| 1449 EXPECT_FALSE(child2Impl->hasTextureIdForTileAt(i, 0)); | 1446 EXPECT_FALSE(child2Impl->hasTextureIdForTileAt(i, 0)); |
| 1450 } | 1447 } |
| 1451 } | 1448 } |
| 1452 ccLayerTreeHost->commitComplete(); | 1449 ccLayerTreeHost->commitComplete(); |
| 1453 | 1450 |
| 1454 { | 1451 textureManagerClearAllMemory(ccLayerTreeHost->contentsTextureManager(), m_re
sourceProvider.get()); |
| 1455 DebugScopedSetImplThread implThread; | |
| 1456 ccLayerTreeHost->contentsTextureManager()->clearAllMemory(m_resourceProv
ider.get()); | |
| 1457 } | |
| 1458 ccLayerTreeHost->setRootLayer(0); | 1452 ccLayerTreeHost->setRootLayer(0); |
| 1459 ccLayerTreeHost.clear(); | 1453 ccLayerTreeHost.clear(); |
| 1460 WebKit::WebCompositor::shutdown(); | |
| 1461 } | 1454 } |
| 1462 | 1455 |
| 1463 class TrackingLayerPainter : public LayerPainterChromium { | 1456 class TrackingLayerPainter : public LayerPainterChromium { |
| 1464 public: | 1457 public: |
| 1465 static PassOwnPtr<TrackingLayerPainter> create() { return adoptPtr(new Track
ingLayerPainter()); } | 1458 static PassOwnPtr<TrackingLayerPainter> create() { return adoptPtr(new Track
ingLayerPainter()); } |
| 1466 | 1459 |
| 1467 virtual void paint(SkCanvas*, const IntRect& contentRect, FloatRect&) OVERRI
DE | 1460 virtual void paint(SkCanvas*, const IntRect& contentRect, FloatRect&) OVERRI
DE |
| 1468 { | 1461 { |
| 1469 m_paintedRect = contentRect; | 1462 m_paintedRect = contentRect; |
| 1470 } | 1463 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 layer->setVisibleContentRect(contentRect); | 1506 layer->setVisibleContentRect(contentRect); |
| 1514 layer->setDrawableContentRect(contentRect); | 1507 layer->setDrawableContentRect(contentRect); |
| 1515 | 1508 |
| 1516 layer->setTexturePriorities(m_priorityCalculator); | 1509 layer->setTexturePriorities(m_priorityCalculator); |
| 1517 m_textureManager->prioritizeTextures(); | 1510 m_textureManager->prioritizeTextures(); |
| 1518 | 1511 |
| 1519 // Update the whole tile. | 1512 // Update the whole tile. |
| 1520 layer->update(m_queue, 0, m_stats); | 1513 layer->update(m_queue, 0, m_stats); |
| 1521 layer->trackingLayerPainter()->resetPaintedRect(); | 1514 layer->trackingLayerPainter()->resetPaintedRect(); |
| 1522 | 1515 |
| 1523 EXPECT_INT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); | 1516 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); |
| 1524 | 1517 updateTextures(); |
| 1525 { | |
| 1526 DebugScopedSetImplThread implThread; | |
| 1527 updateTextures(); | |
| 1528 } | |
| 1529 | 1518 |
| 1530 // Invalidate the entire layer in content space. When painting, the rect giv
en to webkit should match the layer's bounds. | 1519 // Invalidate the entire layer in content space. When painting, the rect giv
en to webkit should match the layer's bounds. |
| 1531 layer->invalidateContentRect(contentRect); | 1520 layer->invalidateContentRect(contentRect); |
| 1532 layer->update(m_queue, 0, m_stats); | 1521 layer->update(m_queue, 0, m_stats); |
| 1533 | 1522 |
| 1534 EXPECT_INT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1523 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
| 1535 } | 1524 } |
| 1536 | 1525 |
| 1537 TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvali
dation) | 1526 TEST_F(TiledLayerChromiumTest, nonIntegerContentsScaleIsNotDistortedDuringInvali
dation) |
| 1538 { | 1527 { |
| 1539 RefPtr<UpdateTrackingTiledLayerChromium> layer = adoptRef(new UpdateTracking
TiledLayerChromium(m_textureManager.get())); | 1528 RefPtr<UpdateTrackingTiledLayerChromium> layer = adoptRef(new UpdateTracking
TiledLayerChromium(m_textureManager.get())); |
| 1540 | 1529 |
| 1541 IntRect layerRect(0, 0, 30, 31); | 1530 IntRect layerRect(0, 0, 30, 31); |
| 1542 layer->setPosition(layerRect.location()); | 1531 layer->setPosition(layerRect.location()); |
| 1543 layer->setBounds(layerRect.size()); | 1532 layer->setBounds(layerRect.size()); |
| 1544 layer->setContentsScale(1.3f); | 1533 layer->setContentsScale(1.3f); |
| 1545 | 1534 |
| 1546 IntRect contentRect(IntPoint(), layer->contentBounds()); | 1535 IntRect contentRect(IntPoint(), layer->contentBounds()); |
| 1547 layer->setVisibleContentRect(contentRect); | 1536 layer->setVisibleContentRect(contentRect); |
| 1548 layer->setDrawableContentRect(contentRect); | 1537 layer->setDrawableContentRect(contentRect); |
| 1549 | 1538 |
| 1550 layer->setTexturePriorities(m_priorityCalculator); | 1539 layer->setTexturePriorities(m_priorityCalculator); |
| 1551 m_textureManager->prioritizeTextures(); | 1540 m_textureManager->prioritizeTextures(); |
| 1552 | 1541 |
| 1553 // Update the whole tile. | 1542 // Update the whole tile. |
| 1554 layer->update(m_queue, 0, m_stats); | 1543 layer->update(m_queue, 0, m_stats); |
| 1555 layer->trackingLayerPainter()->resetPaintedRect(); | 1544 layer->trackingLayerPainter()->resetPaintedRect(); |
| 1556 | 1545 |
| 1557 EXPECT_INT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); | 1546 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); |
| 1558 | 1547 updateTextures(); |
| 1559 { | |
| 1560 DebugScopedSetImplThread implThread; | |
| 1561 updateTextures(); | |
| 1562 } | |
| 1563 | 1548 |
| 1564 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. | 1549 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. |
| 1565 layer->setNeedsDisplayRect(layerRect); | 1550 layer->setNeedsDisplayRect(layerRect); |
| 1566 layer->update(m_queue, 0, m_stats); | 1551 layer->update(m_queue, 0, m_stats); |
| 1567 | 1552 |
| 1568 EXPECT_INT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1553 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
| 1569 } | 1554 } |
| 1570 | 1555 |
| 1571 } // namespace | 1556 } // namespace |
| OLD | NEW |