Policy: check MustRemainInstalled in addition to UserMayModifySettings before offerin...
[chromium-blink-merge.git] / cc / test / fake_picture_pile.h
blob55b4c360111fba7970a00c2d7f4411492214423b
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.
5 #ifndef CC_TEST_FAKE_PICTURE_PILE_H_
6 #define CC_TEST_FAKE_PICTURE_PILE_H_
8 #include "cc/resources/picture_pile.h"
10 namespace base {
11 class WaitableEvent;
14 namespace cc {
16 class FakePicturePile : public PicturePile {
17 public:
18 using PictureInfo = PicturePile::PictureInfo;
19 using PictureMapKey = PicturePile::PictureMapKey;
20 using PictureMap = PicturePile::PictureMap;
22 FakePicturePile(float min_contents_scale, const gfx::Size& tile_grid_size)
23 : PicturePile(min_contents_scale, tile_grid_size),
24 playback_allowed_event_(nullptr) {}
25 ~FakePicturePile() override {}
27 // PicturePile overrides.
28 scoped_refptr<RasterSource> CreateRasterSource() const override;
30 using PicturePile::buffer_pixels;
31 using PicturePile::CanRasterSlowTileCheck;
32 using PicturePile::Clear;
33 using PicturePile::SetMinContentsScale;
34 using PicturePile::SetTileGridSize;
36 PictureMap& picture_map() { return picture_map_; }
37 const gfx::Rect& recorded_viewport() const { return recorded_viewport_; }
39 bool CanRasterLayerRect(gfx::Rect layer_rect) {
40 layer_rect.Intersect(gfx::Rect(tiling_.tiling_size()));
41 if (recorded_viewport_.Contains(layer_rect))
42 return true;
43 return CanRasterSlowTileCheck(layer_rect);
46 bool HasRecordings() const { return has_any_recordings_; }
48 void SetRecordedViewport(const gfx::Rect& viewport) {
49 recorded_viewport_ = viewport;
52 void SetHasAnyRecordings(bool has_recordings) {
53 has_any_recordings_ = has_recordings;
56 void SetPlaybackAllowedEvent(base::WaitableEvent* event) {
57 playback_allowed_event_ = event;
60 TilingData& tiling() { return tiling_; }
62 bool is_solid_color() const { return is_solid_color_; }
63 SkColor solid_color() const { return solid_color_; }
65 void SetPixelRecordDistance(int d) { pixel_record_distance_ = d; }
67 private:
68 base::WaitableEvent* playback_allowed_event_;
71 } // namespace cc
73 #endif // CC_TEST_FAKE_PICTURE_PILE_H_