Home | History | Annotate | Download | only in test
      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   static scoped_ptr<FakePictureLayerImpl> CreateWithPile(
     21       LayerTreeImpl* tree_impl, int id, scoped_refptr<PicturePileImpl> pile) {
     22     return make_scoped_ptr(new FakePictureLayerImpl(tree_impl, id, pile));
     23   }
     24 
     25   virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
     26       OVERRIDE;
     27   virtual void AppendQuads(QuadSink* quad_sink,
     28                            AppendQuadsData* append_quads_data) OVERRIDE;
     29   virtual gfx::Size CalculateTileSize(gfx::Size content_bounds) const OVERRIDE;
     30 
     31   using PictureLayerImpl::AddTiling;
     32   using PictureLayerImpl::CleanUpTilingsOnActiveLayer;
     33   using PictureLayerImpl::CanHaveTilings;
     34   using PictureLayerImpl::MarkVisibleResourcesAsRequired;
     35   using PictureLayerImpl::DoPostCommitInitializationIfNeeded;
     36   using PictureLayerImpl::MinimumContentsScale;
     37 
     38   bool needs_post_commit_initialization() const {
     39     return needs_post_commit_initialization_;
     40   }
     41 
     42   bool is_using_lcd_text() const { return is_using_lcd_text_; }
     43   void force_set_lcd_text(bool enabled) { is_using_lcd_text_ = enabled; }
     44 
     45   PictureLayerTiling* HighResTiling() const;
     46   PictureLayerTiling* LowResTiling() const;
     47   size_t num_tilings() const { return tilings_->num_tilings(); }
     48 
     49   PictureLayerImpl* twin_layer() { return twin_layer_; }
     50   PictureLayerTilingSet* tilings() { return tilings_.get(); }
     51   PicturePileImpl* pile() { return pile_.get(); }
     52   size_t append_quads_count() { return append_quads_count_; }
     53 
     54   const Region& invalidation() const { return invalidation_; }
     55   void set_invalidation(const Region& region) { invalidation_ = region; }
     56 
     57   void set_fixed_tile_size(gfx::Size size) { fixed_tile_size_ = size; }
     58 
     59   void CreateDefaultTilingsAndTiles();
     60   void SetAllTilesVisible();
     61   void SetAllTilesReady();
     62   void SetAllTilesReadyInTiling(PictureLayerTiling* tiling);
     63 
     64  protected:
     65   FakePictureLayerImpl(
     66       LayerTreeImpl* tree_impl,
     67       int id,
     68       scoped_refptr<PicturePileImpl> pile);
     69   FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id);
     70 
     71  private:
     72   gfx::Size fixed_tile_size_;
     73 
     74   size_t append_quads_count_;
     75 };
     76 
     77 }  // namespace cc
     78 
     79 #endif  // CC_TEST_FAKE_PICTURE_LAYER_IMPL_H_
     80