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"
13 class FakePictureLayerImpl
: public PictureLayerImpl
{
15 static scoped_ptr
<FakePictureLayerImpl
> Create(
16 LayerTreeImpl
* tree_impl
, int id
) {
18 return make_scoped_ptr(new FakePictureLayerImpl(tree_impl
, id
, is_mask
));
21 // Create layer from a raster source that covers the entire layer.
22 static scoped_ptr
<FakePictureLayerImpl
> CreateWithRasterSource(
23 LayerTreeImpl
* tree_impl
,
25 scoped_refptr
<RasterSource
> raster_source
) {
27 return make_scoped_ptr(
28 new FakePictureLayerImpl(tree_impl
, id
, raster_source
, is_mask
));
31 // Create layer from a raster source that only covers part of the layer.
32 static scoped_ptr
<FakePictureLayerImpl
> CreateWithPartialRasterSource(
33 LayerTreeImpl
* tree_impl
,
35 scoped_refptr
<RasterSource
> raster_source
,
36 const gfx::Size
& layer_bounds
) {
38 return make_scoped_ptr(new FakePictureLayerImpl(
39 tree_impl
, id
, raster_source
, is_mask
, layer_bounds
));
42 // Create layer from a raster source that covers the entire layer and is a
44 static scoped_ptr
<FakePictureLayerImpl
> CreateMaskWithRasterSource(
45 LayerTreeImpl
* tree_impl
,
47 scoped_refptr
<RasterSource
> raster_source
) {
49 return make_scoped_ptr(
50 new FakePictureLayerImpl(tree_impl
, id
, raster_source
, is_mask
));
53 scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
) override
;
54 void PushPropertiesTo(LayerImpl
* layer_impl
) override
;
55 void AppendQuads(RenderPass
* render_pass
,
56 AppendQuadsData
* append_quads_data
) override
;
57 gfx::Size
CalculateTileSize(const gfx::Size
& content_bounds
) const override
;
59 void DidBecomeActive() override
;
60 size_t did_become_active_call_count() {
61 return did_become_active_call_count_
;
64 bool HasValidTilePriorities() const override
;
65 void set_has_valid_tile_priorities(bool has_valid_priorities
) {
66 has_valid_tile_priorities_
= has_valid_priorities
;
67 use_set_valid_tile_priorities_flag_
= true;
70 size_t CountTilesRequired(
71 TileRequirementCheck is_tile_required_callback
) const;
72 size_t CountTilesRequiredForActivation() const;
73 size_t CountTilesRequiredForDraw() const;
75 using PictureLayerImpl::AddTiling
;
76 using PictureLayerImpl::CleanUpTilingsOnActiveLayer
;
77 using PictureLayerImpl::CanHaveTilings
;
78 using PictureLayerImpl::MinimumContentsScale
;
79 using PictureLayerImpl::SanityCheckTilingState
;
80 using PictureLayerImpl::GetRecycledTwinLayer
;
81 using PictureLayerImpl::UpdateRasterSource
;
83 using PictureLayerImpl::UpdateIdealScales
;
84 using PictureLayerImpl::MaximumTilingContentsScale
;
86 float raster_page_scale() const { return raster_page_scale_
; }
87 void set_raster_page_scale(float scale
) { raster_page_scale_
= scale
; }
89 float ideal_contents_scale() const { return ideal_contents_scale_
; }
90 float raster_contents_scale() const { return raster_contents_scale_
; }
92 PictureLayerTiling
* HighResTiling() const;
93 PictureLayerTiling
* LowResTiling() const;
94 size_t num_tilings() const { return tilings_
->num_tilings(); }
96 PictureLayerTilingSet
* tilings() { return tilings_
.get(); }
97 RasterSource
* raster_source() { return raster_source_
.get(); }
98 void SetRasterSourceOnPending(scoped_refptr
<RasterSource
> raster_source
,
99 const Region
& invalidation
);
100 size_t append_quads_count() { return append_quads_count_
; }
102 const Region
& invalidation() const { return invalidation_
; }
103 void set_invalidation(const Region
& region
) { invalidation_
= region
; }
105 gfx::Rect
visible_rect_for_tile_priority() {
106 return visible_rect_for_tile_priority_
;
109 gfx::Rect
viewport_rect_for_tile_priority_in_content_space() {
110 return viewport_rect_for_tile_priority_in_content_space_
;
113 void set_fixed_tile_size(const gfx::Size
& size
) { fixed_tile_size_
= size
; }
115 void SetIsDrawnRenderSurfaceLayerListMember(bool is
);
117 void CreateAllTiles();
118 void SetAllTilesVisible();
119 void SetAllTilesReady();
120 void SetAllTilesReadyInTiling(PictureLayerTiling
* tiling
);
121 void SetTileReady(Tile
* tile
);
122 void ResetAllTilesPriorities();
123 PictureLayerTilingSet
* GetTilings() { return tilings_
.get(); }
125 // Add the given tiling as a "used" tiling during AppendQuads. This ensures
126 // that future calls to UpdateTiles don't delete the tiling.
127 void MarkAllTilingsUsed() {
128 last_append_quads_tilings_
.clear();
129 for (size_t i
= 0; i
< tilings_
->num_tilings(); ++i
)
130 last_append_quads_tilings_
.push_back(tilings_
->tiling_at(i
));
133 size_t release_resources_count() const { return release_resources_count_
; }
134 void reset_release_resources_count() { release_resources_count_
= 0; }
136 void ReleaseResources() override
;
138 bool only_used_low_res_last_append_quads() const {
139 return only_used_low_res_last_append_quads_
;
143 FakePictureLayerImpl(LayerTreeImpl
* tree_impl
,
145 scoped_refptr
<RasterSource
> raster_source
,
147 FakePictureLayerImpl(LayerTreeImpl
* tree_impl
,
149 scoped_refptr
<RasterSource
> raster_source
,
151 const gfx::Size
& layer_bounds
);
152 FakePictureLayerImpl(LayerTreeImpl
* tree_impl
, int id
, bool is_mask
);
153 FakePictureLayerImpl(
154 LayerTreeImpl
* tree_impl
,
157 scoped_refptr
<LayerImpl::SyncedScrollOffset
> synced_scroll_offset
);
160 gfx::Size fixed_tile_size_
;
162 size_t append_quads_count_
;
163 size_t did_become_active_call_count_
;
164 bool has_valid_tile_priorities_
;
165 bool use_set_valid_tile_priorities_flag_
;
166 size_t release_resources_count_
;
171 #endif // CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_