Skip to content

Commit

Permalink
cc: Indicate that we've updated a tiling if we invalidated it.
Browse files Browse the repository at this point in the history
This patch ensures that we inform the caller that the tiling was updated
if it was invalidated since the last call to ComputeTilePriorityRects.

This ensures that we don't bypass TileManager::PrepareTiles call.

R=danakj, enne
BUG=593449
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1841083004

Cr-Commit-Position: refs/heads/master@{#385020}
  • Loading branch information
vmpstr authored and Commit bot committed Apr 4, 2016
1 parent b5a0f6c commit 6ee1182
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cc/tiles/picture_layer_tiling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ PictureLayerTiling::PictureLayerTiling(
has_skewport_rect_tiles_(false),
has_soon_border_rect_tiles_(false),
has_eventually_rect_tiles_(false),
all_tiles_done_(true) {
all_tiles_done_(true),
invalidated_since_last_compute_priority_rects_(false) {
DCHECK(!raster_source->IsSolidColor());
gfx::Size content_bounds =
gfx::ScaleToCeiledSize(raster_source_->GetSize(), contents_scale);
Expand Down Expand Up @@ -287,6 +288,7 @@ void PictureLayerTiling::SetRasterSourceAndResize(

void PictureLayerTiling::Invalidate(const Region& layer_invalidation) {
DCHECK(tree_ != ACTIVE_TREE || !client_->GetPendingOrActiveTwinTiling(this));
invalidated_since_last_compute_priority_rects_ = true;
RemoveTilesInRegion(layer_invalidation, true /* recreate tiles */);
}

Expand Down Expand Up @@ -638,11 +640,13 @@ bool PictureLayerTiling::ComputeTilePriorityRects(
set_all_tiles_done(false);
}

bool invalidated = invalidated_since_last_compute_priority_rects_;
invalidated_since_last_compute_priority_rects_ = false;
if (!NeedsUpdateForFrameAtTimeAndViewport(current_frame_time_in_seconds,
viewport_in_layer_space)) {
// This should never be zero for the purposes of has_ever_been_updated().
DCHECK_NE(current_frame_time_in_seconds, 0.0);
return false;
return invalidated;
}

const float content_to_screen_scale = ideal_contents_scale / contents_scale_;
Expand Down
1 change: 1 addition & 0 deletions cc/tiles/picture_layer_tiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ class CC_EXPORT PictureLayerTiling {
bool has_soon_border_rect_tiles_;
bool has_eventually_rect_tiles_;
bool all_tiles_done_;
bool invalidated_since_last_compute_priority_rects_;

private:
DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling);
Expand Down
32 changes: 32 additions & 0 deletions cc/tiles/picture_layer_tiling_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,38 @@ TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) {
EXPECT_FALSE(recycle_tiling->TileAt(0, 0));
}

TEST(PictureLayerTilingTest, InvalidateAfterComputeTilePriorityRects) {
FakePictureLayerTilingClient pending_client;
pending_client.SetTileSize(gfx::Size(100, 100));

scoped_refptr<FakeRasterSource> raster_source =
FakeRasterSource::CreateFilled(gfx::Size(100, 100));
scoped_ptr<TestablePictureLayerTiling> pending_tiling =
TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, raster_source,
&pending_client, LayerTreeSettings());
pending_tiling->set_resolution(HIGH_RESOLUTION);

// Ensure that we can compute tile priority rects, invalidate, and compute the
// rects again. It is important that the second compute tile priority rects
// return true, indicating that things have changed (since invalidation has
// changed things). This causes PrepareTiles to be properly scheduled. If the
// second ComputeTilePriorityRects returns false, then we assume that
// PrepareTiles isn't needed and we signal that we're ready to draw
// immediately, which can cause visual glitches.
//
// This can happen we if we process an impl frame deadline before processing a
// commit. That is, when we draw we ComputeTilePriorityRects. If we process
// the commit afterwards, it would use the same timestamp and sometimes would
// use the same viewport to compute tile priority rects again.
double time = 1.;
gfx::Rect viewport(0, 0, 100, 100);
EXPECT_TRUE(pending_tiling->ComputeTilePriorityRects(viewport, 1.0f, time,
Occlusion()));
pending_tiling->Invalidate(viewport);
EXPECT_TRUE(pending_tiling->ComputeTilePriorityRects(viewport, 1.0f, time,
Occlusion()));
}

TEST_F(PictureLayerTilingIteratorTest, ResizeTilesAndUpdateToCurrent) {
// The tiling has four rows and three columns.
Initialize(gfx::Size(150, 100), 1.f, gfx::Size(250, 150));
Expand Down

0 comments on commit 6ee1182

Please sign in to comment.