| 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" |
| (...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = gfx::Rect(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(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueCo
ntents.bounds()); | 1273 EXPECT_RECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueCo
ntents.bounds()); |
| 1274 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1274 EXPECT_EQ(1u, Region::Iterator(opaqueContents).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(gfx::Rect()); | 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(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueCo
ntents.bounds()); | 1286 EXPECT_RECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueCo
ntents.bounds()); |
| 1287 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1287 EXPECT_EQ(1u, Region::Iterator(opaqueContents).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(gfx::Rect()); | 1296 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); |
| 1297 layer->invalidateContentRect(gfx::Rect(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(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueCo
ntents.bounds()); | 1301 EXPECT_RECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueCo
ntents.bounds()); |
| 1302 EXPECT_EQ(1u, opaqueContents.rects().size()); | 1302 EXPECT_EQ(1u, Region::Iterator(opaqueContents).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(gfx::Rect()); | 1311 layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect()); |
| 1312 layer->invalidateContentRect(gfx::Rect(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(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), visibleBound
s), opaqueContents.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, Region::Iterator(opaqueContents).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())); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |