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 "cc/tiled_layer.h" | 7 #include "cc/tiled_layer.h" |
8 | 8 |
9 #include "cc/bitmap_content_layer_updater.h" | 9 #include "cc/bitmap_content_layer_updater.h" |
10 #include "cc/layer_painter.h" | 10 #include "cc/layer_painter.h" |
11 #include "cc/overdraw_metrics.h" | 11 #include "cc/overdraw_metrics.h" |
12 #include "cc/rendering_stats.h" | 12 #include "cc/rendering_stats.h" |
13 #include "cc/resource_update_controller.h" | 13 #include "cc/resource_update_controller.h" |
14 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread | 14 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread |
15 #include "cc/test/animation_test_common.h" | 15 #include "cc/test/animation_test_common.h" |
16 #include "cc/test/fake_graphics_context.h" | 16 #include "cc/test/fake_graphics_context.h" |
17 #include "cc/test/fake_layer_tree_host_client.h" | 17 #include "cc/test/fake_layer_tree_host_client.h" |
18 #include "cc/test/geometry_test_utils.h" | 18 #include "cc/test/geometry_test_utils.h" |
19 #include "cc/test/tiled_layer_test_common.h" | 19 #include "cc/test/tiled_layer_test_common.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/gfx/rect_conversions.h" |
21 #include <public/WebTransformationMatrix.h> | 22 #include <public/WebTransformationMatrix.h> |
22 | 23 |
23 using namespace cc; | 24 using namespace cc; |
24 using namespace WebKitTests; | 25 using namespace WebKitTests; |
25 using WebKit::WebTransformationMatrix; | 26 using WebKit::WebTransformationMatrix; |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 class TestOcclusionTracker : public OcclusionTracker { | 30 class TestOcclusionTracker : public OcclusionTracker { |
30 public: | 31 public: |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 scoped_ptr<PrioritizedTextureManager> m_textureManager; | 164 scoped_ptr<PrioritizedTextureManager> m_textureManager; |
164 TestOcclusionTracker* m_occlusion; | 165 TestOcclusionTracker* m_occlusion; |
165 }; | 166 }; |
166 | 167 |
167 TEST_F(TiledLayerTest, pushDirtyTiles) | 168 TEST_F(TiledLayerTest, pushDirtyTiles) |
168 { | 169 { |
169 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 170 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
170 ScopedFakeTiledLayerImpl layerImpl(1); | 171 ScopedFakeTiledLayerImpl layerImpl(1); |
171 | 172 |
172 // The tile size is 100x100, so this invalidates and then paints two tiles. | 173 // The tile size is 100x100, so this invalidates and then paints two tiles. |
173 layer->setBounds(IntSize(100, 200)); | 174 layer->setBounds(gfx::Size(100, 200)); |
174 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 175 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); |
175 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); | 176 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
176 updateAndPush(layer.get(), layerImpl.get()); | 177 updateAndPush(layer.get(), layerImpl.get()); |
177 | 178 |
178 // We should have both tiles on the impl side. | 179 // We should have both tiles on the impl side. |
179 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 180 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
180 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 181 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
181 | 182 |
182 // Invalidates both tiles, but then only update one of them. | 183 // Invalidates both tiles, but then only update one of them. |
183 layer->setBounds(IntSize(100, 200)); | 184 layer->setBounds(gfx::Size(100, 200)); |
184 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); | 185 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 100)); |
185 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); | 186 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
186 updateAndPush(layer.get(), layerImpl.get()); | 187 updateAndPush(layer.get(), layerImpl.get()); |
187 | 188 |
188 // We should only have the first tile since the other tile was invalidated b
ut not painted. | 189 // We should only have the first tile since the other tile was invalidated b
ut not painted. |
189 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 190 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
190 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 191 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
191 } | 192 } |
192 | 193 |
193 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) | 194 TEST_F(TiledLayerTest, pushOccludedDirtyTiles) |
194 { | 195 { |
195 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 196 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
196 ScopedFakeTiledLayerImpl layerImpl(1); | 197 ScopedFakeTiledLayerImpl layerImpl(1); |
197 TestOcclusionTracker occluded; | 198 TestOcclusionTracker occluded; |
198 m_occlusion = &occluded; | 199 m_occlusion = &occluded; |
199 | 200 |
200 // The tile size is 100x100, so this invalidates and then paints two tiles. | 201 // The tile size is 100x100, so this invalidates and then paints two tiles. |
201 layer->setBounds(IntSize(100, 200)); | 202 layer->setBounds(gfx::Size(100, 200)); |
202 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 203 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); |
203 layer->setDrawableContentRect(IntRect(0, 0, 100, 200)); | 204 layer->setDrawableContentRect(gfx::Rect(0, 0, 100, 200)); |
204 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); | 205 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
205 updateAndPush(layer.get(), layerImpl.get()); | 206 updateAndPush(layer.get(), layerImpl.get()); |
206 | 207 |
207 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 208 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
208 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1
); | 209 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1
); |
209 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 210 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
210 | 211 |
211 // We should have both tiles on the impl side. | 212 // We should have both tiles on the impl side. |
212 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 213 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
213 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 214 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
214 | 215 |
215 // Invalidates part of the top tile... | 216 // Invalidates part of the top tile... |
216 layer->invalidateContentRect(IntRect(0, 0, 50, 50)); | 217 layer->invalidateContentRect(gfx::Rect(0, 0, 50, 50)); |
217 // ....but the area is occluded. | 218 // ....but the area is occluded. |
218 occluded.setOcclusion(IntRect(0, 0, 50, 50)); | 219 occluded.setOcclusion(cc::IntRect(0, 0, 50, 50)); |
219 updateAndPush(layer.get(), layerImpl.get()); | 220 updateAndPush(layer.get(), layerImpl.get()); |
220 | 221 |
221 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 222 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
222 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
2500, 1); | 223 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
2500, 1); |
223 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 224 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
224 | 225 |
225 // We should still have both tiles, as part of the top tile is still unocclu
ded. | 226 // We should still have both tiles, as part of the top tile is still unocclu
ded. |
226 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 227 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
227 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 228 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
228 } | 229 } |
229 | 230 |
230 TEST_F(TiledLayerTest, pushDeletedTiles) | 231 TEST_F(TiledLayerTest, pushDeletedTiles) |
231 { | 232 { |
232 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 233 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
233 ScopedFakeTiledLayerImpl layerImpl(1); | 234 ScopedFakeTiledLayerImpl layerImpl(1); |
234 | 235 |
235 // The tile size is 100x100, so this invalidates and then paints two tiles. | 236 // The tile size is 100x100, so this invalidates and then paints two tiles. |
236 layer->setBounds(IntSize(100, 200)); | 237 layer->setBounds(gfx::Size(100, 200)); |
237 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 238 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); |
238 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); | 239 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
239 updateAndPush(layer.get(), layerImpl.get()); | 240 updateAndPush(layer.get(), layerImpl.get()); |
240 | 241 |
241 // We should have both tiles on the impl side. | 242 // We should have both tiles on the impl side. |
242 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 243 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
243 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 244 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
244 | 245 |
245 m_textureManager->clearPriorities(); | 246 m_textureManager->clearPriorities(); |
246 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.get(
)); | 247 textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.get(
)); |
247 m_textureManager->setMaxMemoryLimitBytes(4*1024*1024); | 248 m_textureManager->setMaxMemoryLimitBytes(4*1024*1024); |
248 | 249 |
249 // This should drop the tiles on the impl thread. | 250 // This should drop the tiles on the impl thread. |
250 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 251 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
251 | 252 |
252 // We should now have no textures on the impl thread. | 253 // We should now have no textures on the impl thread. |
253 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); | 254 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); |
254 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 255 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
255 | 256 |
256 // This should recreate and update one of the deleted textures. | 257 // This should recreate and update one of the deleted textures. |
257 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); | 258 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 100)); |
258 updateAndPush(layer.get(), layerImpl.get()); | 259 updateAndPush(layer.get(), layerImpl.get()); |
259 | 260 |
260 // We should have one tiles on the impl side. | 261 // We should have one tiles on the impl side. |
261 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 262 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
262 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 263 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
263 } | 264 } |
264 | 265 |
265 TEST_F(TiledLayerTest, pushIdlePaintTiles) | 266 TEST_F(TiledLayerTest, pushIdlePaintTiles) |
266 { | 267 { |
267 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 268 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
268 ScopedFakeTiledLayerImpl layerImpl(1); | 269 ScopedFakeTiledLayerImpl layerImpl(1); |
269 | 270 |
270 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce
nter. | 271 // The tile size is 100x100. Setup 5x5 tiles with one visible tile in the ce
nter. |
271 // This paints 1 visible of the 25 invalid tiles. | 272 // This paints 1 visible of the 25 invalid tiles. |
272 layer->setBounds(IntSize(500, 500)); | 273 layer->setBounds(gfx::Size(500, 500)); |
273 layer->setVisibleContentRect(IntRect(200, 200, 100, 100)); | 274 layer->setVisibleContentRect(gfx::Rect(200, 200, 100, 100)); |
274 layer->invalidateContentRect(IntRect(0, 0, 500, 500)); | 275 layer->invalidateContentRect(gfx::Rect(0, 0, 500, 500)); |
275 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 276 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
276 // We should need idle-painting for surrounding tiles. | 277 // We should need idle-painting for surrounding tiles. |
277 EXPECT_TRUE(needsUpdate); | 278 EXPECT_TRUE(needsUpdate); |
278 | 279 |
279 // We should have one tile on the impl side. | 280 // We should have one tile on the impl side. |
280 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(2, 2)); | 281 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(2, 2)); |
281 | 282 |
282 // For the next four updates, we should detect we still need idle painting. | 283 // For the next four updates, we should detect we still need idle painting. |
283 for (int i = 0; i < 4; i++) { | 284 for (int i = 0; i < 4; i++) { |
284 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 285 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
(...skipping 13 matching lines...) Expand all Loading... |
298 EXPECT_FALSE(needsUpdate); | 299 EXPECT_FALSE(needsUpdate); |
299 } | 300 } |
300 | 301 |
301 TEST_F(TiledLayerTest, predictivePainting) | 302 TEST_F(TiledLayerTest, predictivePainting) |
302 { | 303 { |
303 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 304 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
304 ScopedFakeTiledLayerImpl layerImpl(1); | 305 ScopedFakeTiledLayerImpl layerImpl(1); |
305 | 306 |
306 // Prepainting should occur in the scroll direction first, and the | 307 // Prepainting should occur in the scroll direction first, and the |
307 // visible rect should be extruded only along the dominant axis. | 308 // visible rect should be extruded only along the dominant axis. |
308 IntSize directions[6] = { IntSize(-10, 0), | 309 gfx::Vector2d directions[6] = { gfx::Vector2d(-10, 0), |
309 IntSize(10, 0), | 310 gfx::Vector2d(10, 0), |
310 IntSize(0, -10), | 311 gfx::Vector2d(0, -10), |
311 IntSize(0, 10), | 312 gfx::Vector2d(0, 10), |
312 IntSize(10, 20), | 313 gfx::Vector2d(10, 20), |
313 IntSize(-20, 10) }; | 314 gfx::Vector2d(-20, 10) }; |
314 // We should push all tiles that touch the extruded visible rect. | 315 // We should push all tiles that touch the extruded visible rect. |
315 IntRect pushedVisibleTiles[6] = { IntRect(2, 2, 2, 1), | 316 gfx::Rect pushedVisibleTiles[6] = { gfx::Rect(2, 2, 2, 1), |
316 IntRect(1, 2, 2, 1), | 317 gfx::Rect(1, 2, 2, 1), |
317 IntRect(2, 2, 1, 2), | 318 gfx::Rect(2, 2, 1, 2), |
318 IntRect(2, 1, 1, 2), | 319 gfx::Rect(2, 1, 1, 2), |
319 IntRect(2, 1, 1, 2), | 320 gfx::Rect(2, 1, 1, 2), |
320 IntRect(2, 2, 2, 1) }; | 321 gfx::Rect(2, 2, 2, 1) }; |
321 // The first pre-paint should also paint first in the scroll | 322 // The first pre-paint should also paint first in the scroll |
322 // direction so we should find one additional tile in the scroll direction. | 323 // direction so we should find one additional tile in the scroll direction. |
323 IntRect pushedPrepaintTiles[6] = { IntRect(2, 2, 3, 1), | 324 gfx::Rect pushedPrepaintTiles[6] = { gfx::Rect(2, 2, 3, 1), |
324 IntRect(0, 2, 3, 1), | 325 gfx::Rect(0, 2, 3, 1), |
325 IntRect(2, 2, 1, 3), | 326 gfx::Rect(2, 2, 1, 3), |
326 IntRect(2, 0, 1, 3), | 327 gfx::Rect(2, 0, 1, 3), |
327 IntRect(2, 0, 1, 3), | 328 gfx::Rect(2, 0, 1, 3), |
328 IntRect(2, 2, 3, 1) }; | 329 gfx::Rect(2, 2, 3, 1) }; |
329 for(int k = 0; k < 6; k++) { | 330 for(int k = 0; k < 6; k++) { |
330 // The tile size is 100x100. Setup 5x5 tiles with one visible tile | 331 // The tile size is 100x100. Setup 5x5 tiles with one visible tile |
331 // in the center. | 332 // in the center. |
332 IntSize contentBounds = IntSize(500, 500); | 333 gfx::Size contentBounds = gfx::Size(500, 500); |
333 IntRect contentRect = IntRect(0, 0, 500, 500); | 334 gfx::Rect contentRect = gfx::Rect(0, 0, 500, 500); |
334 IntRect visibleRect = IntRect(200, 200, 100, 100); | 335 gfx::Rect visibleRect = gfx::Rect(200, 200, 100, 100); |
335 IntRect previousVisibleRect = IntRect(visibleRect.location() + direction
s[k], visibleRect.size()); | 336 gfx::Rect previousVisibleRect = gfx::Rect(visibleRect.origin() + directi
ons[k], visibleRect.size()); |
336 IntRect nextVisibleRect = IntRect(visibleRect.location() - directions[k]
, visibleRect.size()); | 337 gfx::Rect nextVisibleRect = gfx::Rect(visibleRect.origin() - directions[
k], visibleRect.size()); |
337 | 338 |
338 // Setup. Use the previousVisibleRect to setup the prediction for next f
rame. | 339 // Setup. Use the previousVisibleRect to setup the prediction for next f
rame. |
339 layer->setBounds(contentBounds); | 340 layer->setBounds(contentBounds); |
340 layer->setVisibleContentRect(previousVisibleRect); | 341 layer->setVisibleContentRect(previousVisibleRect); |
341 layer->invalidateContentRect(contentRect); | 342 layer->invalidateContentRect(contentRect); |
342 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 343 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
343 | 344 |
344 // Invalidate and move the visibleRect in the scroll direction. | 345 // Invalidate and move the visibleRect in the scroll direction. |
345 // Check that the correct tiles have been painted in the visible pass. | 346 // Check that the correct tiles have been painted in the visible pass. |
346 layer->invalidateContentRect(contentRect); | 347 layer->invalidateContentRect(contentRect); |
347 layer->setVisibleContentRect(visibleRect); | 348 layer->setVisibleContentRect(visibleRect); |
348 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 349 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
349 for (int i = 0; i < 5; i++) { | 350 for (int i = 0; i < 5; i++) { |
350 for (int j = 0; j < 5; j++) | 351 for (int j = 0; j < 5; j++) |
351 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedVisible
Tiles[k].contains(i, j)); | 352 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedVisible
Tiles[k].Contains(i, j)); |
352 } | 353 } |
353 | 354 |
354 // Move the transform in the same direction without invalidating. | 355 // Move the transform in the same direction without invalidating. |
355 // Check that non-visible pre-painting occured in the correct direction. | 356 // Check that non-visible pre-painting occured in the correct direction. |
356 // Ignore diagonal scrolls here (k > 3) as these have new visible conten
t now. | 357 // Ignore diagonal scrolls here (k > 3) as these have new visible conten
t now. |
357 if (k <= 3) { | 358 if (k <= 3) { |
358 layer->setVisibleContentRect(nextVisibleRect); | 359 layer->setVisibleContentRect(nextVisibleRect); |
359 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 360 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
360 for (int i = 0; i < 5; i++) { | 361 for (int i = 0; i < 5; i++) { |
361 for (int j = 0; j < 5; j++) | 362 for (int j = 0; j < 5; j++) |
362 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedPre
paintTiles[k].contains(i, j)); | 363 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(i, j), pushedPre
paintTiles[k].Contains(i, j)); |
363 } | 364 } |
364 } | 365 } |
365 | 366 |
366 // We should always finish painting eventually. | 367 // We should always finish painting eventually. |
367 for (int i = 0; i < 20; i++) | 368 for (int i = 0; i < 20; i++) |
368 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 369 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
369 EXPECT_FALSE(needsUpdate); | 370 EXPECT_FALSE(needsUpdate); |
370 } | 371 } |
371 } | 372 } |
372 | 373 |
373 TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed) | 374 TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed) |
374 { | 375 { |
375 // 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. | 376 // 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. |
376 m_textureManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); | 377 m_textureManager->setMaxMemoryLimitBytes(2 * 1024 * 1024); |
377 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); | 378 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); |
378 ScopedFakeTiledLayerImpl layerImpl1(1); | 379 ScopedFakeTiledLayerImpl layerImpl1(1); |
379 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); | 380 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); |
380 ScopedFakeTiledLayerImpl layerImpl2(2); | 381 ScopedFakeTiledLayerImpl layerImpl2(2); |
381 | 382 |
382 // For this test we have two layers. layer1 exhausts most texture memory, le
aving room for 2 more tiles from | 383 // For this test we have two layers. layer1 exhausts most texture memory, le
aving room for 2 more tiles from |
383 // layer2, but not all three tiles. First we paint layer1, and one tile from
layer2. Then when we idle paint | 384 // layer2, but not all three tiles. First we paint layer1, and one tile from
layer2. Then when we idle paint |
384 // layer2, we will fail on the third tile of layer2, and this should not lea
ve the second tile in a bad state. | 385 // layer2, we will fail on the third tile of layer2, and this should not lea
ve the second tile in a bad state. |
385 | 386 |
386 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou
gh for 2 tiles only in the other layer. | 387 // This uses 960000 bytes, leaving 88576 bytes of memory left, which is enou
gh for 2 tiles only in the other layer. |
387 IntRect layer1Rect(0, 0, 100, 2400); | 388 gfx::Rect layer1Rect(0, 0, 100, 2400); |
388 | 389 |
389 // This requires 4*30000 bytes of memory. | 390 // This requires 4*30000 bytes of memory. |
390 IntRect layer2Rect(0, 0, 100, 300); | 391 gfx::Rect layer2Rect(0, 0, 100, 300); |
391 | 392 |
392 // Paint a single tile in layer2 so that it will idle paint. | 393 // Paint a single tile in layer2 so that it will idle paint. |
393 layer1->setBounds(layer1Rect.size()); | 394 layer1->setBounds(layer1Rect.size()); |
394 layer1->setVisibleContentRect(layer1Rect); | 395 layer1->setVisibleContentRect(layer1Rect); |
395 layer2->setBounds(layer2Rect.size()); | 396 layer2->setBounds(layer2Rect.size()); |
396 layer2->setVisibleContentRect(IntRect(0, 0, 100, 100)); | 397 layer2->setVisibleContentRect(gfx::Rect(0, 0, 100, 100)); |
397 bool needsUpdate = updateAndPush(layer1.get(), layerImpl1.get(), | 398 bool needsUpdate = updateAndPush(layer1.get(), layerImpl1.get(), |
398 layer2.get(), layerImpl2.get()); | 399 layer2.get(), layerImpl2.get()); |
399 // We should need idle-painting for both remaining tiles in layer2. | 400 // We should need idle-painting for both remaining tiles in layer2. |
400 EXPECT_TRUE(needsUpdate); | 401 EXPECT_TRUE(needsUpdate); |
401 | 402 |
402 // Reduce our memory limits to 1mb. | 403 // Reduce our memory limits to 1mb. |
403 m_textureManager->setMaxMemoryLimitBytes(1024 * 1024); | 404 m_textureManager->setMaxMemoryLimitBytes(1024 * 1024); |
404 | 405 |
405 // Now idle paint layer2. We are going to run out of memory though! | 406 // Now idle paint layer2. We are going to run out of memory though! |
406 // Oh well, commit the frame and push. | 407 // Oh well, commit the frame and push. |
(...skipping 18 matching lines...) Expand all Loading... |
425 } | 426 } |
426 | 427 |
427 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles) | 428 TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles) |
428 { | 429 { |
429 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 430 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
430 ScopedFakeTiledLayerImpl layerImpl(1); | 431 ScopedFakeTiledLayerImpl layerImpl(1); |
431 TestOcclusionTracker occluded; | 432 TestOcclusionTracker occluded; |
432 m_occlusion = &occluded; | 433 m_occlusion = &occluded; |
433 | 434 |
434 // The tile size is 100x100, so this invalidates one occluded tile, culls it
during paint, but prepaints it. | 435 // The tile size is 100x100, so this invalidates one occluded tile, culls it
during paint, but prepaints it. |
435 occluded.setOcclusion(IntRect(0, 0, 100, 100)); | 436 occluded.setOcclusion(cc::IntRect(0, 0, 100, 100)); |
436 | 437 |
437 layer->setBounds(IntSize(100, 100)); | 438 layer->setBounds(gfx::Size(100, 100)); |
438 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); | 439 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 100)); |
439 updateAndPush(layer.get(), layerImpl.get()); | 440 updateAndPush(layer.get(), layerImpl.get()); |
440 | 441 |
441 // We should have the prepainted tile on the impl side, but culled it during
paint. | 442 // We should have the prepainted tile on the impl side, but culled it during
paint. |
442 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 443 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
443 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); | 444 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); |
444 } | 445 } |
445 | 446 |
446 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) | 447 TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint) |
447 { | 448 { |
448 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 449 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
449 ScopedFakeTiledLayerImpl layerImpl(1); | 450 ScopedFakeTiledLayerImpl layerImpl(1); |
450 | 451 |
451 // The tile size is 100x100, so this invalidates and then paints two tiles. | 452 // The tile size is 100x100, so this invalidates and then paints two tiles. |
452 // However, during the paint, we invalidate one of the tiles. This should | 453 // However, during the paint, we invalidate one of the tiles. This should |
453 // not prevent the tile from being pushed. | 454 // not prevent the tile from being pushed. |
454 layer->fakeLayerUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), laye
r.get()); | 455 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), la
yer.get()); |
455 layer->setBounds(IntSize(100, 200)); | 456 layer->setBounds(gfx::Size(100, 200)); |
456 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 457 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); |
457 updateAndPush(layer.get(), layerImpl.get()); | 458 updateAndPush(layer.get(), layerImpl.get()); |
458 | 459 |
459 // We should have both tiles on the impl side. | 460 // We should have both tiles on the impl side. |
460 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 461 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
461 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 462 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
462 } | 463 } |
463 | 464 |
464 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) | 465 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer) |
465 { | 466 { |
466 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); | 467 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); |
467 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); | 468 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); |
468 ScopedFakeTiledLayerImpl layer1Impl(1); | 469 ScopedFakeTiledLayerImpl layer1Impl(1); |
469 ScopedFakeTiledLayerImpl layer2Impl(2); | 470 ScopedFakeTiledLayerImpl layer2Impl(2); |
470 | 471 |
471 // Invalidate a tile on layer1, during update of layer 2. | 472 // Invalidate a tile on layer1, during update of layer 2. |
472 layer2->fakeLayerUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), lay
er1.get()); | 473 layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer1.get()); |
473 layer1->setBounds(IntSize(100, 200)); | 474 layer1->setBounds(gfx::Size(100, 200)); |
474 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 475 layer1->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); |
475 layer2->setBounds(IntSize(100, 200)); | 476 layer2->setBounds(gfx::Size(100, 200)); |
476 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 477 layer2->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); |
477 updateAndPush(layer1.get(), layer1Impl.get(), | 478 updateAndPush(layer1.get(), layer1Impl.get(), |
478 layer2.get(), layer2Impl.get()); | 479 layer2.get(), layer2Impl.get()); |
479 | 480 |
480 // We should have both tiles on the impl side for all layers. | 481 // We should have both tiles on the impl side for all layers. |
481 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); | 482 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); |
482 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); | 483 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); |
483 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); | 484 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); |
484 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); | 485 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); |
485 } | 486 } |
486 | 487 |
487 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) | 488 TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer) |
488 { | 489 { |
489 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); | 490 scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); |
490 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); | 491 scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer
(m_textureManager.get())); |
491 ScopedFakeTiledLayerImpl layer1Impl(1); | 492 ScopedFakeTiledLayerImpl layer1Impl(1); |
492 ScopedFakeTiledLayerImpl layer2Impl(2); | 493 ScopedFakeTiledLayerImpl layer2Impl(2); |
493 | 494 |
494 layer1->fakeLayerUpdater()->setRectToInvalidate(IntRect(0, 50, 100, 50), lay
er2.get()); | 495 layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), l
ayer2.get()); |
495 layer1->setBounds(IntSize(100, 200)); | 496 layer1->setBounds(gfx::Size(100, 200)); |
496 layer1->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 497 layer1->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); |
497 layer2->setBounds(IntSize(100, 200)); | 498 layer2->setBounds(gfx::Size(100, 200)); |
498 layer2->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 499 layer2->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); |
499 updateAndPush(layer1.get(), layer1Impl.get(), | 500 updateAndPush(layer1.get(), layer1Impl.get(), |
500 layer2.get(), layer2Impl.get()); | 501 layer2.get(), layer2Impl.get()); |
501 | 502 |
502 // We should have both tiles on the impl side for all layers. | 503 // We should have both tiles on the impl side for all layers. |
503 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); | 504 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 0)); |
504 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); | 505 EXPECT_TRUE(layer1Impl->hasResourceIdForTileAt(0, 1)); |
505 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); | 506 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 0)); |
506 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); | 507 EXPECT_TRUE(layer2Impl->hasResourceIdForTileAt(0, 1)); |
507 } | 508 } |
508 | 509 |
509 TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately) | 510 TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately) |
510 { | 511 { |
511 // Create a LayerTreeHost that has the right viewportsize, | 512 // Create a LayerTreeHost that has the right viewportsize, |
512 // so the layer is considered small enough. | 513 // so the layer is considered small enough. |
513 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; | 514 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; |
514 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm
plTreeHostClient, LayerTreeSettings()); | 515 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm
plTreeHostClient, LayerTreeSettings()); |
515 | 516 |
516 bool runOutOfMemory[2] = {false, true}; | 517 bool runOutOfMemory[2] = {false, true}; |
517 for (int i = 0; i < 2; i++) { | 518 for (int i = 0; i < 2; i++) { |
518 // Create a layer with 4x4 tiles. | 519 // Create a layer with 4x4 tiles. |
519 int layerWidth = 4 * FakeTiledLayer::tileSize().width(); | 520 int layerWidth = 4 * FakeTiledLayer::tileSize().width(); |
520 int layerHeight = 4 * FakeTiledLayer::tileSize().height(); | 521 int layerHeight = 4 * FakeTiledLayer::tileSize().height(); |
521 int memoryForLayer = layerWidth * layerHeight * 4; | 522 int memoryForLayer = layerWidth * layerHeight * 4; |
522 IntSize viewportSize = IntSize(layerWidth, layerHeight); | 523 gfx::Size viewportSize = gfx::Size(layerWidth, layerHeight); |
523 layerTreeHost->setViewportSize(viewportSize, viewportSize); | 524 layerTreeHost->setViewportSize(viewportSize, viewportSize); |
524 | 525 |
525 // Use 8x4 tiles to run out of memory. | 526 // Use 8x4 tiles to run out of memory. |
526 if (runOutOfMemory[i]) | 527 if (runOutOfMemory[i]) |
527 layerWidth *= 2; | 528 layerWidth *= 2; |
528 | 529 |
529 m_textureManager->setMaxMemoryLimitBytes(memoryForLayer); | 530 m_textureManager->setMaxMemoryLimitBytes(memoryForLayer); |
530 | 531 |
531 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa
yer(m_textureManager.get())); | 532 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLa
yer(m_textureManager.get())); |
532 ScopedFakeTiledLayerImpl layerImpl(1); | 533 ScopedFakeTiledLayerImpl layerImpl(1); |
533 | 534 |
534 // Full size layer with half being visible. | 535 // Full size layer with half being visible. |
535 IntSize contentBounds(layerWidth, layerHeight); | 536 gfx::Size contentBounds(layerWidth, layerHeight); |
536 IntRect contentRect(IntPoint::zero(), contentBounds); | 537 gfx::Rect contentRect(gfx::Point(), contentBounds); |
537 IntRect visibleRect(IntPoint::zero(), IntSize(layerWidth / 2, layerHeigh
t)); | 538 gfx::Rect visibleRect(gfx::Point(), gfx::Size(layerWidth / 2, layerHeigh
t)); |
538 | 539 |
539 // Pretend the layer is animating. | 540 // Pretend the layer is animating. |
540 layer->setDrawTransformIsAnimating(true); | 541 layer->setDrawTransformIsAnimating(true); |
541 layer->setBounds(contentBounds); | 542 layer->setBounds(contentBounds); |
542 layer->setVisibleContentRect(visibleRect); | 543 layer->setVisibleContentRect(visibleRect); |
543 layer->invalidateContentRect(contentRect); | 544 layer->invalidateContentRect(contentRect); |
544 layer->setLayerTreeHost(layerTreeHost.get()); | 545 layer->setLayerTreeHost(layerTreeHost.get()); |
545 | 546 |
546 // The layer should paint it's entire contents on the first paint | 547 // The layer should paint it's entire contents on the first paint |
547 // if it is close to the viewport size and has the available memory. | 548 // if it is close to the viewport size and has the available memory. |
(...skipping 24 matching lines...) Expand all Loading... |
572 { | 573 { |
573 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 574 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
574 ScopedFakeTiledLayerImpl layerImpl(1); | 575 ScopedFakeTiledLayerImpl layerImpl(1); |
575 | 576 |
576 // We have enough memory for only the visible rect, so we will run out of me
mory in first idle paint. | 577 // We have enough memory for only the visible rect, so we will run out of me
mory in first idle paint. |
577 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. | 578 int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel. |
578 m_textureManager->setMaxMemoryLimitBytes(memoryLimit); | 579 m_textureManager->setMaxMemoryLimitBytes(memoryLimit); |
579 | 580 |
580 // The tile size is 100x100, so this invalidates and then paints two tiles. | 581 // The tile size is 100x100, so this invalidates and then paints two tiles. |
581 bool needsUpdate = false; | 582 bool needsUpdate = false; |
582 layer->setBounds(IntSize(300, 300)); | 583 layer->setBounds(gfx::Size(300, 300)); |
583 layer->setVisibleContentRect(IntRect(100, 100, 100, 100)); | 584 layer->setVisibleContentRect(gfx::Rect(100, 100, 100, 100)); |
584 for (int i = 0; i < 2; i++) | 585 for (int i = 0; i < 2; i++) |
585 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 586 needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
586 | 587 |
587 // Idle-painting should see no more priority tiles for painting. | 588 // Idle-painting should see no more priority tiles for painting. |
588 EXPECT_FALSE(needsUpdate); | 589 EXPECT_FALSE(needsUpdate); |
589 | 590 |
590 // We should have one tile on the impl side. | 591 // We should have one tile on the impl side. |
591 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); | 592 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); |
592 } | 593 } |
593 | 594 |
594 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) | 595 TEST_F(TiledLayerTest, idlePaintZeroSizedLayer) |
595 { | 596 { |
596 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 597 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
597 ScopedFakeTiledLayerImpl layerImpl(1); | 598 ScopedFakeTiledLayerImpl layerImpl(1); |
598 | 599 |
599 bool animating[2] = {false, true}; | 600 bool animating[2] = {false, true}; |
600 for (int i = 0; i < 2; i++) { | 601 for (int i = 0; i < 2; i++) { |
601 // Pretend the layer is animating. | 602 // Pretend the layer is animating. |
602 layer->setDrawTransformIsAnimating(animating[i]); | 603 layer->setDrawTransformIsAnimating(animating[i]); |
603 | 604 |
604 // The layer's bounds are empty. | 605 // The layer's bounds are empty. |
605 // Empty layers don't paint or idle-paint. | 606 // Empty layers don't paint or idle-paint. |
606 layer->setBounds(IntSize()); | 607 layer->setBounds(gfx::Size()); |
607 layer->setVisibleContentRect(IntRect()); | 608 layer->setVisibleContentRect(gfx::Rect()); |
608 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 609 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
609 | 610 |
610 // Empty layers don't have tiles. | 611 // Empty layers don't have tiles. |
611 EXPECT_EQ(0u, layer->numPaintedTiles()); | 612 EXPECT_EQ(0u, layer->numPaintedTiles()); |
612 | 613 |
613 // Empty layers don't need prepaint. | 614 // Empty layers don't need prepaint. |
614 EXPECT_FALSE(needsUpdate); | 615 EXPECT_FALSE(needsUpdate); |
615 | 616 |
616 // Empty layers don't have tiles. | 617 // Empty layers don't have tiles. |
617 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); | 618 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0)); |
618 } | 619 } |
619 } | 620 } |
620 | 621 |
621 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers) | 622 TEST_F(TiledLayerTest, idlePaintNonVisibleLayers) |
622 { | 623 { |
623 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 624 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
624 ScopedFakeTiledLayerImpl layerImpl(1); | 625 ScopedFakeTiledLayerImpl layerImpl(1); |
625 | 626 |
626 // Alternate between not visible and visible. | 627 // Alternate between not visible and visible. |
627 IntRect v(0, 0, 100, 100); | 628 gfx::Rect v(0, 0, 100, 100); |
628 IntRect nv(0, 0, 0, 0); | 629 gfx::Rect nv(0, 0, 0, 0); |
629 IntRect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; | 630 gfx::Rect visibleRect[10] = {nv, nv, v, v, nv, nv, v, v, nv, nv}; |
630 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals
e, false }; | 631 bool invalidate[10] = {true, true, true, true, true, true, true, true, fals
e, false }; |
631 | 632 |
632 // We should not have any tiles except for when the layer was visible | 633 // We should not have any tiles except for when the layer was visible |
633 // or after the layer was visible and we didn't invalidate. | 634 // or after the layer was visible and we didn't invalidate. |
634 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr
ue, true }; | 635 bool haveTile[10] = { false, false, true, true, false, false, true, true, tr
ue, true }; |
635 | 636 |
636 for (int i = 0; i < 10; i++) { | 637 for (int i = 0; i < 10; i++) { |
637 layer->setBounds(IntSize(100, 100)); | 638 layer->setBounds(gfx::Size(100, 100)); |
638 layer->setVisibleContentRect(visibleRect[i]); | 639 layer->setVisibleContentRect(visibleRect[i]); |
639 | 640 |
640 if (invalidate[i]) | 641 if (invalidate[i]) |
641 layer->invalidateContentRect(IntRect(0, 0, 100, 100)); | 642 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 100)); |
642 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); | 643 bool needsUpdate = updateAndPush(layer.get(), layerImpl.get()); |
643 | 644 |
644 // We should never signal idle paint, as we painted the entire layer | 645 // We should never signal idle paint, as we painted the entire layer |
645 // or the layer was not visible. | 646 // or the layer was not visible. |
646 EXPECT_FALSE(needsUpdate); | 647 EXPECT_FALSE(needsUpdate); |
647 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); | 648 EXPECT_EQ(layerImpl->hasResourceIdForTileAt(0, 0), haveTile[i]); |
648 } | 649 } |
649 } | 650 } |
650 | 651 |
651 TEST_F(TiledLayerTest, invalidateFromPrepare) | 652 TEST_F(TiledLayerTest, invalidateFromPrepare) |
652 { | 653 { |
653 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 654 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
654 ScopedFakeTiledLayerImpl layerImpl(1); | 655 ScopedFakeTiledLayerImpl layerImpl(1); |
655 | 656 |
656 // The tile size is 100x100, so this invalidates and then paints two tiles. | 657 // The tile size is 100x100, so this invalidates and then paints two tiles. |
657 layer->setBounds(IntSize(100, 200)); | 658 layer->setBounds(gfx::Size(100, 200)); |
658 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 659 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); |
659 updateAndPush(layer.get(), layerImpl.get()); | 660 updateAndPush(layer.get(), layerImpl.get()); |
660 | 661 |
661 // We should have both tiles on the impl side. | 662 // We should have both tiles on the impl side. |
662 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 663 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
663 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 664 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
664 | 665 |
665 layer->fakeLayerUpdater()->clearPrepareCount(); | 666 layer->fakeLayerUpdater()->clearPrepareCount(); |
666 // Invoke update again. As the layer is valid update shouldn't be invoked on | 667 // Invoke update again. As the layer is valid update shouldn't be invoked on |
667 // the LayerUpdater. | 668 // the LayerUpdater. |
668 updateAndPush(layer.get(), layerImpl.get()); | 669 updateAndPush(layer.get(), layerImpl.get()); |
669 EXPECT_EQ(0, layer->fakeLayerUpdater()->prepareCount()); | 670 EXPECT_EQ(0, layer->fakeLayerUpdater()->prepareCount()); |
670 | 671 |
671 // setRectToInvalidate triggers invalidateContentRect() being invoked from u
pdate. | 672 // setRectToInvalidate triggers invalidateContentRect() being invoked from u
pdate. |
672 layer->fakeLayerUpdater()->setRectToInvalidate(IntRect(25, 25, 50, 50), laye
r.get()); | 673 layer->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(25, 25, 50, 50), la
yer.get()); |
673 layer->fakeLayerUpdater()->clearPrepareCount(); | 674 layer->fakeLayerUpdater()->clearPrepareCount(); |
674 layer->invalidateContentRect(IntRect(0, 0, 50, 50)); | 675 layer->invalidateContentRect(gfx::Rect(0, 0, 50, 50)); |
675 updateAndPush(layer.get(), layerImpl.get()); | 676 updateAndPush(layer.get(), layerImpl.get()); |
676 EXPECT_EQ(1, layer->fakeLayerUpdater()->prepareCount()); | 677 EXPECT_EQ(1, layer->fakeLayerUpdater()->prepareCount()); |
677 layer->fakeLayerUpdater()->clearPrepareCount(); | 678 layer->fakeLayerUpdater()->clearPrepareCount(); |
678 | 679 |
679 // The layer should still be invalid as update invoked invalidate. | 680 // The layer should still be invalid as update invoked invalidate. |
680 updateAndPush(layer.get(), layerImpl.get()); // visible | 681 updateAndPush(layer.get(), layerImpl.get()); // visible |
681 EXPECT_EQ(1, layer->fakeLayerUpdater()->prepareCount()); | 682 EXPECT_EQ(1, layer->fakeLayerUpdater()->prepareCount()); |
682 } | 683 } |
683 | 684 |
684 TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled) | 685 TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled) |
685 { | 686 { |
686 // The updateRect (that indicates what was actually painted) should be in | 687 // The updateRect (that indicates what was actually painted) should be in |
687 // layer space, not the content space. | 688 // layer space, not the content space. |
688 scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new
FakeTiledLayerWithScaledBounds(m_textureManager.get())); | 689 scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new
FakeTiledLayerWithScaledBounds(m_textureManager.get())); |
689 | 690 |
690 IntRect layerBounds(0, 0, 300, 200); | 691 gfx::Rect layerBounds(0, 0, 300, 200); |
691 IntRect contentBounds(0, 0, 200, 250); | 692 gfx::Rect contentBounds(0, 0, 200, 250); |
692 | 693 |
693 layer->setBounds(layerBounds.size()); | 694 layer->setBounds(layerBounds.size()); |
694 layer->setContentBounds(contentBounds.size()); | 695 layer->setContentBounds(contentBounds.size()); |
695 layer->setVisibleContentRect(contentBounds); | 696 layer->setVisibleContentRect(contentBounds); |
696 | 697 |
697 // On first update, the updateRect includes all tiles, even beyond the bound
aries of the layer. | 698 // On first update, the updateRect includes all tiles, even beyond the bound
aries of the layer. |
698 // However, it should still be in layer space, not content space. | 699 // However, it should still be in layer space, not content space. |
699 layer->invalidateContentRect(contentBounds); | 700 layer->invalidateContentRect(contentBounds); |
700 | 701 |
701 layer->setTexturePriorities(m_priorityCalculator); | 702 layer->setTexturePriorities(m_priorityCalculator); |
702 m_textureManager->prioritizeTextures(); | 703 m_textureManager->prioritizeTextures(); |
703 layer->update(*m_queue.get(), 0, m_stats); | 704 layer->update(*m_queue.get(), 0, m_stats); |
704 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 300, 300 * 0.8), layer->updateRect()); | 705 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->updateRect()); |
705 updateTextures(); | 706 updateTextures(); |
706 | 707 |
707 // After the tiles are updated once, another invalidate only needs to update
the bounds of the layer. | 708 // After the tiles are updated once, another invalidate only needs to update
the bounds of the layer. |
708 layer->setTexturePriorities(m_priorityCalculator); | 709 layer->setTexturePriorities(m_priorityCalculator); |
709 m_textureManager->prioritizeTextures(); | 710 m_textureManager->prioritizeTextures(); |
710 layer->invalidateContentRect(contentBounds); | 711 layer->invalidateContentRect(contentBounds); |
711 layer->update(*m_queue.get(), 0, m_stats); | 712 layer->update(*m_queue.get(), 0, m_stats); |
712 EXPECT_FLOAT_RECT_EQ(FloatRect(layerBounds), layer->updateRect()); | 713 EXPECT_FLOAT_RECT_EQ(gfx::RectF(layerBounds), layer->updateRect()); |
713 updateTextures(); | 714 updateTextures(); |
714 | 715 |
715 // Partial re-paint should also be represented by the updateRect in layer sp
ace, not content space. | 716 // Partial re-paint should also be represented by the updateRect in layer sp
ace, not content space. |
716 IntRect partialDamage(30, 100, 10, 10); | 717 gfx::Rect partialDamage(30, 100, 10, 10); |
717 layer->invalidateContentRect(partialDamage); | 718 layer->invalidateContentRect(partialDamage); |
718 layer->setTexturePriorities(m_priorityCalculator); | 719 layer->setTexturePriorities(m_priorityCalculator); |
719 m_textureManager->prioritizeTextures(); | 720 m_textureManager->prioritizeTextures(); |
720 layer->update(*m_queue.get(), 0, m_stats); | 721 layer->update(*m_queue.get(), 0, m_stats); |
721 EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect()); | 722 EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect()); |
722 } | 723 } |
723 | 724 |
724 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) | 725 TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) |
725 { | 726 { |
726 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 727 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
727 ScopedFakeTiledLayerImpl layerImpl(1); | 728 ScopedFakeTiledLayerImpl layerImpl(1); |
728 | 729 |
729 // Create a layer with one tile. | 730 // Create a layer with one tile. |
730 layer->setBounds(IntSize(100, 100)); | 731 layer->setBounds(gfx::Size(100, 100)); |
731 layer->setVisibleContentRect(IntRect(0, 0, 100, 100)); | 732 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 100)); |
732 | 733 |
733 // Invalidate the entire layer. | 734 // Invalidate the entire layer. |
734 layer->setNeedsDisplay(); | 735 layer->setNeedsDisplay(); |
735 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect(
)); | 736 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect
()); |
736 | 737 |
737 // Push the tiles to the impl side and check that there is exactly one. | 738 // Push the tiles to the impl side and check that there is exactly one. |
738 layer->setTexturePriorities(m_priorityCalculator); | 739 layer->setTexturePriorities(m_priorityCalculator); |
739 m_textureManager->prioritizeTextures(); | 740 m_textureManager->prioritizeTextures(); |
740 layer->update(*m_queue.get(), 0, m_stats); | 741 layer->update(*m_queue.get(), 0, m_stats); |
741 updateTextures(); | 742 updateTextures(); |
742 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 743 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
743 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 744 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
744 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); | 745 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 1)); |
745 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0)); | 746 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0)); |
746 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); | 747 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); |
747 | 748 |
748 // Change the contents scale and verify that the content rectangle requiring
painting | 749 // Change the contents scale and verify that the content rectangle requiring
painting |
749 // is not scaled. | 750 // is not scaled. |
750 layer->setContentsScale(2); | 751 layer->setContentsScale(2); |
751 layer->setVisibleContentRect(IntRect(0, 0, 200, 200)); | 752 layer->setVisibleContentRect(gfx::Rect(0, 0, 200, 200)); |
752 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect(
)); | 753 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect
()); |
753 | 754 |
754 // The impl side should get 2x2 tiles now. | 755 // The impl side should get 2x2 tiles now. |
755 layer->setTexturePriorities(m_priorityCalculator); | 756 layer->setTexturePriorities(m_priorityCalculator); |
756 m_textureManager->prioritizeTextures(); | 757 m_textureManager->prioritizeTextures(); |
757 layer->update(*m_queue.get(), 0, m_stats); | 758 layer->update(*m_queue.get(), 0, m_stats); |
758 updateTextures(); | 759 updateTextures(); |
759 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 760 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
760 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); | 761 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0)); |
761 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); | 762 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1)); |
762 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 0)); | 763 EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 0)); |
(...skipping 12 matching lines...) Expand all Loading... |
775 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); | 776 EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); |
776 } | 777 } |
777 | 778 |
778 TEST_F(TiledLayerTest, skipsDrawGetsReset) | 779 TEST_F(TiledLayerTest, skipsDrawGetsReset) |
779 { | 780 { |
780 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; | 781 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; |
781 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm
plTreeHostClient, LayerTreeSettings()); | 782 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm
plTreeHostClient, LayerTreeSettings()); |
782 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded()); | 783 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded()); |
783 | 784 |
784 // Create two 300 x 300 tiled layers. | 785 // Create two 300 x 300 tiled layers. |
785 IntSize contentBounds(300, 300); | 786 gfx::Size contentBounds(300, 300); |
786 IntRect contentRect(IntPoint::zero(), contentBounds); | 787 gfx::Rect contentRect(gfx::Point(), contentBounds); |
787 | 788 |
788 // We have enough memory for only one of the two layers. | 789 // We have enough memory for only one of the two layers. |
789 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel. | 790 int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel. |
790 | 791 |
791 scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLa
yer(layerTreeHost->contentsTextureManager())); | 792 scoped_refptr<FakeTiledLayer> rootLayer = make_scoped_refptr(new FakeTiledLa
yer(layerTreeHost->contentsTextureManager())); |
792 scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledL
ayer(layerTreeHost->contentsTextureManager())); | 793 scoped_refptr<FakeTiledLayer> childLayer = make_scoped_refptr(new FakeTiledL
ayer(layerTreeHost->contentsTextureManager())); |
793 rootLayer->addChild(childLayer); | 794 rootLayer->addChild(childLayer); |
794 | 795 |
795 rootLayer->setBounds(contentBounds); | 796 rootLayer->setBounds(contentBounds); |
796 rootLayer->setVisibleContentRect(contentRect); | 797 rootLayer->setVisibleContentRect(contentRect); |
797 rootLayer->setPosition(FloatPoint(0, 0)); | 798 rootLayer->setPosition(gfx::PointF(0, 0)); |
798 childLayer->setBounds(contentBounds); | 799 childLayer->setBounds(contentBounds); |
799 childLayer->setVisibleContentRect(contentRect); | 800 childLayer->setVisibleContentRect(contentRect); |
800 childLayer->setPosition(FloatPoint(0, 0)); | 801 childLayer->setPosition(gfx::PointF(0, 0)); |
801 rootLayer->invalidateContentRect(contentRect); | 802 rootLayer->invalidateContentRect(contentRect); |
802 childLayer->invalidateContentRect(contentRect); | 803 childLayer->invalidateContentRect(contentRect); |
803 | 804 |
804 layerTreeHost->setRootLayer(rootLayer); | 805 layerTreeHost->setRootLayer(rootLayer); |
805 layerTreeHost->setViewportSize(IntSize(300, 300), IntSize(300, 300)); | 806 layerTreeHost->setViewportSize(gfx::Size(300, 300), gfx::Size(300, 300)); |
806 | 807 |
807 layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); | 808 layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); |
808 | 809 |
809 // We'll skip the root layer. | 810 // We'll skip the root layer. |
810 EXPECT_TRUE(rootLayer->skipsDraw()); | 811 EXPECT_TRUE(rootLayer->skipsDraw()); |
811 EXPECT_FALSE(childLayer->skipsDraw()); | 812 EXPECT_FALSE(childLayer->skipsDraw()); |
812 | 813 |
813 layerTreeHost->commitComplete(); | 814 layerTreeHost->commitComplete(); |
814 | 815 |
815 // Remove the child layer. | 816 // Remove the child layer. |
816 rootLayer->removeAllChildren(); | 817 rootLayer->removeAllChildren(); |
817 | 818 |
818 layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); | 819 layerTreeHost->updateLayers(*m_queue.get(), memoryLimit); |
819 EXPECT_FALSE(rootLayer->skipsDraw()); | 820 EXPECT_FALSE(rootLayer->skipsDraw()); |
820 | 821 |
821 textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_reso
urceProvider.get()); | 822 textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_reso
urceProvider.get()); |
822 layerTreeHost->setRootLayer(0); | 823 layerTreeHost->setRootLayer(0); |
823 } | 824 } |
824 | 825 |
825 TEST_F(TiledLayerTest, resizeToSmaller) | 826 TEST_F(TiledLayerTest, resizeToSmaller) |
826 { | 827 { |
827 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 828 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
828 | 829 |
829 layer->setBounds(IntSize(700, 700)); | 830 layer->setBounds(gfx::Size(700, 700)); |
830 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); | 831 layer->setVisibleContentRect(gfx::Rect(0, 0, 700, 700)); |
831 layer->invalidateContentRect(IntRect(0, 0, 700, 700)); | 832 layer->invalidateContentRect(gfx::Rect(0, 0, 700, 700)); |
832 | 833 |
833 layer->setTexturePriorities(m_priorityCalculator); | 834 layer->setTexturePriorities(m_priorityCalculator); |
834 m_textureManager->prioritizeTextures(); | 835 m_textureManager->prioritizeTextures(); |
835 layer->update(*m_queue.get(), 0, m_stats); | 836 layer->update(*m_queue.get(), 0, m_stats); |
836 | 837 |
837 layer->setBounds(IntSize(200, 200)); | 838 layer->setBounds(gfx::Size(200, 200)); |
838 layer->invalidateContentRect(IntRect(0, 0, 200, 200)); | 839 layer->invalidateContentRect(gfx::Rect(0, 0, 200, 200)); |
839 } | 840 } |
840 | 841 |
841 TEST_F(TiledLayerTest, hugeLayerUpdateCrash) | 842 TEST_F(TiledLayerTest, hugeLayerUpdateCrash) |
842 { | 843 { |
843 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 844 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
844 | 845 |
845 int size = 1 << 30; | 846 int size = 1 << 30; |
846 layer->setBounds(IntSize(size, size)); | 847 layer->setBounds(gfx::Size(size, size)); |
847 layer->setVisibleContentRect(IntRect(0, 0, 700, 700)); | 848 layer->setVisibleContentRect(gfx::Rect(0, 0, 700, 700)); |
848 layer->invalidateContentRect(IntRect(0, 0, size, size)); | 849 layer->invalidateContentRect(gfx::Rect(0, 0, size, size)); |
849 | 850 |
850 // Ensure no crash for bounds where size * size would overflow an int. | 851 // Ensure no crash for bounds where size * size would overflow an int. |
851 layer->setTexturePriorities(m_priorityCalculator); | 852 layer->setTexturePriorities(m_priorityCalculator); |
852 m_textureManager->prioritizeTextures(); | 853 m_textureManager->prioritizeTextures(); |
853 layer->update(*m_queue.get(), 0, m_stats); | 854 layer->update(*m_queue.get(), 0, m_stats); |
854 } | 855 } |
855 | 856 |
856 TEST_F(TiledLayerTest, partialUpdates) | 857 TEST_F(TiledLayerTest, partialUpdates) |
857 { | 858 { |
858 LayerTreeSettings settings; | 859 LayerTreeSettings settings; |
859 settings.maxPartialTextureUpdates = 4; | 860 settings.maxPartialTextureUpdates = 4; |
860 | 861 |
861 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; | 862 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; |
862 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm
plTreeHostClient, settings); | 863 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm
plTreeHostClient, settings); |
863 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded()); | 864 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded()); |
864 | 865 |
865 // Create one 300 x 200 tiled layer with 3 x 2 tiles. | 866 // Create one 300 x 200 tiled layer with 3 x 2 tiles. |
866 IntSize contentBounds(300, 200); | 867 gfx::Size contentBounds(300, 200); |
867 IntRect contentRect(IntPoint::zero(), contentBounds); | 868 gfx::Rect contentRect(gfx::Point(), contentBounds); |
868 | 869 |
869 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
layerTreeHost->contentsTextureManager())); | 870 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
layerTreeHost->contentsTextureManager())); |
870 layer->setBounds(contentBounds); | 871 layer->setBounds(contentBounds); |
871 layer->setPosition(FloatPoint(0, 0)); | 872 layer->setPosition(gfx::PointF(0, 0)); |
872 layer->setVisibleContentRect(contentRect); | 873 layer->setVisibleContentRect(contentRect); |
873 layer->invalidateContentRect(contentRect); | 874 layer->invalidateContentRect(contentRect); |
874 | 875 |
875 layerTreeHost->setRootLayer(layer); | 876 layerTreeHost->setRootLayer(layer); |
876 layerTreeHost->setViewportSize(IntSize(300, 200), IntSize(300, 200)); | 877 layerTreeHost->setViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); |
877 | 878 |
878 // Full update of all 6 tiles. | 879 // Full update of all 6 tiles. |
879 layerTreeHost->updateLayers( | 880 layerTreeHost->updateLayers( |
880 *m_queue.get(), std::numeric_limits<size_t>::max()); | 881 *m_queue.get(), std::numeric_limits<size_t>::max()); |
881 { | 882 { |
882 ScopedFakeTiledLayerImpl layerImpl(1); | 883 ScopedFakeTiledLayerImpl layerImpl(1); |
883 EXPECT_EQ(6, m_queue->fullUploadSize()); | 884 EXPECT_EQ(6, m_queue->fullUploadSize()); |
884 EXPECT_EQ(0, m_queue->partialUploadSize()); | 885 EXPECT_EQ(0, m_queue->partialUploadSize()); |
885 updateTextures(); | 886 updateTextures(); |
886 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 887 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
887 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 888 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
888 layer->fakeLayerUpdater()->clearUpdateCount(); | 889 layer->fakeLayerUpdater()->clearUpdateCount(); |
889 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 890 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
890 } | 891 } |
891 layerTreeHost->commitComplete(); | 892 layerTreeHost->commitComplete(); |
892 | 893 |
893 // Full update of 3 tiles and partial update of 3 tiles. | 894 // Full update of 3 tiles and partial update of 3 tiles. |
894 layer->invalidateContentRect(IntRect(0, 0, 300, 150)); | 895 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150)); |
895 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max
()); | 896 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max
()); |
896 { | 897 { |
897 ScopedFakeTiledLayerImpl layerImpl(1); | 898 ScopedFakeTiledLayerImpl layerImpl(1); |
898 EXPECT_EQ(3, m_queue->fullUploadSize()); | 899 EXPECT_EQ(3, m_queue->fullUploadSize()); |
899 EXPECT_EQ(3, m_queue->partialUploadSize()); | 900 EXPECT_EQ(3, m_queue->partialUploadSize()); |
900 updateTextures(); | 901 updateTextures(); |
901 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 902 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
902 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 903 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
903 layer->fakeLayerUpdater()->clearUpdateCount(); | 904 layer->fakeLayerUpdater()->clearUpdateCount(); |
904 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 905 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
905 } | 906 } |
906 layerTreeHost->commitComplete(); | 907 layerTreeHost->commitComplete(); |
907 | 908 |
908 // Partial update of 6 tiles. | 909 // Partial update of 6 tiles. |
909 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); | 910 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); |
910 { | 911 { |
911 ScopedFakeTiledLayerImpl layerImpl(1); | 912 ScopedFakeTiledLayerImpl layerImpl(1); |
912 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>:
:max()); | 913 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>:
:max()); |
913 EXPECT_EQ(2, m_queue->fullUploadSize()); | 914 EXPECT_EQ(2, m_queue->fullUploadSize()); |
914 EXPECT_EQ(4, m_queue->partialUploadSize()); | 915 EXPECT_EQ(4, m_queue->partialUploadSize()); |
915 updateTextures(); | 916 updateTextures(); |
916 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 917 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
917 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 918 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
918 layer->fakeLayerUpdater()->clearUpdateCount(); | 919 layer->fakeLayerUpdater()->clearUpdateCount(); |
919 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 920 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
920 } | 921 } |
921 layerTreeHost->commitComplete(); | 922 layerTreeHost->commitComplete(); |
922 | 923 |
923 // Checkerboard all tiles. | 924 // Checkerboard all tiles. |
924 layer->invalidateContentRect(IntRect(0, 0, 300, 200)); | 925 layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200)); |
925 { | 926 { |
926 ScopedFakeTiledLayerImpl layerImpl(1); | 927 ScopedFakeTiledLayerImpl layerImpl(1); |
927 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 928 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
928 } | 929 } |
929 layerTreeHost->commitComplete(); | 930 layerTreeHost->commitComplete(); |
930 | 931 |
931 // Partial update of 6 checkerboard tiles. | 932 // Partial update of 6 checkerboard tiles. |
932 layer->invalidateContentRect(IntRect(50, 50, 200, 100)); | 933 layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100)); |
933 { | 934 { |
934 ScopedFakeTiledLayerImpl layerImpl(1); | 935 ScopedFakeTiledLayerImpl layerImpl(1); |
935 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>:
:max()); | 936 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>:
:max()); |
936 EXPECT_EQ(6, m_queue->fullUploadSize()); | 937 EXPECT_EQ(6, m_queue->fullUploadSize()); |
937 EXPECT_EQ(0, m_queue->partialUploadSize()); | 938 EXPECT_EQ(0, m_queue->partialUploadSize()); |
938 updateTextures(); | 939 updateTextures(); |
939 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); | 940 EXPECT_EQ(6, layer->fakeLayerUpdater()->updateCount()); |
940 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 941 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
941 layer->fakeLayerUpdater()->clearUpdateCount(); | 942 layer->fakeLayerUpdater()->clearUpdateCount(); |
942 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 943 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
943 } | 944 } |
944 layerTreeHost->commitComplete(); | 945 layerTreeHost->commitComplete(); |
945 | 946 |
946 // Partial update of 4 tiles. | 947 // Partial update of 4 tiles. |
947 layer->invalidateContentRect(IntRect(50, 50, 100, 100)); | 948 layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100)); |
948 { | 949 { |
949 ScopedFakeTiledLayerImpl layerImpl(1); | 950 ScopedFakeTiledLayerImpl layerImpl(1); |
950 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>:
:max()); | 951 layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>:
:max()); |
951 EXPECT_EQ(0, m_queue->fullUploadSize()); | 952 EXPECT_EQ(0, m_queue->fullUploadSize()); |
952 EXPECT_EQ(4, m_queue->partialUploadSize()); | 953 EXPECT_EQ(4, m_queue->partialUploadSize()); |
953 updateTextures(); | 954 updateTextures(); |
954 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); | 955 EXPECT_EQ(4, layer->fakeLayerUpdater()->updateCount()); |
955 EXPECT_FALSE(m_queue->hasMoreUpdates()); | 956 EXPECT_FALSE(m_queue->hasMoreUpdates()); |
956 layer->fakeLayerUpdater()->clearUpdateCount(); | 957 layer->fakeLayerUpdater()->clearUpdateCount(); |
957 layerPushPropertiesTo(layer.get(), layerImpl.get()); | 958 layerPushPropertiesTo(layer.get(), layerImpl.get()); |
958 } | 959 } |
959 layerTreeHost->commitComplete(); | 960 layerTreeHost->commitComplete(); |
960 | 961 |
961 textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_reso
urceProvider.get()); | 962 textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_reso
urceProvider.get()); |
962 layerTreeHost->setRootLayer(0); | 963 layerTreeHost->setRootLayer(0); |
963 } | 964 } |
964 | 965 |
965 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) | 966 TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion) |
966 { | 967 { |
967 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 968 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
968 | 969 |
969 // The tile size is 100x100, so this invalidates and then paints two tiles. | 970 // The tile size is 100x100, so this invalidates and then paints two tiles. |
970 layer->setBounds(IntSize(100, 200)); | 971 layer->setBounds(gfx::Size(100, 200)); |
971 layer->setDrawableContentRect(IntRect(0, 0, 100, 200)); | 972 layer->setDrawableContentRect(gfx::Rect(0, 0, 100, 200)); |
972 layer->setVisibleContentRect(IntRect(0, 0, 100, 200)); | 973 layer->setVisibleContentRect(gfx::Rect(0, 0, 100, 200)); |
973 layer->invalidateContentRect(IntRect(0, 0, 100, 200)); | 974 layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
974 | 975 |
975 layer->setTexturePriorities(m_priorityCalculator); | 976 layer->setTexturePriorities(m_priorityCalculator); |
976 m_textureManager->prioritizeTextures(); | 977 m_textureManager->prioritizeTextures(); |
977 layer->update(*m_queue.get(), 0, m_stats); | 978 layer->update(*m_queue.get(), 0, m_stats); |
978 EXPECT_EQ(2, layer->fakeLayerUpdater()->updateCount()); | 979 EXPECT_EQ(2, layer->fakeLayerUpdater()->updateCount()); |
979 } | 980 } |
980 | 981 |
981 TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) | 982 TEST_F(TiledLayerTest, tilesPaintedWithOcclusion) |
982 { | 983 { |
983 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 984 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
984 TestOcclusionTracker occluded; | 985 TestOcclusionTracker occluded; |
985 | 986 |
986 // The tile size is 100x100. | 987 // The tile size is 100x100. |
987 | 988 |
988 layer->setBounds(IntSize(600, 600)); | 989 layer->setBounds(gfx::Size(600, 600)); |
989 | 990 |
990 occluded.setOcclusion(IntRect(200, 200, 300, 100)); | 991 occluded.setOcclusion(cc::IntRect(200, 200, 300, 100)); |
991 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); | 992 layer->setDrawableContentRect(gfx::Rect(gfx::Point(), layer->contentBounds()
)); |
992 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); | 993 layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds())
); |
993 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 994 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
994 | 995 |
995 layer->setTexturePriorities(m_priorityCalculator); | 996 layer->setTexturePriorities(m_priorityCalculator); |
996 m_textureManager->prioritizeTextures(); | 997 m_textureManager->prioritizeTextures(); |
997 layer->update(*m_queue.get(), &occluded, m_stats); | 998 layer->update(*m_queue.get(), &occluded, m_stats); |
998 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); | 999 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); |
999 | 1000 |
1000 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1001 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1001 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); | 1002 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); |
1002 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 1003 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
1003 | 1004 |
1004 layer->fakeLayerUpdater()->clearUpdateCount(); | 1005 layer->fakeLayerUpdater()->clearUpdateCount(); |
1005 layer->setTexturePriorities(m_priorityCalculator); | 1006 layer->setTexturePriorities(m_priorityCalculator); |
1006 m_textureManager->prioritizeTextures(); | 1007 m_textureManager->prioritizeTextures(); |
1007 | 1008 |
1008 occluded.setOcclusion(IntRect(250, 200, 300, 100)); | 1009 occluded.setOcclusion(cc::IntRect(250, 200, 300, 100)); |
1009 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1010 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1010 layer->update(*m_queue.get(), &occluded, m_stats); | 1011 layer->update(*m_queue.get(), &occluded, m_stats); |
1011 EXPECT_EQ(36-2, layer->fakeLayerUpdater()->updateCount()); | 1012 EXPECT_EQ(36-2, layer->fakeLayerUpdater()->updateCount()); |
1012 | 1013 |
1013 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1014 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1014 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 +
340000, 1); | 1015 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 +
340000, 1); |
1015 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); | 1016 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); |
1016 | 1017 |
1017 layer->fakeLayerUpdater()->clearUpdateCount(); | 1018 layer->fakeLayerUpdater()->clearUpdateCount(); |
1018 layer->setTexturePriorities(m_priorityCalculator); | 1019 layer->setTexturePriorities(m_priorityCalculator); |
1019 m_textureManager->prioritizeTextures(); | 1020 m_textureManager->prioritizeTextures(); |
1020 | 1021 |
1021 occluded.setOcclusion(IntRect(250, 250, 300, 100)); | 1022 occluded.setOcclusion(cc::IntRect(250, 250, 300, 100)); |
1022 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1023 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1023 layer->update(*m_queue.get(), &occluded, m_stats); | 1024 layer->update(*m_queue.get(), &occluded, m_stats); |
1024 EXPECT_EQ(36, layer->fakeLayerUpdater()->updateCount()); | 1025 EXPECT_EQ(36, layer->fakeLayerUpdater()->updateCount()); |
1025 | 1026 |
1026 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1027 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1027 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 +
340000 + 360000, 1); | 1028 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000 +
340000 + 360000, 1); |
1028 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); | 1029 EXPECT_EQ(3 + 2, occluded.overdrawMetrics().tilesCulledForUpload()); |
1029 } | 1030 } |
1030 | 1031 |
1031 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) | 1032 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints) |
1032 { | 1033 { |
1033 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 1034 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
1034 TestOcclusionTracker occluded; | 1035 TestOcclusionTracker occluded; |
1035 | 1036 |
1036 // The tile size is 100x100. | 1037 // The tile size is 100x100. |
1037 | 1038 |
1038 layer->setBounds(IntSize(600, 600)); | 1039 layer->setBounds(gfx::Size(600, 600)); |
1039 | 1040 |
1040 // The partially occluded tiles (by the 150 occlusion height) are visible be
yond the occlusion, so not culled. | 1041 // The partially occluded tiles (by the 150 occlusion height) are visible be
yond the occlusion, so not culled. |
1041 occluded.setOcclusion(IntRect(200, 200, 300, 150)); | 1042 occluded.setOcclusion(cc::IntRect(200, 200, 300, 150)); |
1042 layer->setDrawableContentRect(IntRect(0, 0, 600, 360)); | 1043 layer->setDrawableContentRect(gfx::Rect(0, 0, 600, 360)); |
1043 layer->setVisibleContentRect(IntRect(0, 0, 600, 360)); | 1044 layer->setVisibleContentRect(gfx::Rect(0, 0, 600, 360)); |
1044 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1045 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1045 | 1046 |
1046 layer->setTexturePriorities(m_priorityCalculator); | 1047 layer->setTexturePriorities(m_priorityCalculator); |
1047 m_textureManager->prioritizeTextures(); | 1048 m_textureManager->prioritizeTextures(); |
1048 layer->update(*m_queue.get(), &occluded, m_stats); | 1049 layer->update(*m_queue.get(), &occluded, m_stats); |
1049 EXPECT_EQ(24-3, layer->fakeLayerUpdater()->updateCount()); | 1050 EXPECT_EQ(24-3, layer->fakeLayerUpdater()->updateCount()); |
1050 | 1051 |
1051 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1052 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1052 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000,
1); | 1053 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000,
1); |
1053 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 1054 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
1054 | 1055 |
1055 layer->fakeLayerUpdater()->clearUpdateCount(); | 1056 layer->fakeLayerUpdater()->clearUpdateCount(); |
1056 | 1057 |
1057 // Now the visible region stops at the edge of the occlusion so the partly v
isible tiles become fully occluded. | 1058 // Now the visible region stops at the edge of the occlusion so the partly v
isible tiles become fully occluded. |
1058 occluded.setOcclusion(IntRect(200, 200, 300, 150)); | 1059 occluded.setOcclusion(cc::IntRect(200, 200, 300, 150)); |
1059 layer->setDrawableContentRect(IntRect(0, 0, 600, 350)); | 1060 layer->setDrawableContentRect(gfx::Rect(0, 0, 600, 350)); |
1060 layer->setVisibleContentRect(IntRect(0, 0, 600, 350)); | 1061 layer->setVisibleContentRect(gfx::Rect(0, 0, 600, 350)); |
1061 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1062 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1062 layer->setTexturePriorities(m_priorityCalculator); | 1063 layer->setTexturePriorities(m_priorityCalculator); |
1063 m_textureManager->prioritizeTextures(); | 1064 m_textureManager->prioritizeTextures(); |
1064 layer->update(*m_queue.get(), &occluded, m_stats); | 1065 layer->update(*m_queue.get(), &occluded, m_stats); |
1065 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); | 1066 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); |
1066 | 1067 |
1067 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1068 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1068 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000, 1); | 1069 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000, 1); |
1069 EXPECT_EQ(3 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); | 1070 EXPECT_EQ(3 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); |
1070 | 1071 |
1071 layer->fakeLayerUpdater()->clearUpdateCount(); | 1072 layer->fakeLayerUpdater()->clearUpdateCount(); |
1072 | 1073 |
1073 // Now the visible region is even smaller than the occlusion, it should have
the same result. | 1074 // Now the visible region is even smaller than the occlusion, it should have
the same result. |
1074 occluded.setOcclusion(IntRect(200, 200, 300, 150)); | 1075 occluded.setOcclusion(cc::IntRect(200, 200, 300, 150)); |
1075 layer->setDrawableContentRect(IntRect(0, 0, 600, 340)); | 1076 layer->setDrawableContentRect(gfx::Rect(0, 0, 600, 340)); |
1076 layer->setVisibleContentRect(IntRect(0, 0, 600, 340)); | 1077 layer->setVisibleContentRect(gfx::Rect(0, 0, 600, 340)); |
1077 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1078 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1078 layer->setTexturePriorities(m_priorityCalculator); | 1079 layer->setTexturePriorities(m_priorityCalculator); |
1079 m_textureManager->prioritizeTextures(); | 1080 m_textureManager->prioritizeTextures(); |
1080 layer->update(*m_queue.get(), &occluded, m_stats); | 1081 layer->update(*m_queue.get(), &occluded, m_stats); |
1081 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); | 1082 EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount()); |
1082 | 1083 |
1083 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1084 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1084 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000 + 180000, 1); | 1085 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 210000 +
180000 + 180000, 1); |
1085 EXPECT_EQ(3 + 6 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); | 1086 EXPECT_EQ(3 + 6 + 6, occluded.overdrawMetrics().tilesCulledForUpload()); |
1086 | 1087 |
1087 } | 1088 } |
1088 | 1089 |
1089 TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) | 1090 TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation) |
1090 { | 1091 { |
1091 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 1092 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
1092 TestOcclusionTracker occluded; | 1093 TestOcclusionTracker occluded; |
1093 | 1094 |
1094 // The tile size is 100x100. | 1095 // The tile size is 100x100. |
1095 | 1096 |
1096 layer->setBounds(IntSize(600, 600)); | 1097 layer->setBounds(gfx::Size(600, 600)); |
1097 | 1098 |
1098 occluded.setOcclusion(IntRect(200, 200, 300, 100)); | 1099 occluded.setOcclusion(cc::IntRect(200, 200, 300, 100)); |
1099 layer->setDrawableContentRect(IntRect(0, 0, 600, 600)); | 1100 layer->setDrawableContentRect(gfx::Rect(0, 0, 600, 600)); |
1100 layer->setVisibleContentRect(IntRect(0, 0, 600, 600)); | 1101 layer->setVisibleContentRect(gfx::Rect(0, 0, 600, 600)); |
1101 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1102 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1102 layer->setTexturePriorities(m_priorityCalculator); | 1103 layer->setTexturePriorities(m_priorityCalculator); |
1103 m_textureManager->prioritizeTextures(); | 1104 m_textureManager->prioritizeTextures(); |
1104 layer->update(*m_queue.get(), &occluded, m_stats); | 1105 layer->update(*m_queue.get(), &occluded, m_stats); |
1105 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); | 1106 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); |
1106 { | 1107 { |
1107 updateTextures(); | 1108 updateTextures(); |
1108 } | 1109 } |
1109 | 1110 |
1110 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1111 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1111 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); | 1112 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); |
(...skipping 14 matching lines...) Expand all Loading... |
1126 | 1127 |
1127 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms) | 1128 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms) |
1128 { | 1129 { |
1129 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 1130 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
1130 TestOcclusionTracker occluded; | 1131 TestOcclusionTracker occluded; |
1131 | 1132 |
1132 // The tile size is 100x100. | 1133 // The tile size is 100x100. |
1133 | 1134 |
1134 // This makes sure the painting works when the occluded region (in screen sp
ace) | 1135 // This makes sure the painting works when the occluded region (in screen sp
ace) |
1135 // is transformed differently than the layer. | 1136 // is transformed differently than the layer. |
1136 layer->setBounds(IntSize(600, 600)); | 1137 layer->setBounds(gfx::Size(600, 600)); |
1137 WebTransformationMatrix screenTransform; | 1138 WebTransformationMatrix screenTransform; |
1138 screenTransform.scale(0.5); | 1139 screenTransform.scale(0.5); |
1139 layer->setScreenSpaceTransform(screenTransform); | 1140 layer->setScreenSpaceTransform(screenTransform); |
1140 layer->setDrawTransform(screenTransform); | 1141 layer->setDrawTransform(screenTransform); |
1141 | 1142 |
1142 occluded.setOcclusion(IntRect(100, 100, 150, 50)); | 1143 occluded.setOcclusion(cc::IntRect(100, 100, 150, 50)); |
1143 layer->setDrawableContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1144 layer->setDrawableContentRect(gfx::Rect(gfx::Point(), layer->contentBounds()
)); |
1144 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1145 layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds())
); |
1145 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1146 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1146 layer->setTexturePriorities(m_priorityCalculator); | 1147 layer->setTexturePriorities(m_priorityCalculator); |
1147 m_textureManager->prioritizeTextures(); | 1148 m_textureManager->prioritizeTextures(); |
1148 layer->update(*m_queue.get(), &occluded, m_stats); | 1149 layer->update(*m_queue.get(), &occluded, m_stats); |
1149 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); | 1150 EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount()); |
1150 | 1151 |
1151 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1152 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1152 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); | 1153 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 330000,
1); |
1153 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); | 1154 EXPECT_EQ(3, occluded.overdrawMetrics().tilesCulledForUpload()); |
1154 } | 1155 } |
1155 | 1156 |
1156 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) | 1157 TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling) |
1157 { | 1158 { |
1158 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 1159 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
1159 TestOcclusionTracker occluded; | 1160 TestOcclusionTracker occluded; |
1160 | 1161 |
1161 // The tile size is 100x100. | 1162 // The tile size is 100x100. |
1162 | 1163 |
1163 // This makes sure the painting works when the content space is scaled to | 1164 // This makes sure the painting works when the content space is scaled to |
1164 // a different layer space. In this case tiles are scaled to be 200x200 | 1165 // a different layer space. In this case tiles are scaled to be 200x200 |
1165 // pixels, which means none should be occluded. | 1166 // pixels, which means none should be occluded. |
1166 layer->setContentsScale(0.5); | 1167 layer->setContentsScale(0.5); |
1167 EXPECT_FLOAT_EQ(layer->contentsScaleX(), layer->contentsScaleY()); | 1168 EXPECT_FLOAT_EQ(layer->contentsScaleX(), layer->contentsScaleY()); |
1168 layer->setBounds(IntSize(600, 600)); | 1169 layer->setBounds(gfx::Size(600, 600)); |
1169 WebTransformationMatrix drawTransform; | 1170 WebTransformationMatrix drawTransform; |
1170 drawTransform.scale(1 / layer->contentsScaleX()); | 1171 drawTransform.scale(1 / layer->contentsScaleX()); |
1171 layer->setDrawTransform(drawTransform); | 1172 layer->setDrawTransform(drawTransform); |
1172 layer->setScreenSpaceTransform(drawTransform); | 1173 layer->setScreenSpaceTransform(drawTransform); |
1173 | 1174 |
1174 occluded.setOcclusion(IntRect(200, 200, 300, 100)); | 1175 occluded.setOcclusion(cc::IntRect(200, 200, 300, 100)); |
1175 layer->setDrawableContentRect(IntRect(IntPoint(), layer->bounds())); | 1176 layer->setDrawableContentRect(gfx::Rect(gfx::Point(), layer->bounds())); |
1176 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1177 layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds())
); |
1177 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1178 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1178 layer->setTexturePriorities(m_priorityCalculator); | 1179 layer->setTexturePriorities(m_priorityCalculator); |
1179 m_textureManager->prioritizeTextures(); | 1180 m_textureManager->prioritizeTextures(); |
1180 layer->update(*m_queue.get(), &occluded, m_stats); | 1181 layer->update(*m_queue.get(), &occluded, m_stats); |
1181 // The content is half the size of the layer (so the number of tiles is fewe
r). | 1182 // The content is half the size of the layer (so the number of tiles is fewe
r). |
1182 // In this case, the content is 300x300, and since the tile size is 100, the | 1183 // In this case, the content is 300x300, and since the tile size is 100, the |
1183 // number of tiles 3x3. | 1184 // number of tiles 3x3. |
1184 EXPECT_EQ(9, layer->fakeLayerUpdater()->updateCount()); | 1185 EXPECT_EQ(9, layer->fakeLayerUpdater()->updateCount()); |
1185 | 1186 |
1186 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1187 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1187 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000, 1
); | 1188 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000, 1
); |
1188 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1189 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
1189 | 1190 |
1190 layer->fakeLayerUpdater()->clearUpdateCount(); | 1191 layer->fakeLayerUpdater()->clearUpdateCount(); |
1191 | 1192 |
1192 // This makes sure the painting works when the content space is scaled to | 1193 // This makes sure the painting works when the content space is scaled to |
1193 // a different layer space. In this case the occluded region catches the | 1194 // a different layer space. In this case the occluded region catches the |
1194 // blown up tiles. | 1195 // blown up tiles. |
1195 occluded.setOcclusion(IntRect(200, 200, 300, 200)); | 1196 occluded.setOcclusion(cc::IntRect(200, 200, 300, 200)); |
1196 layer->setDrawableContentRect(IntRect(IntPoint(), layer->bounds())); | 1197 layer->setDrawableContentRect(gfx::Rect(gfx::Point(), layer->bounds())); |
1197 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1198 layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds())
); |
1198 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | 1199 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1199 layer->setTexturePriorities(m_priorityCalculator); | 1200 layer->setTexturePriorities(m_priorityCalculator); |
1200 m_textureManager->prioritizeTextures(); | 1201 m_textureManager->prioritizeTextures(); |
1201 layer->update(*m_queue.get(), &occluded, m_stats); | 1202 layer->update(*m_queue.get(), &occluded, m_stats); |
1202 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); | 1203 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); |
1203 | 1204 |
1204 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1205 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1205 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000, 1); | 1206 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000, 1); |
1206 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); | 1207 EXPECT_EQ(1, occluded.overdrawMetrics().tilesCulledForUpload()); |
1207 | 1208 |
1208 layer->fakeLayerUpdater()->clearUpdateCount(); | 1209 layer->fakeLayerUpdater()->clearUpdateCount(); |
1209 | 1210 |
1210 // This makes sure content scaling and transforms work together. | 1211 // This makes sure content scaling and transforms work together. |
1211 WebTransformationMatrix screenTransform; | 1212 WebTransformationMatrix screenTransform; |
1212 screenTransform.scale(0.5); | 1213 screenTransform.scale(0.5); |
1213 layer->setScreenSpaceTransform(screenTransform); | 1214 layer->setScreenSpaceTransform(screenTransform); |
1214 layer->setDrawTransform(screenTransform); | 1215 layer->setDrawTransform(screenTransform); |
1215 | 1216 |
1216 occluded.setOcclusion(IntRect(100, 100, 150, 100)); | 1217 occluded.setOcclusion(cc::IntRect(100, 100, 150, 100)); |
1217 | 1218 |
1218 IntRect drawableContentRect(IntPoint(), layer->bounds()); | 1219 gfx::Rect layerBoundsRect(gfx::Point(), layer->bounds()); |
1219 drawableContentRect.scale(0.5); | 1220 layer->setDrawableContentRect(gfx::ToEnclosingRect(gfx::ScaleRect(layerBound
sRect, 0.5))); |
1220 layer->setDrawableContentRect(drawableContentRect); | 1221 layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds())
); |
1221 layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds())); | 1222 layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1222 layer->invalidateContentRect(IntRect(0, 0, 600, 600)); | |
1223 layer->setTexturePriorities(m_priorityCalculator); | 1223 layer->setTexturePriorities(m_priorityCalculator); |
1224 m_textureManager->prioritizeTextures(); | 1224 m_textureManager->prioritizeTextures(); |
1225 layer->update(*m_queue.get(), &occluded, m_stats); | 1225 layer->update(*m_queue.get(), &occluded, m_stats); |
1226 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); | 1226 EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount()); |
1227 | 1227 |
1228 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1228 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1229 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000 + 80000, 1); | 1229 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 90000 +
80000 + 80000, 1); |
1230 EXPECT_EQ(1 + 1, occluded.overdrawMetrics().tilesCulledForUpload()); | 1230 EXPECT_EQ(1 + 1, occluded.overdrawMetrics().tilesCulledForUpload()); |
1231 } | 1231 } |
1232 | 1232 |
1233 TEST_F(TiledLayerTest, visibleContentOpaqueRegion) | 1233 TEST_F(TiledLayerTest, visibleContentOpaqueRegion) |
1234 { | 1234 { |
1235 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 1235 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
1236 TestOcclusionTracker occluded; | 1236 TestOcclusionTracker occluded; |
1237 | 1237 |
1238 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. | 1238 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. |
1239 | 1239 |
1240 IntRect opaquePaintRect; | 1240 gfx::Rect opaquePaintRect; |
1241 Region opaqueContents; | 1241 Region opaqueContents; |
1242 | 1242 |
1243 IntRect contentBounds = IntRect(0, 0, 100, 200); | 1243 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 200); |
1244 IntRect visibleBounds = IntRect(0, 0, 100, 150); | 1244 gfx::Rect visibleBounds = gfx::Rect(0, 0, 100, 150); |
1245 | 1245 |
1246 layer->setBounds(contentBounds.size()); | 1246 layer->setBounds(contentBounds.size()); |
1247 layer->setDrawableContentRect(visibleBounds); | 1247 layer->setDrawableContentRect(visibleBounds); |
1248 layer->setVisibleContentRect(visibleBounds); | 1248 layer->setVisibleContentRect(visibleBounds); |
1249 layer->setDrawOpacity(1); | 1249 layer->setDrawOpacity(1); |
1250 | 1250 |
1251 layer->setTexturePriorities(m_priorityCalculator); | 1251 layer->setTexturePriorities(m_priorityCalculator); |
1252 m_textureManager->prioritizeTextures(); | 1252 m_textureManager->prioritizeTextures(); |
1253 | 1253 |
1254 // If the layer doesn't paint opaque content, then the visibleContentOpaqueR
egion should be empty. | 1254 // If the layer doesn't paint opaque content, then the visibleContentOpaqueR
egion should be empty. |
1255 layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); | 1255 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); |
1256 layer->invalidateContentRect(contentBounds); | 1256 layer->invalidateContentRect(contentBounds); |
1257 layer->update(*m_queue.get(), &occluded, m_stats); | 1257 layer->update(*m_queue.get(), &occluded, m_stats); |
1258 opaqueContents = layer->visibleContentOpaqueRegion(); | 1258 opaqueContents = layer->visibleContentOpaqueRegion(); |
1259 EXPECT_TRUE(opaqueContents.isEmpty()); | 1259 EXPECT_TRUE(opaqueContents.isEmpty()); |
1260 | 1260 |
1261 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000, 1); | 1261 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000, 1); |
1262 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1262 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1263 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1
); | 1263 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000, 1
); |
1264 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1264 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
1265 | 1265 |
1266 // visibleContentOpaqueRegion should match the visible part of what is paint
ed opaque. | 1266 // visibleContentOpaqueRegion should match the visible part of what is paint
ed opaque. |
1267 opaquePaintRect = IntRect(10, 10, 90, 190); | 1267 opaquePaintRect = gfx::Rect(10, 10, 90, 190); |
1268 layer->fakeLayerUpdater()->setOpaquePaintRect(opaquePaintRect); | 1268 layer->fakeLayerUpdater()->setOpaquePaintRect(opaquePaintRect); |
1269 layer->invalidateContentRect(contentBounds); | 1269 layer->invalidateContentRect(contentBounds); |
1270 layer->update(*m_queue.get(), &occluded, m_stats); | 1270 layer->update(*m_queue.get(), &occluded, m_stats); |
1271 updateTextures(); | 1271 updateTextures(); |
1272 opaqueContents = layer->visibleContentOpaqueRegion(); | 1272 opaqueContents = layer->visibleContentOpaqueRegion(); |
1273 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); | 1273 EXPECT_RECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueCo
ntents.bounds()); |
1274 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1274 EXPECT_EQ(1u, opaqueContents.rects().size()); |
1275 | 1275 |
1276 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); | 1276 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); |
1277 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1277 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
1278 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); | 1278 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); |
1279 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1279 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
1280 | 1280 |
1281 // If we paint again without invalidating, the same stuff should be opaque. | 1281 // If we paint again without invalidating, the same stuff should be opaque. |
1282 layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); | 1282 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); |
1283 layer->update(*m_queue.get(), &occluded, m_stats); | 1283 layer->update(*m_queue.get(), &occluded, m_stats); |
1284 updateTextures(); | 1284 updateTextures(); |
1285 opaqueContents = layer->visibleContentOpaqueRegion(); | 1285 opaqueContents = layer->visibleContentOpaqueRegion(); |
1286 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); | 1286 EXPECT_RECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueCo
ntents.bounds()); |
1287 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1287 EXPECT_EQ(1u, opaqueContents.rects().size()); |
1288 | 1288 |
1289 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); | 1289 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1); |
1290 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1290 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
1291 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); | 1291 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100, 1); |
1292 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1292 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
1293 | 1293 |
1294 // If we repaint a non-opaque part of the tile, then it shouldn't lose its o
paque-ness. And other tiles should | 1294 // If we repaint a non-opaque part of the tile, then it shouldn't lose its o
paque-ness. And other tiles should |
1295 // not be affected. | 1295 // not be affected. |
1296 layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); | 1296 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); |
1297 layer->invalidateContentRect(IntRect(0, 0, 1, 1)); | 1297 layer->invalidateContentRect(gfx::Rect(0, 0, 1, 1)); |
1298 layer->update(*m_queue.get(), &occluded, m_stats); | 1298 layer->update(*m_queue.get(), &occluded, m_stats); |
1299 updateTextures(); | 1299 updateTextures(); |
1300 opaqueContents = layer->visibleContentOpaqueRegion(); | 1300 opaqueContents = layer->visibleContentOpaqueRegion(); |
1301 EXPECT_RECT_EQ(intersection(opaquePaintRect, visibleBounds), opaqueContents.
bounds()); | 1301 EXPECT_RECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueCo
ntents.bounds()); |
1302 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1302 EXPECT_EQ(1u, opaqueContents.rects().size()); |
1303 | 1303 |
1304 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1, 1); | 1304 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1, 1); |
1305 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1305 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
1306 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1, 1); | 1306 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1, 1); |
1307 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1307 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
1308 | 1308 |
1309 // If we repaint an opaque part of the tile, then it should lose its opaque-
ness. But other tiles should still | 1309 // If we repaint an opaque part of the tile, then it should lose its opaque-
ness. But other tiles should still |
1310 // not be affected. | 1310 // not be affected. |
1311 layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); | 1311 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); |
1312 layer->invalidateContentRect(IntRect(10, 10, 1, 1)); | 1312 layer->invalidateContentRect(gfx::Rect(10, 10, 1, 1)); |
1313 layer->update(*m_queue.get(), &occluded, m_stats); | 1313 layer->update(*m_queue.get(), &occluded, m_stats); |
1314 updateTextures(); | 1314 updateTextures(); |
1315 opaqueContents = layer->visibleContentOpaqueRegion(); | 1315 opaqueContents = layer->visibleContentOpaqueRegion(); |
1316 EXPECT_RECT_EQ(intersection(IntRect(10, 100, 90, 100), visibleBounds), opaqu
eContents.bounds()); | 1316 EXPECT_RECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), visibleBound
s), opaqueContents.bounds()); |
1317 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1317 EXPECT_EQ(1u, opaqueContents.rects().size()); |
1318 | 1318 |
1319 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1 + 1,
1); | 1319 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1 + 1,
1); |
1320 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); | 1320 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1); |
1321 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1 + 1, 1); | 1321 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 20000 +
20000 - 17100 + 1 + 1, 1); |
1322 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1322 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
1323 } | 1323 } |
1324 | 1324 |
1325 TEST_F(TiledLayerTest, pixelsPaintedMetrics) | 1325 TEST_F(TiledLayerTest, pixelsPaintedMetrics) |
1326 { | 1326 { |
1327 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); | 1327 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(
m_textureManager.get())); |
1328 TestOcclusionTracker occluded; | 1328 TestOcclusionTracker occluded; |
1329 | 1329 |
1330 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. | 1330 // The tile size is 100x100, so this invalidates and then paints two tiles i
n various ways. |
1331 | 1331 |
1332 IntRect opaquePaintRect; | 1332 gfx::Rect opaquePaintRect; |
1333 Region opaqueContents; | 1333 Region opaqueContents; |
1334 | 1334 |
1335 IntRect contentBounds = IntRect(0, 0, 100, 300); | 1335 gfx::Rect contentBounds = gfx::Rect(0, 0, 100, 300); |
1336 IntRect visibleBounds = IntRect(0, 0, 100, 300); | 1336 gfx::Rect visibleBounds = gfx::Rect(0, 0, 100, 300); |
1337 | 1337 |
1338 layer->setBounds(contentBounds.size()); | 1338 layer->setBounds(contentBounds.size()); |
1339 layer->setDrawableContentRect(visibleBounds); | 1339 layer->setDrawableContentRect(visibleBounds); |
1340 layer->setVisibleContentRect(visibleBounds); | 1340 layer->setVisibleContentRect(visibleBounds); |
1341 layer->setDrawOpacity(1); | 1341 layer->setDrawOpacity(1); |
1342 | 1342 |
1343 layer->setTexturePriorities(m_priorityCalculator); | 1343 layer->setTexturePriorities(m_priorityCalculator); |
1344 m_textureManager->prioritizeTextures(); | 1344 m_textureManager->prioritizeTextures(); |
1345 | 1345 |
1346 // Invalidates and paints the whole layer. | 1346 // Invalidates and paints the whole layer. |
1347 layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); | 1347 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); |
1348 layer->invalidateContentRect(contentBounds); | 1348 layer->invalidateContentRect(contentBounds); |
1349 layer->update(*m_queue.get(), &occluded, m_stats); | 1349 layer->update(*m_queue.get(), &occluded, m_stats); |
1350 updateTextures(); | 1350 updateTextures(); |
1351 opaqueContents = layer->visibleContentOpaqueRegion(); | 1351 opaqueContents = layer->visibleContentOpaqueRegion(); |
1352 EXPECT_TRUE(opaqueContents.isEmpty()); | 1352 EXPECT_TRUE(opaqueContents.isEmpty()); |
1353 | 1353 |
1354 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000, 1); | 1354 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000, 1); |
1355 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1355 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1356 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000, 1
); | 1356 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000, 1
); |
1357 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1357 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
1358 | 1358 |
1359 // Invalidates an area on the top and bottom tile, which will cause us to pa
int the tile in the middle, | 1359 // Invalidates an area on the top and bottom tile, which will cause us to pa
int the tile in the middle, |
1360 // even though it is not dirty and will not be uploaded. | 1360 // even though it is not dirty and will not be uploaded. |
1361 layer->fakeLayerUpdater()->setOpaquePaintRect(IntRect()); | 1361 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); |
1362 layer->invalidateContentRect(IntRect(0, 0, 1, 1)); | 1362 layer->invalidateContentRect(gfx::Rect(0, 0, 1, 1)); |
1363 layer->invalidateContentRect(IntRect(50, 200, 10, 10)); | 1363 layer->invalidateContentRect(gfx::Rect(50, 200, 10, 10)); |
1364 layer->update(*m_queue.get(), &occluded, m_stats); | 1364 layer->update(*m_queue.get(), &occluded, m_stats); |
1365 updateTextures(); | 1365 updateTextures(); |
1366 opaqueContents = layer->visibleContentOpaqueRegion(); | 1366 opaqueContents = layer->visibleContentOpaqueRegion(); |
1367 EXPECT_TRUE(opaqueContents.isEmpty()); | 1367 EXPECT_TRUE(opaqueContents.isEmpty()); |
1368 | 1368 |
1369 // The middle tile was painted even though not invalidated. | 1369 // The middle tile was painted even though not invalidated. |
1370 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000 + 60 * 210, 1)
; | 1370 EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 30000 + 60 * 210, 1)
; |
1371 // The pixels uploaded will not include the non-invalidated tile in the midd
le. | 1371 // The pixels uploaded will not include the non-invalidated tile in the midd
le. |
1372 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); | 1372 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 0, 1); |
1373 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000 +
1 + 100, 1); | 1373 EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedTranslucent(), 30000 +
1 + 100, 1); |
1374 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); | 1374 EXPECT_EQ(0, occluded.overdrawMetrics().tilesCulledForUpload()); |
1375 } | 1375 } |
1376 | 1376 |
1377 TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated) | 1377 TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated) |
1378 { | 1378 { |
1379 // Tile size is 100x100. | 1379 // Tile size is 100x100. |
1380 IntRect rootRect(0, 0, 300, 200); | 1380 gfx::Rect rootRect(0, 0, 300, 200); |
1381 IntRect childRect(0, 0, 300, 100); | 1381 gfx::Rect childRect(0, 0, 300, 100); |
1382 IntRect child2Rect(0, 100, 300, 100); | 1382 gfx::Rect child2Rect(0, 100, 300, 100); |
1383 | 1383 |
1384 LayerTreeSettings settings; | 1384 LayerTreeSettings settings; |
1385 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; | 1385 FakeLayerImplTreeHostClient fakeLayerImplTreeHostClient; |
1386 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm
plTreeHostClient, settings); | 1386 scoped_ptr<LayerTreeHost> layerTreeHost = LayerTreeHost::create(&fakeLayerIm
plTreeHostClient, settings); |
1387 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded()); | 1387 ASSERT_TRUE(layerTreeHost->initializeRendererIfNeeded()); |
1388 | 1388 |
1389 scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(l
ayerTreeHost->contentsTextureManager())); | 1389 scoped_refptr<FakeTiledLayer> root = make_scoped_refptr(new FakeTiledLayer(l
ayerTreeHost->contentsTextureManager())); |
1390 scoped_refptr<Layer> surface = Layer::create(); | 1390 scoped_refptr<Layer> surface = Layer::create(); |
1391 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer(
layerTreeHost->contentsTextureManager())); | 1391 scoped_refptr<FakeTiledLayer> child = make_scoped_refptr(new FakeTiledLayer(
layerTreeHost->contentsTextureManager())); |
1392 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer
(layerTreeHost->contentsTextureManager())); | 1392 scoped_refptr<FakeTiledLayer> child2 = make_scoped_refptr(new FakeTiledLayer
(layerTreeHost->contentsTextureManager())); |
1393 | 1393 |
1394 root->setBounds(rootRect.size()); | 1394 root->setBounds(rootRect.size()); |
1395 root->setAnchorPoint(FloatPoint()); | 1395 root->setAnchorPoint(gfx::PointF()); |
1396 root->setDrawableContentRect(rootRect); | 1396 root->setDrawableContentRect(rootRect); |
1397 root->setVisibleContentRect(rootRect); | 1397 root->setVisibleContentRect(rootRect); |
1398 root->addChild(surface); | 1398 root->addChild(surface); |
1399 | 1399 |
1400 surface->setForceRenderSurface(true); | 1400 surface->setForceRenderSurface(true); |
1401 surface->setAnchorPoint(FloatPoint()); | 1401 surface->setAnchorPoint(gfx::PointF()); |
1402 surface->setOpacity(0.5); | 1402 surface->setOpacity(0.5); |
1403 surface->addChild(child); | 1403 surface->addChild(child); |
1404 surface->addChild(child2); | 1404 surface->addChild(child2); |
1405 | 1405 |
1406 child->setBounds(childRect.size()); | 1406 child->setBounds(childRect.size()); |
1407 child->setAnchorPoint(FloatPoint()); | 1407 child->setAnchorPoint(gfx::PointF()); |
1408 child->setPosition(childRect.location()); | 1408 child->setPosition(childRect.origin()); |
1409 child->setVisibleContentRect(childRect); | 1409 child->setVisibleContentRect(childRect); |
1410 child->setDrawableContentRect(rootRect); | 1410 child->setDrawableContentRect(rootRect); |
1411 | 1411 |
1412 child2->setBounds(child2Rect.size()); | 1412 child2->setBounds(child2Rect.size()); |
1413 child2->setAnchorPoint(FloatPoint()); | 1413 child2->setAnchorPoint(gfx::PointF()); |
1414 child2->setPosition(child2Rect.location()); | 1414 child2->setPosition(child2Rect.origin()); |
1415 child2->setVisibleContentRect(child2Rect); | 1415 child2->setVisibleContentRect(child2Rect); |
1416 child2->setDrawableContentRect(rootRect); | 1416 child2->setDrawableContentRect(rootRect); |
1417 | 1417 |
1418 layerTreeHost->setRootLayer(root); | 1418 layerTreeHost->setRootLayer(root); |
1419 layerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); | 1419 layerTreeHost->setViewportSize(rootRect.size(), rootRect.size()); |
1420 | 1420 |
1421 // With a huge memory limit, all layers should update and push their texture
s. | 1421 // With a huge memory limit, all layers should update and push their texture
s. |
1422 root->invalidateContentRect(rootRect); | 1422 root->invalidateContentRect(rootRect); |
1423 child->invalidateContentRect(childRect); | 1423 child->invalidateContentRect(childRect); |
1424 child2->invalidateContentRect(child2Rect); | 1424 child2->invalidateContentRect(child2Rect); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 | 1563 |
1564 private: | 1564 private: |
1565 TrackingLayerPainter* m_trackingLayerPainter; | 1565 TrackingLayerPainter* m_trackingLayerPainter; |
1566 scoped_refptr<BitmapContentLayerUpdater> m_layerUpdater; | 1566 scoped_refptr<BitmapContentLayerUpdater> m_layerUpdater; |
1567 }; | 1567 }; |
1568 | 1568 |
1569 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) | 1569 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint) |
1570 { | 1570 { |
1571 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat
eTrackingTiledLayer(m_textureManager.get())); | 1571 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat
eTrackingTiledLayer(m_textureManager.get())); |
1572 | 1572 |
1573 IntRect layerRect(0, 0, 30, 31); | 1573 gfx::Rect layerRect(0, 0, 30, 31); |
1574 layer->setPosition(layerRect.location()); | 1574 layer->setPosition(layerRect.origin()); |
1575 layer->setBounds(layerRect.size()); | 1575 layer->setBounds(layerRect.size()); |
1576 layer->setContentsScale(1.5); | 1576 layer->setContentsScale(1.5); |
1577 | 1577 |
1578 IntRect contentRect(0, 0, 45, 47); | 1578 gfx::Rect contentRect(0, 0, 45, 47); |
1579 EXPECT_EQ(contentRect.size(), layer->contentBounds()); | 1579 EXPECT_EQ(contentRect.size(), layer->contentBounds()); |
1580 layer->setVisibleContentRect(contentRect); | 1580 layer->setVisibleContentRect(contentRect); |
1581 layer->setDrawableContentRect(contentRect); | 1581 layer->setDrawableContentRect(contentRect); |
1582 | 1582 |
1583 layer->setTexturePriorities(m_priorityCalculator); | 1583 layer->setTexturePriorities(m_priorityCalculator); |
1584 m_textureManager->prioritizeTextures(); | 1584 m_textureManager->prioritizeTextures(); |
1585 | 1585 |
1586 // Update the whole tile. | 1586 // Update the whole tile. |
1587 layer->update(*m_queue.get(), 0, m_stats); | 1587 layer->update(*m_queue.get(), 0, m_stats); |
1588 layer->trackingLayerPainter()->resetPaintedRect(); | 1588 layer->trackingLayerPainter()->resetPaintedRect(); |
1589 | 1589 |
1590 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); | 1590 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); |
1591 updateTextures(); | 1591 updateTextures(); |
1592 | 1592 |
1593 // Invalidate the entire layer in content space. When painting, the rect giv
en to webkit should match the layer's bounds. | 1593 // Invalidate the entire layer in content space. When painting, the rect giv
en to webkit should match the layer's bounds. |
1594 layer->invalidateContentRect(contentRect); | 1594 layer->invalidateContentRect(contentRect); |
1595 layer->update(*m_queue.get(), 0, m_stats); | 1595 layer->update(*m_queue.get(), 0, m_stats); |
1596 | 1596 |
1597 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1597 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
1598 } | 1598 } |
1599 | 1599 |
1600 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation) | 1600 TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation) |
1601 { | 1601 { |
1602 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat
eTrackingTiledLayer(m_textureManager.get())); | 1602 scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new Updat
eTrackingTiledLayer(m_textureManager.get())); |
1603 | 1603 |
1604 IntRect layerRect(0, 0, 30, 31); | 1604 gfx::Rect layerRect(0, 0, 30, 31); |
1605 layer->setPosition(layerRect.location()); | 1605 layer->setPosition(layerRect.origin()); |
1606 layer->setBounds(layerRect.size()); | 1606 layer->setBounds(layerRect.size()); |
1607 layer->setContentsScale(1.3f); | 1607 layer->setContentsScale(1.3f); |
1608 | 1608 |
1609 IntRect contentRect(IntPoint(), layer->contentBounds()); | 1609 gfx::Rect contentRect(gfx::Point(), layer->contentBounds()); |
1610 layer->setVisibleContentRect(contentRect); | 1610 layer->setVisibleContentRect(contentRect); |
1611 layer->setDrawableContentRect(contentRect); | 1611 layer->setDrawableContentRect(contentRect); |
1612 | 1612 |
1613 layer->setTexturePriorities(m_priorityCalculator); | 1613 layer->setTexturePriorities(m_priorityCalculator); |
1614 m_textureManager->prioritizeTextures(); | 1614 m_textureManager->prioritizeTextures(); |
1615 | 1615 |
1616 // Update the whole tile. | 1616 // Update the whole tile. |
1617 layer->update(*m_queue.get(), 0, m_stats); | 1617 layer->update(*m_queue.get(), 0, m_stats); |
1618 layer->trackingLayerPainter()->resetPaintedRect(); | 1618 layer->trackingLayerPainter()->resetPaintedRect(); |
1619 | 1619 |
1620 EXPECT_RECT_EQ(IntRect(), layer->trackingLayerPainter()->paintedRect()); | 1620 EXPECT_RECT_EQ(gfx::Rect(), layer->trackingLayerPainter()->paintedRect()); |
1621 updateTextures(); | 1621 updateTextures(); |
1622 | 1622 |
1623 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. | 1623 // Invalidate the entire layer in layer space. When painting, the rect given
to webkit should match the layer's bounds. |
1624 layer->setNeedsDisplayRect(layerRect); | 1624 layer->setNeedsDisplayRect(layerRect); |
1625 layer->update(*m_queue.get(), 0, m_stats); | 1625 layer->update(*m_queue.get(), 0, m_stats); |
1626 | 1626 |
1627 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); | 1627 EXPECT_RECT_EQ(layerRect, layer->trackingLayerPainter()->paintedRect()); |
1628 } | 1628 } |
1629 | 1629 |
1630 } // namespace | 1630 } // namespace |
OLD | NEW |