| Index: cc/tiles/picture_layer_tiling.cc
|
| diff --git a/cc/tiles/picture_layer_tiling.cc b/cc/tiles/picture_layer_tiling.cc
|
| index 94a36cdde51411ad70db1f54187c9c44e042301d..832b310f68ba0f81d46de2b72d244a5394f4d03f 100644
|
| --- a/cc/tiles/picture_layer_tiling.cc
|
| +++ b/cc/tiles/picture_layer_tiling.cc
|
| @@ -32,10 +32,10 @@ namespace cc {
|
|
|
| PictureLayerTiling::PictureLayerTiling(
|
| WhichTree tree,
|
| - float contents_scale,
|
| + const ScaleTranslate2d& contents_transform,
|
| scoped_refptr<RasterSource> raster_source,
|
| PictureLayerTilingClient* client)
|
| - : contents_scale_(contents_scale),
|
| + : contents_transform_(contents_transform),
|
| client_(client),
|
| tree_(tree),
|
| raster_source_(raster_source),
|
| @@ -50,17 +50,24 @@ PictureLayerTiling::PictureLayerTiling(
|
| has_eventually_rect_tiles_(false),
|
| all_tiles_done_(true) {
|
| DCHECK(!raster_source->IsSolidColor());
|
| - gfx::Size content_bounds =
|
| - gfx::ScaleToCeiledSize(raster_source_->GetSize(), contents_scale);
|
| - gfx::Size tile_size = client_->CalculateTileSize(content_bounds);
|
| + DCHECK_GE(contents_transform.translation().x(), 0.f);
|
| + DCHECK_LT(contents_transform.translation().x(), 1.f);
|
| + DCHECK_GE(contents_transform.translation().y(), 0.f);
|
| + DCHECK_LT(contents_transform.translation().y(), 1.f);
|
|
|
| - DCHECK(!gfx::ScaleToFlooredSize(raster_source_->GetSize(), contents_scale)
|
| + DCHECK(!gfx::ScaleToFlooredSize(raster_source_->GetSize(),
|
| + contents_transform.pre_scale())
|
| .IsEmpty())
|
| << "Tiling created with scale too small as contents become empty."
|
| << " Layer bounds: " << raster_source_->GetSize().ToString()
|
| - << " Contents scale: " << contents_scale;
|
| -
|
| - tiling_data_.SetTilingSize(content_bounds);
|
| + << " Contents scale: " << contents_transform.pre_scale();
|
| +
|
| + gfx::Rect content_bounds_rect =
|
| + EnclosingContentsRectFromLayerRect(gfx::Rect(raster_source_->GetSize()));
|
| + gfx::Size tiling_size = gfx::Size(content_bounds_rect.bottom_right().x(),
|
| + content_bounds_rect.bottom_right().y());
|
| + tiling_data_.SetTilingSize(tiling_size);
|
| + gfx::Size tile_size = client_->CalculateTileSize(tiling_size);
|
| tiling_data_.SetMaxTextureSize(tile_size);
|
| }
|
|
|
| @@ -114,7 +121,7 @@ void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() {
|
| for (Region::Iterator iter(*invalidation); iter.has_rect();
|
| iter.next()) {
|
| gfx::Rect invalid_content_rect =
|
| - gfx::ScaleToEnclosingRect(iter.rect(), contents_scale_);
|
| + EnclosingContentsRectFromLayerRect(iter.rect());
|
| invalid_content_rect.Intersect(tile_rect);
|
| invalidated.Union(invalid_content_rect);
|
| }
|
| @@ -176,12 +183,13 @@ void PictureLayerTiling::SetRasterSourceAndResize(
|
| gfx::Size old_layer_bounds = raster_source_->GetSize();
|
| raster_source_ = std::move(raster_source);
|
| gfx::Size new_layer_bounds = raster_source_->GetSize();
|
| - gfx::Size content_bounds =
|
| - gfx::ScaleToCeiledSize(new_layer_bounds, contents_scale_);
|
| - gfx::Size tile_size = client_->CalculateTileSize(content_bounds);
|
| + gfx::Rect content_rect =
|
| + EnclosingContentsRectFromLayerRect(gfx::Rect(new_layer_bounds));
|
| + DCHECK(content_rect.origin() == gfx::Point());
|
| + gfx::Size tile_size = client_->CalculateTileSize(content_rect.size());
|
|
|
| if (tile_size != tiling_data_.max_texture_size()) {
|
| - tiling_data_.SetTilingSize(content_bounds);
|
| + tiling_data_.SetTilingSize(content_rect.size());
|
| tiling_data_.SetMaxTextureSize(tile_size);
|
| // When the tile size changes, the TilingData positions no longer work
|
| // as valid keys to the TileMap, so just drop all tiles and clear the live
|
| @@ -196,7 +204,6 @@ void PictureLayerTiling::SetRasterSourceAndResize(
|
| // The SetLiveTilesRect() method would drop tiles outside the new bounds,
|
| // but may do so incorrectly if resizing the tiling causes the number of
|
| // tiles in the tiling_data_ to change.
|
| - gfx::Rect content_rect(content_bounds);
|
| int before_left = tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.x());
|
| int before_top = tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.y());
|
| int before_right =
|
| @@ -207,7 +214,7 @@ void PictureLayerTiling::SetRasterSourceAndResize(
|
| // The live_tiles_rect_ is clamped to stay within the tiling size as we
|
| // change it.
|
| live_tiles_rect_.Intersect(content_rect);
|
| - tiling_data_.SetTilingSize(content_bounds);
|
| + tiling_data_.SetTilingSize(content_rect.size());
|
|
|
| int after_right = -1;
|
| int after_bottom = -1;
|
| @@ -272,7 +279,7 @@ void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation,
|
| gfx::Rect layer_rect = iter.rect();
|
| // The pixels which are invalid in content space.
|
| gfx::Rect invalid_content_rect =
|
| - gfx::ScaleToEnclosingRect(layer_rect, contents_scale_);
|
| + EnclosingContentsRectFromLayerRect(layer_rect);
|
| gfx::Rect coverage_content_rect = invalid_content_rect;
|
| // Avoid needless work by not bothering to invalidate where there aren't
|
| // tiles.
|
| @@ -309,9 +316,9 @@ Tile::CreateInfo PictureLayerTiling::CreateInfoForTile(int i, int j) const {
|
| gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j);
|
| tile_rect.set_size(tiling_data_.max_texture_size());
|
| gfx::Rect enclosing_layer_rect =
|
| - gfx::ScaleToEnclosingRect(tile_rect, 1.f / contents_scale_);
|
| + EnclosingLayerRectFromContentsRect(tile_rect);
|
| return Tile::CreateInfo(i, j, enclosing_layer_rect, tile_rect,
|
| - contents_scale_);
|
| + contents_transform_);
|
| }
|
|
|
| bool PictureLayerTiling::ShouldCreateTileAt(
|
| @@ -351,7 +358,7 @@ bool PictureLayerTiling::ShouldCreateTileAt(
|
| for (Region::Iterator iter(*layer_invalidation); iter.has_rect();
|
| iter.next()) {
|
| gfx::Rect invalid_content_rect =
|
| - gfx::ScaleToEnclosingRect(iter.rect(), contents_scale_);
|
| + EnclosingContentsRectFromLayerRect(iter.rect());
|
| if (invalid_content_rect.Intersects(info.content_rect))
|
| return true;
|
| }
|
| @@ -391,7 +398,8 @@ PictureLayerTiling::CoverageIterator::CoverageIterator(
|
| const gfx::Rect& dest_rect)
|
| : tiling_(tiling),
|
| dest_rect_(dest_rect),
|
| - dest_to_content_scale_(0),
|
| + dest_to_content_(ScaleTranslate2d::PreScale(tiling->contents_transform(),
|
| + 1.f / dest_scale)),
|
| current_tile_(NULL),
|
| tile_i_(0),
|
| tile_j_(0),
|
| @@ -403,12 +411,9 @@ PictureLayerTiling::CoverageIterator::CoverageIterator(
|
| if (dest_rect_.IsEmpty())
|
| return;
|
|
|
| - dest_to_content_scale_ = tiling_->contents_scale_ / dest_scale;
|
| -
|
| gfx::Rect content_rect =
|
| - gfx::ScaleToEnclosingRect(dest_rect_,
|
| - dest_to_content_scale_,
|
| - dest_to_content_scale_);
|
| + gfx::ToEnclosingRect(dest_to_content_.Transform(gfx::RectF(dest_rect_)));
|
| +
|
| // IndexFromSrcCoord clamps to valid tile ranges, so it's necessary to
|
| // check for non-intersection first.
|
| content_rect.Intersect(gfx::Rect(tiling_->tiling_size()));
|
| @@ -455,10 +460,9 @@ PictureLayerTiling::CoverageIterator::operator++() {
|
| // edges.
|
| gfx::Rect last_geometry_rect = current_geometry_rect_;
|
|
|
| - gfx::Rect content_rect = tiling_->tiling_data_.TileBounds(tile_i_, tile_j_);
|
| -
|
| current_geometry_rect_ =
|
| - gfx::ScaleToEnclosingRect(content_rect, 1 / dest_to_content_scale_);
|
| + gfx::ToEnclosingRect(dest_to_content_.TransformReverse(
|
| + gfx::RectF(tiling_->tiling_data_.TileBounds(tile_i_, tile_j_))));
|
|
|
| current_geometry_rect_.Intersect(dest_rect_);
|
| DCHECK(!current_geometry_rect_.IsEmpty());
|
| @@ -501,9 +505,8 @@ gfx::RectF PictureLayerTiling::CoverageIterator::texture_rect() const {
|
| tiling_->tiling_data_.TileBoundsWithBorder(tile_i_, tile_j_).origin());
|
|
|
| // Convert from dest space => content space => texture space.
|
| - gfx::RectF texture_rect(current_geometry_rect_);
|
| - texture_rect.Scale(dest_to_content_scale_,
|
| - dest_to_content_scale_);
|
| + gfx::RectF texture_rect =
|
| + dest_to_content_.Transform(gfx::RectF(current_geometry_rect_));
|
| texture_rect.Intersect(gfx::RectF(gfx::SizeF(tiling_->tiling_size())));
|
| if (texture_rect.IsEmpty())
|
| return texture_rect;
|
| @@ -549,16 +552,15 @@ void PictureLayerTiling::ComputeTilePriorityRects(
|
| set_all_tiles_done(false);
|
| }
|
|
|
| - const float content_to_screen_scale = ideal_contents_scale / contents_scale_;
|
| + const float content_to_screen_scale =
|
| + ideal_contents_scale / contents_transform_.pre_scale();
|
|
|
| const gfx::Rect* input_rects[] = {
|
| &visible_rect_in_layer_space, &skewport_in_layer_space,
|
| &soon_border_rect_in_layer_space, &eventually_rect_in_layer_space};
|
| gfx::Rect output_rects[4];
|
| - for (size_t i = 0; i < arraysize(input_rects); ++i) {
|
| - output_rects[i] = gfx::ToEnclosingRect(
|
| - gfx::ScaleRect(gfx::RectF(*input_rects[i]), contents_scale_));
|
| - }
|
| + for (size_t i = 0; i < arraysize(input_rects); ++i)
|
| + output_rects[i] = EnclosingContentsRectFromLayerRect(*input_rects[i]);
|
| // Make sure the eventually rect is aligned to tile bounds.
|
| output_rects[3] =
|
| tiling_data_.ExpandRectIgnoringBordersToTileBounds(output_rects[3]);
|
| @@ -689,10 +691,7 @@ bool PictureLayerTiling::IsTileOccludedOnCurrentTree(const Tile* tile) const {
|
| if (tile_query_rect.IsEmpty())
|
| return false;
|
|
|
| - if (contents_scale_ != 1.f) {
|
| - tile_query_rect =
|
| - gfx::ScaleToEnclosingRect(tile_query_rect, 1.f / contents_scale_);
|
| - }
|
| + tile_query_rect = EnclosingLayerRectFromContentsRect(tile_query_rect);
|
| return current_occlusion_in_layer_space_.IsOccluded(tile_query_rect);
|
| }
|
|
|
| @@ -774,9 +773,7 @@ PrioritizedTile PictureLayerTiling::MakePrioritizedTile(
|
| DCHECK(tile);
|
| DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect()))
|
| << "Recording rect: "
|
| - << gfx::ScaleToEnclosingRect(tile->content_rect(),
|
| - 1.f / tile->contents_scale())
|
| - .ToString();
|
| + << EnclosingLayerRectFromContentsRect(tile->content_rect()).ToString();
|
|
|
| return PrioritizedTile(tile, this,
|
| ComputePriorityForTile(tile, priority_rect_type),
|
| @@ -867,7 +864,10 @@ void PictureLayerTiling::GetAllPrioritizedTilesForTracing(
|
| void PictureLayerTiling::AsValueInto(
|
| base::trace_event::TracedValue* state) const {
|
| state->SetInteger("num_tiles", base::saturated_cast<int>(tiles_.size()));
|
| - state->SetDouble("content_scale", contents_scale_);
|
| + state->SetDouble("content_transform_pre_scale",
|
| + contents_transform_.pre_scale());
|
| + MathUtil::AddToTracedValue("content_transform_translation",
|
| + contents_transform_.translation(), state);
|
| MathUtil::AddToTracedValue("visible_rect", current_visible_rect_, state);
|
| MathUtil::AddToTracedValue("skewport_rect", current_skewport_rect_, state);
|
| MathUtil::AddToTracedValue("soon_rect", current_soon_border_rect_, state);
|
| @@ -885,4 +885,15 @@ size_t PictureLayerTiling::GPUMemoryUsageInBytes() const {
|
| return amount;
|
| }
|
|
|
| +gfx::Rect PictureLayerTiling::EnclosingContentsRectFromLayerRect(
|
| + const gfx::Rect& layer_rect) const {
|
| + return ToEnclosingRect(contents_transform_.Transform(gfx::RectF(layer_rect)));
|
| +}
|
| +
|
| +gfx::Rect PictureLayerTiling::EnclosingLayerRectFromContentsRect(
|
| + const gfx::Rect& contents_rect) const {
|
| + return ToEnclosingRect(
|
| + contents_transform_.TransformReverse(gfx::RectF(contents_rect)));
|
| +}
|
| +
|
| } // namespace cc
|
|
|