Add connectivity check for Android feedback.
[chromium-blink-merge.git] / cc / test / fake_picture_layer_impl.h
blob1a9c6a66866c736f48c26e8a26ef2e2af67ba99e
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::GetRecycledTwinLayer;
87 using PictureLayerImpl::UpdateRasterSource;
89 using PictureLayerImpl::UpdateIdealScales;
90 using PictureLayerImpl::MaximumTilingContentsScale;
92 void AddTilingUntilNextDraw(float scale) {
93 last_append_quads_tilings_.push_back(AddTiling(scale));
96 float raster_page_scale() const { return raster_page_scale_; }
97 void set_raster_page_scale(float scale) { raster_page_scale_ = scale; }
99 float ideal_contents_scale() const { return ideal_contents_scale_; }
100 float raster_contents_scale() const { return raster_contents_scale_; }
102 PictureLayerTiling* HighResTiling() const;
103 PictureLayerTiling* LowResTiling() const;
104 size_t num_tilings() const { return tilings_->num_tilings(); }
106 PictureLayerTilingSet* tilings() { return tilings_.get(); }
107 RasterSource* raster_source() { return raster_source_.get(); }
108 void SetRasterSourceOnPending(scoped_refptr<RasterSource> raster_source,
109 const Region& invalidation);
110 size_t append_quads_count() { return append_quads_count_; }
112 const Region& invalidation() const { return invalidation_; }
113 void set_invalidation(const Region& region) { invalidation_ = region; }
115 gfx::Rect visible_rect_for_tile_priority() {
116 return visible_rect_for_tile_priority_;
119 gfx::Rect viewport_rect_for_tile_priority_in_content_space() {
120 return viewport_rect_for_tile_priority_in_content_space_;
123 void set_fixed_tile_size(const gfx::Size& size) { fixed_tile_size_ = size; }
125 void SetIsDrawnRenderSurfaceLayerListMember(bool is);
127 void CreateAllTiles();
128 void SetAllTilesReady();
129 void SetAllTilesReadyInTiling(PictureLayerTiling* tiling);
130 void SetTileReady(Tile* tile);
131 PictureLayerTilingSet* GetTilings() { return tilings_.get(); }
133 // Add the given tiling as a "used" tiling during AppendQuads. This ensures
134 // that future calls to UpdateTiles don't delete the tiling.
135 void MarkAllTilingsUsed() {
136 last_append_quads_tilings_.clear();
137 for (size_t i = 0; i < tilings_->num_tilings(); ++i)
138 last_append_quads_tilings_.push_back(tilings_->tiling_at(i));
141 size_t release_resources_count() const { return release_resources_count_; }
142 void reset_release_resources_count() { release_resources_count_ = 0; }
144 void ReleaseResources() override;
146 bool only_used_low_res_last_append_quads() const {
147 return only_used_low_res_last_append_quads_;
150 protected:
151 FakePictureLayerImpl(LayerTreeImpl* tree_impl,
152 int id,
153 scoped_refptr<RasterSource> raster_source,
154 bool is_mask);
155 FakePictureLayerImpl(LayerTreeImpl* tree_impl,
156 int id,
157 scoped_refptr<RasterSource> raster_source,
158 bool is_mask,
159 const gfx::Size& layer_bounds);
160 FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id, bool is_mask);
161 FakePictureLayerImpl(
162 LayerTreeImpl* tree_impl,
163 int id,
164 bool is_mask,
165 scoped_refptr<LayerImpl::SyncedScrollOffset> synced_scroll_offset);
167 private:
168 gfx::Size fixed_tile_size_;
170 size_t append_quads_count_;
171 size_t did_become_active_call_count_;
172 bool has_valid_tile_priorities_;
173 bool use_set_valid_tile_priorities_flag_;
174 size_t release_resources_count_;
177 } // namespace cc
179 #endif // CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_