| 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 "cc/layers/picture_layer.h" | 5 #include "cc/layers/picture_layer.h" |
| 6 | 6 |
| 7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
| 8 #include "cc/layers/picture_layer_impl.h" | 8 #include "cc/layers/picture_layer_impl.h" |
| 9 #include "cc/resources/resource_update_queue.h" | 9 #include "cc/resources/resource_update_queue.h" |
| 10 #include "cc/test/fake_layer_tree_host.h" | 10 #include "cc/test/fake_layer_tree_host.h" |
| 11 #include "cc/test/fake_picture_layer_impl.h" | 11 #include "cc/test/fake_picture_layer_impl.h" |
| 12 #include "cc/test/fake_proxy.h" | 12 #include "cc/test/fake_proxy.h" |
| 13 #include "cc/test/impl_side_painting_settings.h" | 13 #include "cc/test/impl_side_painting_settings.h" |
| 14 #include "cc/trees/occlusion_tracker.h" | 14 #include "cc/trees/occlusion_tracker.h" |
| 15 #include "cc/trees/single_thread_proxy.h" | 15 #include "cc/trees/single_thread_proxy.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class MockContentLayerClient : public ContentLayerClient { | 21 class MockContentLayerClient : public ContentLayerClient { |
| 22 public: | 22 public: |
| 23 void PaintContents( | 23 void PaintContents( |
| 24 SkCanvas* canvas, | 24 SkCanvas* canvas, |
| 25 const gfx::Rect& clip, | 25 const gfx::Rect& clip, |
| 26 ContentLayerClient::GraphicsContextStatus gc_status) override {} | 26 ContentLayerClient::GraphicsContextStatus gc_status) override {} |
| 27 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 28 const gfx::Rect& clip, |
| 29 GraphicsContextStatus gc_status) override { |
| 30 NOTIMPLEMENTED(); |
| 31 return DisplayItemList::Create(); |
| 32 } |
| 27 bool FillsBoundsCompletely() const override { return false; }; | 33 bool FillsBoundsCompletely() const override { return false; }; |
| 28 }; | 34 }; |
| 29 | 35 |
| 30 TEST(PictureLayerTest, NoTilesIfEmptyBounds) { | 36 TEST(PictureLayerTest, NoTilesIfEmptyBounds) { |
| 31 MockContentLayerClient client; | 37 MockContentLayerClient client; |
| 32 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 38 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 33 layer->SetBounds(gfx::Size(10, 10)); | 39 layer->SetBounds(gfx::Size(10, 10)); |
| 34 | 40 |
| 35 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 41 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 36 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); | 42 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 66 EXPECT_FALSE(layer_impl->CanHaveTilings()); | 72 EXPECT_FALSE(layer_impl->CanHaveTilings()); |
| 67 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); | 73 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); |
| 68 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize()); | 74 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize()); |
| 69 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); | 75 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); |
| 70 } | 76 } |
| 71 } | 77 } |
| 72 | 78 |
| 73 TEST(PictureLayerTest, SuitableForGpuRasterization) { | 79 TEST(PictureLayerTest, SuitableForGpuRasterization) { |
| 74 MockContentLayerClient client; | 80 MockContentLayerClient client; |
| 75 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 81 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 82 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 83 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
| 84 host->SetRootLayer(layer); |
| 76 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 85 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
| 77 | 86 |
| 78 // Layer is suitable for gpu rasterization by default. | 87 // Layer is suitable for gpu rasterization by default. |
| 79 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); | 88 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); |
| 80 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); | 89 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); |
| 81 | 90 |
| 82 // Veto gpu rasterization. | 91 // Veto gpu rasterization. |
| 83 recording_source->SetUnsuitableForGpuRasterizationForTesting(); | 92 recording_source->SetUnsuitableForGpuRasterizationForTesting(); |
| 84 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); | 93 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); |
| 85 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); | 94 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 98 | 107 |
| 99 // Tile-grid is set according to its setting. | 108 // Tile-grid is set according to its setting. |
| 100 SkTileGridFactory::TileGridInfo info = | 109 SkTileGridFactory::TileGridInfo info = |
| 101 layer->GetRecordingSourceForTesting()->GetTileGridInfoForTesting(); | 110 layer->GetRecordingSourceForTesting()->GetTileGridInfoForTesting(); |
| 102 EXPECT_EQ(info.fTileInterval.width(), 123 - 2 * info.fMargin.width()); | 111 EXPECT_EQ(info.fTileInterval.width(), 123 - 2 * info.fMargin.width()); |
| 103 EXPECT_EQ(info.fTileInterval.height(), 123 - 2 * info.fMargin.height()); | 112 EXPECT_EQ(info.fTileInterval.height(), 123 - 2 * info.fMargin.height()); |
| 104 } | 113 } |
| 105 | 114 |
| 106 } // namespace | 115 } // namespace |
| 107 } // namespace cc | 116 } // namespace cc |
| OLD | NEW |