diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-21 20:24:33 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-21 20:24:33 +0000 |
commit | f6776538cacd9c33d1a9f2ac0c30cf9132da1222 (patch) | |
tree | a1267bff484e78e4b0ddd9f5a54d375e81b9e73d | |
parent | 1360980ca0ac29732b7e3d9fbf6e5c367f460219 (diff) | |
download | chromium_src-f6776538cacd9c33d1a9f2ac0c30cf9132da1222.zip chromium_src-f6776538cacd9c33d1a9f2ac0c30cf9132da1222.tar.gz chromium_src-f6776538cacd9c33d1a9f2ac0c30cf9132da1222.tar.bz2 |
cc: Support mask layers in impl-side painting
Mask layers just set always update their tiling to be exactly the size of the
mask content bounds, so that there's exactly one tile.
R=nduca@chromium.org
BUG=165730
Review URL: https://chromiumcodereview.appspot.com/11639050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174443 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/layer_tree_host_common.cc | 10 | ||||
-rw-r--r-- | cc/layer_tree_impl.cc | 6 | ||||
-rw-r--r-- | cc/layer_tree_impl.h | 1 | ||||
-rw-r--r-- | cc/picture_layer.cc | 8 | ||||
-rw-r--r-- | cc/picture_layer.h | 2 | ||||
-rw-r--r-- | cc/picture_layer_impl.cc | 46 | ||||
-rw-r--r-- | cc/picture_layer_impl.h | 6 | ||||
-rw-r--r-- | cc/picture_layer_tiling.cc | 3 | ||||
-rw-r--r-- | cc/picture_layer_tiling_set.cc | 2 | ||||
-rw-r--r-- | cc/picture_layer_tiling_set.h | 7 |
10 files changed, 80 insertions, 11 deletions
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc index d6fc3b9..2210894 100644 --- a/cc/layer_tree_host_common.cc +++ b/cc/layer_tree_host_common.cc @@ -233,6 +233,16 @@ static inline bool subtreeShouldBeSkipped(Layer* layer) static inline void markLayerAsUpdated(LayerImpl* layer) { layer->didUpdateTransforms(); + + // Mask layers don't get this call, so explicitly update them so they can + // kick off tile rasterization. + if (layer->maskLayer()) + layer->maskLayer()->didUpdateTransforms(); + if (layer->replicaLayer()) { + layer->replicaLayer()->didUpdateTransforms(); + if (layer->replicaLayer()->maskLayer()) + layer->replicaLayer()->maskLayer()->didUpdateTransforms(); + } } static inline void markLayerAsUpdated(Layer* layer) diff --git a/cc/layer_tree_impl.cc b/cc/layer_tree_impl.cc index 949cf84..5abe6e4 100644 --- a/cc/layer_tree_impl.cc +++ b/cc/layer_tree_impl.cc @@ -126,7 +126,7 @@ void LayerTreeImpl::UpdateDrawProperties() { device_viewport_size(), device_scale_factor(), pinch_zoom_viewport().pageScaleFactor(), - layer_tree_host_impl_->rendererCapabilities().maxTextureSize, + MaxTextureSize(), settings().canUseLCDText, render_surface_layer_list_); } @@ -217,6 +217,10 @@ LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) { return tree->LayerById(id); } +int LayerTreeImpl::MaxTextureSize() const { + return layer_tree_host_impl_->rendererCapabilities().maxTextureSize; +} + void LayerTreeImpl::SetNeedsRedraw() { layer_tree_host_impl_->setNeedsRedraw(); } diff --git a/cc/layer_tree_impl.h b/cc/layer_tree_impl.h index 4b16f46..8d65030 100644 --- a/cc/layer_tree_impl.h +++ b/cc/layer_tree_impl.h @@ -54,6 +54,7 @@ class CC_EXPORT LayerTreeImpl { bool IsPendingTree() const; LayerImpl* FindActiveTreeLayerById(int id); LayerImpl* FindPendingTreeLayerById(int id); + int MaxTextureSize() const; // Tree specific methods exposed to layer-impl tree. // --------------------------------------------------------------------------- diff --git a/cc/picture_layer.cc b/cc/picture_layer.cc index 241aff4..d00f54b 100644 --- a/cc/picture_layer.cc +++ b/cc/picture_layer.cc @@ -15,7 +15,8 @@ scoped_refptr<PictureLayer> PictureLayer::create(ContentLayerClient* client) { } PictureLayer::PictureLayer(ContentLayerClient* client) : - client_(client) { + client_(client), + is_mask_(false) { } PictureLayer::~PictureLayer() { @@ -33,6 +34,7 @@ void PictureLayer::pushPropertiesTo(LayerImpl* base_layer) { Layer::pushPropertiesTo(base_layer); PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); + layer_impl->SetIsMask(is_mask_); layer_impl->tilings_.SetLayerBounds(bounds()); layer_impl->invalidation_.Clear(); layer_impl->invalidation_.Swap(pile_invalidation_); @@ -62,4 +64,8 @@ void PictureLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, pile_.Update(client_, pile_invalidation_, stats); } +void PictureLayer::setIsMask(bool is_mask) { + is_mask_ = is_mask; +} + } // namespace cc diff --git a/cc/picture_layer.h b/cc/picture_layer.h index fd330fb..2ff522f 100644 --- a/cc/picture_layer.h +++ b/cc/picture_layer.h @@ -30,6 +30,7 @@ public: virtual void setNeedsDisplayRect(const gfx::RectF& layerRect) OVERRIDE; virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) OVERRIDE; + virtual void setIsMask(bool is_mask) OVERRIDE; protected: explicit PictureLayer(ContentLayerClient*); @@ -42,6 +43,7 @@ private: Region pending_invalidation_; // Invalidation from the last time update was called. Region pile_invalidation_; + bool is_mask_; }; } // namespace cc diff --git a/cc/picture_layer_impl.cc b/cc/picture_layer_impl.cc index 245ade0..24f2b47 100644 --- a/cc/picture_layer_impl.cc +++ b/cc/picture_layer_impl.cc @@ -22,7 +22,8 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id) : LayerImpl(treeImpl, id), tilings_(this), pile_(PicturePileImpl::Create()), - last_update_time_(0) { + last_update_time_(0), + is_mask_(false) { } PictureLayerImpl::~PictureLayerImpl() { @@ -132,8 +133,7 @@ void PictureLayerImpl::didUpdateTransforms() { // TODO(enne): Add tilings during pinch zoom // TODO(enne): Consider culling old tilings after pinch finishes. if (!tilings_.num_tilings()) { - gfx::Size tile_size = layerTreeImpl()->settings().defaultTileSize; - AddTiling(contentsScaleX(), tile_size); + AddTiling(contentsScaleX(), TileSize()); // TODO(enne): Add a low-res tiling as well. } } else { @@ -141,7 +141,8 @@ void PictureLayerImpl::didUpdateTransforms() { tilings_.Reset(); } - gfx::Transform current_screen_space_transform = screenSpaceTransform(); + gfx::Transform current_screen_space_transform = + screenSpaceTransform(); double current_time = (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); double time_delta = 0; @@ -170,6 +171,8 @@ void PictureLayerImpl::didUpdateTransforms() { } void PictureLayerImpl::didUpdateBounds() { + if (is_mask_) + tilings_.Reset(); tilings_.SetLayerBounds(bounds()); } @@ -210,6 +213,30 @@ void PictureLayerImpl::SyncTiling( tilings_.Clone(tiling, invalidation_); } +void PictureLayerImpl::SetIsMask(bool is_mask) { + if (is_mask_ == is_mask) + return; + is_mask_ = is_mask; + tilings_.Reset(); +} + +ResourceProvider::ResourceId PictureLayerImpl::contentsResourceId() const { + gfx::Rect content_rect(gfx::Point(), contentBounds()); + float scale = contentsScaleX(); + for (PictureLayerTilingSet::Iterator iter(&tilings_, scale, content_rect); + iter; + ++iter) { + // Mask resource not ready yet. + if (!*iter || !iter->GetResourceId()) + return 0; + // Masks only supported if they fit on exactly one tile. + if (iter.geometry_rect() != content_rect) + return 0; + return iter->GetResourceId(); + } + return 0; +} + void PictureLayerImpl::AddTiling(float contents_scale, gfx::Size tile_size) { const PictureLayerTiling* tiling = tilings_.AddTiling( contents_scale, @@ -228,4 +255,15 @@ void PictureLayerImpl::AddTiling(float contents_scale, gfx::Size tile_size) { pending_twin->SyncTiling(tiling); } +gfx::Size PictureLayerImpl::TileSize() const { + if (is_mask_) { + int max_size = layerTreeImpl()->MaxTextureSize(); + return gfx::Size( + std::min(max_size, contentBounds().width()), + std::min(max_size, contentBounds().height())); + } + + return layerTreeImpl()->settings().defaultTileSize; +} + } // namespace cc diff --git a/cc/picture_layer_impl.h b/cc/picture_layer_impl.h index 66f739b..bf2db9e 100644 --- a/cc/picture_layer_impl.h +++ b/cc/picture_layer_impl.h @@ -41,10 +41,15 @@ public: void SyncFromActiveLayer(); void SyncTiling(const PictureLayerTiling* tiling); + // Mask-related functions + void SetIsMask(bool is_mask); + virtual ResourceProvider::ResourceId contentsResourceId() const OVERRIDE; + protected: PictureLayerImpl(LayerTreeImpl* treeImpl, int id); void AddTiling(float contents_scale, gfx::Size tile_size); void SyncFromActiveLayer(const PictureLayerImpl* other); + gfx::Size TileSize() const; PictureLayerTilingSet tilings_; scoped_refptr<PicturePileImpl> pile_; @@ -56,6 +61,7 @@ protected: gfx::Size last_content_bounds_; float last_content_scale_x_; float last_content_scale_y_; + bool is_mask_; friend class PictureLayer; DISALLOW_COPY_AND_ASSIGN(PictureLayerImpl); diff --git a/cc/picture_layer_tiling.cc b/cc/picture_layer_tiling.cc index 62a39b3..7ea16fd 100644 --- a/cc/picture_layer_tiling.cc +++ b/cc/picture_layer_tiling.cc @@ -283,6 +283,7 @@ void PictureLayerTiling::UpdateTilePriorities( gfx::Rect view_rect(gfx::Point(), device_viewport); int right = tiling_data_.TileXIndexFromSrcCoord(content_rect.width() - 1); int bottom = tiling_data_.TileYIndexFromSrcCoord(content_rect.height() - 1); + for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { TileMapKey key = it->first; TilePriority priority; @@ -290,7 +291,6 @@ void PictureLayerTiling::UpdateTilePriorities( priority.distance_to_visible_in_pixels = std::numeric_limits<int>::max(); priority.time_to_visible_in_seconds = TilePriority::kMaxTimeToVisibleInSeconds; - // TODO(qinmin): pass the correct tree to this function. it->second->set_priority(tree, priority); continue; } @@ -312,7 +312,6 @@ void PictureLayerTiling::UpdateTilePriorities( priority.distance_to_visible_in_pixels = TilePriority::manhattanDistance(screen_rect, view_rect); - // TODO(qinmin): pass the correct tree to this function. it->second->set_priority(tree, priority); } } diff --git a/cc/picture_layer_tiling_set.cc b/cc/picture_layer_tiling_set.cc index b0744b8..25243a3 100644 --- a/cc/picture_layer_tiling_set.cc +++ b/cc/picture_layer_tiling_set.cc @@ -73,7 +73,7 @@ void PictureLayerTilingSet::Reset() { tilings_[i]->Reset(); } -PictureLayerTilingSet::Iterator::Iterator(PictureLayerTilingSet* set, +PictureLayerTilingSet::Iterator::Iterator(const PictureLayerTilingSet* set, float contents_scale, gfx::Rect content_rect) : set_(set), diff --git a/cc/picture_layer_tiling_set.h b/cc/picture_layer_tiling_set.h index 55bf71e..ddb8ffa 100644 --- a/cc/picture_layer_tiling_set.h +++ b/cc/picture_layer_tiling_set.h @@ -52,7 +52,10 @@ class CC_EXPORT PictureLayerTilingSet { // exactly fill rect with no overlap. class CC_EXPORT Iterator { public: - Iterator(PictureLayerTilingSet* set, float contents_scale, gfx::Rect rect); + Iterator( + const PictureLayerTilingSet* set, + float contents_scale, + gfx::Rect rect); ~Iterator(); // Visible rect (no borders), always in the space of rect, @@ -70,7 +73,7 @@ class CC_EXPORT PictureLayerTilingSet { operator bool() const; private: - PictureLayerTilingSet* set_; + const PictureLayerTilingSet* set_; float contents_scale_; PictureLayerTiling::Iterator tiling_iter_; int current_tiling_; |