Temporarily re-enabling SizeAfterPrefChange test with traces.
[chromium-blink-merge.git] / cc / resources / picture_layer_tiling_set.h
blobdb1e4ef4390b20e1aee14b9bb7c515433e3f2b28
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.
5 #ifndef CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_
6 #define CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_
8 #include "cc/base/region.h"
9 #include "cc/base/scoped_ptr_vector.h"
10 #include "cc/resources/picture_layer_tiling.h"
11 #include "ui/gfx/size.h"
13 namespace cc {
15 class CC_EXPORT PictureLayerTilingSet {
16 public:
17 PictureLayerTilingSet(PictureLayerTilingClient* client,
18 const gfx::Size& layer_bounds);
19 ~PictureLayerTilingSet();
21 void SetClient(PictureLayerTilingClient* client);
22 const PictureLayerTilingClient* client() const { return client_; }
24 // Make this set of tilings match the same set of content scales from |other|.
25 // Delete any tilings that don't meet |minimum_contents_scale|. Recreate
26 // any tiles that intersect |layer_invalidation|. Update the size of all
27 // tilings to |new_layer_bounds|.
28 // Returns true if we had at least one high res tiling synced.
29 bool SyncTilings(const PictureLayerTilingSet& other,
30 const gfx::Size& new_layer_bounds,
31 const Region& layer_invalidation,
32 float minimum_contents_scale);
34 void RemoveTilesInRegion(const Region& region);
36 gfx::Size layer_bounds() const { return layer_bounds_; }
38 void SetCanUseLCDText(bool can_use_lcd_text);
40 PictureLayerTiling* AddTiling(float contents_scale);
41 size_t num_tilings() const { return tilings_.size(); }
42 int NumHighResTilings() const;
43 PictureLayerTiling* tiling_at(size_t idx) { return tilings_[idx]; }
44 const PictureLayerTiling* tiling_at(size_t idx) const {
45 return tilings_[idx];
48 PictureLayerTiling* TilingAtScale(float scale) const;
50 // Remove all tilings.
51 void RemoveAllTilings();
53 // Remove one tiling.
54 void Remove(PictureLayerTiling* tiling);
56 // Remove all tiles; keep all tilings.
57 void RemoveAllTiles();
59 void UpdateTilePriorities(WhichTree tree,
60 const gfx::Rect& visible_content_rect,
61 float layer_contents_scale,
62 double current_frame_time_in_seconds);
64 void DidBecomeActive();
65 void DidBecomeRecycled();
67 // For a given rect, iterates through tiles that can fill it. If no
68 // set of tiles with resources can fill the rect, then it will iterate
69 // through null tiles with valid geometry_rect() until the rect is full.
70 // If all tiles have resources, the union of all geometry_rects will
71 // exactly fill rect with no overlap.
72 class CC_EXPORT CoverageIterator {
73 public:
74 CoverageIterator(const PictureLayerTilingSet* set,
75 float contents_scale,
76 const gfx::Rect& content_rect,
77 float ideal_contents_scale);
78 ~CoverageIterator();
80 // Visible rect (no borders), always in the space of rect,
81 // regardless of the relative contents scale of the tiling.
82 gfx::Rect geometry_rect() const;
83 // Texture rect (in texels) for geometry_rect
84 gfx::RectF texture_rect() const;
85 // Texture size in texels
86 gfx::Size texture_size() const;
88 Tile* operator->() const;
89 Tile* operator*() const;
91 CoverageIterator& operator++();
92 operator bool() const;
94 PictureLayerTiling* CurrentTiling();
96 private:
97 int NextTiling() const;
99 const PictureLayerTilingSet* set_;
100 float contents_scale_;
101 float ideal_contents_scale_;
102 PictureLayerTiling::CoverageIterator tiling_iter_;
103 int current_tiling_;
104 int ideal_tiling_;
106 Region current_region_;
107 Region missing_region_;
108 Region::Iterator region_iter_;
111 scoped_ptr<base::Value> AsValue() const;
112 size_t GPUMemoryUsageInBytes() const;
114 private:
115 PictureLayerTilingClient* client_;
116 gfx::Size layer_bounds_;
117 ScopedPtrVector<PictureLayerTiling> tilings_;
119 friend class Iterator;
120 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingSet);
123 } // namespace cc
125 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_