blob: 5e4d92fec6980acfe39f4e656a928550099f9769 [file] [log] [blame]
[email protected]cd696272012-11-21 19:15:271// 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.
4
[email protected]e12dd0e2013-03-18 08:24:405#ifndef CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_
6#define CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_
[email protected]cd696272012-11-21 19:15:277
[email protected]681ccff2013-03-18 06:13:528#include "cc/base/region.h"
9#include "cc/base/scoped_ptr_vector.h"
[email protected]e12dd0e2013-03-18 08:24:4010#include "cc/resources/picture_layer_tiling.h"
[email protected]cd696272012-11-21 19:15:2711#include "ui/gfx/size.h"
12
13namespace cc {
14
15class CC_EXPORT PictureLayerTilingSet {
16 public:
[email protected]48871fc2013-01-23 07:36:5117 explicit PictureLayerTilingSet(PictureLayerTilingClient* client);
[email protected]cd696272012-11-21 19:15:2718 ~PictureLayerTilingSet();
19
[email protected]48871fc2013-01-23 07:36:5120 void SetClient(PictureLayerTilingClient* client);
21
[email protected]2e7ca422012-12-20 02:57:2722 // Shallow copies all data (except client and bounds from other).
[email protected]f117a4c2012-12-16 04:53:1023 void CloneAll(
24 const PictureLayerTilingSet& other,
[email protected]24ef9b8c2013-02-26 19:15:2725 const Region& invalidation,
26 float minimum_contents_scale);
[email protected]f117a4c2012-12-16 04:53:1027 void Clone(const PictureLayerTiling* tiling, const Region& invalidation);
28
[email protected]cd696272012-11-21 19:15:2729 void SetLayerBounds(gfx::Size layer_bounds);
30 gfx::Size LayerBounds() const;
31
[email protected]d7eb8c72013-03-23 22:57:1332 void Invalidate(const Region& layer_invalidation);
33
[email protected]3edd52c2013-02-02 15:26:2834 PictureLayerTiling* AddTiling(float contents_scale);
[email protected]cd696272012-11-21 19:15:2735 size_t num_tilings() const { return tilings_.size(); }
[email protected]e0eb7c42013-01-08 00:00:1936 PictureLayerTiling* tiling_at(size_t idx) { return tilings_[idx]; }
[email protected]b0a917c8d2013-01-12 17:42:2537 const PictureLayerTiling* tiling_at(size_t idx) const {
38 return tilings_[idx];
39 }
[email protected]cd696272012-11-21 19:15:2740
[email protected]166db5c82013-01-09 23:54:3141 // Remove all tilings.
42 void RemoveAllTilings();
43
44 // Remove one tiling.
45 void Remove(PictureLayerTiling* tiling);
46
47 // Remove all tiles; keep all tilings.
48 void RemoveAllTiles();
[email protected]14148f12012-12-08 06:01:4949
[email protected]fd3eec62013-01-24 19:54:0350 // For all tilings, create any tile that intersects |layer_rect|.
51 void CreateTilesFromLayerRect(gfx::Rect layer_rect);
52
[email protected]2e7ca422012-12-20 02:57:2753 void UpdateTilePriorities(
54 WhichTree tree,
[email protected]af7c44e2013-02-15 13:33:0955 gfx::Size device_viewport,
[email protected]63db9222013-01-29 22:13:4756 gfx::Rect viewport_in_content_space,
[email protected]1ebc7b02013-01-31 22:00:0957 gfx::Size last_layer_bounds,
58 gfx::Size current_layer_bounds,
[email protected]1ebc7b02013-01-31 22:00:0959 float last_layer_contents_scale,
60 float current_layer_contents_scale,
[email protected]2e7ca422012-12-20 02:57:2761 const gfx::Transform& last_screen_transform,
62 const gfx::Transform& current_screen_transform,
[email protected]1ebc7b02013-01-31 22:00:0963 int current_source_frame_number,
[email protected]131a0c22013-02-12 18:31:0864 double current_frame_time,
65 bool store_screen_space_quads_on_tiles);
[email protected]4cbadc882012-12-04 08:52:5866
[email protected]b221a222013-01-22 21:38:5667 void DidBecomeActive();
[email protected]37386f052013-01-13 00:42:2268
[email protected]cd696272012-11-21 19:15:2769 // 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 {
75 public:
[email protected]b64e1d342013-02-13 04:31:1676 Iterator(const PictureLayerTilingSet* set,
[email protected]f6776532012-12-21 20:24:3377 float contents_scale,
[email protected]166db5c82013-01-09 23:54:3178 gfx::Rect content_rect,
[email protected]536769782013-03-20 09:12:2179 float ideal_contents_scale);
[email protected]cd696272012-11-21 19:15:2780 ~Iterator();
81
82 // Visible rect (no borders), always in the space of rect,
83 // regardless of the relative contents scale of the tiling.
84 gfx::Rect geometry_rect() const;
85 // Texture rect (in texels) for geometry_rect
86 gfx::RectF texture_rect() const;
87 // Texture size in texels
88 gfx::Size texture_size() const;
89
90 Tile* operator->() const;
91 Tile* operator*() const;
92
93 Iterator& operator++();
94 operator bool() const;
95
[email protected]166db5c82013-01-09 23:54:3196 PictureLayerTiling* CurrentTiling();
97
[email protected]cd696272012-11-21 19:15:2798 private:
[email protected]166db5c82013-01-09 23:54:3199 int NextTiling() const;
100
[email protected]f6776532012-12-21 20:24:33101 const PictureLayerTilingSet* set_;
[email protected]cd696272012-11-21 19:15:27102 float contents_scale_;
[email protected]166db5c82013-01-09 23:54:31103 float ideal_contents_scale_;
[email protected]cd696272012-11-21 19:15:27104 PictureLayerTiling::Iterator tiling_iter_;
105 int current_tiling_;
[email protected]166db5c82013-01-09 23:54:31106 int ideal_tiling_;
[email protected]cd696272012-11-21 19:15:27107
108 Region current_region_;
109 Region missing_region_;
110 Region::Iterator region_iter_;
111 };
112
[email protected]8c5690222013-02-15 17:36:43113 scoped_ptr<base::Value> AsValue() const;
114
[email protected]cd696272012-11-21 19:15:27115 private:
116 PictureLayerTilingClient* client_;
117 gfx::Size layer_bounds_;
118 ScopedPtrVector<PictureLayerTiling> tilings_;
[email protected]cd696272012-11-21 19:15:27119
120 friend class Iterator;
121};
122
123} // namespace cc
124
[email protected]e12dd0e2013-03-18 08:24:40125#endif // CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_