| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "cc/test/layer_tree_settings_for_testing.h" | 27 #include "cc/test/layer_tree_settings_for_testing.h" |
| 28 #include "cc/test/test_layer_tree_host_base.h" | 28 #include "cc/test/test_layer_tree_host_base.h" |
| 29 #include "cc/test/test_task_graph_runner.h" | 29 #include "cc/test/test_task_graph_runner.h" |
| 30 #include "cc/test/test_tile_priorities.h" | 30 #include "cc/test/test_tile_priorities.h" |
| 31 #include "cc/tiles/eviction_tile_priority_queue.h" | 31 #include "cc/tiles/eviction_tile_priority_queue.h" |
| 32 #include "cc/tiles/raster_tile_priority_queue.h" | 32 #include "cc/tiles/raster_tile_priority_queue.h" |
| 33 #include "cc/tiles/tile.h" | 33 #include "cc/tiles/tile.h" |
| 34 #include "cc/tiles/tile_priority.h" | 34 #include "cc/tiles/tile_priority.h" |
| 35 #include "cc/tiles/tiling_set_raster_queue_all.h" | 35 #include "cc/tiles/tiling_set_raster_queue_all.h" |
| 36 #include "cc/trees/layer_tree_impl.h" | 36 #include "cc/trees/layer_tree_impl.h" |
| 37 #include "skia/ext/cdl_paint.h" |
| 37 #include "testing/gmock/include/gmock/gmock.h" | 38 #include "testing/gmock/include/gmock/gmock.h" |
| 38 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
| 39 #include "third_party/skia/include/core/SkRefCnt.h" | 40 #include "third_party/skia/include/core/SkRefCnt.h" |
| 40 #include "third_party/skia/include/core/SkSurface.h" | 41 #include "third_party/skia/include/core/SkSurface.h" |
| 41 | 42 |
| 42 namespace cc { | 43 namespace cc { |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 class TileManagerTilePriorityQueueTest : public TestLayerTreeHostBase { | 46 class TileManagerTilePriorityQueueTest : public TestLayerTreeHostBase { |
| 46 public: | 47 public: |
| (...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 } | 1410 } |
| 1410 } | 1411 } |
| 1411 | 1412 |
| 1412 TEST_F(TileManagerTilePriorityQueueTest, NoRasterTasksforSolidColorTiles) { | 1413 TEST_F(TileManagerTilePriorityQueueTest, NoRasterTasksforSolidColorTiles) { |
| 1413 gfx::Size size(10, 10); | 1414 gfx::Size size(10, 10); |
| 1414 const gfx::Size layer_bounds(1000, 1000); | 1415 const gfx::Size layer_bounds(1000, 1000); |
| 1415 | 1416 |
| 1416 std::unique_ptr<FakeRecordingSource> recording_source = | 1417 std::unique_ptr<FakeRecordingSource> recording_source = |
| 1417 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); | 1418 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); |
| 1418 | 1419 |
| 1419 SkPaint solid_paint; | 1420 CdlPaint solid_paint; |
| 1420 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); | 1421 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); |
| 1421 solid_paint.setColor(solid_color); | 1422 solid_paint.setColor(solid_color); |
| 1422 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), | 1423 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds), |
| 1423 solid_paint); | 1424 solid_paint); |
| 1424 | 1425 |
| 1425 // Create non solid tile as well, otherwise tilings wouldnt be created. | 1426 // Create non solid tile as well, otherwise tilings wouldnt be created. |
| 1426 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); | 1427 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); |
| 1427 SkPaint non_solid_paint; | 1428 CdlPaint non_solid_paint; |
| 1428 non_solid_paint.setColor(non_solid_color); | 1429 non_solid_paint.setColor(non_solid_color); |
| 1429 | 1430 |
| 1430 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 10, 10), | 1431 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 10, 10), |
| 1431 non_solid_paint); | 1432 non_solid_paint); |
| 1432 recording_source->Rerecord(); | 1433 recording_source->Rerecord(); |
| 1433 | 1434 |
| 1434 scoped_refptr<RasterSource> raster_source = | 1435 scoped_refptr<RasterSource> raster_source = |
| 1435 RasterSource::CreateFromRecordingSource(recording_source.get(), false); | 1436 RasterSource::CreateFromRecordingSource(recording_source.get(), false); |
| 1436 | 1437 |
| 1437 FakePictureLayerTilingClient tiling_client; | 1438 FakePictureLayerTilingClient tiling_client; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1579 SkSurface::MakeRasterN32Premul(size.width(), size.height()); | 1580 SkSurface::MakeRasterN32Premul(size.width(), size.height()); |
| 1580 ASSERT_NE(surface, nullptr); | 1581 ASSERT_NE(surface, nullptr); |
| 1581 surface->getCanvas()->clear(SK_ColorBLUE); | 1582 surface->getCanvas()->clear(SK_ColorBLUE); |
| 1582 sk_sp<SkImage> blue_image = surface->makeImageSnapshot(); | 1583 sk_sp<SkImage> blue_image = surface->makeImageSnapshot(); |
| 1583 | 1584 |
| 1584 std::unique_ptr<FakeRecordingSource> recording_source = | 1585 std::unique_ptr<FakeRecordingSource> recording_source = |
| 1585 FakeRecordingSource::CreateFilledRecordingSource(size); | 1586 FakeRecordingSource::CreateFilledRecordingSource(size); |
| 1586 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT); | 1587 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT); |
| 1587 recording_source->SetRequiresClear(true); | 1588 recording_source->SetRequiresClear(true); |
| 1588 recording_source->SetClearCanvasWithDebugColor(false); | 1589 recording_source->SetClearCanvasWithDebugColor(false); |
| 1589 SkPaint paint; | 1590 CdlPaint paint; |
| 1590 paint.setColor(SK_ColorGREEN); | 1591 paint.setColor(SK_ColorGREEN); |
| 1591 recording_source->add_draw_rect_with_paint(gfx::Rect(size), paint); | 1592 recording_source->add_draw_rect_with_paint(gfx::Rect(size), paint); |
| 1592 recording_source->add_draw_image(std::move(blue_image), gfx::Point()); | 1593 recording_source->add_draw_image(std::move(blue_image), gfx::Point()); |
| 1593 recording_source->Rerecord(); | 1594 recording_source->Rerecord(); |
| 1594 scoped_refptr<RasterSource> raster = | 1595 scoped_refptr<RasterSource> raster = |
| 1595 RasterSource::CreateFromRecordingSource(recording_source.get(), false); | 1596 RasterSource::CreateFromRecordingSource(recording_source.get(), false); |
| 1596 | 1597 |
| 1597 FakePictureLayerTilingClient tiling_client; | 1598 FakePictureLayerTilingClient tiling_client; |
| 1598 tiling_client.SetTileSize(size); | 1599 tiling_client.SetTileSize(size); |
| 1599 | 1600 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 TEST_F(ActivationTasksDoNotBlockReadyToDrawTest, | 1672 TEST_F(ActivationTasksDoNotBlockReadyToDrawTest, |
| 1672 ActivationTasksDoNotBlockReadyToDraw) { | 1673 ActivationTasksDoNotBlockReadyToDraw) { |
| 1673 const gfx::Size layer_bounds(1000, 1000); | 1674 const gfx::Size layer_bounds(1000, 1000); |
| 1674 | 1675 |
| 1675 EXPECT_TRUE(host_impl()->use_gpu_rasterization()); | 1676 EXPECT_TRUE(host_impl()->use_gpu_rasterization()); |
| 1676 | 1677 |
| 1677 // Active tree has no non-solid tiles, so it will generate no tile tasks. | 1678 // Active tree has no non-solid tiles, so it will generate no tile tasks. |
| 1678 std::unique_ptr<FakeRecordingSource> active_tree_recording_source = | 1679 std::unique_ptr<FakeRecordingSource> active_tree_recording_source = |
| 1679 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); | 1680 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); |
| 1680 | 1681 |
| 1681 SkPaint solid_paint; | 1682 CdlPaint solid_paint; |
| 1682 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); | 1683 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); |
| 1683 solid_paint.setColor(solid_color); | 1684 solid_paint.setColor(solid_color); |
| 1684 active_tree_recording_source->add_draw_rect_with_paint( | 1685 active_tree_recording_source->add_draw_rect_with_paint( |
| 1685 gfx::Rect(layer_bounds), solid_paint); | 1686 gfx::Rect(layer_bounds), solid_paint); |
| 1686 | 1687 |
| 1687 active_tree_recording_source->Rerecord(); | 1688 active_tree_recording_source->Rerecord(); |
| 1688 | 1689 |
| 1689 // Pending tree has non-solid tiles, so it will generate tile tasks. | 1690 // Pending tree has non-solid tiles, so it will generate tile tasks. |
| 1690 std::unique_ptr<FakeRecordingSource> pending_tree_recording_source = | 1691 std::unique_ptr<FakeRecordingSource> pending_tree_recording_source = |
| 1691 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); | 1692 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); |
| 1692 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); | 1693 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); |
| 1693 SkPaint non_solid_paint; | 1694 CdlPaint non_solid_paint; |
| 1694 non_solid_paint.setColor(non_solid_color); | 1695 non_solid_paint.setColor(non_solid_color); |
| 1695 | 1696 |
| 1696 pending_tree_recording_source->add_draw_rect_with_paint( | 1697 pending_tree_recording_source->add_draw_rect_with_paint( |
| 1697 gfx::Rect(5, 5, 10, 10), non_solid_paint); | 1698 gfx::Rect(5, 5, 10, 10), non_solid_paint); |
| 1698 pending_tree_recording_source->Rerecord(); | 1699 pending_tree_recording_source->Rerecord(); |
| 1699 | 1700 |
| 1700 scoped_refptr<RasterSource> active_tree_raster_source = | 1701 scoped_refptr<RasterSource> active_tree_raster_source = |
| 1701 RasterSource::CreateFromRecordingSource( | 1702 RasterSource::CreateFromRecordingSource( |
| 1702 active_tree_recording_source.get(), false); | 1703 active_tree_recording_source.get(), false); |
| 1703 scoped_refptr<RasterSource> pending_tree_raster_source = | 1704 scoped_refptr<RasterSource> pending_tree_raster_source = |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1879 } | 1880 } |
| 1880 | 1881 |
| 1881 // Ensures that the tile manager does not attempt to reuse tiles when partial | 1882 // Ensures that the tile manager does not attempt to reuse tiles when partial |
| 1882 // raster is disabled. | 1883 // raster is disabled. |
| 1883 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { | 1884 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { |
| 1884 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); | 1885 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); |
| 1885 } | 1886 } |
| 1886 | 1887 |
| 1887 } // namespace | 1888 } // namespace |
| 1888 } // namespace cc | 1889 } // namespace cc |
| OLD | NEW |