summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/layers/picture_layer.cc20
-rw-r--r--cc/layers/picture_layer.h1
-rw-r--r--cc/layers/picture_layer_impl.cc7
-rw-r--r--cc/layers/picture_layer_impl.h2
-rw-r--r--cc/layers/picture_layer_impl_unittest.cc24
-rw-r--r--cc/resources/picture_pile.cc46
-rw-r--r--cc/resources/picture_pile.h13
-rw-r--r--cc/resources/picture_pile_impl.cc48
-rw-r--r--cc/resources/picture_pile_impl.h7
-rw-r--r--cc/resources/picture_pile_impl_unittest.cc19
-rw-r--r--cc/resources/picture_pile_unittest.cc15
-rw-r--r--cc/resources/raster_source.h6
-rw-r--r--cc/resources/recording_source.h10
-rw-r--r--cc/test/fake_picture_pile.h10
-rw-r--r--cc/test/fake_picture_pile_impl.h9
15 files changed, 99 insertions, 138 deletions
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc
index dbfa63c..029e99d5 100644
--- a/cc/layers/picture_layer.cc
+++ b/cc/layers/picture_layer.cc
@@ -23,7 +23,8 @@ PictureLayer::PictureLayer(ContentLayerClient* client)
recording_source_(new PicturePile),
instrumentation_object_tracker_(id()),
update_source_frame_number_(-1),
- can_use_lcd_text_last_frame_(can_use_lcd_text()) {
+ can_use_lcd_text_last_frame_(can_use_lcd_text()),
+ is_mask_(false) {
}
PictureLayer::PictureLayer(ContentLayerClient* client,
@@ -66,13 +67,18 @@ void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
// See PictureLayerImpl::PushPropertiesTo for more details.
layer_impl->invalidation_.Clear();
layer_impl->invalidation_.Swap(&recording_invalidation_);
- layer_impl->UpdateRasterSource(recording_source_->CreateRasterSource());
+ layer_impl->set_is_mask(is_mask_);
+ scoped_refptr<RasterSource> raster_source =
+ recording_source_->CreateRasterSource();
+ raster_source->SetBackgoundColor(SafeOpaqueBackgroundColor());
+ raster_source->SetRequiresClear(!contents_opaque() &&
+ !client_->FillsBoundsCompletely());
+ layer_impl->UpdateRasterSource(raster_source);
}
void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) {
Layer::SetLayerTreeHost(host);
if (host) {
- // TODO(hendrikw): Perhaps use and initialization function to do this work.
recording_source_->SetMinContentsScale(
host->settings().minimum_contents_scale);
recording_source_->SetTileGridSize(host->settings().default_tile_grid_size);
@@ -135,10 +141,8 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue,
// for them.
DCHECK(client_);
updated |= recording_source_->UpdateAndExpandInvalidation(
- client_, &recording_invalidation_, SafeOpaqueBackgroundColor(),
- contents_opaque(), client_->FillsBoundsCompletely(), layer_size,
- visible_layer_rect, update_source_frame_number_,
- Picture::RECORD_NORMALLY);
+ client_, &recording_invalidation_, layer_size, visible_layer_rect,
+ update_source_frame_number_, Picture::RECORD_NORMALLY);
last_updated_visible_content_rect_ = visible_content_rect();
if (updated) {
@@ -153,7 +157,7 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue,
}
void PictureLayer::SetIsMask(bool is_mask) {
- recording_source_->SetIsMask(is_mask);
+ is_mask_ = is_mask;
}
bool PictureLayer::SupportsLCDText() const {
diff --git a/cc/layers/picture_layer.h b/cc/layers/picture_layer.h
index ebd6427..e4acb1f 100644
--- a/cc/layers/picture_layer.h
+++ b/cc/layers/picture_layer.h
@@ -65,6 +65,7 @@ class CC_EXPORT PictureLayer : public Layer {
int update_source_frame_number_;
bool can_use_lcd_text_last_frame_;
+ bool is_mask_;
DISALLOW_COPY_AND_ASSIGN(PictureLayer);
};
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 1f2bfbd..111a0e7 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -87,7 +87,8 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id)
was_screen_space_transform_animating_(false),
needs_post_commit_initialization_(true),
should_update_tile_priorities_(false),
- only_used_low_res_last_append_quads_(false) {
+ only_used_low_res_last_append_quads_(false),
+ is_mask_(false) {
layer_tree_impl()->RegisterPictureLayerImpl(this);
}
@@ -618,7 +619,7 @@ scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
// memory savings that we can get. Note that we don't handle solid color
// masks, so we shouldn't bother analyzing those.
// Bugs: crbug.com/397198, crbug.com/396908
- if (!raster_source_->IsMask())
+ if (!is_mask_)
flags = Tile::USE_PICTURE_ANALYSIS;
return layer_tree_impl()->tile_manager()->CreateTile(
@@ -690,7 +691,7 @@ gfx::Size PictureLayerImpl::CalculateTileSize(
int max_texture_size =
layer_tree_impl()->resource_provider()->max_texture_size();
- if (raster_source_->IsMask()) {
+ if (is_mask_) {
// Masks are not tiled, so if we can't cover the whole mask with one tile,
// don't make any tiles at all. Returning an empty size signals this.
if (content_bounds.width() > max_texture_size ||
diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h
index 59ee3bf..78b13fc 100644
--- a/cc/layers/picture_layer_impl.h
+++ b/cc/layers/picture_layer_impl.h
@@ -138,6 +138,7 @@ class CC_EXPORT PictureLayerImpl
// Mask-related functions.
void GetContentsResourceId(ResourceProvider::ResourceId* resource_id,
gfx::Size* resource_size) const override;
+ void set_is_mask(bool is_mask) { is_mask_ = is_mask; }
size_t GPUMemoryUsageInBytes() const override;
@@ -221,6 +222,7 @@ class CC_EXPORT PictureLayerImpl
// after a CalculateContentsScale/ManageTilings.
bool should_update_tile_priorities_;
bool only_used_low_res_last_append_quads_;
+ bool is_mask_;
// Any draw properties derived from |transform|, |viewport|, and |clip|
// parameters in LayerTreeHostImpl::SetExternalDrawConstraints are not valid
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index a717ade..1d7e2ee 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -1188,8 +1188,8 @@ TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) {
ResetTilingsAndRasterScales();
// Mask layers dont create low res since they always fit on one tile.
- pending_pile->SetIsMask(true);
- active_pile->SetIsMask(true);
+ pending_layer_->set_is_mask(true);
+ active_layer_->set_is_mask(true);
SetContentsScaleOnBothLayers(contents_scale,
device_scale,
page_scale,
@@ -1204,8 +1204,8 @@ TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) {
scoped_refptr<FakePicturePileImpl> valid_pile =
FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000));
- valid_pile->SetIsMask(true);
SetupPendingTree(valid_pile);
+ pending_layer_->set_is_mask(true);
SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale());
@@ -1231,8 +1231,8 @@ TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) {
scoped_refptr<FakePicturePileImpl> huge_pile =
FakePicturePileImpl::CreateFilledPile(
tile_size, gfx::Size(max_texture_size + 1, 10));
- huge_pile->SetIsMask(true);
SetupPendingTree(huge_pile);
+ pending_layer_->set_is_mask(true);
SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale());
@@ -1256,8 +1256,8 @@ TEST_F(PictureLayerImplTest, ScaledMaskLayer) {
scoped_refptr<FakePicturePileImpl> valid_pile =
FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000));
- valid_pile->SetIsMask(true);
SetupPendingTree(valid_pile);
+ pending_layer_->set_is_mask(true);
float ideal_contents_scale = 1.3f;
SetupDrawPropertiesAndUpdateTiles(
@@ -3716,10 +3716,10 @@ TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) {
scoped_refptr<FakePicturePileImpl> pending_pile =
FakePicturePileImpl::CreateFilledPile(tile_size, bounds);
- pending_pile->SetIsMask(true);
scoped_ptr<FakePictureLayerImpl> mask =
FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 3,
pending_pile);
+ mask->set_is_mask(true);
mask->SetBounds(bounds);
mask->SetContentBounds(bounds);
@@ -4504,8 +4504,8 @@ void PictureLayerImplTest::TestQuadsForSolidColor(bool test_for_solid) {
Region invalidation(layer_rect);
recording_source->UpdateAndExpandInvalidation(
- &client, &invalidation, SK_ColorWHITE, false, false, layer_bounds,
- layer_rect, frame_number++, Picture::RECORD_NORMALLY);
+ &client, &invalidation, layer_bounds, layer_rect, frame_number++,
+ Picture::RECORD_NORMALLY);
scoped_refptr<RasterSource> pending_raster_source =
recording_source->CreateRasterSource();
@@ -4571,8 +4571,8 @@ TEST_F(PictureLayerImplTest, NonSolidToSolidNoTilings) {
Region invalidation1(layer_rect);
recording_source->UpdateAndExpandInvalidation(
- &client, &invalidation1, SK_ColorWHITE, false, false, layer_bounds,
- layer_rect, frame_number++, Picture::RECORD_NORMALLY);
+ &client, &invalidation1, layer_bounds, layer_rect, frame_number++,
+ Picture::RECORD_NORMALLY);
scoped_refptr<RasterSource> raster_source1 =
recording_source->CreateRasterSource();
@@ -4589,8 +4589,8 @@ TEST_F(PictureLayerImplTest, NonSolidToSolidNoTilings) {
Region invalidation2(layer_rect);
recording_source->UpdateAndExpandInvalidation(
- &client, &invalidation2, SK_ColorWHITE, false, false, layer_bounds,
- layer_rect, frame_number++, Picture::RECORD_NORMALLY);
+ &client, &invalidation2, layer_bounds, layer_rect, frame_number++,
+ Picture::RECORD_NORMALLY);
scoped_refptr<RasterSource> raster_source2 =
recording_source->CreateRasterSource();
diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc
index ab138ca..eed12ea 100644
--- a/cc/resources/picture_pile.cc
+++ b/cc/resources/picture_pile.cc
@@ -26,11 +26,6 @@ const int kOpCountThatIsOkToAnalyze = 10;
// the base picture in each tile.
const int kBasePictureSize = 512;
const int kTileGridBorderPixels = 1;
-#ifdef NDEBUG
-const bool kDefaultClearCanvasSetting = false;
-#else
-const bool kDefaultClearCanvasSetting = true;
-#endif
// Invalidation frequency settings. kInvalidationFrequencyThreshold is a value
// between 0 and 1 meaning invalidation frequency between 0% and 100% that
@@ -169,11 +164,7 @@ namespace cc {
PicturePile::PicturePile()
: min_contents_scale_(0),
slow_down_raster_scale_factor_for_debug_(0),
- contents_opaque_(false),
- contents_fill_bounds_completely_(false),
- clear_canvas_with_debug_color_(kDefaultClearCanvasSetting),
has_any_recordings_(false),
- is_mask_(false),
is_solid_color_(false),
solid_color_(SK_ColorTRANSPARENT),
pixel_record_distance_(kPixelDistanceToRecord),
@@ -190,17 +181,10 @@ PicturePile::~PicturePile() {
bool PicturePile::UpdateAndExpandInvalidation(
ContentLayerClient* painter,
Region* invalidation,
- SkColor background_color,
- bool contents_opaque,
- bool contents_fill_bounds_completely,
const gfx::Size& layer_size,
const gfx::Rect& visible_layer_rect,
int frame_number,
Picture::RecordingMode recording_mode) {
- background_color_ = background_color;
- contents_opaque_ = contents_opaque;
- contents_fill_bounds_completely_ = contents_fill_bounds_completely;
-
bool updated = false;
Region resize_invalidation;
@@ -569,6 +553,11 @@ bool PicturePile::UpdateAndExpandInvalidation(
return true;
}
+scoped_refptr<RasterSource> PicturePile::CreateRasterSource() const {
+ return scoped_refptr<RasterSource>(
+ PicturePileImpl::CreateFromPicturePile(this));
+}
+
gfx::Size PicturePile::GetSize() const {
return tiling_.tiling_size();
}
@@ -599,6 +588,14 @@ void PicturePile::SetMinContentsScale(float min_contents_scale) {
min_contents_scale_ = min_contents_scale;
}
+void PicturePile::SetSlowdownRasterScaleFactor(int factor) {
+ slow_down_raster_scale_factor_for_debug_ = factor;
+}
+
+bool PicturePile::IsSuitableForGpuRasterization() const {
+ return is_suitable_for_gpu_rasterization_;
+}
+
// static
void PicturePile::ComputeTileGridInfo(const gfx::Size& tile_grid_size,
SkTileGridFactory::TileGridInfo* info) {
@@ -618,27 +615,10 @@ void PicturePile::SetTileGridSize(const gfx::Size& tile_grid_size) {
ComputeTileGridInfo(tile_grid_size, &tile_grid_info_);
}
-void PicturePile::SetSlowdownRasterScaleFactor(int factor) {
- slow_down_raster_scale_factor_for_debug_ = factor;
-}
-
-void PicturePile::SetIsMask(bool is_mask) {
- is_mask_ = is_mask;
-}
-
void PicturePile::SetUnsuitableForGpuRasterizationForTesting() {
is_suitable_for_gpu_rasterization_ = false;
}
-bool PicturePile::IsSuitableForGpuRasterization() const {
- return is_suitable_for_gpu_rasterization_;
-}
-
-scoped_refptr<RasterSource> PicturePile::CreateRasterSource() const {
- return scoped_refptr<RasterSource>(
- PicturePileImpl::CreateFromPicturePile(this));
-}
-
SkTileGridFactory::TileGridInfo PicturePile::GetTileGridInfoForTesting() const {
return tile_grid_info_;
}
diff --git a/cc/resources/picture_pile.h b/cc/resources/picture_pile.h
index 1f41d01..e252e97 100644
--- a/cc/resources/picture_pile.h
+++ b/cc/resources/picture_pile.h
@@ -25,21 +25,17 @@ class CC_EXPORT PicturePile : public RecordingSource {
bool UpdateAndExpandInvalidation(
ContentLayerClient* painter,
Region* invalidation,
- SkColor background_color,
- bool contents_opaque,
- bool contents_fill_bounds_completely,
const gfx::Size& layer_size,
const gfx::Rect& visible_layer_rect,
int frame_number,
Picture::RecordingMode recording_mode) override;
+ scoped_refptr<RasterSource> CreateRasterSource() const override;
gfx::Size GetSize() const final;
void SetEmptyBounds() override;
void SetMinContentsScale(float min_contents_scale) override;
- void SetTileGridSize(const gfx::Size& tile_grid_size) override;
void SetSlowdownRasterScaleFactor(int factor) override;
- void SetIsMask(bool is_mask) override;
bool IsSuitableForGpuRasterization() const override;
- scoped_refptr<RasterSource> CreateRasterSource() const override;
+ void SetTileGridSize(const gfx::Size& tile_grid_size) override;
void SetUnsuitableForGpuRasterizationForTesting() override;
SkTileGridFactory::TileGridInfo GetTileGridInfoForTesting() const override;
@@ -97,15 +93,10 @@ class CC_EXPORT PicturePile : public RecordingSource {
gfx::Rect recorded_viewport_;
float min_contents_scale_;
SkTileGridFactory::TileGridInfo tile_grid_info_;
- SkColor background_color_;
int slow_down_raster_scale_factor_for_debug_;
- bool contents_opaque_;
- bool contents_fill_bounds_completely_;
- bool clear_canvas_with_debug_color_;
// A hint about whether there are any recordings. This may be a false
// positive.
bool has_any_recordings_;
- bool is_mask_;
bool is_solid_color_;
SkColor solid_color_;
int pixel_record_distance_;
diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc
index 7ec9252..7416538 100644
--- a/cc/resources/picture_pile_impl.cc
+++ b/cc/resources/picture_pile_impl.cc
@@ -14,6 +14,16 @@
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "ui/gfx/geometry/rect_conversions.h"
+namespace {
+
+#ifdef NDEBUG
+const bool kDefaultClearCanvasSetting = false;
+#else
+const bool kDefaultClearCanvasSetting = true;
+#endif
+
+} // namespace
+
namespace cc {
scoped_refptr<PicturePileImpl> PicturePileImpl::Create() {
@@ -27,13 +37,11 @@ scoped_refptr<PicturePileImpl> PicturePileImpl::CreateFromPicturePile(
PicturePileImpl::PicturePileImpl()
: background_color_(SK_ColorTRANSPARENT),
- contents_opaque_(false),
- contents_fill_bounds_completely_(false),
+ requires_clear_(true),
is_solid_color_(false),
solid_color_(SK_ColorTRANSPARENT),
has_any_recordings_(false),
- is_mask_(false),
- clear_canvas_with_debug_color_(false),
+ clear_canvas_with_debug_color_(kDefaultClearCanvasSetting),
min_contents_scale_(0.f),
slow_down_raster_scale_factor_for_debug_(0),
should_attempt_to_use_distance_field_text_(false) {
@@ -42,15 +50,13 @@ PicturePileImpl::PicturePileImpl()
PicturePileImpl::PicturePileImpl(const PicturePile* other)
: picture_map_(other->picture_map_),
tiling_(other->tiling_),
- background_color_(other->background_color_),
- contents_opaque_(other->contents_opaque_),
- contents_fill_bounds_completely_(other->contents_fill_bounds_completely_),
+ background_color_(SK_ColorTRANSPARENT),
+ requires_clear_(true),
is_solid_color_(other->is_solid_color_),
solid_color_(other->solid_color_),
recorded_viewport_(other->recorded_viewport_),
has_any_recordings_(other->has_any_recordings_),
- is_mask_(other->is_mask_),
- clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
+ clear_canvas_with_debug_color_(kDefaultClearCanvasSetting),
min_contents_scale_(other->min_contents_scale_),
slow_down_raster_scale_factor_for_debug_(
other->slow_down_raster_scale_factor_for_debug_),
@@ -88,7 +94,12 @@ void PicturePileImpl::PlaybackToCanvas(SkCanvas* canvas,
// If this picture has opaque contents, it is guaranteeing that it will
// draw an opaque rect the size of the layer. If it is not, then we must
// clear this canvas ourselves.
- if (contents_opaque_ || contents_fill_bounds_completely_) {
+ if (requires_clear_) {
+ TRACE_EVENT_INSTANT0("cc", "SkCanvas::clear", TRACE_EVENT_SCOPE_THREAD);
+ // Clearing is about ~4x faster than drawing a rect even if the content
+ // isn't covering a majority of the canvas.
+ canvas->clear(SK_ColorTRANSPARENT);
+ } else {
// Even if completely covered, for rasterizations that touch the edge of the
// layer, we also need to raster the background color underneath the last
// texel (since the recording won't cover it) and outside the last texel
@@ -129,11 +140,6 @@ void PicturePileImpl::PlaybackToCanvas(SkCanvas* canvas,
canvas->drawColor(background_color_, SkXfermode::kSrc_Mode);
canvas->restore();
}
- } else {
- TRACE_EVENT_INSTANT0("cc", "SkCanvas::clear", TRACE_EVENT_SCOPE_THREAD);
- // Clearing is about ~4x faster than drawing a rect even if the content
- // isn't covering a majority of the canvas.
- canvas->clear(SK_ColorTRANSPARENT);
}
RasterCommon(canvas,
@@ -401,6 +407,14 @@ void PicturePileImpl::SetShouldAttemptToUseDistanceFieldText() {
should_attempt_to_use_distance_field_text_ = true;
}
+void PicturePileImpl::SetBackgoundColor(SkColor background_color) {
+ background_color_ = background_color;
+}
+
+void PicturePileImpl::SetRequiresClear(bool requires_clear) {
+ requires_clear_ = requires_clear;
+}
+
bool PicturePileImpl::ShouldAttemptToUseDistanceFieldText() const {
return should_attempt_to_use_distance_field_text_;
}
@@ -423,10 +437,6 @@ void PicturePileImpl::AsValueInto(base::debug::TracedValue* pictures) const {
}
}
-bool PicturePileImpl::IsMask() const {
- return is_mask_;
-}
-
PicturePileImpl::PixelRefIterator::PixelRefIterator(
const gfx::Rect& content_rect,
float contents_scale,
diff --git a/cc/resources/picture_pile_impl.h b/cc/resources/picture_pile_impl.h
index 9f5b5f6..b4209e3 100644
--- a/cc/resources/picture_pile_impl.h
+++ b/cc/resources/picture_pile_impl.h
@@ -54,12 +54,13 @@ class CC_EXPORT PicturePileImpl : public RasterSource {
bool CoversRect(const gfx::Rect& content_rect,
float contents_scale) const override;
void SetShouldAttemptToUseDistanceFieldText() override;
+ void SetBackgoundColor(SkColor background_color) override;
+ void SetRequiresClear(bool requires_clear) override;
bool ShouldAttemptToUseDistanceFieldText() const override;
gfx::Size GetSize() const override;
bool IsSolidColor() const override;
SkColor GetSolidColor() const override;
bool HasRecordings() const override;
- bool IsMask() const override;
// Tracing functionality.
void DidBeginTracing() override;
@@ -108,13 +109,11 @@ class CC_EXPORT PicturePileImpl : public RasterSource {
PictureMap picture_map_;
TilingData tiling_;
SkColor background_color_;
- bool contents_opaque_;
- bool contents_fill_bounds_completely_;
+ bool requires_clear_;
bool is_solid_color_;
SkColor solid_color_;
gfx::Rect recorded_viewport_;
bool has_any_recordings_;
- bool is_mask_;
bool clear_canvas_with_debug_color_;
float min_contents_scale_;
int slow_down_raster_scale_factor_for_debug_;
diff --git a/cc/resources/picture_pile_impl_unittest.cc b/cc/resources/picture_pile_impl_unittest.cc
index 6dcf740..6e9afc7 100644
--- a/cc/resources/picture_pile_impl_unittest.cc
+++ b/cc/resources/picture_pile_impl_unittest.cc
@@ -634,17 +634,11 @@ TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsBaseNonDiscardable) {
}
}
-class FullContentsTest : public ::testing::TestWithParam<bool> {};
-
-TEST_P(FullContentsTest, RasterFullContents) {
+TEST(PicturePileImplTest, RasterFullContents) {
gfx::Size tile_size(1000, 1000);
gfx::Size layer_bounds(3, 5);
float contents_scale = 1.5f;
float raster_divisions = 2.f;
- // Param in this case is whether the content is fully opaque
- // or just filled completely. For this test they should behave the same.
- bool contents_opaque = GetParam();
- bool fills_content = !GetParam();
scoped_refptr<FakePicturePileImpl> pile =
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
@@ -656,8 +650,7 @@ TEST_P(FullContentsTest, RasterFullContents) {
pile->SetMinContentsScale(contents_scale);
pile->set_background_color(SK_ColorBLACK);
- pile->set_contents_opaque(contents_opaque);
- pile->set_contents_fill_bounds_completely(fills_content);
+ pile->SetRequiresClear(false);
pile->set_clear_canvas_with_debug_color(false);
pile->RerecordPile();
@@ -705,10 +698,6 @@ TEST_P(FullContentsTest, RasterFullContents) {
}
}
-INSTANTIATE_TEST_CASE_P(PicturePileImpl,
- FullContentsTest,
- ::testing::Values(false, true));
-
TEST(PicturePileImpl, RasterContentsTransparent) {
gfx::Size tile_size(1000, 1000);
gfx::Size layer_bounds(5, 3);
@@ -717,7 +706,7 @@ TEST(PicturePileImpl, RasterContentsTransparent) {
scoped_refptr<FakePicturePileImpl> pile =
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
pile->set_background_color(SK_ColorTRANSPARENT);
- pile->set_contents_opaque(false);
+ pile->SetRequiresClear(true);
pile->SetMinContentsScale(contents_scale);
pile->set_clear_canvas_with_debug_color(false);
pile->RerecordPile();
@@ -757,7 +746,7 @@ TEST_P(OverlapTest, NoOverlap) {
scoped_refptr<FakePicturePileImpl> pile =
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
pile->set_background_color(SK_ColorTRANSPARENT);
- pile->set_contents_opaque(false);
+ pile->SetRequiresClear(true);
pile->SetMinContentsScale(MinContentsScale());
pile->set_clear_canvas_with_debug_color(true);
SkPaint color_paint;
diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc
index bfb4692..0a9a907 100644
--- a/cc/resources/picture_pile_unittest.cc
+++ b/cc/resources/picture_pile_unittest.cc
@@ -17,11 +17,7 @@ namespace {
class PicturePileTestBase {
public:
- PicturePileTestBase()
- : background_color_(SK_ColorBLUE),
- min_scale_(0.125),
- frame_number_(0),
- contents_opaque_(false) {}
+ PicturePileTestBase() : min_scale_(0.125), frame_number_(0) {}
void InitializeData() {
pile_.SetTileGridSize(gfx::Size(1000, 1000));
@@ -43,10 +39,9 @@ class PicturePileTestBase {
const gfx::Size& layer_size,
const gfx::Rect& visible_layer_rect) {
frame_number_++;
- return pile_.UpdateAndExpandInvalidation(
- &client_, invalidation, background_color_, contents_opaque_, false,
- layer_size, visible_layer_rect, frame_number_,
- Picture::RECORD_NORMALLY);
+ return pile_.UpdateAndExpandInvalidation(&client_, invalidation, layer_size,
+ visible_layer_rect, frame_number_,
+ Picture::RECORD_NORMALLY);
}
bool UpdateWholePile() {
@@ -59,10 +54,8 @@ class PicturePileTestBase {
FakeContentLayerClient client_;
FakePicturePile pile_;
- SkColor background_color_;
float min_scale_;
int frame_number_;
- bool contents_opaque_;
};
class PicturePileTest : public PicturePileTestBase, public testing::Test {
diff --git a/cc/resources/raster_source.h b/cc/resources/raster_source.h
index f7ea271..5f200db 100644
--- a/cc/resources/raster_source.h
+++ b/cc/resources/raster_source.h
@@ -81,6 +81,9 @@ class CC_EXPORT RasterSource : public base::RefCountedThreadSafe<RasterSource> {
// during rasterization.
virtual void SetShouldAttemptToUseDistanceFieldText() = 0;
+ virtual void SetBackgoundColor(SkColor background_color) = 0;
+ virtual void SetRequiresClear(bool requires_clear) = 0;
+
// Return true iff this raster source would benefit from using distance
// field text.
virtual bool ShouldAttemptToUseDistanceFieldText() const = 0;
@@ -90,9 +93,6 @@ class CC_EXPORT RasterSource : public base::RefCountedThreadSafe<RasterSource> {
virtual void AsValueInto(base::debug::TracedValue* array) const = 0;
virtual skia::RefPtr<SkPicture> GetFlattenedPicture() = 0;
- // TODO(vmpstr): This should be a layer property.
- virtual bool IsMask() const = 0;
-
protected:
friend class base::RefCountedThreadSafe<RasterSource>;
diff --git a/cc/resources/recording_source.h b/cc/resources/recording_source.h
index d2b0893..19eea72 100644
--- a/cc/resources/recording_source.h
+++ b/cc/resources/recording_source.h
@@ -28,23 +28,21 @@ class CC_EXPORT RecordingSource {
virtual bool UpdateAndExpandInvalidation(
ContentLayerClient* painter,
Region* invalidation,
- SkColor background_color,
- bool contents_opaque,
- bool contents_fill_bounds_completely,
const gfx::Size& layer_size,
const gfx::Rect& visible_layer_rect,
int frame_number,
Picture::RecordingMode recording_mode) = 0;
+ virtual scoped_refptr<RasterSource> CreateRasterSource() const = 0;
+
virtual gfx::Size GetSize() const = 0;
virtual void SetEmptyBounds() = 0;
virtual void SetMinContentsScale(float min_contents_scale) = 0;
- virtual void SetTileGridSize(const gfx::Size& tile_grid_size) = 0;
virtual void SetSlowdownRasterScaleFactor(int factor) = 0;
- virtual void SetIsMask(bool is_mask) = 0;
virtual bool IsSuitableForGpuRasterization() const = 0;
- virtual scoped_refptr<RasterSource> CreateRasterSource() const = 0;
+ // TODO(hendrikw): This is an implementation detail, remove it when possible.
+ virtual void SetTileGridSize(const gfx::Size& tile_grid_size) = 0;
// TODO(hendrikw): Figure out how to remove this.
virtual void SetUnsuitableForGpuRasterizationForTesting() = 0;
diff --git a/cc/test/fake_picture_pile.h b/cc/test/fake_picture_pile.h
index 2d8f4bf..4a7b65b 100644
--- a/cc/test/fake_picture_pile.h
+++ b/cc/test/fake_picture_pile.h
@@ -15,6 +15,10 @@ namespace cc {
class FakePicturePile : public PicturePile {
public:
+ using PictureInfo = PicturePile::PictureInfo;
+ using PictureMapKey = PicturePile::PictureMapKey;
+ using PictureMap = PicturePile::PictureMap;
+
FakePicturePile() : playback_allowed_event_(nullptr) {}
~FakePicturePile() override {}
@@ -24,6 +28,8 @@ class FakePicturePile : public PicturePile {
using PicturePile::buffer_pixels;
using PicturePile::CanRasterSlowTileCheck;
using PicturePile::Clear;
+ using PicturePile::SetMinContentsScale;
+ using PicturePile::SetTileGridSize;
PictureMap& picture_map() { return picture_map_; }
const gfx::Rect& recorded_viewport() const { return recorded_viewport_; }
@@ -56,10 +62,6 @@ class FakePicturePile : public PicturePile {
void SetPixelRecordDistance(int d) { pixel_record_distance_ = d; }
- typedef PicturePile::PictureInfo PictureInfo;
- typedef PicturePile::PictureMapKey PictureMapKey;
- typedef PicturePile::PictureMap PictureMap;
-
private:
base::WaitableEvent* playback_allowed_event_;
};
diff --git a/cc/test/fake_picture_pile_impl.h b/cc/test/fake_picture_pile_impl.h
index c32684c..5769d37 100644
--- a/cc/test/fake_picture_pile_impl.h
+++ b/cc/test/fake_picture_pile_impl.h
@@ -68,14 +68,6 @@ class FakePicturePileImpl : public PicturePileImpl {
background_color_ = color;
}
- void set_contents_opaque(bool contents_opaque) {
- contents_opaque_ = contents_opaque;
- }
-
- void set_contents_fill_bounds_completely(bool fills) {
- contents_fill_bounds_completely_ = fills;
- }
-
void set_clear_canvas_with_debug_color(bool clear) {
clear_canvas_with_debug_color_ = clear;
}
@@ -85,7 +77,6 @@ class FakePicturePileImpl : public PicturePileImpl {
}
bool HasRecordingAt(int x, int y) const;
- void SetIsMask(bool mask) { is_mask_ = mask; }
int num_tiles_x() const { return tiling_.num_tiles_x(); }
int num_tiles_y() const { return tiling_.num_tiles_y(); }