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