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_RESOURCES_PICTURE_PILE_BASE_H_ 6 #define CC_RESOURCES_PICTURE_PILE_BASE_H_ 7 8 #include <list> 9 #include <utility> 10 11 #include "base/containers/hash_tables.h" 12 #include "base/memory/ref_counted.h" 13 #include "cc/base/cc_export.h" 14 #include "cc/base/region.h" 15 #include "cc/base/tiling_data.h" 16 #include "cc/resources/picture.h" 17 #include "ui/gfx/size.h" 18 19 namespace base { 20 class Value; 21 } 22 23 namespace cc { 24 25 class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> { 26 public: 27 PicturePileBase(); 28 explicit PicturePileBase(const PicturePileBase* other); 29 PicturePileBase(const PicturePileBase* other, unsigned thread_index); 30 31 void Resize(gfx::Size size); 32 gfx::Size size() const { return tiling_.total_size(); } 33 void SetMinContentsScale(float min_contents_scale); 34 35 void UpdateRecordedRegion(); 36 const Region& recorded_region() const { return recorded_region_; } 37 38 int num_tiles_x() const { return tiling_.num_tiles_x(); } 39 int num_tiles_y() const { return tiling_.num_tiles_y(); } 40 gfx::Rect tile_bounds(int x, int y) const { return tiling_.TileBounds(x, y); } 41 bool HasRecordingAt(int x, int y); 42 bool CanRaster(float contents_scale, gfx::Rect content_rect); 43 44 void SetTileGridSize(gfx::Size tile_grid_size); 45 TilingData& tiling() { return tiling_; } 46 47 scoped_ptr<base::Value> AsValue() const; 48 49 protected: 50 virtual ~PicturePileBase(); 51 52 int num_raster_threads() { return num_raster_threads_; } 53 int buffer_pixels() const { return tiling_.border_texels(); } 54 void Clear(); 55 56 typedef std::pair<int, int> PictureListMapKey; 57 typedef std::list<scoped_refptr<Picture> > PictureList; 58 typedef base::hash_map<PictureListMapKey, PictureList> PictureListMap; 59 60 // A picture pile is a tiled set of picture lists. The picture list map 61 // is a map of tile indices to picture lists. 62 PictureListMap picture_list_map_; 63 TilingData tiling_; 64 Region recorded_region_; 65 float min_contents_scale_; 66 SkTileGridPicture::TileGridInfo tile_grid_info_; 67 SkColor background_color_; 68 bool contents_opaque_; 69 int slow_down_raster_scale_factor_for_debug_; 70 bool show_debug_picture_borders_; 71 int num_raster_threads_; 72 73 private: 74 void SetBufferPixels(int buffer_pixels); 75 76 friend class base::RefCounted<PicturePileBase>; 77 DISALLOW_COPY_AND_ASSIGN(PicturePileBase); 78 }; 79 80 } // namespace cc 81 82 #endif // CC_RESOURCES_PICTURE_PILE_BASE_H_ 83