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.
5 #ifndef CC_RESOURCES_PICTURE_PILE_BASE_H_
6 #define CC_RESOURCES_PICTURE_PILE_BASE_H_
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"
25 class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> {
28 explicit PicturePileBase(const PicturePileBase* other);
29 PicturePileBase(const PicturePileBase* other, unsigned thread_index);
31 void Resize(gfx::Size size);
32 gfx::Size size() const { return tiling_.total_size(); }
33 void SetMinContentsScale(float min_contents_scale);
35 void UpdateRecordedRegion();
36 const Region& recorded_region() const { return recorded_region_; }
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);
44 void SetTileGridSize(gfx::Size tile_grid_size);
45 TilingData& tiling() { return tiling_; }
47 scoped_ptr<base::Value> AsValue() const;
50 struct CC_EXPORT PictureInfo {
55 PictureInfo CloneForThread(int thread_index) const;
57 scoped_refptr<Picture> picture;
60 typedef std::pair<int, int> PictureMapKey;
61 typedef base::hash_map<PictureMapKey, PictureInfo> PictureMap;
63 virtual ~PicturePileBase();
65 int num_raster_threads() { return num_raster_threads_; }
66 int buffer_pixels() const { return tiling_.border_texels(); }
69 gfx::Rect PaddedRect(const PictureMapKey& key);
71 // A picture pile is a tiled set of pictures. The picture map is a map of tile
72 // indices to picture infos.
73 PictureMap picture_map_;
75 Region recorded_region_;
76 float min_contents_scale_;
77 SkTileGridPicture::TileGridInfo tile_grid_info_;
78 SkColor background_color_;
79 int slow_down_raster_scale_factor_for_debug_;
80 bool contents_opaque_;
81 bool show_debug_picture_borders_;
82 bool clear_canvas_with_debug_color_;
83 int num_raster_threads_;
86 void SetBufferPixels(int buffer_pixels);
88 friend class base::RefCounted<PicturePileBase>;
89 DISALLOW_COPY_AND_ASSIGN(PicturePileBase);
94 #endif // CC_RESOURCES_PICTURE_PILE_BASE_H_