[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 | |
| 5 | #ifndef CC_PICTURE_LAYER_TILING_SET_H_ |
| 6 | #define CC_PICTURE_LAYER_TILING_SET_H_ |
| 7 | |
| 8 | #include "cc/picture_layer_tiling.h" |
| 9 | #include "cc/region.h" |
| 10 | #include "cc/scoped_ptr_vector.h" |
| 11 | #include "ui/gfx/size.h" |
| 12 | |
| 13 | namespace cc { |
| 14 | |
| 15 | class CC_EXPORT PictureLayerTilingSet { |
| 16 | public: |
| 17 | PictureLayerTilingSet(PictureLayerTilingClient* client); |
| 18 | ~PictureLayerTilingSet(); |
| 19 | |
| 20 | // Shallow copies all data (except client) from other. |
| 21 | void CloneFrom(const PictureLayerTilingSet& other); |
| 22 | |
| 23 | void SetLayerBounds(gfx::Size layer_bounds); |
| 24 | gfx::Size LayerBounds() const; |
| 25 | |
| 26 | void Invalidate(const Region& invalidation); |
| 27 | |
| 28 | void AddTiling(float contents_scale, gfx::Size tile_size); |
| 29 | size_t num_tilings() const { return tilings_.size(); } |
| 30 | |
| 31 | // For a given rect, iterates through tiles that can fill it. If no |
| 32 | // set of tiles with resources can fill the rect, then it will iterate |
| 33 | // through null tiles with valid geometry_rect() until the rect is full. |
| 34 | // If all tiles have resources, the union of all geometry_rects will |
| 35 | // exactly fill rect with no overlap. |
| 36 | class CC_EXPORT Iterator { |
| 37 | public: |
| 38 | Iterator(PictureLayerTilingSet* set, float contents_scale, gfx::Rect rect); |
| 39 | ~Iterator(); |
| 40 | |
| 41 | // Visible rect (no borders), always in the space of rect, |
| 42 | // regardless of the relative contents scale of the tiling. |
| 43 | gfx::Rect geometry_rect() const; |
| 44 | // Texture rect (in texels) for geometry_rect |
| 45 | gfx::RectF texture_rect() const; |
| 46 | // Texture size in texels |
| 47 | gfx::Size texture_size() const; |
| 48 | |
| 49 | Tile* operator->() const; |
| 50 | Tile* operator*() const; |
| 51 | |
| 52 | Iterator& operator++(); |
| 53 | operator bool() const; |
| 54 | |
| 55 | private: |
| 56 | PictureLayerTilingSet* set_; |
| 57 | float contents_scale_; |
| 58 | PictureLayerTiling::Iterator tiling_iter_; |
| 59 | int current_tiling_; |
| 60 | |
| 61 | Region current_region_; |
| 62 | Region missing_region_; |
| 63 | Region::Iterator region_iter_; |
| 64 | }; |
| 65 | |
| 66 | private: |
| 67 | PictureLayerTilingClient* client_; |
| 68 | gfx::Size layer_bounds_; |
| 69 | ScopedPtrVector<PictureLayerTiling> tilings_; |
| 70 | |
| 71 | friend class Iterator; |
| 72 | }; |
| 73 | |
| 74 | } // namespace cc |
| 75 | |
| 76 | #endif // CC_PICTURE_LAYER_TILING_SET_H_ |