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 const Occlusion
& occlusion_in_content_space
,
57 AppendQuadsData
* append_quads_data
) override
;
58 gfx::Size
CalculateTileSize(const gfx::Size
& content_bounds
) const override
;
60 void DidBecomeActive() override
;
61 size_t did_become_active_call_count() {
62 return did_become_active_call_count_
;
65 bool HasValidTilePriorities() const override
;
66 void set_has_valid_tile_priorities(bool has_valid_priorities
) {
67 has_valid_tile_priorities_
= has_valid_priorities
;
68 use_set_valid_tile_priorities_flag_
= true;
71 size_t CountTilesRequired(
72 TileRequirementCheck is_tile_required_callback
) const;
73 size_t CountTilesRequiredForActivation() const;
74 size_t CountTilesRequiredForDraw() const;
76 using PictureLayerImpl::AddTiling
;
77 using PictureLayerImpl::CleanUpTilingsOnActiveLayer
;
78 using PictureLayerImpl::CanHaveTilings
;
79 using PictureLayerImpl::MinimumContentsScale
;
80 using PictureLayerImpl::SanityCheckTilingState
;
81 using PictureLayerImpl::GetRecycledTwinLayer
;
82 using PictureLayerImpl::UpdateRasterSource
;
84 using PictureLayerImpl::UpdateIdealScales
;
85 using PictureLayerImpl::MaximumTilingContentsScale
;
87 float raster_page_scale() const { return raster_page_scale_
; }
88 void set_raster_page_scale(float scale
) { raster_page_scale_
= scale
; }
90 float ideal_contents_scale() const { return ideal_contents_scale_
; }
91 float raster_contents_scale() const { return raster_contents_scale_
; }
93 PictureLayerTiling
* HighResTiling() const;
94 PictureLayerTiling
* LowResTiling() const;
95 size_t num_tilings() const { return tilings_
->num_tilings(); }
97 PictureLayerTilingSet
* tilings() { return tilings_
.get(); }
98 RasterSource
* raster_source() { return raster_source_
.get(); }
99 void SetRasterSourceOnPending(scoped_refptr
<RasterSource
> raster_source
,
100 const Region
& invalidation
);
101 size_t append_quads_count() { return append_quads_count_
; }
103 const Region
& invalidation() const { return invalidation_
; }
104 void set_invalidation(const Region
& region
) { invalidation_
= region
; }
106 gfx::Rect
visible_rect_for_tile_priority() {
107 return visible_rect_for_tile_priority_
;
110 gfx::Rect
viewport_rect_for_tile_priority_in_content_space() {
111 return viewport_rect_for_tile_priority_in_content_space_
;
114 void set_fixed_tile_size(const gfx::Size
& size
) { fixed_tile_size_
= size
; }
116 void CreateAllTiles();
117 void SetAllTilesVisible();
118 void SetAllTilesReady();
119 void SetAllTilesReadyInTiling(PictureLayerTiling
* tiling
);
120 void SetTileReady(Tile
* tile
);
121 void ResetAllTilesPriorities();
122 PictureLayerTilingSet
* GetTilings() { return tilings_
.get(); }
124 size_t release_resources_count() const { return release_resources_count_
; }
125 void reset_release_resources_count() { release_resources_count_
= 0; }
127 void ReleaseResources() override
;
129 bool only_used_low_res_last_append_quads() const {
130 return only_used_low_res_last_append_quads_
;
134 FakePictureLayerImpl(LayerTreeImpl
* tree_impl
,
136 scoped_refptr
<RasterSource
> raster_source
,
138 FakePictureLayerImpl(LayerTreeImpl
* tree_impl
,
140 scoped_refptr
<RasterSource
> raster_source
,
142 const gfx::Size
& layer_bounds
);
143 FakePictureLayerImpl(LayerTreeImpl
* tree_impl
, int id
, bool is_mask
);
146 gfx::Size fixed_tile_size_
;
148 size_t append_quads_count_
;
149 size_t did_become_active_call_count_
;
150 bool has_valid_tile_priorities_
;
151 bool use_set_valid_tile_priorities_flag_
;
152 size_t release_resources_count_
;
157 #endif // CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_