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

Unified Diff: cc/layers/picture_layer_impl.cc

Issue 181063022: cc: Trigger GPU rasterization based on a per-layer hint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move flags to RenderThreadImpl 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_impl.cc
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index fc8647c06672435caf30524513c896e74b9ba2d7..cadb385bebc4a397a347544400ccc8f8156a2a67 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -54,7 +54,7 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id)
is_using_lcd_text_(tree_impl->settings().can_use_lcd_text),
needs_post_commit_initialization_(true),
should_update_tile_priorities_(false),
- should_use_gpu_rasterization_(tree_impl->settings().gpu_rasterization) {}
+ has_gpu_rasterization_hint_(false) {}
PictureLayerImpl::~PictureLayerImpl() {}
@@ -91,6 +91,7 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
layer_impl->SetIsMask(is_mask_);
layer_impl->pile_ = pile_;
+ layer_impl->SetHasGpuRasterizationHint(has_gpu_rasterization_hint_);
// Tilings would be expensive to push, so we swap. This optimization requires
// an extra invalidation in SyncFromActiveLayer.
@@ -449,14 +450,24 @@ skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() {
return pile_->GetFlattenedPicture();
}
-void PictureLayerImpl::SetShouldUseGpuRasterization(
- bool should_use_gpu_rasterization) {
- if (should_use_gpu_rasterization != should_use_gpu_rasterization_) {
- should_use_gpu_rasterization_ = should_use_gpu_rasterization;
+void PictureLayerImpl::SetHasGpuRasterizationHint(bool has_hint) {
+ bool old_should_use_gpu_rasterization = ShouldUseGpuRasterization();
+ has_gpu_rasterization_hint_ = has_hint;
+ if (ShouldUseGpuRasterization() != old_should_use_gpu_rasterization)
RemoveAllTilings();
- } else {
- should_use_gpu_rasterization_ = should_use_gpu_rasterization;
+}
+
+bool PictureLayerImpl::ShouldUseGpuRasterization() const {
+ switch (layer_tree_impl()->settings().rasterization_site) {
+ case LayerTreeSettings::CpuRasterization:
+ return false;
+ case LayerTreeSettings::HybridRasterization:
+ return has_gpu_rasterization_hint_;
+ case LayerTreeSettings::GpuRasterization:
+ return true;
}
+ NOTREACHED();
+ return false;
}
scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
@@ -467,7 +478,7 @@ scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
int flags = 0;
if (is_using_lcd_text_)
flags |= Tile::USE_LCD_TEXT;
- if (should_use_gpu_rasterization())
+ if (ShouldUseGpuRasterization())
flags |= Tile::USE_GPU_RASTERIZATION;
return layer_tree_impl()->tile_manager()->CreateTile(
pile_.get(),
@@ -491,8 +502,8 @@ const Region* PictureLayerImpl::GetInvalidation() {
const PictureLayerTiling* PictureLayerImpl::GetTwinTiling(
const PictureLayerTiling* tiling) const {
- if (!twin_layer_ || twin_layer_->should_use_gpu_rasterization() !=
- should_use_gpu_rasterization())
+ if (!twin_layer_ ||
+ twin_layer_->ShouldUseGpuRasterization() != ShouldUseGpuRasterization())
return NULL;
for (size_t i = 0; i < twin_layer_->tilings_->num_tilings(); ++i)
if (twin_layer_->tilings_->tiling_at(i)->contents_scale() ==
@@ -841,8 +852,8 @@ PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
const Region& recorded = pile_->recorded_region();
DCHECK(!recorded.IsEmpty());
- if (twin_layer_ && twin_layer_->should_use_gpu_rasterization() ==
- should_use_gpu_rasterization())
+ if (twin_layer_ &&
+ twin_layer_->ShouldUseGpuRasterization() == ShouldUseGpuRasterization())
twin_layer_->SyncTiling(tiling);
return tiling;
@@ -862,7 +873,8 @@ void PictureLayerImpl::RemoveTiling(float contents_scale) {
}
void PictureLayerImpl::RemoveAllTilings() {
- tilings_->RemoveAllTilings();
+ if (tilings_)
+ tilings_->RemoveAllTilings();
// If there are no tilings, then raster scales are no longer meaningful.
ResetRasterScale();
}
@@ -1217,6 +1229,7 @@ void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const {
}
state->Set("coverage_tiles", coverage_tiles.release());
state->SetBoolean("is_using_lcd_text", is_using_lcd_text_);
+ state->SetBoolean("using_gpu_rasterization", ShouldUseGpuRasterization());
}
size_t PictureLayerImpl::GPUMemoryUsageInBytes() const {

Powered by Google App Engine
This is Rietveld 408576698