• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_
6 #define CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_
7 
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/layers/picture_layer_impl.h"
10 
11 namespace cc {
12 
13 class FakePictureLayerImpl : public PictureLayerImpl {
14  public:
Create(LayerTreeImpl * tree_impl,int id)15   static scoped_ptr<FakePictureLayerImpl> Create(
16       LayerTreeImpl* tree_impl, int id) {
17     return make_scoped_ptr(new FakePictureLayerImpl(tree_impl, id));
18   }
19 
20   // Create layer from a pile that covers the entire layer.
CreateWithPile(LayerTreeImpl * tree_impl,int id,scoped_refptr<PicturePileImpl> pile)21   static scoped_ptr<FakePictureLayerImpl> CreateWithPile(
22       LayerTreeImpl* tree_impl, int id, scoped_refptr<PicturePileImpl> pile) {
23     return make_scoped_ptr(new FakePictureLayerImpl(tree_impl, id, pile));
24   }
25 
26   // Create layer from a pile that only covers part of the layer.
CreateWithPartialPile(LayerTreeImpl * tree_impl,int id,scoped_refptr<PicturePileImpl> pile,const gfx::Size & layer_bounds)27   static scoped_ptr<FakePictureLayerImpl> CreateWithPartialPile(
28       LayerTreeImpl* tree_impl,
29       int id,
30       scoped_refptr<PicturePileImpl> pile,
31       const gfx::Size& layer_bounds) {
32     return make_scoped_ptr(
33         new FakePictureLayerImpl(tree_impl, id, pile, layer_bounds));
34   }
35 
36   virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
37       OVERRIDE;
38   virtual void AppendQuads(RenderPass* render_pass,
39                            const OcclusionTracker<LayerImpl>& occlusion_tracker,
40                            AppendQuadsData* append_quads_data) OVERRIDE;
41   virtual gfx::Size CalculateTileSize(
42       const gfx::Size& content_bounds) const OVERRIDE;
43 
44   virtual void DidBecomeActive() OVERRIDE;
did_become_active_call_count()45   size_t did_become_active_call_count() {
46     return did_become_active_call_count_;
47   }
48 
49   virtual bool HasValidTilePriorities() const OVERRIDE;
set_has_valid_tile_priorities(bool has_valid_priorities)50   void set_has_valid_tile_priorities(bool has_valid_priorities) {
51     has_valid_tile_priorities_ = has_valid_priorities;
52     use_set_valid_tile_priorities_flag_ = true;
53   }
54 
55   using PictureLayerImpl::AddTiling;
56   using PictureLayerImpl::CleanUpTilingsOnActiveLayer;
57   using PictureLayerImpl::CanHaveTilings;
58   using PictureLayerImpl::MarkVisibleResourcesAsRequired;
59   using PictureLayerImpl::DoPostCommitInitializationIfNeeded;
60   using PictureLayerImpl::MinimumContentsScale;
61   using PictureLayerImpl::GetViewportForTilePriorityInContentSpace;
62   using PictureLayerImpl::SanityCheckTilingState;
63   using PictureLayerImpl::GetRecycledTwinLayer;
64   using PictureLayerImpl::UpdatePile;
65 
66   using PictureLayerImpl::UpdateIdealScales;
67   using PictureLayerImpl::MaximumTilingContentsScale;
68 
SetNeedsPostCommitInitialization()69   void SetNeedsPostCommitInitialization() {
70     needs_post_commit_initialization_ = true;
71   }
72 
needs_post_commit_initialization()73   bool needs_post_commit_initialization() const {
74     return needs_post_commit_initialization_;
75   }
76 
raster_page_scale()77   float raster_page_scale() const { return raster_page_scale_; }
set_raster_page_scale(float scale)78   void set_raster_page_scale(float scale) { raster_page_scale_ = scale; }
79 
ideal_contents_scale()80   float ideal_contents_scale() const { return ideal_contents_scale_; }
raster_contents_scale()81   float raster_contents_scale() const { return raster_contents_scale_; }
82 
83   PictureLayerTiling* HighResTiling() const;
84   PictureLayerTiling* LowResTiling() const;
num_tilings()85   size_t num_tilings() const { return tilings_->num_tilings(); }
86 
twin_layer()87   PictureLayerImpl* twin_layer() { return twin_layer_; }
set_twin_layer(PictureLayerImpl * twin)88   void set_twin_layer(PictureLayerImpl* twin) { twin_layer_ = twin; }
tilings()89   PictureLayerTilingSet* tilings() { return tilings_.get(); }
pile()90   PicturePileImpl* pile() { return pile_.get(); }
append_quads_count()91   size_t append_quads_count() { return append_quads_count_; }
92 
invalidation()93   const Region& invalidation() const { return invalidation_; }
set_invalidation(const Region & region)94   void set_invalidation(const Region& region) { invalidation_ = region; }
95 
visible_rect_for_tile_priority()96   gfx::Rect visible_rect_for_tile_priority() {
97     return visible_rect_for_tile_priority_;
98   }
viewport_rect_for_tile_priority()99   gfx::Rect viewport_rect_for_tile_priority() {
100     return viewport_rect_for_tile_priority_;
101   }
screen_space_transform_for_tile_priority()102   gfx::Transform screen_space_transform_for_tile_priority() {
103     return screen_space_transform_for_tile_priority_;
104   }
105 
set_fixed_tile_size(const gfx::Size & size)106   void set_fixed_tile_size(const gfx::Size& size) { fixed_tile_size_ = size; }
107 
108   void CreateDefaultTilingsAndTiles();
109   void SetAllTilesVisible();
110   void SetAllTilesReady();
111   void SetAllTilesReadyInTiling(PictureLayerTiling* tiling);
112   void SetTileReady(Tile* tile);
113   void ResetAllTilesPriorities();
GetTilings()114   PictureLayerTilingSet* GetTilings() { return tilings_.get(); }
115 
release_resources_count()116   size_t release_resources_count() const { return release_resources_count_; }
reset_release_resources_count()117   void reset_release_resources_count() { release_resources_count_ = 0; }
118 
119   virtual void ReleaseResources() OVERRIDE;
120 
121  protected:
122   FakePictureLayerImpl(
123       LayerTreeImpl* tree_impl,
124       int id,
125       scoped_refptr<PicturePileImpl> pile);
126   FakePictureLayerImpl(LayerTreeImpl* tree_impl,
127                        int id,
128                        scoped_refptr<PicturePileImpl> pile,
129                        const gfx::Size& layer_bounds);
130   FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id);
131 
132  private:
133   gfx::Size fixed_tile_size_;
134 
135   size_t append_quads_count_;
136   size_t did_become_active_call_count_;
137   bool has_valid_tile_priorities_;
138   bool use_set_valid_tile_priorities_flag_;
139   size_t release_resources_count_;
140 };
141 
142 }  // namespace cc
143 
144 #endif  // CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_
145