Upstream version 9.38.198.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::SanityCheckTilingState;
62
63   using PictureLayerImpl::UpdateIdealScales;
64   using PictureLayerImpl::MaximumTilingContentsScale;
65
66   void SetNeedsPostCommitInitialization() {
67     needs_post_commit_initialization_ = true;
68   }
69
70   bool needs_post_commit_initialization() const {
71     return needs_post_commit_initialization_;
72   }
73
74   float raster_page_scale() const { return raster_page_scale_; }
75   void set_raster_page_scale(float scale) { raster_page_scale_ = scale; }
76
77   PictureLayerTiling* HighResTiling() const;
78   PictureLayerTiling* LowResTiling() const;
79   size_t num_tilings() const { return tilings_->num_tilings(); }
80
81   PictureLayerImpl* twin_layer() { return twin_layer_; }
82   void set_twin_layer(PictureLayerImpl* twin) { twin_layer_ = twin; }
83   PictureLayerTilingSet* tilings() { return tilings_.get(); }
84   PicturePileImpl* pile() { return pile_.get(); }
85   size_t append_quads_count() { return append_quads_count_; }
86
87   const Region& invalidation() const { return invalidation_; }
88   void set_invalidation(const Region& region) { invalidation_ = region; }
89
90   gfx::Rect visible_rect_for_tile_priority() {
91     return visible_rect_for_tile_priority_;
92   }
93   gfx::Rect viewport_rect_for_tile_priority() {
94     return viewport_rect_for_tile_priority_;
95   }
96   gfx::Transform screen_space_transform_for_tile_priority() {
97     return screen_space_transform_for_tile_priority_;
98   }
99
100   void set_fixed_tile_size(const gfx::Size& size) { fixed_tile_size_ = size; }
101
102   void CreateDefaultTilingsAndTiles();
103   void SetAllTilesVisible();
104   void SetAllTilesReady();
105   void SetAllTilesReadyInTiling(PictureLayerTiling* tiling);
106   void ResetAllTilesPriorities();
107   PictureLayerTilingSet* GetTilings() { return tilings_.get(); }
108
109  protected:
110   FakePictureLayerImpl(
111       LayerTreeImpl* tree_impl,
112       int id,
113       scoped_refptr<PicturePileImpl> pile);
114   FakePictureLayerImpl(LayerTreeImpl* tree_impl,
115                        int id,
116                        scoped_refptr<PicturePileImpl> pile,
117                        const gfx::Size& layer_bounds);
118   FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id);
119
120  private:
121   gfx::Size fixed_tile_size_;
122
123   size_t append_quads_count_;
124   size_t did_become_active_call_count_;
125   bool has_valid_tile_priorities_;
126   bool use_set_valid_tile_priorities_flag_;
127 };
128
129 }  // namespace cc
130
131 #endif  // CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_