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_PICTURE_LAYER_TILING_SET_H_
6 #define CC_PICTURE_LAYER_TILING_SET_H_
8 #include "cc/picture_layer_tiling.h"
10 #include "cc/scoped_ptr_vector.h"
11 #include "ui/gfx/size.h"
15 class CC_EXPORT PictureLayerTilingSet
{
17 explicit PictureLayerTilingSet(PictureLayerTilingClient
* client
);
18 ~PictureLayerTilingSet();
20 void SetClient(PictureLayerTilingClient
* client
);
22 // Shallow copies all data (except client and bounds from other).
24 const PictureLayerTilingSet
& other
,
25 const Region
& invalidation
,
26 float minimum_contents_scale
);
27 void Clone(const PictureLayerTiling
* tiling
, const Region
& invalidation
);
29 void SetLayerBounds(gfx::Size layer_bounds
);
30 gfx::Size
LayerBounds() const;
32 PictureLayerTiling
* AddTiling(float contents_scale
);
33 size_t num_tilings() const { return tilings_
.size(); }
34 PictureLayerTiling
* tiling_at(size_t idx
) { return tilings_
[idx
]; }
35 const PictureLayerTiling
* tiling_at(size_t idx
) const {
39 // Remove all tilings.
40 void RemoveAllTilings();
43 void Remove(PictureLayerTiling
* tiling
);
45 // Remove all tiles; keep all tilings.
46 void RemoveAllTiles();
48 // For all tilings, create any tile that intersects |layer_rect|.
49 void CreateTilesFromLayerRect(gfx::Rect layer_rect
);
51 void UpdateTilePriorities(
53 gfx::Size device_viewport
,
54 gfx::Rect viewport_in_content_space
,
55 gfx::Size last_layer_bounds
,
56 gfx::Size current_layer_bounds
,
57 gfx::Size last_layer_content_bounds
,
58 gfx::Size current_layer_content_bounds
,
59 float last_layer_contents_scale
,
60 float current_layer_contents_scale
,
61 const gfx::Transform
& last_screen_transform
,
62 const gfx::Transform
& current_screen_transform
,
63 int current_source_frame_number
,
64 double current_frame_time
,
65 bool store_screen_space_quads_on_tiles
);
67 void DidBecomeActive();
69 // For a given rect, iterates through tiles that can fill it. If no
70 // set of tiles with resources can fill the rect, then it will iterate
71 // through null tiles with valid geometry_rect() until the rect is full.
72 // If all tiles have resources, the union of all geometry_rects will
73 // exactly fill rect with no overlap.
74 class CC_EXPORT Iterator
{
76 Iterator(const PictureLayerTilingSet
* set
,
78 gfx::Rect content_rect
,
79 float ideal_contents_scale
,
80 PictureLayerTiling::LayerDeviceAlignment layerDeviceAlignment
);
83 // Visible rect (no borders), always in the space of rect,
84 // regardless of the relative contents scale of the tiling.
85 gfx::Rect
geometry_rect() const;
86 // Texture rect (in texels) for geometry_rect
87 gfx::RectF
texture_rect() const;
88 // Texture size in texels
89 gfx::Size
texture_size() const;
91 Tile
* operator->() const;
92 Tile
* operator*() const;
94 Iterator
& operator++();
95 operator bool() const;
97 PictureLayerTiling
* CurrentTiling();
100 int NextTiling() const;
102 const PictureLayerTilingSet
* set_
;
103 float contents_scale_
;
104 float ideal_contents_scale_
;
105 PictureLayerTiling::LayerDeviceAlignment layer_device_alignment_
;
106 PictureLayerTiling::Iterator tiling_iter_
;
110 Region current_region_
;
111 Region missing_region_
;
112 Region::Iterator region_iter_
;
115 scoped_ptr
<base::Value
> AsValue() const;
118 PictureLayerTilingClient
* client_
;
119 gfx::Size layer_bounds_
;
120 ScopedPtrVector
<PictureLayerTiling
> tilings_
;
122 friend class Iterator
;
127 #endif // CC_PICTURE_LAYER_TILING_SET_H_