cc: Move update tile priorities to PictureLayerTilingSet.
[chromium-blink-merge.git] / cc / test / fake_picture_pile_impl.h
blobc32684c67b915850a269a42dbc13834704b6cac9
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_TEST_FAKE_PICTURE_PILE_IMPL_H_
6 #define CC_TEST_FAKE_PICTURE_PILE_IMPL_H_
8 #include "base/memory/ref_counted.h"
9 #include "cc/resources/picture_pile_impl.h"
10 #include "cc/test/fake_content_layer_client.h"
12 namespace base {
13 class WaitableEvent;
16 namespace cc {
18 class FakePicturePileImpl : public PicturePileImpl {
19 public:
20 static scoped_refptr<FakePicturePileImpl> CreateFilledPile(
21 const gfx::Size& tile_size,
22 const gfx::Size& layer_bounds);
23 static scoped_refptr<FakePicturePileImpl> CreateEmptyPile(
24 const gfx::Size& tile_size,
25 const gfx::Size& layer_bounds);
26 static scoped_refptr<FakePicturePileImpl>
27 CreateEmptyPileThatThinksItHasRecordings(const gfx::Size& tile_size,
28 const gfx::Size& layer_bounds);
29 static scoped_refptr<FakePicturePileImpl> CreateInfiniteFilledPile();
30 static scoped_refptr<FakePicturePileImpl> CreateFromPile(
31 const PicturePile* other,
32 base::WaitableEvent* playback_allowed_event);
34 // Hi-jack the PlaybackToCanvas method to delay its completion.
35 void PlaybackToCanvas(SkCanvas* canvas,
36 const gfx::Rect& canvas_rect,
37 float contents_scale) const override;
39 TilingData& tiling() { return tiling_; }
41 void AddRecordingAt(int x, int y);
42 void RemoveRecordingAt(int x, int y);
43 void RerecordPile();
45 void add_draw_rect(const gfx::RectF& rect) {
46 client_.add_draw_rect(rect, default_paint_);
49 void add_draw_bitmap(const SkBitmap& bitmap, const gfx::Point& point) {
50 client_.add_draw_bitmap(bitmap, point, default_paint_);
53 void add_draw_rect_with_paint(const gfx::RectF& rect, const SkPaint& paint) {
54 client_.add_draw_rect(rect, paint);
57 void add_draw_bitmap_with_paint(const SkBitmap& bitmap,
58 const gfx::Point& point,
59 const SkPaint& paint) {
60 client_.add_draw_bitmap(bitmap, point, paint);
63 void set_default_paint(const SkPaint& paint) {
64 default_paint_ = paint;
67 void set_background_color(SkColor color) {
68 background_color_ = color;
71 void set_contents_opaque(bool contents_opaque) {
72 contents_opaque_ = contents_opaque;
75 void set_contents_fill_bounds_completely(bool fills) {
76 contents_fill_bounds_completely_ = fills;
79 void set_clear_canvas_with_debug_color(bool clear) {
80 clear_canvas_with_debug_color_ = clear;
83 void set_is_solid_color(bool is_solid_color) {
84 is_solid_color_ = is_solid_color;
87 bool HasRecordingAt(int x, int y) const;
88 void SetIsMask(bool mask) { is_mask_ = mask; }
90 int num_tiles_x() const { return tiling_.num_tiles_x(); }
91 int num_tiles_y() const { return tiling_.num_tiles_y(); }
93 void SetMinContentsScale(float scale);
94 void SetBufferPixels(int new_buffer_pixels);
95 void Clear();
97 protected:
98 FakePicturePileImpl();
99 FakePicturePileImpl(const PicturePile* other,
100 base::WaitableEvent* playback_allowed_event);
101 ~FakePicturePileImpl() override;
103 FakeContentLayerClient client_;
104 SkPaint default_paint_;
105 base::WaitableEvent* playback_allowed_event_;
106 SkTileGridFactory::TileGridInfo tile_grid_info_;
109 } // namespace cc
111 #endif // CC_TEST_FAKE_PICTURE_PILE_IMPL_H_