[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 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. |
| 4 | |
[email protected] | e12dd0e | 2013-03-18 08:24:40 | [diff] [blame] | 5 | #ifndef CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_ |
| 6 | #define CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_ |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 7 | |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 8 | #include "cc/base/region.h" |
| 9 | #include "cc/base/scoped_ptr_vector.h" |
[email protected] | e12dd0e | 2013-03-18 08:24:40 | [diff] [blame] | 10 | #include "cc/resources/picture_layer_tiling.h" |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 11 | #include "ui/gfx/size.h" |
| 12 | |
| 13 | namespace cc { |
| 14 | |
| 15 | class CC_EXPORT PictureLayerTilingSet { |
| 16 | public: |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 17 | explicit PictureLayerTilingSet(PictureLayerTilingClient* client); |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 18 | ~PictureLayerTilingSet(); |
| 19 | |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 20 | void SetClient(PictureLayerTilingClient* client); |
| 21 | |
[email protected] | 2e7ca42 | 2012-12-20 02:57:27 | [diff] [blame] | 22 | // Shallow copies all data (except client and bounds from other). |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 23 | void CloneAll( |
| 24 | const PictureLayerTilingSet& other, |
[email protected] | 24ef9b8c | 2013-02-26 19:15:27 | [diff] [blame] | 25 | const Region& invalidation, |
| 26 | float minimum_contents_scale); |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 27 | void Clone(const PictureLayerTiling* tiling, const Region& invalidation); |
| 28 | |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 29 | void SetLayerBounds(gfx::Size layer_bounds); |
| 30 | gfx::Size LayerBounds() const; |
| 31 | |
[email protected] | d7eb8c7 | 2013-03-23 22:57:13 | [diff] [blame^] | 32 | void Invalidate(const Region& layer_invalidation); |
| 33 | |
[email protected] | 3edd52c | 2013-02-02 15:26:28 | [diff] [blame] | 34 | PictureLayerTiling* AddTiling(float contents_scale); |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 35 | size_t num_tilings() const { return tilings_.size(); } |
[email protected] | e0eb7c4 | 2013-01-08 00:00:19 | [diff] [blame] | 36 | PictureLayerTiling* tiling_at(size_t idx) { return tilings_[idx]; } |
[email protected] | b0a917c8d | 2013-01-12 17:42:25 | [diff] [blame] | 37 | const PictureLayerTiling* tiling_at(size_t idx) const { |
| 38 | return tilings_[idx]; |
| 39 | } |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 40 | |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 41 | // 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] | 14148f1 | 2012-12-08 06:01:49 | [diff] [blame] | 49 | |
[email protected] | fd3eec6 | 2013-01-24 19:54:03 | [diff] [blame] | 50 | // For all tilings, create any tile that intersects |layer_rect|. |
| 51 | void CreateTilesFromLayerRect(gfx::Rect layer_rect); |
| 52 | |
[email protected] | 2e7ca42 | 2012-12-20 02:57:27 | [diff] [blame] | 53 | void UpdateTilePriorities( |
| 54 | WhichTree tree, |
[email protected] | af7c44e | 2013-02-15 13:33:09 | [diff] [blame] | 55 | gfx::Size device_viewport, |
[email protected] | 63db922 | 2013-01-29 22:13:47 | [diff] [blame] | 56 | gfx::Rect viewport_in_content_space, |
[email protected] | 1ebc7b0 | 2013-01-31 22:00:09 | [diff] [blame] | 57 | gfx::Size last_layer_bounds, |
| 58 | gfx::Size current_layer_bounds, |
[email protected] | 1ebc7b0 | 2013-01-31 22:00:09 | [diff] [blame] | 59 | float last_layer_contents_scale, |
| 60 | float current_layer_contents_scale, |
[email protected] | 2e7ca42 | 2012-12-20 02:57:27 | [diff] [blame] | 61 | const gfx::Transform& last_screen_transform, |
| 62 | const gfx::Transform& current_screen_transform, |
[email protected] | 1ebc7b0 | 2013-01-31 22:00:09 | [diff] [blame] | 63 | int current_source_frame_number, |
[email protected] | 131a0c2 | 2013-02-12 18:31:08 | [diff] [blame] | 64 | double current_frame_time, |
| 65 | bool store_screen_space_quads_on_tiles); |
[email protected] | 4cbadc88 | 2012-12-04 08:52:58 | [diff] [blame] | 66 | |
[email protected] | b221a22 | 2013-01-22 21:38:56 | [diff] [blame] | 67 | void DidBecomeActive(); |
[email protected] | 37386f05 | 2013-01-13 00:42:22 | [diff] [blame] | 68 | |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 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 { |
| 75 | public: |
[email protected] | b64e1d34 | 2013-02-13 04:31:16 | [diff] [blame] | 76 | Iterator(const PictureLayerTilingSet* set, |
[email protected] | f677653 | 2012-12-21 20:24:33 | [diff] [blame] | 77 | float contents_scale, |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 78 | gfx::Rect content_rect, |
[email protected] | 53676978 | 2013-03-20 09:12:21 | [diff] [blame] | 79 | float ideal_contents_scale); |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 80 | ~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] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 96 | PictureLayerTiling* CurrentTiling(); |
| 97 | |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 98 | private: |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 99 | int NextTiling() const; |
| 100 | |
[email protected] | f677653 | 2012-12-21 20:24:33 | [diff] [blame] | 101 | const PictureLayerTilingSet* set_; |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 102 | float contents_scale_; |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 103 | float ideal_contents_scale_; |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 104 | PictureLayerTiling::Iterator tiling_iter_; |
| 105 | int current_tiling_; |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 106 | int ideal_tiling_; |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 107 | |
| 108 | Region current_region_; |
| 109 | Region missing_region_; |
| 110 | Region::Iterator region_iter_; |
| 111 | }; |
| 112 | |
[email protected] | 8c569022 | 2013-02-15 17:36:43 | [diff] [blame] | 113 | scoped_ptr<base::Value> AsValue() const; |
| 114 | |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 115 | private: |
| 116 | PictureLayerTilingClient* client_; |
| 117 | gfx::Size layer_bounds_; |
| 118 | ScopedPtrVector<PictureLayerTiling> tilings_; |
[email protected] | cd69627 | 2012-11-21 19:15:27 | [diff] [blame] | 119 | |
| 120 | friend class Iterator; |
| 121 | }; |
| 122 | |
| 123 | } // namespace cc |
| 124 | |
[email protected] | e12dd0e | 2013-03-18 08:24:40 | [diff] [blame] | 125 | #endif // CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_ |