diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 19:15:27 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 19:15:27 +0000 |
commit | cd696271b3c491f2de0109e4dc6d991884f89540 (patch) | |
tree | 9425a004275595dd0d354b730cf47d58e24d6b93 /cc/picture_layer_tiling_set.h | |
parent | 6c99c7bc949fc15b559793467fc1e1a6df857372 (diff) | |
download | chromium_src-cd696271b3c491f2de0109e4dc6d991884f89540.zip chromium_src-cd696271b3c491f2de0109e4dc6d991884f89540.tar.gz chromium_src-cd696271b3c491f2de0109e4dc6d991884f89540.tar.bz2 |
cc: Add PictureLayerTilingSet to manage PictureLayerTiling
PictureLayerTilingSet has multiple tilings at different content scales.
This should abstract managing the tilings from PictureLayerImpl. The
layer can then ask the set to fill in a given (integer) rect at a given
content scale and then get back the set of tiles/rects/texture
coordinates to generate that set. Using an integer rect allows textures
at different contents scales to fill a piece of geometry without cracks.
R=nduca@chromium.org
BUG=155209
Review URL: https://chromiumcodereview.appspot.com/11417111
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169083 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/picture_layer_tiling_set.h')
-rw-r--r-- | cc/picture_layer_tiling_set.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/cc/picture_layer_tiling_set.h b/cc/picture_layer_tiling_set.h new file mode 100644 index 0000000..d302125 --- /dev/null +++ b/cc/picture_layer_tiling_set.h @@ -0,0 +1,76 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_PICTURE_LAYER_TILING_SET_H_ +#define CC_PICTURE_LAYER_TILING_SET_H_ + +#include "cc/picture_layer_tiling.h" +#include "cc/region.h" +#include "cc/scoped_ptr_vector.h" +#include "ui/gfx/size.h" + +namespace cc { + +class CC_EXPORT PictureLayerTilingSet { + public: + PictureLayerTilingSet(PictureLayerTilingClient* client); + ~PictureLayerTilingSet(); + + // Shallow copies all data (except client) from other. + void CloneFrom(const PictureLayerTilingSet& other); + + void SetLayerBounds(gfx::Size layer_bounds); + gfx::Size LayerBounds() const; + + void Invalidate(const Region& invalidation); + + void AddTiling(float contents_scale, gfx::Size tile_size); + size_t num_tilings() const { return tilings_.size(); } + + // For a given rect, iterates through tiles that can fill it. If no + // set of tiles with resources can fill the rect, then it will iterate + // through null tiles with valid geometry_rect() until the rect is full. + // If all tiles have resources, the union of all geometry_rects will + // exactly fill rect with no overlap. + class CC_EXPORT Iterator { + public: + Iterator(PictureLayerTilingSet* set, float contents_scale, gfx::Rect rect); + ~Iterator(); + + // Visible rect (no borders), always in the space of rect, + // regardless of the relative contents scale of the tiling. + gfx::Rect geometry_rect() const; + // Texture rect (in texels) for geometry_rect + gfx::RectF texture_rect() const; + // Texture size in texels + gfx::Size texture_size() const; + + Tile* operator->() const; + Tile* operator*() const; + + Iterator& operator++(); + operator bool() const; + + private: + PictureLayerTilingSet* set_; + float contents_scale_; + PictureLayerTiling::Iterator tiling_iter_; + int current_tiling_; + + Region current_region_; + Region missing_region_; + Region::Iterator region_iter_; + }; + + private: + PictureLayerTilingClient* client_; + gfx::Size layer_bounds_; + ScopedPtrVector<PictureLayerTiling> tilings_; + + friend class Iterator; +}; + +} // namespace cc + +#endif // CC_PICTURE_LAYER_TILING_SET_H_ |