Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Unified Diff: cc/layers/picture_layer_unittest.cc

Issue 222903005: cc: Let skia veto gpu rasterization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added comment about SetNeedsCommit Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/picture_layer_impl_unittest.cc ('k') | cc/resources/picture.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/picture_layer_unittest.cc
diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc
index 3ff1de5cd8114eb7a009adb5c4a4f25530bdeb18..5df344918884780bf08faceaf688062d4543712a 100644
--- a/cc/layers/picture_layer_unittest.cc
+++ b/cc/layers/picture_layer_unittest.cc
@@ -10,6 +10,8 @@
#include "cc/test/fake_layer_tree_host.h"
#include "cc/test/fake_picture_layer_impl.h"
#include "cc/test/fake_proxy.h"
+#include "cc/test/gpu_rasterization_settings.h"
+#include "cc/test/hybrid_rasterization_settings.h"
#include "cc/test/impl_side_painting_settings.h"
#include "cc/trees/occlusion_tracker.h"
#include "cc/trees/single_thread_proxy.h"
@@ -67,5 +69,86 @@ TEST(PictureLayerTest, NoTilesIfEmptyBounds) {
}
}
+TEST(PictureLayerTest, ForcedCpuRaster) {
+ MockContentLayerClient client;
+ scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
+
+ scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
+ host->SetRootLayer(layer);
+
+ // The default value is false.
+ EXPECT_FALSE(layer->ShouldUseGpuRasterization());
+
+ // Gpu rasterization cannot be enabled even with raster hint.
+ layer->SetHasGpuRasterizationHint(true);
+ EXPECT_FALSE(layer->ShouldUseGpuRasterization());
+}
+
+TEST(PictureLayerTest, ForcedGpuRaster) {
+ MockContentLayerClient client;
+ scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
+
+ scoped_ptr<FakeLayerTreeHost> host =
+ FakeLayerTreeHost::Create(GpuRasterizationSettings());
+ host->SetRootLayer(layer);
+
+ // The default value is true.
+ EXPECT_TRUE(layer->ShouldUseGpuRasterization());
+
+ // Gpu rasterization cannot be disabled even with raster hint.
+ layer->SetHasGpuRasterizationHint(false);
+ EXPECT_TRUE(layer->ShouldUseGpuRasterization());
+
+ // Gpu rasterization cannot be disabled even with skia veto.
+ PicturePile* pile = layer->GetPicturePileForTesting();
+ EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization());
+ pile->SetUnsuitableForGpuRasterizationForTesting();
+ EXPECT_TRUE(layer->ShouldUseGpuRasterization());
+}
+
+TEST(PictureLayerTest, HybridRaster) {
+ MockContentLayerClient client;
+ scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
+
+ scoped_ptr<FakeLayerTreeHost> host =
+ FakeLayerTreeHost::Create(HybridRasterizationSettings());
+ host->SetRootLayer(layer);
+
+ // The default value is false.
+ EXPECT_FALSE(layer->ShouldUseGpuRasterization());
+
+ // Gpu rasterization can be enabled first time.
+ layer->SetHasGpuRasterizationHint(true);
+ EXPECT_TRUE(layer->ShouldUseGpuRasterization());
+
+ // Gpu rasterization can always be disabled.
+ layer->SetHasGpuRasterizationHint(false);
+ EXPECT_FALSE(layer->ShouldUseGpuRasterization());
+
+ // Gpu rasterization cannot be enabled once disabled.
+ layer->SetHasGpuRasterizationHint(true);
+ EXPECT_FALSE(layer->ShouldUseGpuRasterization());
+}
+
+TEST(PictureLayerTest, VetoGpuRaster) {
+ MockContentLayerClient client;
+ scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
+
+ scoped_ptr<FakeLayerTreeHost> host =
+ FakeLayerTreeHost::Create(HybridRasterizationSettings());
+ host->SetRootLayer(layer);
+
+ EXPECT_FALSE(layer->ShouldUseGpuRasterization());
+
+ layer->SetHasGpuRasterizationHint(true);
+ EXPECT_TRUE(layer->ShouldUseGpuRasterization());
+
+ // Veto gpu rasterization.
+ PicturePile* pile = layer->GetPicturePileForTesting();
+ EXPECT_TRUE(pile->is_suitable_for_gpu_rasterization());
+ pile->SetUnsuitableForGpuRasterizationForTesting();
+ EXPECT_FALSE(layer->ShouldUseGpuRasterization());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/layers/picture_layer_impl_unittest.cc ('k') | cc/resources/picture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698