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

Unified Diff: cc/layers/picture_layer_impl.cc

Issue 271533011: cc: Move tiling management out of draw properties calculation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WIP - use properly scaled content_bounds Created 6 years, 7 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 6b2a0759e0d6480ab8acfc78f4069595e0b4da9a..7bd44e26f7a67438a086c9eb26434c0ebbf3d592 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -60,7 +60,6 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id)
was_animating_transform_to_screen_(false),
is_using_lcd_text_(tree_impl->settings().can_use_lcd_text),
needs_post_commit_initialization_(true),
- should_update_tile_priorities_(false),
should_use_low_res_tiling_(tree_impl->settings().create_low_res_tiling),
layer_needs_to_register_itself_(true) {
}
@@ -139,10 +138,30 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
void PictureLayerImpl::AppendQuads(QuadSink* quad_sink,
AppendQuadsData* append_quads_data) {
DCHECK(!needs_post_commit_initialization_);
- gfx::Rect rect(visible_content_rect());
- gfx::Rect content_rect(content_bounds());
SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState();
+
+ float max_contents_scale = GetMaxContentScale();
+ gfx::Transform scaled_transform = draw_transform();
danakj 2014/05/15 15:15:31 scaled_draw_transform
+ scaled_transform.Scale(SK_MScalar1 / max_contents_scale,
+ SK_MScalar1 / max_contents_scale);
+ gfx::Size bounds(
danakj 2014/05/15 15:15:31 name this scaled_content_bounds
+ gfx::Size(std::ceil(content_bounds().width() * max_contents_scale),
danakj 2014/05/15 15:15:31 Use gfx::ToCeiledSize(gfx::ScaleSize()) to do this
+ std::ceil(content_bounds().height() * max_contents_scale)));
+
+ gfx::Rect scaled_rect =
danakj 2014/05/15 15:15:31 scaled_visible_content_rect
+ gfx::Rect(visible_content_rect().x() * max_contents_scale,
danakj 2014/05/15 15:15:31 Use gfx::ScaleToEnclosingRect() to do this.
+ visible_content_rect().y() * max_contents_scale,
+ visible_content_rect().width() * max_contents_scale,
+ visible_content_rect().height() * max_contents_scale);
+ scaled_rect.Intersect(gfx::Rect(bounds));
+ gfx::Rect rect = gfx::ToEnclosingRect(scaled_rect);
+
+ draw_properties().content_bounds = bounds;
+ draw_properties().visible_content_rect = rect;
danakj 2014/05/15 15:15:31 The draw properties should stay unchanged here, we
+ draw_properties().contents_scale_x = max_contents_scale;
+ draw_properties().contents_scale_y = max_contents_scale;
+ draw_properties().target_space_transform = scaled_transform;
PopulateSharedQuadState(shared_quad_state);
danakj 2014/05/15 15:15:31 The SQS transform/visible_content_rect/content_bou
if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) {
@@ -185,7 +204,7 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink,
if (ShowDebugBorders()) {
for (PictureLayerTilingSet::CoverageIterator iter(
- tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_);
+ tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_);
danakj 2014/05/15 15:15:31 because you don't want to change the draw_props, y
iter;
++iter) {
SkColor color;
@@ -236,7 +255,7 @@ void PictureLayerImpl::AppendQuads(QuadSink* quad_sink,
bool had_checkerboard_quads = false;
for (PictureLayerTilingSet::CoverageIterator iter(
- tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_);
+ tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_);
iter;
++iter) {
gfx::Rect geometry_rect = iter.geometry_rect();
@@ -364,7 +383,10 @@ void PictureLayerImpl::DidUnregisterLayer() {
void PictureLayerImpl::UpdateTilePriorities() {
DCHECK(!needs_post_commit_initialization_);
- CHECK(should_update_tile_priorities_);
+
+ CalculateIdealScales();
+ ManageTilings(draw_properties().screen_space_transform_is_animating,
+ draw_properties().maximum_animation_contents_scale);
if (layer_needs_to_register_itself_) {
layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this);
@@ -456,74 +478,6 @@ void PictureLayerImpl::ReleaseResources() {
layer_tree_impl()->set_needs_update_draw_properties();
}
-void PictureLayerImpl::CalculateContentsScale(
- float ideal_contents_scale,
- float device_scale_factor,
- float page_scale_factor,
- float maximum_animation_contents_scale,
- bool animating_transform_to_screen,
- float* contents_scale_x,
- float* contents_scale_y,
- gfx::Size* content_bounds) {
- DoPostCommitInitializationIfNeeded();
-
- // This function sets valid raster scales and manages tilings, so tile
- // priorities can now be updated.
- should_update_tile_priorities_ = true;
-
- if (!CanHaveTilings()) {
- ideal_page_scale_ = page_scale_factor;
- ideal_device_scale_ = device_scale_factor;
- ideal_contents_scale_ = ideal_contents_scale;
- ideal_source_scale_ =
- ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_;
- *contents_scale_x = ideal_contents_scale_;
- *contents_scale_y = ideal_contents_scale_;
- *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(),
- ideal_contents_scale_,
- ideal_contents_scale_));
- return;
- }
-
- float min_contents_scale = MinimumContentsScale();
- DCHECK_GT(min_contents_scale, 0.f);
- float min_page_scale = layer_tree_impl()->min_page_scale_factor();
- DCHECK_GT(min_page_scale, 0.f);
- float min_device_scale = 1.f;
- float min_source_scale =
- min_contents_scale / min_page_scale / min_device_scale;
-
- float ideal_page_scale = page_scale_factor;
- float ideal_device_scale = device_scale_factor;
- float ideal_source_scale =
- ideal_contents_scale / ideal_page_scale / ideal_device_scale;
-
- ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale);
- ideal_page_scale_ = ideal_page_scale;
- ideal_device_scale_ = ideal_device_scale;
- ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale);
-
- ManageTilings(animating_transform_to_screen,
- maximum_animation_contents_scale);
-
- // The content scale and bounds for a PictureLayerImpl is somewhat fictitious.
- // There are (usually) several tilings at different scales. However, the
- // content bounds is the (integer!) space in which quads are generated.
- // In order to guarantee that we can fill this integer space with any set of
- // tilings (and then map back to floating point texture coordinates), the
- // contents scale must be at least as large as the largest of the tilings.
- float max_contents_scale = min_contents_scale;
- for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
- const PictureLayerTiling* tiling = tilings_->tiling_at(i);
- max_contents_scale = std::max(max_contents_scale, tiling->contents_scale());
- }
-
- *contents_scale_x = max_contents_scale;
- *contents_scale_y = max_contents_scale;
- *content_bounds = gfx::ToCeiledSize(
- gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale));
-}
-
skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() {
return pile_->GetFlattenedPicture();
}
@@ -702,14 +656,17 @@ void PictureLayerImpl::SyncTiling(
const PictureLayerTiling* tiling) {
if (!CanHaveTilingWithScale(tiling->contents_scale()))
return;
+
+ if (!IsDrawnRenderSurfaceLayerListMember())
danakj 2014/05/15 15:15:31 Do this in a separate CL? This isn't related right
+ return;
+
tilings_->AddTiling(tiling->contents_scale());
// If this tree needs update draw properties, then the tiling will
// get updated prior to drawing or activation. If this tree does not
// need update draw properties, then its transforms are up to date and
// we can create tiles for this tiling immediately.
- if (!layer_tree_impl()->needs_update_draw_properties() &&
- should_update_tile_priorities_) {
+ if (!layer_tree_impl()->needs_update_draw_properties()) {
UpdateTilePriorities();
}
}
@@ -724,7 +681,7 @@ void PictureLayerImpl::SetIsMask(bool is_mask) {
ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const {
gfx::Rect content_rect(content_bounds());
- float scale = contents_scale_x();
+ float scale = GetMaxContentScale();
PictureLayerTilingSet::CoverageIterator iter(
tilings_.get(), scale, content_rect, ideal_contents_scale_);
@@ -985,6 +942,9 @@ void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen,
if (!change_target_tiling)
return;
+ if (!IsDrawnRenderSurfaceLayerListMember())
danakj 2014/05/15 15:15:31 Same here, separate CL?
+ return;
+
PictureLayerTiling* high_res = NULL;
PictureLayerTiling* low_res = NULL;
@@ -1251,10 +1211,6 @@ void PictureLayerImpl::ResetRasterScale() {
raster_contents_scale_ = 0.f;
low_res_raster_contents_scale_ = 0.f;
raster_source_scale_is_fixed_ = false;
-
- // When raster scales aren't valid, don't update tile priorities until
- // this layer has been updated via UpdateDrawProperties.
- should_update_tile_priorities_ = false;
}
bool PictureLayerImpl::CanHaveTilings() const {
@@ -1288,6 +1244,47 @@ void PictureLayerImpl::SanityCheckTilingState() const {
#endif
}
+float PictureLayerImpl::GetMaxContentScale() const {
+ float max_contents_scale = 1.f;
+ for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
+ const PictureLayerTiling* tiling = tilings_->tiling_at(i);
+ max_contents_scale = std::max(max_contents_scale, tiling->contents_scale());
+ }
+ return max_contents_scale;
+}
+
+void PictureLayerImpl::CalculateIdealScales() {
+ DoPostCommitInitializationIfNeeded();
danakj 2014/05/15 15:15:31 Move this up to the UpdateTilePrios method please
+
+ if (!CanHaveTilings()) {
+ ideal_page_scale_ = layer_tree_impl()->page_scale_factor();
danakj 2014/05/15 15:15:31 This value is different from before, this is the v
+ ideal_device_scale_ = layer_tree_impl()->device_scale_factor();
+ ideal_contents_scale_ = draw_properties().ideal_contents_scale;
+ ideal_source_scale_ =
+ ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_;
+ return;
+ }
+
+ float min_contents_scale = MinimumContentsScale();
+ DCHECK_GT(min_contents_scale, 0.f);
+ float min_page_scale = layer_tree_impl()->min_page_scale_factor();
+ DCHECK_GT(min_page_scale, 0.f);
+ float min_device_scale = 1.f;
+ float min_source_scale =
+ min_contents_scale / min_page_scale / min_device_scale;
+
+ float ideal_page_scale = layer_tree_impl()->page_scale_factor();
+ float ideal_device_scale = layer_tree_impl()->device_scale_factor();
+ float ideal_source_scale = draw_properties().ideal_contents_scale /
+ ideal_page_scale / ideal_device_scale;
+
+ ideal_contents_scale_ =
+ std::max(draw_properties().ideal_contents_scale, min_contents_scale);
+ ideal_page_scale_ = layer_tree_impl()->page_scale_factor();
+ ideal_device_scale_ = layer_tree_impl()->device_scale_factor();
+ ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale);
+}
+
void PictureLayerImpl::GetDebugBorderProperties(
SkColor* color,
float* width) const {

Powered by Google App Engine
This is Rietveld 408576698