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
) {
17 return make_scoped_ptr(new FakePictureLayerImpl(tree_impl
, id
));
20 // Create layer from a raster source that covers the entire layer.
21 static scoped_ptr
<FakePictureLayerImpl
> CreateWithRasterSource(
22 LayerTreeImpl
* tree_impl
,
24 scoped_refptr
<RasterSource
> raster_source
) {
25 return make_scoped_ptr(
26 new FakePictureLayerImpl(tree_impl
, id
, raster_source
));
29 // Create layer from a raster source that only covers part of the layer.
30 static scoped_ptr
<FakePictureLayerImpl
> CreateWithPartialRasterSource(
31 LayerTreeImpl
* tree_impl
,
33 scoped_refptr
<RasterSource
> raster_source
,
34 const gfx::Size
& layer_bounds
) {
35 return make_scoped_ptr(
36 new FakePictureLayerImpl(tree_impl
, id
, raster_source
, layer_bounds
));
39 scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
) override
;
40 void AppendQuads(RenderPass
* render_pass
,
41 const Occlusion
& occlusion_in_content_space
,
42 AppendQuadsData
* append_quads_data
) override
;
43 gfx::Size
CalculateTileSize(const gfx::Size
& content_bounds
) const override
;
45 void DidBecomeActive() override
;
46 size_t did_become_active_call_count() {
47 return did_become_active_call_count_
;
50 bool HasValidTilePriorities() const override
;
51 void set_has_valid_tile_priorities(bool has_valid_priorities
) {
52 has_valid_tile_priorities_
= has_valid_priorities
;
53 use_set_valid_tile_priorities_flag_
= true;
56 size_t CountTilesRequired(
57 TileRequirementCheck is_tile_required_callback
) const;
58 size_t CountTilesRequiredForActivation() const;
59 size_t CountTilesRequiredForDraw() const;
61 using PictureLayerImpl::AddTiling
;
62 using PictureLayerImpl::CleanUpTilingsOnActiveLayer
;
63 using PictureLayerImpl::CanHaveTilings
;
64 using PictureLayerImpl::DoPostCommitInitializationIfNeeded
;
65 using PictureLayerImpl::MinimumContentsScale
;
66 using PictureLayerImpl::GetViewportForTilePriorityInContentSpace
;
67 using PictureLayerImpl::SanityCheckTilingState
;
68 using PictureLayerImpl::GetRecycledTwinLayer
;
69 using PictureLayerImpl::UpdateRasterSource
;
71 using PictureLayerImpl::UpdateIdealScales
;
72 using PictureLayerImpl::MaximumTilingContentsScale
;
74 void SetNeedsPostCommitInitialization() {
75 needs_post_commit_initialization_
= true;
78 bool needs_post_commit_initialization() const {
79 return needs_post_commit_initialization_
;
82 float raster_page_scale() const { return raster_page_scale_
; }
83 void set_raster_page_scale(float scale
) { raster_page_scale_
= scale
; }
85 float ideal_contents_scale() const { return ideal_contents_scale_
; }
86 float raster_contents_scale() const { return raster_contents_scale_
; }
88 PictureLayerTiling
* HighResTiling() const;
89 PictureLayerTiling
* LowResTiling() const;
90 size_t num_tilings() const { return tilings_
->num_tilings(); }
92 PictureLayerTilingSet
* tilings() { return tilings_
.get(); }
93 RasterSource
* raster_source() { return raster_source_
.get(); }
94 void SetRasterSource(scoped_refptr
<RasterSource
> raster_source
);
95 size_t append_quads_count() { return append_quads_count_
; }
97 const Region
& invalidation() const { return invalidation_
; }
98 void set_invalidation(const Region
& region
) { invalidation_
= region
; }
100 gfx::Rect
visible_rect_for_tile_priority() {
101 return visible_rect_for_tile_priority_
;
104 void set_fixed_tile_size(const gfx::Size
& size
) { fixed_tile_size_
= size
; }
106 void CreateDefaultTilingsAndTiles();
107 void SetAllTilesVisible();
108 void SetAllTilesReady();
109 void SetAllTilesReadyInTiling(PictureLayerTiling
* tiling
);
110 void SetTileReady(Tile
* tile
);
111 void ResetAllTilesPriorities();
112 PictureLayerTilingSet
* GetTilings() { return tilings_
.get(); }
114 size_t release_resources_count() const { return release_resources_count_
; }
115 void reset_release_resources_count() { release_resources_count_
= 0; }
117 void ReleaseResources() override
;
119 bool only_used_low_res_last_append_quads() const {
120 return only_used_low_res_last_append_quads_
;
124 FakePictureLayerImpl(LayerTreeImpl
* tree_impl
,
126 scoped_refptr
<RasterSource
> raster_source
);
127 FakePictureLayerImpl(LayerTreeImpl
* tree_impl
,
129 scoped_refptr
<RasterSource
> raster_source
,
130 const gfx::Size
& layer_bounds
);
131 FakePictureLayerImpl(LayerTreeImpl
* tree_impl
, int id
);
134 gfx::Size fixed_tile_size_
;
136 size_t append_quads_count_
;
137 size_t did_become_active_call_count_
;
138 bool has_valid_tile_priorities_
;
139 bool use_set_valid_tile_priorities_flag_
;
140 size_t release_resources_count_
;
145 #endif // CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_