• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 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_TILING_CLIENT_H_
6 #define CC_TEST_FAKE_PICTURE_LAYER_TILING_CLIENT_H_
7 
8 #include "cc/resources/picture_layer_tiling.h"
9 #include "cc/resources/picture_pile_impl.h"
10 #include "cc/resources/tile.h"
11 #include "cc/resources/tile_manager.h"
12 #include "cc/test/fake_tile_manager_client.h"
13 #include "ui/gfx/rect.h"
14 
15 namespace cc {
16 
17 class FakePictureLayerTilingClient : public PictureLayerTilingClient {
18  public:
19   FakePictureLayerTilingClient();
20   explicit FakePictureLayerTilingClient(ResourceProvider* resource_provider);
21   virtual ~FakePictureLayerTilingClient();
22 
23   // PictureLayerTilingClient implementation.
24   virtual scoped_refptr<Tile> CreateTile(
25       PictureLayerTiling* tiling, const gfx::Rect& rect) OVERRIDE;
26   virtual PicturePileImpl* GetPile() OVERRIDE;
27   virtual gfx::Size CalculateTileSize(
28       const gfx::Size& content_bounds) const OVERRIDE;
29   virtual size_t GetMaxTilesForInterestArea() const OVERRIDE;
30   virtual float GetSkewportTargetTimeInSeconds() const OVERRIDE;
31   virtual int GetSkewportExtrapolationLimitInContentPixels() const OVERRIDE;
32 
33   void SetTileSize(const gfx::Size& tile_size);
TileSize()34   gfx::Size TileSize() const { return tile_size_; }
35 
36   virtual const Region* GetInvalidation() OVERRIDE;
37   virtual const PictureLayerTiling* GetTwinTiling(
38       const PictureLayerTiling* tiling) const OVERRIDE;
39   virtual PictureLayerTiling* GetRecycledTwinTiling(
40       const PictureLayerTiling* tiling) OVERRIDE;
41   virtual WhichTree GetTree() const OVERRIDE;
42 
set_twin_tiling(PictureLayerTiling * tiling)43   void set_twin_tiling(PictureLayerTiling* tiling) { twin_tiling_ = tiling; }
set_recycled_twin_tiling(PictureLayerTiling * tiling)44   void set_recycled_twin_tiling(PictureLayerTiling* tiling) {
45     recycled_twin_tiling_ = tiling;
46   }
set_text_rect(const gfx::Rect & rect)47   void set_text_rect(const gfx::Rect& rect) { text_rect_ = rect; }
set_allow_create_tile(bool allow)48   void set_allow_create_tile(bool allow) { allow_create_tile_ = allow; }
set_invalidation(const Region & region)49   void set_invalidation(const Region& region) { invalidation_ = region; }
set_max_tiles_for_interest_area(size_t area)50   void set_max_tiles_for_interest_area(size_t area) {
51     max_tiles_for_interest_area_ = area;
52   }
set_skewport_target_time_in_seconds(float time)53   void set_skewport_target_time_in_seconds(float time) {
54     skewport_target_time_in_seconds_ = time;
55   }
set_skewport_extrapolation_limit_in_content_pixels(int limit)56   void set_skewport_extrapolation_limit_in_content_pixels(int limit) {
57     skewport_extrapolation_limit_in_content_pixels_ = limit;
58   }
set_tree(WhichTree tree)59   void set_tree(WhichTree tree) { tree_ = tree; }
60 
tile_manager()61   TileManager* tile_manager() const {
62     return tile_manager_.get();
63   }
64 
65  protected:
66   FakeTileManagerClient tile_manager_client_;
67   scoped_ptr<ResourcePool> resource_pool_;
68   scoped_ptr<TileManager> tile_manager_;
69   scoped_refptr<PicturePileImpl> pile_;
70   gfx::Size tile_size_;
71   PictureLayerTiling* twin_tiling_;
72   PictureLayerTiling* recycled_twin_tiling_;
73   gfx::Rect text_rect_;
74   bool allow_create_tile_;
75   Region invalidation_;
76   size_t max_tiles_for_interest_area_;
77   float skewport_target_time_in_seconds_;
78   int skewport_extrapolation_limit_in_content_pixels_;
79   WhichTree tree_;
80 };
81 
82 }  // namespace cc
83 
84 #endif  // CC_TEST_FAKE_PICTURE_LAYER_TILING_CLIENT_H_
85