OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_TEST_FAKE_PICTURE_PILE_IMPL_H_ | 5 #ifndef CC_TEST_FAKE_PICTURE_PILE_IMPL_H_ |
6 #define CC_TEST_FAKE_PICTURE_PILE_IMPL_H_ | 6 #define CC_TEST_FAKE_PICTURE_PILE_IMPL_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "cc/resources/picture_pile_impl.h" | 9 #include "cc/resources/picture_pile_impl.h" |
10 #include "cc/test/fake_content_layer_client.h" | 10 #include "cc/test/fake_content_layer_client.h" |
11 | 11 |
| 12 namespace base { |
| 13 class WaitableEvent; |
| 14 } |
| 15 |
12 namespace cc { | 16 namespace cc { |
13 | 17 |
14 class FakePicturePileImpl : public PicturePileImpl { | 18 class FakePicturePileImpl : public PicturePileImpl { |
15 public: | 19 public: |
16 static scoped_refptr<FakePicturePileImpl> CreateFilledPile( | 20 static scoped_refptr<FakePicturePileImpl> CreateFilledPile( |
17 const gfx::Size& tile_size, | 21 const gfx::Size& tile_size, |
18 const gfx::Size& layer_bounds); | 22 const gfx::Size& layer_bounds); |
19 static scoped_refptr<FakePicturePileImpl> CreateEmptyPile( | 23 static scoped_refptr<FakePicturePileImpl> CreateEmptyPile( |
20 const gfx::Size& tile_size, | 24 const gfx::Size& tile_size, |
21 const gfx::Size& layer_bounds); | 25 const gfx::Size& layer_bounds); |
22 static scoped_refptr<FakePicturePileImpl> | 26 static scoped_refptr<FakePicturePileImpl> |
23 CreateEmptyPileThatThinksItHasRecordings(const gfx::Size& tile_size, | 27 CreateEmptyPileThatThinksItHasRecordings(const gfx::Size& tile_size, |
24 const gfx::Size& layer_bounds); | 28 const gfx::Size& layer_bounds); |
25 static scoped_refptr<FakePicturePileImpl> CreateInfiniteFilledPile(); | 29 static scoped_refptr<FakePicturePileImpl> CreateInfiniteFilledPile(); |
| 30 static scoped_refptr<FakePicturePileImpl> CreateFromPile( |
| 31 const PicturePile* other, |
| 32 base::WaitableEvent* playback_allowed_event); |
| 33 |
| 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; |
26 | 38 |
27 TilingData& tiling() { return tiling_; } | 39 TilingData& tiling() { return tiling_; } |
28 | 40 |
29 void AddRecordingAt(int x, int y); | 41 void AddRecordingAt(int x, int y); |
30 void RemoveRecordingAt(int x, int y); | 42 void RemoveRecordingAt(int x, int y); |
31 void RerecordPile(); | 43 void RerecordPile(); |
32 | 44 |
33 void add_draw_rect(const gfx::RectF& rect) { | 45 void add_draw_rect(const gfx::RectF& rect) { |
34 client_.add_draw_rect(rect, default_paint_); | 46 client_.add_draw_rect(rect, default_paint_); |
35 } | 47 } |
(...skipping 13 matching lines...) Expand all Loading... |
49 } | 61 } |
50 | 62 |
51 void set_default_paint(const SkPaint& paint) { | 63 void set_default_paint(const SkPaint& paint) { |
52 default_paint_ = paint; | 64 default_paint_ = paint; |
53 } | 65 } |
54 | 66 |
55 void set_background_color(SkColor color) { | 67 void set_background_color(SkColor color) { |
56 background_color_ = color; | 68 background_color_ = color; |
57 } | 69 } |
58 | 70 |
59 void set_contents_opaque(bool contents_opaque) { | |
60 contents_opaque_ = contents_opaque; | |
61 } | |
62 | |
63 void set_contents_fill_bounds_completely(bool fills) { | |
64 contents_fill_bounds_completely_ = fills; | |
65 } | |
66 | |
67 void set_clear_canvas_with_debug_color(bool clear) { | 71 void set_clear_canvas_with_debug_color(bool clear) { |
68 clear_canvas_with_debug_color_ = clear; | 72 clear_canvas_with_debug_color_ = clear; |
69 } | 73 } |
70 | 74 |
71 void set_is_solid_color(bool is_solid_color) { | 75 void set_is_solid_color(bool is_solid_color) { |
72 is_solid_color_ = is_solid_color; | 76 is_solid_color_ = is_solid_color; |
73 } | 77 } |
74 | 78 |
75 bool HasRecordingAt(int x, int y) const; | 79 bool HasRecordingAt(int x, int y) const; |
76 void SetIsMask(bool mask) { is_mask_ = mask; } | |
77 | 80 |
78 int num_tiles_x() const { return tiling_.num_tiles_x(); } | 81 int num_tiles_x() const { return tiling_.num_tiles_x(); } |
79 int num_tiles_y() const { return tiling_.num_tiles_y(); } | 82 int num_tiles_y() const { return tiling_.num_tiles_y(); } |
80 | 83 |
81 void SetMinContentsScale(float scale); | 84 void SetMinContentsScale(float scale); |
82 void SetBufferPixels(int new_buffer_pixels); | 85 void SetBufferPixels(int new_buffer_pixels); |
83 void Clear(); | 86 void Clear(); |
84 | 87 |
85 protected: | 88 protected: |
86 FakePicturePileImpl(); | 89 FakePicturePileImpl(); |
87 explicit FakePicturePileImpl(const PicturePile* other); | 90 FakePicturePileImpl(const PicturePile* other, |
| 91 base::WaitableEvent* playback_allowed_event); |
88 ~FakePicturePileImpl() override; | 92 ~FakePicturePileImpl() override; |
89 | 93 |
90 FakeContentLayerClient client_; | 94 FakeContentLayerClient client_; |
91 SkPaint default_paint_; | 95 SkPaint default_paint_; |
| 96 base::WaitableEvent* playback_allowed_event_; |
92 SkTileGridFactory::TileGridInfo tile_grid_info_; | 97 SkTileGridFactory::TileGridInfo tile_grid_info_; |
93 }; | 98 }; |
94 | 99 |
95 } // namespace cc | 100 } // namespace cc |
96 | 101 |
97 #endif // CC_TEST_FAKE_PICTURE_PILE_IMPL_H_ | 102 #endif // CC_TEST_FAKE_PICTURE_PILE_IMPL_H_ |
OLD | NEW |