Upstream version 11.39.250.0
[platform/framework/web/crosswalk.git] / src / cc / test / fake_picture_layer_impl.h
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:
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.
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.
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;
45   size_t did_become_active_call_count() {
46     return did_become_active_call_count_;
47   }
48
49   virtual bool HasValidTilePriorities() const OVERRIDE;
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
69   void SetNeedsPostCommitInitialization() {
70     needs_post_commit_initialization_ = true;
71   }
72
73   bool needs_post_commit_initialization() const {
74     return needs_post_commit_initialization_;
75   }
76
77   float raster_page_scale() const { return raster_page_scale_; }
78   void set_raster_page_scale(float scale) { raster_page_scale_ = scale; }
79
80   float ideal_contents_scale() const { return ideal_contents_scale_; }
81   float raster_contents_scale() const { return raster_contents_scale_; }
82
83   PictureLayerTiling* HighResTiling() const;
84   PictureLayerTiling* LowResTiling() const;
85   size_t num_tilings() const { return tilings_->num_tilings(); }
86
87   PictureLayerImpl* twin_layer() { return twin_layer_; }
88   void set_twin_layer(PictureLayerImpl* twin) { twin_layer_ = twin; }
89   PictureLayerTilingSet* tilings() { return tilings_.get(); }
90   PicturePileImpl* pile() { return pile_.get(); }
91   size_t append_quads_count() { return append_quads_count_; }
92
93   const Region& invalidation() const { return invalidation_; }
94   void set_invalidation(const Region& region) { invalidation_ = region; }
95
96   gfx::Rect visible_rect_for_tile_priority() {
97     return visible_rect_for_tile_priority_;
98   }
99   gfx::Rect viewport_rect_for_tile_priority() {
100     return viewport_rect_for_tile_priority_;
101   }
102   gfx::Transform screen_space_transform_for_tile_priority() {
103     return screen_space_transform_for_tile_priority_;
104   }
105
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();
114   PictureLayerTilingSet* GetTilings() { return tilings_.get(); }
115
116   size_t release_resources_count() const { return 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_