Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / cc / test / fake_picture_layer_impl.h
blob296cd1a1dd4fc48216e1600cab1a10d982d7a7f5
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_LAYER_IMPL_H_
6 #define CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/layers/picture_layer_impl.h"
11 namespace cc {
13 class FakePictureLayerImpl : public PictureLayerImpl {
14 public:
15 static scoped_ptr<FakePictureLayerImpl> Create(
16 LayerTreeImpl* tree_impl, int id) {
17 bool is_mask = false;
18 return make_scoped_ptr(new FakePictureLayerImpl(tree_impl, id, is_mask));
21 static scoped_ptr<FakePictureLayerImpl> CreateMask(LayerTreeImpl* tree_impl,
22 int id) {
23 bool is_mask = true;
24 return make_scoped_ptr(new FakePictureLayerImpl(tree_impl, id, is_mask));
27 // Create layer from a raster source that covers the entire layer.
28 static scoped_ptr<FakePictureLayerImpl> CreateWithRasterSource(
29 LayerTreeImpl* tree_impl,
30 int id,
31 scoped_refptr<RasterSource> raster_source) {
32 bool is_mask = false;
33 return make_scoped_ptr(
34 new FakePictureLayerImpl(tree_impl, id, raster_source, is_mask));
37 // Create layer from a raster source that only covers part of the layer.
38 static scoped_ptr<FakePictureLayerImpl> CreateWithPartialRasterSource(
39 LayerTreeImpl* tree_impl,
40 int id,
41 scoped_refptr<RasterSource> raster_source,
42 const gfx::Size& layer_bounds) {
43 bool is_mask = false;
44 return make_scoped_ptr(new FakePictureLayerImpl(
45 tree_impl, id, raster_source, is_mask, layer_bounds));
48 // Create layer from a raster source that covers the entire layer and is a
49 // mask.
50 static scoped_ptr<FakePictureLayerImpl> CreateMaskWithRasterSource(
51 LayerTreeImpl* tree_impl,
52 int id,
53 scoped_refptr<RasterSource> raster_source) {
54 bool is_mask = true;
55 return make_scoped_ptr(
56 new FakePictureLayerImpl(tree_impl, id, raster_source, is_mask));
59 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
60 void PushPropertiesTo(LayerImpl* layer_impl) override;
61 void AppendQuads(RenderPass* render_pass,
62 AppendQuadsData* append_quads_data) override;
63 gfx::Size CalculateTileSize(const gfx::Size& content_bounds) const override;
65 void DidBecomeActive() override;
66 size_t did_become_active_call_count() {
67 return did_become_active_call_count_;
70 bool HasValidTilePriorities() const override;
71 void set_has_valid_tile_priorities(bool has_valid_priorities) {
72 has_valid_tile_priorities_ = has_valid_priorities;
73 use_set_valid_tile_priorities_flag_ = true;
76 size_t CountTilesRequired(
77 TileRequirementCheck is_tile_required_callback) const;
78 size_t CountTilesRequiredForActivation() const;
79 size_t CountTilesRequiredForDraw() const;
81 using PictureLayerImpl::AddTiling;
82 using PictureLayerImpl::CleanUpTilingsOnActiveLayer;
83 using PictureLayerImpl::CanHaveTilings;
84 using PictureLayerImpl::MinimumContentsScale;
85 using PictureLayerImpl::SanityCheckTilingState;
86 using PictureLayerImpl::UpdateRasterSource;
88 using PictureLayerImpl::UpdateIdealScales;
89 using PictureLayerImpl::MaximumTilingContentsScale;
91 void AddTilingUntilNextDraw(float scale) {
92 last_append_quads_tilings_.push_back(AddTiling(scale));
95 float raster_page_scale() const { return raster_page_scale_; }
96 void set_raster_page_scale(float scale) { raster_page_scale_ = scale; }
98 float ideal_contents_scale() const { return ideal_contents_scale_; }
99 float raster_contents_scale() const { return raster_contents_scale_; }
101 PictureLayerTiling* HighResTiling() const;
102 PictureLayerTiling* LowResTiling() const;
103 size_t num_tilings() const { return tilings_->num_tilings(); }
105 PictureLayerTilingSet* tilings() { return tilings_.get(); }
106 RasterSource* raster_source() { return raster_source_.get(); }
107 void SetRasterSourceOnPending(scoped_refptr<RasterSource> raster_source,
108 const Region& invalidation);
109 size_t append_quads_count() { return append_quads_count_; }
111 const Region& invalidation() const { return invalidation_; }
112 void set_invalidation(const Region& region) { invalidation_ = region; }
114 gfx::Rect visible_rect_for_tile_priority() {
115 return visible_rect_for_tile_priority_;
118 gfx::Rect viewport_rect_for_tile_priority_in_content_space() {
119 return viewport_rect_for_tile_priority_in_content_space_;
122 void set_fixed_tile_size(const gfx::Size& size) { fixed_tile_size_ = size; }
124 void SetIsDrawnRenderSurfaceLayerListMember(bool is);
126 void CreateAllTiles();
127 void SetAllTilesReady();
128 void SetAllTilesReadyInTiling(PictureLayerTiling* tiling);
129 void SetTileReady(Tile* tile);
130 PictureLayerTilingSet* GetTilings() { return tilings_.get(); }
132 // Add the given tiling as a "used" tiling during AppendQuads. This ensures
133 // that future calls to UpdateTiles don't delete the tiling.
134 void MarkAllTilingsUsed() {
135 last_append_quads_tilings_.clear();
136 for (size_t i = 0; i < tilings_->num_tilings(); ++i)
137 last_append_quads_tilings_.push_back(tilings_->tiling_at(i));
140 size_t release_resources_count() const { return release_resources_count_; }
141 void reset_release_resources_count() { release_resources_count_ = 0; }
143 void ReleaseResources() override;
145 bool only_used_low_res_last_append_quads() const {
146 return only_used_low_res_last_append_quads_;
149 protected:
150 FakePictureLayerImpl(LayerTreeImpl* tree_impl,
151 int id,
152 scoped_refptr<RasterSource> raster_source,
153 bool is_mask);
154 FakePictureLayerImpl(LayerTreeImpl* tree_impl,
155 int id,
156 scoped_refptr<RasterSource> raster_source,
157 bool is_mask,
158 const gfx::Size& layer_bounds);
159 FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id, bool is_mask);
160 FakePictureLayerImpl(
161 LayerTreeImpl* tree_impl,
162 int id,
163 bool is_mask,
164 scoped_refptr<LayerImpl::SyncedScrollOffset> synced_scroll_offset);
166 private:
167 gfx::Size fixed_tile_size_;
169 size_t append_quads_count_;
170 size_t did_become_active_call_count_;
171 bool has_valid_tile_priorities_;
172 bool use_set_valid_tile_priorities_flag_;
173 size_t release_resources_count_;
176 } // namespace cc
178 #endif // CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_