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

Unified Diff: cc/layers/picture_layer.cc

Issue 222903005: cc: Let skia veto gpu rasterization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added comments Created 6 years, 9 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
Index: cc/layers/picture_layer.cc
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc
index dee9a78bc950e185644ed90e3b3bdb17fd6538c5..5827af27eb531a722bdafe51755c40674dbf16e2 100644
--- a/cc/layers/picture_layer.cc
+++ b/cc/layers/picture_layer.cc
@@ -20,7 +20,7 @@ PictureLayer::PictureLayer(ContentLayerClient* client)
pile_(make_scoped_refptr(new PicturePile())),
instrumentation_object_tracker_(id()),
is_mask_(false),
- has_gpu_rasterization_hint_(false),
+ has_gpu_rasterization_hint_(TRIBOOL_UNKNOWN),
update_source_frame_number_(-1) {}
PictureLayer::~PictureLayer() {
@@ -50,7 +50,7 @@ void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
}
layer_impl->SetIsMask(is_mask_);
- layer_impl->SetHasGpuRasterizationHint(has_gpu_rasterization_hint_);
+ layer_impl->SetUseGpuRasterization(ShouldUseGpuRasterization());
// Unlike other properties, invalidation must always be set on layer_impl.
// See PictureLayerImpl::PushPropertiesTo for more details.
@@ -138,11 +138,34 @@ void PictureLayer::SetIsMask(bool is_mask) {
}
void PictureLayer::SetHasGpuRasterizationHint(bool has_hint) {
- DCHECK(IsPropertyChangeAllowed());
- if (has_gpu_rasterization_hint_ == has_hint)
- return;
- has_gpu_rasterization_hint_ = has_hint;
- SetNeedsCommit();
+ switch (has_gpu_rasterization_hint_) {
+ case TRIBOOL_UNKNOWN: // Fall-through.
+ case TRIBOOL_TRUE:
+ has_gpu_rasterization_hint_ = has_hint ? TRIBOOL_TRUE : TRIBOOL_FALSE;
+ break;
+ case TRIBOOL_FALSE:
+ // GPU rasterization cannot be enabled once disabled.
+ // This is done to prevent frequent invalidations and visual flashing.
+ break;
+ default:
+ NOTREACHED();
+ }
+ // No need to commit immediately.
+ // This flag will be pushed with the next commit.
enne (OOO) 2014/04/04 18:34:19 I'm confused why the SetNeedsCommit went away.
alokp 2014/04/04 18:50:34 If only the hint changes and the layer is still va
enne (OOO) 2014/04/04 19:40:07 Yeah, this just seems a little dodgy to me, becaus
+}
+
+bool PictureLayer::ShouldUseGpuRasterization() const {
+ switch (layer_tree_host()->settings().rasterization_site) {
+ case LayerTreeSettings::CpuRasterization:
+ return false;
+ case LayerTreeSettings::HybridRasterization:
+ return has_gpu_rasterization_hint_ == TRIBOOL_TRUE &&
+ pile_->is_suitable_for_gpu_rasterization();
+ case LayerTreeSettings::GpuRasterization:
+ return true;
+ }
+ NOTREACHED();
+ return false;
}
bool PictureLayer::SupportsLCDText() const {

Powered by Google App Engine
This is Rietveld 408576698