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_impl.cc | |
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_impl.cc')
-rw-r--r-- | cc/picture_layer_impl.cc | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/cc/picture_layer_impl.cc b/cc/picture_layer_impl.cc index 5c1d8e8..6155ed0 100644 --- a/cc/picture_layer_impl.cc +++ b/cc/picture_layer_impl.cc @@ -12,7 +12,8 @@ namespace cc { PictureLayerImpl::PictureLayerImpl(int id) : - LayerImpl(id) { + LayerImpl(id), + tilings_(this) { } PictureLayerImpl::~PictureLayerImpl() { @@ -25,24 +26,21 @@ const char* PictureLayerImpl::layerTypeAsString() const { void PictureLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsData) { - const gfx::Rect& visible_rect = visibleContentRect(); + const gfx::Rect& rect = visibleContentRect(); gfx::Rect content_rect(gfx::Point(), contentBounds()); - if (!tilings_.size()) - return; - SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQuadState()); bool clipped = false; gfx::QuadF target_quad = MathUtil::mapQuad( drawTransform(), - gfx::QuadF(visible_rect), + gfx::QuadF(rect), clipped); bool isAxisAlignedInTarget = !clipped && target_quad.IsRectilinear(); bool useAA = !isAxisAlignedInTarget; - // TODO(enne): Generate quads from multiple tilings. - PictureLayerTiling* tiling = tilings_[0]; - for (PictureLayerTiling::Iterator iter(tiling, visible_rect); iter; ++iter) { + for (PictureLayerTilingSet::Iterator iter(&tilings_, contentsScaleX(), rect); + iter; + ++iter) { ResourceProvider::ResourceId resource; if (*iter) resource = iter->resource_id(); @@ -54,7 +52,8 @@ void PictureLayerImpl::appendQuads(QuadSink& quadSink, gfx::Rect geometry_rect = iter.geometry_rect(); gfx::RectF texture_rect = iter.texture_rect(); - gfx::Rect opaque_rect = iter.opaque_rect(); + gfx::Rect opaque_rect = iter->opaque_rect(); + opaque_rect.Intersect(content_rect); bool outside_left_edge = geometry_rect.x() == content_rect.x(); bool outside_top_edge = geometry_rect.y() == content_rect.y(); @@ -95,26 +94,15 @@ scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling*, } void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { - tilings_.clear(); - for (size_t i = 0; i < other->tilings_.size(); ++i) { - scoped_ptr<PictureLayerTiling> clone = other->tilings_[i]->Clone(); - clone->set_client(this); - tilings_.append(clone.Pass()); - } + tilings_.CloneFrom(other->tilings_); } void PictureLayerImpl::Update() { + tilings_.SetLayerBounds(bounds()); // TODO(enne): Add more tilings during pinch zoom. - if (!tilings_.size()) { + if (!tilings_.num_tilings()) { gfx::Size tile_size = layerTreeHostImpl()->settings().defaultTileSize; - - scoped_ptr<PictureLayerTiling> tiling = PictureLayerTiling::Create( - tile_size); - tiling->set_client(this); - tiling->SetBounds(contentBounds()); - tiling->create_tiles(gfx::Rect(gfx::Point(), contentBounds())); - tilings_.append(tiling.Pass()); - + tilings_.AddTiling(contentsScaleX(), tile_size); // TODO(enne): handle invalidations, create new tiles } } |