OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_H_ | 5 #ifndef CC_TEST_FAKE_PICTURE_PILE_H_ |
6 #define CC_TEST_FAKE_PICTURE_PILE_H_ | 6 #define CC_TEST_FAKE_PICTURE_PILE_H_ |
7 | 7 |
8 #include "cc/resources/picture_pile.h" | 8 #include "cc/resources/picture_pile.h" |
| 9 #include "cc/test/fake_content_layer_client.h" |
| 10 #include "cc/test/impl_side_painting_settings.h" |
9 | 11 |
10 namespace base { | 12 namespace base { |
11 class WaitableEvent; | 13 class WaitableEvent; |
12 } | 14 } |
13 | 15 |
14 namespace cc { | 16 namespace cc { |
15 | 17 |
16 class FakePicturePile : public PicturePile { | 18 class FakePicturePile : public PicturePile { |
17 public: | 19 public: |
18 using PictureInfo = PicturePile::PictureInfo; | 20 using PictureInfo = PicturePile::PictureInfo; |
19 using PictureMapKey = PicturePile::PictureMapKey; | 21 using PictureMapKey = PicturePile::PictureMapKey; |
20 using PictureMap = PicturePile::PictureMap; | 22 using PictureMap = PicturePile::PictureMap; |
21 | 23 |
22 FakePicturePile(float min_contents_scale, const gfx::Size& tile_grid_size) | 24 FakePicturePile(float min_contents_scale, const gfx::Size& tile_grid_size) |
23 : PicturePile(min_contents_scale, tile_grid_size), | 25 : PicturePile(min_contents_scale, tile_grid_size), |
24 playback_allowed_event_(nullptr) {} | 26 playback_allowed_event_(nullptr) {} |
25 ~FakePicturePile() override {} | 27 ~FakePicturePile() override {} |
26 | 28 |
| 29 static scoped_ptr<FakePicturePile> CreateFilledPile( |
| 30 const gfx::Size& tile_size, |
| 31 const gfx::Size& layer_bounds); |
| 32 static scoped_ptr<FakePicturePile> CreateEmptyPile( |
| 33 const gfx::Size& tile_size, |
| 34 const gfx::Size& layer_bounds); |
| 35 |
27 // PicturePile overrides. | 36 // PicturePile overrides. |
28 scoped_refptr<RasterSource> CreateRasterSource() const override; | 37 scoped_refptr<RasterSource> CreateRasterSource() const override; |
29 | 38 |
30 using PicturePile::buffer_pixels; | 39 using PicturePile::buffer_pixels; |
31 using PicturePile::CanRasterSlowTileCheck; | 40 using PicturePile::CanRasterSlowTileCheck; |
32 using PicturePile::Clear; | 41 using PicturePile::Clear; |
33 using PicturePile::SetMinContentsScale; | 42 using PicturePile::SetMinContentsScale; |
34 using PicturePile::SetTileGridSize; | 43 using PicturePile::SetTileGridSize; |
35 | 44 |
36 PictureMap& picture_map() { return picture_map_; } | 45 PictureMap& picture_map() { return picture_map_; } |
37 const gfx::Rect& recorded_viewport() const { return recorded_viewport_; } | 46 const gfx::Rect& recorded_viewport() const { return recorded_viewport_; } |
38 | 47 |
39 bool CanRasterLayerRect(gfx::Rect layer_rect) { | 48 bool CanRasterLayerRect(gfx::Rect layer_rect) { |
40 layer_rect.Intersect(gfx::Rect(tiling_.tiling_size())); | 49 layer_rect.Intersect(gfx::Rect(tiling_.tiling_size())); |
41 if (recorded_viewport_.Contains(layer_rect)) | 50 if (recorded_viewport_.Contains(layer_rect)) |
42 return true; | 51 return true; |
43 return CanRasterSlowTileCheck(layer_rect); | 52 return CanRasterSlowTileCheck(layer_rect); |
44 } | 53 } |
45 | 54 |
46 bool HasRecordings() const { return has_any_recordings_; } | 55 bool HasRecordings() const { return has_any_recordings_; } |
47 | 56 |
48 void SetRecordedViewport(const gfx::Rect& viewport) { | 57 void SetRecordedViewport(const gfx::Rect& viewport) { |
49 recorded_viewport_ = viewport; | 58 recorded_viewport_ = viewport; |
50 } | 59 } |
51 | 60 |
52 void SetHasAnyRecordings(bool has_recordings) { | 61 void SetHasAnyRecordings(bool has_recordings) { |
53 has_any_recordings_ = has_recordings; | 62 has_any_recordings_ = has_recordings; |
54 } | 63 } |
55 | 64 |
| 65 void SetClearCanvasWithDebugColor(bool clear) { |
| 66 clear_canvas_with_debug_color_ = clear; |
| 67 } |
| 68 |
56 void SetPlaybackAllowedEvent(base::WaitableEvent* event) { | 69 void SetPlaybackAllowedEvent(base::WaitableEvent* event) { |
57 playback_allowed_event_ = event; | 70 playback_allowed_event_ = event; |
58 } | 71 } |
59 | 72 |
60 TilingData& tiling() { return tiling_; } | 73 TilingData& tiling() { return tiling_; } |
61 | 74 |
62 bool is_solid_color() const { return is_solid_color_; } | 75 bool is_solid_color() const { return is_solid_color_; } |
63 SkColor solid_color() const { return solid_color_; } | 76 SkColor solid_color() const { return solid_color_; } |
| 77 void SetIsSolidColor(bool is_solid) { is_solid_color_ = is_solid; } |
64 | 78 |
65 void SetPixelRecordDistance(int d) { pixel_record_distance_ = d; } | 79 void SetPixelRecordDistance(int d) { pixel_record_distance_ = d; } |
66 | 80 |
| 81 void add_draw_rect(const gfx::RectF& rect) { |
| 82 client_.add_draw_rect(rect, default_paint_); |
| 83 } |
| 84 |
| 85 void add_draw_bitmap(const SkBitmap& bitmap, const gfx::Point& point) { |
| 86 client_.add_draw_bitmap(bitmap, point, default_paint_); |
| 87 } |
| 88 |
| 89 void add_draw_rect_with_paint(const gfx::RectF& rect, const SkPaint& paint) { |
| 90 client_.add_draw_rect(rect, paint); |
| 91 } |
| 92 |
| 93 void add_draw_bitmap_with_paint(const SkBitmap& bitmap, |
| 94 const gfx::Point& point, |
| 95 const SkPaint& paint) { |
| 96 client_.add_draw_bitmap(bitmap, point, paint); |
| 97 } |
| 98 |
| 99 void set_default_paint(const SkPaint& paint) { default_paint_ = paint; } |
| 100 |
| 101 void AddRecordingAt(int x, int y); |
| 102 void RemoveRecordingAt(int x, int y); |
| 103 bool HasRecordingAt(int x, int y) const; |
| 104 int num_tiles_x() const { return tiling_.num_tiles_x(); } |
| 105 int num_tiles_y() const { return tiling_.num_tiles_y(); } |
| 106 void RerecordPile(); |
| 107 |
67 private: | 108 private: |
68 base::WaitableEvent* playback_allowed_event_; | 109 base::WaitableEvent* playback_allowed_event_; |
| 110 |
| 111 FakeContentLayerClient client_; |
| 112 SkPaint default_paint_; |
69 }; | 113 }; |
70 | 114 |
71 } // namespace cc | 115 } // namespace cc |
72 | 116 |
73 #endif // CC_TEST_FAKE_PICTURE_PILE_H_ | 117 #endif // CC_TEST_FAKE_PICTURE_PILE_H_ |
OLD | NEW |