summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/layers/picture_layer_impl.cc25
-rw-r--r--cc/resources/tile.cc2
-rw-r--r--cc/resources/tile.h16
-rw-r--r--cc/resources/tile_manager.cc23
4 files changed, 28 insertions, 38 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 76ab5bb6..f71c3fd 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -39,6 +39,9 @@ const float kCpuSkewportTargetTimeInFrames = 60.0f;
// Don't pre-rasterize on the GPU (except for kBackflingGuardDistancePixels in
// TileManager::BinFromTilePriority).
const float kGpuSkewportTargetTimeInFrames = 0.0f;
+
+// Minimum width/height of a layer that would require analysis for tiles.
+const int kMinDimensionsForAnalysis = 256;
} // namespace
namespace cc {
@@ -552,8 +555,26 @@ scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
int flags = 0;
if (is_using_lcd_text_)
flags |= Tile::USE_LCD_TEXT;
- if (layer_tree_impl()->use_gpu_rasterization())
- flags |= Tile::USE_GPU_RASTERIZATION;
+
+ // We analyze picture before rasterization to detect solid-color tiles.
+ // If the tile is detected as such there is no need to raster or upload.
+ // It is drawn directly as a solid-color quad saving memory, raster and upload
+ // cost. The analysis step is however expensive and may not be justified when
+ // doing gpu rasterization which runs on the compositor thread and where there
+ // is no upload.
+ // TODO(alokp): Revisit the decision to avoid analysis for gpu rasterization
+ // becuase it too can potentially benefit from memory savings.
+ if (!layer_tree_impl()->use_gpu_rasterization()) {
+ // Additionally, we do not want to do the analysis if the layer is too
+ // narrow, since more likely than not the tile would not be solid. Note that
+ // this last optimization is a heuristic that ensures that we don't spend
+ // too much time analyzing tiles on a multitude of small layers, as it is
+ // likely that these layers have some non-solid content.
+ int min_dimension = std::min(bounds().width(), bounds().height());
+ if (min_dimension >= kMinDimensionsForAnalysis)
+ flags |= Tile::USE_PICTURE_ANALYSIS;
+ }
+
return layer_tree_impl()->tile_manager()->CreateTile(
pile_.get(),
content_rect.size(),
diff --git a/cc/resources/tile.cc b/cc/resources/tile.cc
index f976cfe..485e230 100644
--- a/cc/resources/tile.cc
+++ b/cc/resources/tile.cc
@@ -72,7 +72,7 @@ scoped_ptr<base::Value> Tile::AsValue() const {
res->Set("pending_priority", priority_[PENDING_TREE].AsValue().release());
res->Set("managed_state", managed_state_.AsValue().release());
res->SetBoolean("can_use_lcd_text", can_use_lcd_text());
- res->SetBoolean("use_gpu_rasterization", use_gpu_rasterization());
+ res->SetBoolean("use_picture_analysis", use_picture_analysis());
return res.PassAs<base::Value>();
}
diff --git a/cc/resources/tile.h b/cc/resources/tile.h
index a1e1c35..d7cb16b 100644
--- a/cc/resources/tile.h
+++ b/cc/resources/tile.h
@@ -20,10 +20,7 @@ namespace cc {
class CC_EXPORT Tile : public RefCountedManaged<Tile> {
public:
- enum TileRasterFlags {
- USE_LCD_TEXT = 1 << 0,
- USE_GPU_RASTERIZATION = 1 << 1
- };
+ enum TileRasterFlags { USE_LCD_TEXT = 1 << 0, USE_PICTURE_ANALYSIS = 1 << 1 };
typedef uint64 Id;
@@ -80,15 +77,8 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> {
return !!(flags_ & USE_LCD_TEXT);
}
- void set_use_gpu_rasterization(bool use_gpu_rasterization) {
- if (use_gpu_rasterization)
- flags_ |= USE_GPU_RASTERIZATION;
- else
- flags_ &= ~USE_GPU_RASTERIZATION;
- }
-
- bool use_gpu_rasterization() const {
- return !!(flags_ & USE_GPU_RASTERIZATION);
+ bool use_picture_analysis() const {
+ return !!(flags_ & USE_PICTURE_ANALYSIS);
}
bool NeedsRasterForMode(RasterMode mode) const {
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc
index 416c4e6..c88ba66 100644
--- a/cc/resources/tile_manager.cc
+++ b/cc/resources/tile_manager.cc
@@ -30,9 +30,6 @@ namespace {
// a tile is of solid color.
const bool kUseColorEstimator = true;
-// Minimum width/height of a pile that would require analysis for tiles.
-const int kMinDimensionsForAnalysis = 256;
-
class DisableLCDTextFilter : public SkDrawFilter {
public:
// SkDrawFilter interface.
@@ -1108,24 +1105,6 @@ scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) {
existing_pixel_refs[id] = decode_task;
}
- // We analyze picture before rasterization to detect solid-color tiles.
- // If the tile is detected as such there is no need to raster or upload.
- // It is drawn directly as a solid-color quad saving raster and upload cost.
- // The analysis step is however expensive and is not justified when doing
- // gpu rasterization where there is no upload.
- //
- // Additionally, we do not want to do the analysis if the layer that produced
- // this tile is narrow, since more likely than not the tile would not be
- // solid. We use the picture pile size as a proxy for layer size, since it
- // represents the recorded (and thus rasterizable) content.
- // Note that this last optimization is a heuristic that ensures that we don't
- // spend too much time analyzing tiles on a multitude of small layers, as it
- // is likely that these layers have some non-solid content.
- gfx::Size pile_size = tile->picture_pile()->tiling_rect().size();
- bool analyze_picture = !tile->use_gpu_rasterization() &&
- std::min(pile_size.width(), pile_size.height()) >=
- kMinDimensionsForAnalysis;
-
return make_scoped_refptr(
new RasterTaskImpl(const_resource,
tile->picture_pile(),
@@ -1136,7 +1115,7 @@ scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) {
tile->layer_id(),
static_cast<const void*>(tile),
tile->source_frame_number(),
- analyze_picture,
+ tile->use_picture_analysis(),
rendering_stats_instrumentation_,
base::Bind(&TileManager::OnRasterTaskCompleted,
base::Unretained(this),