Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_RESOURCES_PICTURE_PILE_BASE_H_ | 5 #ifndef CC_RESOURCES_PICTURE_PILE_BASE_H_ |
| 6 #define CC_RESOURCES_PICTURE_PILE_BASE_H_ | 6 #define CC_RESOURCES_PICTURE_PILE_BASE_H_ |
| 7 | 7 |
| 8 #include <bitset> | 8 #include <bitset> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> { | 26 class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> { |
| 27 public: | 27 public: |
| 28 PicturePileBase(); | 28 PicturePileBase(); |
| 29 explicit PicturePileBase(const PicturePileBase* other); | 29 explicit PicturePileBase(const PicturePileBase* other); |
| 30 PicturePileBase(const PicturePileBase* other, unsigned thread_index); | 30 PicturePileBase(const PicturePileBase* other, unsigned thread_index); |
| 31 | 31 |
| 32 void Resize(const gfx::Size& size); | 32 void Resize(const gfx::Size& size); |
| 33 gfx::Size size() const { return tiling_.total_size(); } | 33 gfx::Size size() const { return tiling_.total_size(); } |
| 34 void SetMinContentsScale(float min_contents_scale); | 34 void SetMinContentsScale(float min_contents_scale); |
| 35 | 35 |
| 36 void UpdateRecordedRegion(); | |
| 37 const Region& recorded_region() const { return recorded_region_; } | |
| 38 | |
| 39 int num_tiles_x() const { return tiling_.num_tiles_x(); } | 36 int num_tiles_x() const { return tiling_.num_tiles_x(); } |
| 40 int num_tiles_y() const { return tiling_.num_tiles_y(); } | 37 int num_tiles_y() const { return tiling_.num_tiles_y(); } |
| 41 gfx::Rect tile_bounds(int x, int y) const { return tiling_.TileBounds(x, y); } | 38 gfx::Rect tile_bounds(int x, int y) const { return tiling_.TileBounds(x, y); } |
| 42 bool HasRecordingAt(int x, int y); | 39 bool HasRecordingAt(int x, int y); |
| 43 bool CanRaster(float contents_scale, const gfx::Rect& content_rect); | 40 bool CanRaster(float contents_scale, const gfx::Rect& content_rect); |
| 44 | 41 |
| 42 // If this pile contains any valid recordings. May have false positives. | |
| 43 bool HasAnyRecordings() const { return has_any_recordings_; } | |
|
vmpstr
2014/03/12 23:57:35
nit: Maybe just HasRecordings? "any" is kind of im
enne (OOO)
2014/03/13 01:35:43
Done.
| |
| 44 | |
| 45 static void ComputeTileGridInfo(const gfx::Size& tile_grid_size, | 45 static void ComputeTileGridInfo(const gfx::Size& tile_grid_size, |
| 46 SkTileGridPicture::TileGridInfo* info); | 46 SkTileGridPicture::TileGridInfo* info); |
| 47 | 47 |
| 48 void SetTileGridSize(const gfx::Size& tile_grid_size); | 48 void SetTileGridSize(const gfx::Size& tile_grid_size); |
| 49 TilingData& tiling() { return tiling_; } | 49 TilingData& tiling() { return tiling_; } |
| 50 | 50 |
| 51 scoped_ptr<base::Value> AsValue() const; | 51 scoped_ptr<base::Value> AsValue() const; |
| 52 | 52 |
| 53 protected: | 53 protected: |
| 54 class CC_EXPORT PictureInfo { | 54 class CC_EXPORT PictureInfo { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 77 int last_frame_number_; | 77 int last_frame_number_; |
| 78 scoped_refptr<Picture> picture_; | 78 scoped_refptr<Picture> picture_; |
| 79 std::bitset<INVALIDATION_FRAMES_TRACKED> invalidation_history_; | 79 std::bitset<INVALIDATION_FRAMES_TRACKED> invalidation_history_; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 typedef std::pair<int, int> PictureMapKey; | 82 typedef std::pair<int, int> PictureMapKey; |
| 83 typedef base::hash_map<PictureMapKey, PictureInfo> PictureMap; | 83 typedef base::hash_map<PictureMapKey, PictureInfo> PictureMap; |
| 84 | 84 |
| 85 virtual ~PicturePileBase(); | 85 virtual ~PicturePileBase(); |
| 86 | 86 |
| 87 void SetRecordedRegionForTesting(const Region& recorded_region) { | |
| 88 recorded_region_ = recorded_region; | |
| 89 } | |
| 90 | |
| 91 int buffer_pixels() const { return tiling_.border_texels(); } | 87 int buffer_pixels() const { return tiling_.border_texels(); } |
| 92 void Clear(); | 88 void Clear(); |
| 93 | 89 |
| 94 gfx::Rect PaddedRect(const PictureMapKey& key); | 90 gfx::Rect PaddedRect(const PictureMapKey& key); |
| 95 gfx::Rect PadRect(const gfx::Rect& rect); | 91 gfx::Rect PadRect(const gfx::Rect& rect); |
| 96 | 92 |
| 93 // An internal CanRaster check that goes to the picture_map rather than | |
| 94 // using the recorded_viewport hint. | |
| 95 bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const; | |
| 96 | |
| 97 // A picture pile is a tiled set of pictures. The picture map is a map of tile | 97 // A picture pile is a tiled set of pictures. The picture map is a map of tile |
| 98 // indices to picture infos. | 98 // indices to picture infos. |
| 99 PictureMap picture_map_; | 99 PictureMap picture_map_; |
| 100 TilingData tiling_; | 100 TilingData tiling_; |
| 101 Region recorded_region_; | 101 // If non-empty, all pictures tiles inside this rect are recorded. |
| 102 gfx::Rect recorded_viewport_; | |
| 102 float min_contents_scale_; | 103 float min_contents_scale_; |
| 103 SkTileGridPicture::TileGridInfo tile_grid_info_; | 104 SkTileGridPicture::TileGridInfo tile_grid_info_; |
| 104 SkColor background_color_; | 105 SkColor background_color_; |
| 105 int slow_down_raster_scale_factor_for_debug_; | 106 int slow_down_raster_scale_factor_for_debug_; |
| 106 bool contents_opaque_; | 107 bool contents_opaque_; |
| 107 bool show_debug_picture_borders_; | 108 bool show_debug_picture_borders_; |
| 108 bool clear_canvas_with_debug_color_; | 109 bool clear_canvas_with_debug_color_; |
| 110 // A hint about whether there are any recordings. This may be a false | |
| 111 // positive. | |
| 112 bool has_any_recordings_; | |
| 109 | 113 |
| 110 private: | 114 private: |
| 111 void SetBufferPixels(int buffer_pixels); | 115 void SetBufferPixels(int buffer_pixels); |
| 112 | 116 |
| 113 friend class base::RefCounted<PicturePileBase>; | 117 friend class base::RefCounted<PicturePileBase>; |
| 114 DISALLOW_COPY_AND_ASSIGN(PicturePileBase); | 118 DISALLOW_COPY_AND_ASSIGN(PicturePileBase); |
| 115 }; | 119 }; |
| 116 | 120 |
| 117 } // namespace cc | 121 } // namespace cc |
| 118 | 122 |
| 119 #endif // CC_RESOURCES_PICTURE_PILE_BASE_H_ | 123 #endif // CC_RESOURCES_PICTURE_PILE_BASE_H_ |
| OLD | NEW |