chrome.windows.create should return new window id in Guest mode
[chromium-blink-merge.git] / cc / resources / picture_layer_tiling_set.h
blob29e6bf453f58f471a95b75859653e360a36dd5b6
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 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 void SyncTilings(
29 const PictureLayerTilingSet& other,
30 gfx::Size new_layer_bounds,
31 const Region& layer_invalidation,
32 float minimum_contents_scale);
34 gfx::Size layer_bounds() const { return layer_bounds_; }
36 void SetCanUseLCDText(bool can_use_lcd_text);
38 PictureLayerTiling* AddTiling(float contents_scale);
39 size_t num_tilings() const { return tilings_.size(); }
40 int NumHighResTilings() const;
41 PictureLayerTiling* tiling_at(size_t idx) { return tilings_[idx]; }
42 const PictureLayerTiling* tiling_at(size_t idx) const {
43 return tilings_[idx];
46 PictureLayerTiling* TilingAtScale(float scale) const;
48 // Remove all tilings.
49 void RemoveAllTilings();
51 // Remove one tiling.
52 void Remove(PictureLayerTiling* tiling);
54 // Remove all tiles; keep all tilings.
55 void RemoveAllTiles();
57 void UpdateTilePriorities(
58 WhichTree tree,
59 gfx::Size device_viewport,
60 gfx::Rect viewport_in_content_space,
61 gfx::Rect visible_content_rect,
62 gfx::Size last_layer_bounds,
63 gfx::Size current_layer_bounds,
64 float last_layer_contents_scale,
65 float current_layer_contents_scale,
66 const gfx::Transform& last_screen_transform,
67 const gfx::Transform& current_screen_transform,
68 double current_frame_time_in_seconds,
69 size_t max_tiles_for_interest_area);
71 void DidBecomeActive();
72 void DidBecomeRecycled();
74 // For a given rect, iterates through tiles that can fill it. If no
75 // set of tiles with resources can fill the rect, then it will iterate
76 // through null tiles with valid geometry_rect() until the rect is full.
77 // If all tiles have resources, the union of all geometry_rects will
78 // exactly fill rect with no overlap.
79 class CC_EXPORT CoverageIterator {
80 public:
81 CoverageIterator(const PictureLayerTilingSet* set,
82 float contents_scale,
83 gfx::Rect content_rect,
84 float ideal_contents_scale);
85 ~CoverageIterator();
87 // Visible rect (no borders), always in the space of rect,
88 // regardless of the relative contents scale of the tiling.
89 gfx::Rect geometry_rect() const;
90 // Texture rect (in texels) for geometry_rect
91 gfx::RectF texture_rect() const;
92 // Texture size in texels
93 gfx::Size texture_size() const;
95 Tile* operator->() const;
96 Tile* operator*() const;
98 CoverageIterator& operator++();
99 operator bool() const;
101 PictureLayerTiling* CurrentTiling();
103 private:
104 int NextTiling() const;
106 const PictureLayerTilingSet* set_;
107 float contents_scale_;
108 float ideal_contents_scale_;
109 PictureLayerTiling::CoverageIterator tiling_iter_;
110 int current_tiling_;
111 int ideal_tiling_;
113 Region current_region_;
114 Region missing_region_;
115 Region::Iterator region_iter_;
118 scoped_ptr<base::Value> AsValue() const;
119 size_t GPUMemoryUsageInBytes() const;
121 private:
122 PictureLayerTilingClient* client_;
123 gfx::Size layer_bounds_;
124 ScopedPtrVector<PictureLayerTiling> tilings_;
126 friend class Iterator;
127 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingSet);
130 } // namespace cc
132 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_