| Index: cc/test/fake_display_list_recording_source.h
|
| diff --git a/cc/test/fake_display_list_recording_source.h b/cc/test/fake_display_list_recording_source.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b9a15f327884e455d3fd7f876b283378a501360a
|
| --- /dev/null
|
| +++ b/cc/test/fake_display_list_recording_source.h
|
| @@ -0,0 +1,88 @@
|
| +// 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.
|
| +
|
| +#ifndef CC_TEST_FAKE_DISPLAY_LIST_RECORDING_SOURCE_H_
|
| +#define CC_TEST_FAKE_DISPLAY_LIST_RECORDING_SOURCE_H_
|
| +
|
| +#include "cc/resources/display_list_recording_source.h"
|
| +#include "cc/test/fake_content_layer_client.h"
|
| +#include "cc/test/impl_side_painting_settings.h"
|
| +
|
| +namespace cc {
|
| +
|
| +// This class provides method for test to add bitmap and draw rect to content
|
| +// layer client. This class also provides function to rerecord to generate a new
|
| +// display list.
|
| +class FakeDisplayListRecordingSource : public DisplayListRecordingSource {
|
| + public:
|
| + explicit FakeDisplayListRecordingSource(const gfx::Size& grid_cell_size)
|
| + : DisplayListRecordingSource(grid_cell_size) {}
|
| + ~FakeDisplayListRecordingSource() override {}
|
| +
|
| + static scoped_ptr<FakeDisplayListRecordingSource> CreateRecordingSource(
|
| + const gfx::Rect& recorded_viewport) {
|
| + scoped_ptr<FakeDisplayListRecordingSource> recording_source(
|
| + new FakeDisplayListRecordingSource(
|
| + ImplSidePaintingSettings().default_tile_grid_size));
|
| + recording_source->SetRecordedViewport(recorded_viewport);
|
| + return recording_source;
|
| + }
|
| +
|
| + void SetRecordedViewport(const gfx::Rect& recorded_viewport) {
|
| + recorded_viewport_ = recorded_viewport;
|
| + }
|
| +
|
| + void SetGridCellSize(const gfx::Size& grid_cell_size) {
|
| + grid_cell_size_ = grid_cell_size;
|
| + }
|
| +
|
| + void Rerecord() {
|
| + ContentLayerClient::PaintingControlSetting painting_control =
|
| + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL;
|
| + display_list_ = client_.PaintContentsToDisplayList(recorded_viewport_,
|
| + painting_control);
|
| + display_list_->set_layer_rect(recorded_viewport_);
|
| + display_list_->CreateAndCacheSkPicture();
|
| + display_list_->GatherPixelRefs(grid_cell_size_);
|
| + }
|
| +
|
| + void add_draw_rect(const gfx::RectF& rect) {
|
| + client_.add_draw_rect(rect, default_paint_);
|
| + }
|
| +
|
| + void add_draw_rect_with_paint(const gfx::RectF& rect, const SkPaint& paint) {
|
| + client_.add_draw_rect(rect, paint);
|
| + }
|
| +
|
| + void add_draw_bitmap(const SkBitmap& bitmap, const gfx::Point& point) {
|
| + client_.add_draw_bitmap(bitmap, point, default_paint_);
|
| + }
|
| +
|
| + void add_draw_bitmap_with_transform(const SkBitmap& bitmap,
|
| + const gfx::Transform& transform) {
|
| + client_.add_draw_bitmap_with_transform(bitmap, transform, default_paint_);
|
| + }
|
| +
|
| + void add_draw_bitmap_with_paint(const SkBitmap& bitmap,
|
| + const gfx::Point& point,
|
| + const SkPaint& paint) {
|
| + client_.add_draw_bitmap(bitmap, point, paint);
|
| + }
|
| +
|
| + void add_draw_bitmap_with_paint_and_transform(const SkBitmap& bitmap,
|
| + const gfx::Transform& transform,
|
| + const SkPaint& paint) {
|
| + client_.add_draw_bitmap_with_transform(bitmap, transform, paint);
|
| + }
|
| +
|
| + void set_default_paint(const SkPaint& paint) { default_paint_ = paint; }
|
| +
|
| + private:
|
| + FakeContentLayerClient client_;
|
| + SkPaint default_paint_;
|
| +};
|
| +
|
| +} // namespace cc
|
| +
|
| +#endif // CC_TEST_FAKE_DISPLAY_LIST_RECORDING_SOURCE_H_
|
|
|