Skip to content

Commit

Permalink
Remove non-slimming-paint codepaths in chrome
Browse files Browse the repository at this point in the history
Slimming paint has shipped so the non-sp codepaths are rapidly rotting.
This patch removes the slimming paint codepaths in chrome while leaving
the removal of PicturePile and ContentLayerClient::PaintContents to a
followup.

BUG=524314
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

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

Cr-Commit-Position: refs/heads/master@{#349168}
  • Loading branch information
progers authored and Commit bot committed Sep 16, 2015
1 parent c9d5f86 commit b42dfda
Show file tree
Hide file tree
Showing 28 changed files with 172 additions and 212 deletions.
1 change: 0 additions & 1 deletion blimp/common/compositor/blimp_layer_tree_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ void PopulateCommonLayerTreeSettings(cc::LayerTreeSettings* settings) {
!cmd.HasSwitch(cc::switches::kDisableMainFrameBeforeActivation);
settings->accelerated_animation_enabled =
!cmd.HasSwitch(cc::switches::kDisableThreadedAnimation);
settings->use_display_lists = cmd.HasSwitch(switches::kEnableSlimmingPaint);

settings->default_tile_size = gfx::Size(256, 256);
if (cmd.HasSwitch(switches::kDefaultTileWidth)) {
Expand Down
1 change: 1 addition & 0 deletions cc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ source_set("test_support") {
"test/fake_delegated_renderer_layer.h",
"test/fake_delegated_renderer_layer_impl.cc",
"test/fake_delegated_renderer_layer_impl.h",
"test/fake_display_list_recording_source.cc",
"test/fake_display_list_recording_source.h",
"test/fake_external_begin_frame_source.cc",
"test/fake_external_begin_frame_source.h",
Expand Down
1 change: 1 addition & 0 deletions cc/cc_tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
'test/fake_delegated_renderer_layer.h',
'test/fake_delegated_renderer_layer_impl.cc',
'test/fake_delegated_renderer_layer_impl.h',
'test/fake_display_list_recording_source.cc',
'test/fake_display_list_recording_source.h',
'test/fake_external_begin_frame_source.cc',
'test/fake_external_begin_frame_source.h',
Expand Down
68 changes: 1 addition & 67 deletions cc/debug/rasterize_and_record_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,80 +114,14 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) {
if (visible_layer_rect.IsEmpty())
return;

if (host_->settings().use_display_lists) {
RunOnDisplayListLayer(layer, visible_layer_rect);
} else {
RunOnPictureLayer(layer, visible_layer_rect);
}
}

void RasterizeAndRecordBenchmark::RunOnPictureLayer(
PictureLayer* layer,
const gfx::Rect& visible_layer_rect) {
ContentLayerClient* painter = layer->client();

DCHECK(host_ && !host_->settings().use_display_lists);

gfx::Size tile_grid_size = host_->settings().default_tile_size;

for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT;
mode_index++) {
RecordingSource::RecordingMode mode =
static_cast<RecordingSource::RecordingMode>(mode_index);

// Not supported for SkPicture recording.
if (mode == RecordingSource::RECORD_WITH_CONSTRUCTION_DISABLED)
continue;

base::TimeDelta min_time = base::TimeDelta::Max();
size_t memory_used = 0;

for (int i = 0; i < record_repeat_count_; ++i) {
// Run for a minimum amount of time to avoid problems with timer
// quantization when the layer is very small.
LapTimer timer(kWarmupRuns,
base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
kTimeCheckInterval);
scoped_refptr<Picture> picture;
do {
picture = Picture::Create(visible_layer_rect, painter, tile_grid_size,
false, mode);
if (picture->ShouldBeAnalyzedForSolidColor()) {
gfx::Size layer_size = layer->paint_properties().bounds;
skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height());
picture->Raster(&canvas, nullptr, gfx::Rect(), 1.f);
}
if (memory_used) {
// Verify we are recording the same thing each time.
DCHECK(memory_used == picture->ApproximateMemoryUsage());
} else {
memory_used = picture->ApproximateMemoryUsage();
}

timer.NextLap();
} while (!timer.HasTimeLimitExpired());
base::TimeDelta duration =
base::TimeDelta::FromMillisecondsD(timer.MsPerLap());
if (duration < min_time)
min_time = duration;
}

if (mode == RecordingSource::RECORD_NORMALLY) {
record_results_.bytes_used += memory_used;
record_results_.pixels_recorded +=
visible_layer_rect.width() * visible_layer_rect.height();
}
record_results_.total_best_time[mode_index] += min_time;
}
RunOnDisplayListLayer(layer, visible_layer_rect);
}

void RasterizeAndRecordBenchmark::RunOnDisplayListLayer(
PictureLayer* layer,
const gfx::Rect& visible_layer_rect) {
ContentLayerClient* painter = layer->client();

DCHECK(host_ && host_->settings().use_display_lists);

for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT;
mode_index++) {
ContentLayerClient::PaintingControlSetting painting_control =
Expand Down
2 changes: 0 additions & 2 deletions cc/debug/rasterize_and_record_benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class RasterizeAndRecordBenchmark : public MicroBenchmark {
private:
void RunOnDisplayListLayer(PictureLayer* layer,
const gfx::Rect& visible_layer_rect);
void RunOnPictureLayer(PictureLayer* layer,
const gfx::Rect& visible_layer_rect);

void RecordRasterResults(scoped_ptr<base::Value> results);

Expand Down
41 changes: 11 additions & 30 deletions cc/layers/picture_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,8 @@ void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) {

const LayerTreeSettings& settings = layer_tree_host()->settings();
if (!recording_source_) {
if (settings.use_display_lists) {
recording_source_.reset(
new DisplayListRecordingSource(settings.default_tile_grid_size));
} else {
recording_source_.reset(new PicturePile(settings.minimum_contents_scale,
settings.default_tile_grid_size));
}
recording_source_.reset(
new DisplayListRecordingSource(settings.default_tile_grid_size));
}
recording_source_->SetSlowdownRasterScaleFactor(
host->debug_state().slow_down_raster_scale_factor);
Expand Down Expand Up @@ -183,31 +178,17 @@ skia::RefPtr<SkPicture> PictureLayer::GetPicture() const {
gfx::Size layer_size = bounds();
const LayerTreeSettings& settings = layer_tree_host()->settings();

if (settings.use_display_lists) {
scoped_ptr<RecordingSource> recording_source;
recording_source.reset(
new DisplayListRecordingSource(settings.default_tile_grid_size));
Region recording_invalidation;
recording_source->UpdateAndExpandInvalidation(
client_, &recording_invalidation, layer_size, gfx::Rect(layer_size),
update_source_frame_number_, RecordingSource::RECORD_NORMALLY);

scoped_refptr<RasterSource> raster_source =
recording_source->CreateRasterSource(false);

return raster_source->GetFlattenedPicture();
}
scoped_ptr<RecordingSource> recording_source(
new DisplayListRecordingSource(settings.default_tile_grid_size));
Region recording_invalidation;
recording_source->UpdateAndExpandInvalidation(
client_, &recording_invalidation, layer_size, gfx::Rect(layer_size),
update_source_frame_number_, RecordingSource::RECORD_NORMALLY);

int width = layer_size.width();
int height = layer_size.height();
scoped_refptr<RasterSource> raster_source =
recording_source->CreateRasterSource(false);

SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0);
client_->PaintContents(canvas, gfx::Rect(width, height),
ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(recorder.endRecordingAsPicture());
return picture;
return raster_source->GetFlattenedPicture();
}

bool PictureLayer::IsSuitableForGpuRasterization() const {
Expand Down
23 changes: 1 addition & 22 deletions cc/layers/picture_layer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class MockContentLayerClient : public ContentLayerClient {
scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
const gfx::Rect& clip,
PaintingControlSetting picture_control) override {
NOTIMPLEMENTED();
return nullptr;
return DisplayItemList::Create(clip, false);
}
bool FillsBoundsCompletely() const override { return false; };
size_t GetApproximateUnsharedMemoryUsage() const override { return 0; }
Expand Down Expand Up @@ -98,26 +97,6 @@ TEST(PictureLayerTest, SuitableForGpuRasterization) {
EXPECT_FALSE(layer->IsSuitableForGpuRasterization());
}

TEST(PictureLayerTest, UseTileGridSize) {
LayerTreeSettings settings;
settings.default_tile_grid_size = gfx::Size(123, 123);

MockContentLayerClient client;
scoped_refptr<PictureLayer> layer =
PictureLayer::Create(LayerSettings(), &client);
FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D);
TestTaskGraphRunner task_graph_runner;
scoped_ptr<FakeLayerTreeHost> host =
FakeLayerTreeHost::Create(&host_client, &task_graph_runner, settings);
host->SetRootLayer(layer);

// Tile-grid is set according to its setting.
gfx::Size size =
layer->GetRecordingSourceForTesting()->GetTileGridSizeForTesting();
EXPECT_EQ(size.width(), 123);
EXPECT_EQ(size.height(), 123);
}

// PicturePile uses the source frame number as a unit for measuring invalidation
// frequency. When a pile moves between compositors, the frame number increases
// non-monotonically. This executes that code path under this scenario allowing
Expand Down
4 changes: 0 additions & 4 deletions cc/playback/display_list_recording_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,6 @@ scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource(
this, can_use_lcd_text));
}

gfx::Size DisplayListRecordingSource::GetTileGridSizeForTesting() const {
return gfx::Size();
}

void DisplayListRecordingSource::DetermineIfSolidColor() {
DCHECK(display_list_.get());
is_solid_color_ = false;
Expand Down
1 change: 0 additions & 1 deletion cc/playback/display_list_recording_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class CC_EXPORT DisplayListRecordingSource : public RecordingSource {
void SetRequiresClear(bool requires_clear) override;
bool IsSuitableForGpuRasterization() const override;
void SetUnsuitableForGpuRasterizationForTesting() override;
gfx::Size GetTileGridSizeForTesting() const override;
// Returns true if the new recorded viewport exposes enough new area to be
// worth re-recording.
static bool ExposesEnoughNewArea(
Expand Down
4 changes: 0 additions & 4 deletions cc/playback/picture_pile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,6 @@ void PicturePile::SetUnsuitableForGpuRasterizationForTesting() {
is_suitable_for_gpu_rasterization_ = false;
}

gfx::Size PicturePile::GetTileGridSizeForTesting() const {
return tile_grid_size_;
}

bool PicturePile::CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const {
bool include_borders = false;
for (TilingData::Iterator tile_iter(&tiling_, layer_rect, include_borders);
Expand Down
1 change: 0 additions & 1 deletion cc/playback/picture_pile.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class CC_EXPORT PicturePile : public RecordingSource {
void SetRequiresClear(bool requires_clear) override;
bool IsSuitableForGpuRasterization() const override;
void SetUnsuitableForGpuRasterizationForTesting() override;
gfx::Size GetTileGridSizeForTesting() const override;

typedef std::pair<int, int> PictureMapKey;
typedef base::hash_map<PictureMapKey, scoped_refptr<const Picture>>
Expand Down
1 change: 0 additions & 1 deletion cc/playback/recording_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class CC_EXPORT RecordingSource {

// TODO(hendrikw): Figure out how to remove this.
virtual void SetUnsuitableForGpuRasterizationForTesting() = 0;
virtual gfx::Size GetTileGridSizeForTesting() const = 0;
};

} // namespace cc
Expand Down
20 changes: 20 additions & 0 deletions cc/test/fake_display_list_recording_source.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/test/fake_display_list_recording_source.h"

namespace cc {

bool FakeDisplayListRecordingSource::IsSuitableForGpuRasterization() const {
if (force_unsuitable_for_gpu_rasterization_)
return false;
return DisplayListRecordingSource::IsSuitableForGpuRasterization();
}

void FakeDisplayListRecordingSource::
SetUnsuitableForGpuRasterizationForTesting() {
force_unsuitable_for_gpu_rasterization_ = true;
}

} // namespace cc
7 changes: 6 additions & 1 deletion cc/test/fake_display_list_recording_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ namespace cc {
class FakeDisplayListRecordingSource : public DisplayListRecordingSource {
public:
explicit FakeDisplayListRecordingSource(const gfx::Size& grid_cell_size)
: DisplayListRecordingSource(grid_cell_size) {}
: DisplayListRecordingSource(grid_cell_size),
force_unsuitable_for_gpu_rasterization_(false) {}
~FakeDisplayListRecordingSource() override {}

static scoped_ptr<FakeDisplayListRecordingSource> CreateRecordingSource(
Expand Down Expand Up @@ -93,9 +94,13 @@ class FakeDisplayListRecordingSource : public DisplayListRecordingSource {
client_.set_reported_memory_usage(reported_memory_usage);
}

bool IsSuitableForGpuRasterization() const override;
void SetUnsuitableForGpuRasterizationForTesting() override;

private:
FakeContentLayerClient client_;
SkPaint default_paint_;
bool force_unsuitable_for_gpu_rasterization_;
};

} // namespace cc
Expand Down
4 changes: 1 addition & 3 deletions cc/test/fake_picture_pile_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ FakePicturePileImpl::FakePicturePileImpl(
const PicturePile* other,
base::WaitableEvent* playback_allowed_event)
: PicturePileImpl(other, true),
playback_allowed_event_(playback_allowed_event),
tile_grid_size_(other->GetTileGridSizeForTesting()) {
}
playback_allowed_event_(playback_allowed_event) {}

FakePicturePileImpl::~FakePicturePileImpl() {}

Expand Down
1 change: 0 additions & 1 deletion cc/test/fake_picture_pile_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class FakePicturePileImpl : public PicturePileImpl {
~FakePicturePileImpl() override;

base::WaitableEvent* playback_allowed_event_;
gfx::Size tile_grid_size_;
};

} // namespace cc
Expand Down
38 changes: 29 additions & 9 deletions cc/test/solid_color_content_layer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,53 @@

#include "cc/test/solid_color_content_layer_client.h"

#include "cc/playback/drawing_display_item.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/skia_util.h"

namespace cc {

// TODO(pdr): Remove PaintContents as all calls should go through
// PaintContentsToDisplayList.
void SolidColorContentLayerClient::PaintContents(
SkCanvas* canvas,
const gfx::Rect& rect,
PaintingControlSetting painting_control) {
scoped_refptr<DisplayItemList> contents =
PaintContentsToDisplayList(rect, painting_control);
contents->Raster(canvas, nullptr, rect, 1.0f);
}

scoped_refptr<DisplayItemList>
SolidColorContentLayerClient::PaintContentsToDisplayList(
const gfx::Rect& clip,
PaintingControlSetting painting_control) {
SkPictureRecorder recorder;
skia::RefPtr<SkCanvas> canvas =
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(clip)));

SkPaint paint;
paint.setStyle(SkPaint::kFill_Style);
paint.setColor(color_);

canvas->clear(SK_ColorTRANSPARENT);
canvas->drawRect(
SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()),
paint);
}
SkRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height()), paint);

scoped_refptr<DisplayItemList>
SolidColorContentLayerClient::PaintContentsToDisplayList(
const gfx::Rect& clip,
PaintingControlSetting painting_control) {
NOTIMPLEMENTED();
return nullptr;
scoped_refptr<DisplayItemList> display_list =
DisplayItemList::Create(clip, false);
auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>();

skia::RefPtr<SkPicture> picture =
skia::AdoptRef(recorder.endRecordingAsPicture());
item->SetNew(picture.Pass());

display_list->Finalize();
return display_list;
}

bool SolidColorContentLayerClient::FillsBoundsCompletely() const {
Expand Down
Loading

0 comments on commit b42dfda

Please sign in to comment.