| Index: cc/layer.cc
|
| diff --git a/cc/layer.cc b/cc/layer.cc
|
| index ec7f8dd3f86e8e6caf6d9db544899321cffcec16..bc0280302b893bb30a3cbf9c6431ef9060900f3c 100644
|
| --- a/cc/layer.cc
|
| +++ b/cc/layer.cc
|
| @@ -18,884 +18,794 @@
|
|
|
| namespace cc {
|
|
|
| -static int s_nextLayerId = 1;
|
| +static int s_next_layer_id = 1;
|
|
|
| -scoped_refptr<Layer> Layer::create()
|
| -{
|
| - return make_scoped_refptr(new Layer());
|
| +scoped_refptr<Layer> Layer::Create() {
|
| + return make_scoped_refptr(new Layer());
|
| }
|
|
|
| Layer::Layer()
|
| - : m_needsDisplay(false)
|
| - , m_stackingOrderChanged(false)
|
| - , m_layerId(s_nextLayerId++)
|
| - , m_ignoreSetNeedsCommit(false)
|
| - , m_parent(0)
|
| - , m_layerTreeHost(0)
|
| - , m_scrollable(false)
|
| - , m_shouldScrollOnMainThread(false)
|
| - , m_haveWheelEventHandlers(false)
|
| - , m_anchorPoint(0.5, 0.5)
|
| - , m_backgroundColor(0)
|
| - , m_opacity(1.0)
|
| - , m_anchorPointZ(0)
|
| - , m_isContainerForFixedPositionLayers(false)
|
| - , m_fixedToContainerLayer(false)
|
| - , m_isDrawable(false)
|
| - , m_masksToBounds(false)
|
| - , m_contentsOpaque(false)
|
| - , m_doubleSided(true)
|
| - , m_preserves3D(false)
|
| - , m_useParentBackfaceVisibility(false)
|
| - , m_drawCheckerboardForMissingTiles(false)
|
| - , m_forceRenderSurface(false)
|
| - , m_replicaLayer(0)
|
| - , m_rasterScale(1.0)
|
| - , m_automaticallyComputeRasterScale(false)
|
| - , m_boundsContainPageScale(false)
|
| - , m_layerAnimationDelegate(0)
|
| - , m_layerScrollClient(0)
|
| -{
|
| - if (m_layerId < 0) {
|
| - s_nextLayerId = 1;
|
| - m_layerId = s_nextLayerId++;
|
| - }
|
| -
|
| - m_layerAnimationController = LayerAnimationController::Create(m_layerId);
|
| - m_layerAnimationController->AddObserver(this);
|
| - addLayerAnimationEventObserver(m_layerAnimationController.get());
|
| -}
|
| -
|
| -Layer::~Layer()
|
| -{
|
| - // Our parent should be holding a reference to us so there should be no
|
| - // way for us to be destroyed while we still have a parent.
|
| - DCHECK(!parent());
|
| -
|
| - m_layerAnimationController->RemoveObserver(this);
|
| -
|
| - // Remove the parent reference from all children and dependents.
|
| - removeAllChildren();
|
| - if (m_maskLayer) {
|
| - DCHECK_EQ(this, m_maskLayer->parent());
|
| - m_maskLayer->removeFromParent();
|
| - }
|
| - if (m_replicaLayer) {
|
| - DCHECK_EQ(this, m_replicaLayer->parent());
|
| - m_replicaLayer->removeFromParent();
|
| - }
|
| -}
|
| -
|
| -void Layer::setLayerTreeHost(LayerTreeHost* host)
|
| -{
|
| - if (m_layerTreeHost == host)
|
| - return;
|
| -
|
| - m_layerTreeHost = host;
|
| -
|
| - for (size_t i = 0; i < m_children.size(); ++i)
|
| - m_children[i]->setLayerTreeHost(host);
|
| -
|
| - if (m_maskLayer)
|
| - m_maskLayer->setLayerTreeHost(host);
|
| - if (m_replicaLayer)
|
| - m_replicaLayer->setLayerTreeHost(host);
|
| -
|
| - m_layerAnimationController->SetAnimationRegistrar(host ? host->animationRegistrar() : 0);
|
| -
|
| - if (host && m_layerAnimationController->has_any_animation())
|
| - host->setNeedsCommit();
|
| - if (host && (!m_filters.isEmpty() || !m_backgroundFilters.isEmpty() || m_filter))
|
| - m_layerTreeHost->setNeedsFilterContext();
|
| -
|
| -}
|
| -
|
| -void Layer::setNeedsCommit()
|
| -{
|
| - if (m_ignoreSetNeedsCommit)
|
| - return;
|
| - if (m_layerTreeHost)
|
| - m_layerTreeHost->setNeedsCommit();
|
| -}
|
| -
|
| -void Layer::setNeedsFullTreeSync()
|
| -{
|
| - if (m_layerTreeHost)
|
| - m_layerTreeHost->setNeedsFullTreeSync();
|
| -}
|
| -
|
| -gfx::Rect Layer::layerRectToContentRect(const gfx::RectF& layerRect) const
|
| -{
|
| - gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), contentsScaleY());
|
| - // Intersect with content rect to avoid the extra pixel because for some
|
| - // values x and y, ceil((x / y) * y) may be x + 1.
|
| - contentRect.Intersect(gfx::Rect(gfx::Point(), contentBounds()));
|
| - return gfx::ToEnclosingRect(contentRect);
|
| -}
|
| -
|
| -bool Layer::blocksPendingCommit() const
|
| -{
|
| - return false;
|
| -}
|
| -
|
| -bool Layer::canClipSelf() const
|
| -{
|
| - return false;
|
| -}
|
| -
|
| -bool Layer::blocksPendingCommitRecursive() const
|
| -{
|
| - if (blocksPendingCommit())
|
| - return true;
|
| - if (maskLayer() && maskLayer()->blocksPendingCommitRecursive())
|
| - return true;
|
| - if (replicaLayer() && replicaLayer()->blocksPendingCommitRecursive())
|
| - return true;
|
| - for (size_t i = 0; i < m_children.size(); ++i)
|
| - {
|
| - if (m_children[i]->blocksPendingCommitRecursive())
|
| - return true;
|
| - }
|
| - return false;
|
| -}
|
| -
|
| -void Layer::setParent(Layer* layer)
|
| -{
|
| - DCHECK(!layer || !layer->hasAncestor(this));
|
| - m_parent = layer;
|
| - setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0);
|
| -
|
| - forceAutomaticRasterScaleToBeRecomputed();
|
| - if (m_maskLayer)
|
| - m_maskLayer->forceAutomaticRasterScaleToBeRecomputed();
|
| - if (m_replicaLayer && m_replicaLayer->m_maskLayer)
|
| - m_replicaLayer->m_maskLayer->forceAutomaticRasterScaleToBeRecomputed();
|
| -}
|
| + : needs_display_(false),
|
| + stacking_order_changed_(false),
|
| + layer_id_(s_next_layer_id++),
|
| + ignore_set_needs_commit_(false),
|
| + parent_(NULL),
|
| + layer_tree_host_(NULL),
|
| + scrollable_(false),
|
| + should_scroll_on_main_thread_(false),
|
| + have_wheel_event_handlers_(false),
|
| + anchor_point_(0.5f, 0.5f),
|
| + background_color_(0),
|
| + opacity_(1.f),
|
| + anchor_point_z_(0.f),
|
| + is_container_for_fixed_position_layers_(false),
|
| + fixed_to_container_layer_(false),
|
| + is_drawable_(false),
|
| + masks_to_bounds_(false),
|
| + contents_opaque_(false),
|
| + double_sided_(true),
|
| + preserves_3d_(false),
|
| + use_parent_backface_visibility_(false),
|
| + draw_checkerboard_for_missing_tiles_(false),
|
| + force_render_surface_(false),
|
| + replica_layer_(NULL),
|
| + raster_scale_(1.f),
|
| + automatically_compute_raster_scale_(false),
|
| + bounds_contain_page_scale_(false),
|
| + layer_animation_delegate_(NULL),
|
| + layer_scroll_client_(NULL) {
|
| + if (layer_id_ < 0) {
|
| + s_next_layer_id = 1;
|
| + layer_id_ = s_next_layer_id++;
|
| + }
|
| +
|
| + layer_animation_controller_ = LayerAnimationController::Create(layer_id_);
|
| + layer_animation_controller_->AddObserver(this);
|
| + AddLayerAnimationEventObserver(layer_animation_controller_.get());
|
| +}
|
| +
|
| +Layer::~Layer() {
|
| + // Our parent should be holding a reference to us so there should be no
|
| + // way for us to be destroyed while we still have a parent.
|
| + DCHECK(!parent());
|
| +
|
| + layer_animation_controller_->RemoveObserver(this);
|
| +
|
| + // Remove the parent reference from all children and dependents.
|
| + RemoveAllChildren();
|
| + if (mask_layer_) {
|
| + DCHECK_EQ(this, mask_layer_->parent());
|
| + mask_layer_->RemoveFromParent();
|
| + }
|
| + if (replica_layer_) {
|
| + DCHECK_EQ(this, replica_layer_->parent());
|
| + replica_layer_->RemoveFromParent();
|
| + }
|
| +}
|
| +
|
| +void Layer::SetLayerTreeHost(LayerTreeHost* host) {
|
| + if (layer_tree_host_ == host)
|
| + return;
|
| +
|
| + layer_tree_host_ = host;
|
| +
|
| + for (size_t i = 0; i < children_.size(); ++i)
|
| + children_[i]->SetLayerTreeHost(host);
|
| +
|
| + if (mask_layer_)
|
| + mask_layer_->SetLayerTreeHost(host);
|
| + if (replica_layer_)
|
| + replica_layer_->SetLayerTreeHost(host);
|
| +
|
| + layer_animation_controller_->SetAnimationRegistrar(
|
| + host ? host->animationRegistrar() : NULL);
|
| +
|
| + if (host && layer_animation_controller_->has_any_animation())
|
| + host->setNeedsCommit();
|
| + if (host &&
|
| + (!filters_.isEmpty() || !background_filters_.isEmpty() || filter_))
|
| + layer_tree_host_->setNeedsFilterContext();
|
| +
|
| +}
|
| +
|
| +void Layer::SetNeedsCommit() {
|
| + if (ignore_set_needs_commit_)
|
| + return;
|
| + if (layer_tree_host_)
|
| + layer_tree_host_->setNeedsCommit();
|
| +}
|
| +
|
| +void Layer::SetNeedsFullTreeSync() {
|
| + if (layer_tree_host_)
|
| + layer_tree_host_->setNeedsFullTreeSync();
|
| +}
|
| +
|
| +gfx::Rect Layer::LayerRectToContentRect(const gfx::RectF& layer_rect) const {
|
| + gfx::RectF content_rect =
|
| + gfx::ScaleRect(layer_rect, contents_scale_x(), contents_scale_y());
|
| + // Intersect with content rect to avoid the extra pixel because for some
|
| + // values x and y, ceil((x / y) * y) may be x + 1.
|
| + content_rect.Intersect(gfx::Rect(gfx::Point(), content_bounds()));
|
| + return gfx::ToEnclosingRect(content_rect);
|
| +}
|
| +
|
| +bool Layer::BlocksPendingCommit() const {
|
| + return false;
|
| +}
|
| +
|
| +bool Layer::CanClipSelf() const {
|
| + return false;
|
| +}
|
|
|
| -bool Layer::hasAncestor(Layer* ancestor) const
|
| -{
|
| - for (const Layer* layer = parent(); layer; layer = layer->parent()) {
|
| - if (layer == ancestor)
|
| - return true;
|
| - }
|
| - return false;
|
| -}
|
| -
|
| -void Layer::addChild(scoped_refptr<Layer> child)
|
| -{
|
| - insertChild(child, m_children.size());
|
| -}
|
| -
|
| -void Layer::insertChild(scoped_refptr<Layer> child, size_t index)
|
| -{
|
| - child->removeFromParent();
|
| - child->setParent(this);
|
| - child->m_stackingOrderChanged = true;
|
| -
|
| - index = std::min(index, m_children.size());
|
| - m_children.insert(m_children.begin() + index, child);
|
| - setNeedsFullTreeSync();
|
| -}
|
| -
|
| -void Layer::removeFromParent()
|
| -{
|
| - if (m_parent)
|
| - m_parent->removeChildOrDependent(this);
|
| -}
|
| -
|
| -void Layer::removeChildOrDependent(Layer* child)
|
| -{
|
| - if (m_maskLayer == child) {
|
| - m_maskLayer->setParent(NULL);
|
| - m_maskLayer = NULL;
|
| - setNeedsFullTreeSync();
|
| - return;
|
| - }
|
| - if (m_replicaLayer == child) {
|
| - m_replicaLayer->setParent(NULL);
|
| - m_replicaLayer = NULL;
|
| - setNeedsFullTreeSync();
|
| - return;
|
| - }
|
| -
|
| - for (LayerList::iterator iter = m_children.begin(); iter != m_children.end(); ++iter)
|
| - {
|
| - if (*iter != child)
|
| - continue;
|
| -
|
| - child->setParent(0);
|
| - m_children.erase(iter);
|
| - setNeedsFullTreeSync();
|
| - return;
|
| - }
|
| +bool Layer::BlocksPendingCommitRecursive() const {
|
| + if (BlocksPendingCommit())
|
| + return true;
|
| + if (mask_layer() && mask_layer()->BlocksPendingCommitRecursive())
|
| + return true;
|
| + if (replica_layer() && replica_layer()->BlocksPendingCommitRecursive())
|
| + return true;
|
| + for (size_t i = 0; i < children_.size(); ++i) {
|
| + if (children_[i]->BlocksPendingCommitRecursive())
|
| + return true;
|
| + }
|
| + return false;
|
| }
|
|
|
| -void Layer::replaceChild(Layer* reference, scoped_refptr<Layer> newLayer)
|
| -{
|
| - DCHECK(reference);
|
| - DCHECK_EQ(reference->parent(), this);
|
| -
|
| - if (reference == newLayer)
|
| - return;
|
| -
|
| - int referenceIndex = indexOfChild(reference);
|
| - if (referenceIndex == -1) {
|
| - NOTREACHED();
|
| - return;
|
| - }
|
| -
|
| - reference->removeFromParent();
|
| +void Layer::SetParent(Layer* layer) {
|
| + DCHECK(!layer || !layer->HasAncestor(this));
|
| + parent_ = layer;
|
| + SetLayerTreeHost(parent_ ? parent_->layer_tree_host() : NULL);
|
|
|
| - if (newLayer) {
|
| - newLayer->removeFromParent();
|
| - insertChild(newLayer, referenceIndex);
|
| - }
|
| + ForceAutomaticRasterScaleToBeRecomputed();
|
| + if (mask_layer_)
|
| + mask_layer_->ForceAutomaticRasterScaleToBeRecomputed();
|
| + if (replica_layer_ && replica_layer_->mask_layer_)
|
| + replica_layer_->mask_layer_->ForceAutomaticRasterScaleToBeRecomputed();
|
| }
|
|
|
| -int Layer::indexOfChild(const Layer* reference)
|
| -{
|
| - for (size_t i = 0; i < m_children.size(); ++i) {
|
| - if (m_children[i] == reference)
|
| - return i;
|
| - }
|
| - return -1;
|
| +bool Layer::HasAncestor(Layer* ancestor) const {
|
| + for (const Layer* layer = parent(); layer; layer = layer->parent()) {
|
| + if (layer == ancestor)
|
| + return true;
|
| + }
|
| + return false;
|
| }
|
|
|
| -void Layer::setBounds(const gfx::Size& size)
|
| -{
|
| - if (bounds() == size)
|
| - return;
|
| -
|
| - bool firstResize = bounds().IsEmpty() && !size.IsEmpty();
|
| -
|
| - m_bounds = size;
|
| -
|
| - if (firstResize)
|
| - setNeedsDisplay();
|
| - else
|
| - setNeedsCommit();
|
| +void Layer::AddChild(scoped_refptr<Layer> child) {
|
| + InsertChild(child, children_.size());
|
| }
|
|
|
| -Layer* Layer::rootLayer()
|
| -{
|
| - Layer* layer = this;
|
| - while (layer->parent())
|
| - layer = layer->parent();
|
| - return layer;
|
| -}
|
| +void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) {
|
| + child->RemoveFromParent();
|
| + child->SetParent(this);
|
| + child->stacking_order_changed_ = true;
|
|
|
| -void Layer::removeAllChildren()
|
| -{
|
| - while (m_children.size()) {
|
| - Layer* layer = m_children[0].get();
|
| - DCHECK_EQ(this, layer->parent());
|
| - layer->removeFromParent();
|
| - }
|
| + index = std::min(index, children_.size());
|
| + children_.insert(children_.begin() + index, child);
|
| + SetNeedsFullTreeSync();
|
| }
|
|
|
| -void Layer::setChildren(const LayerList& children)
|
| -{
|
| - if (children == m_children)
|
| - return;
|
| -
|
| - removeAllChildren();
|
| - for (size_t i = 0; i < children.size(); ++i)
|
| - addChild(children[i]);
|
| +void Layer::RemoveFromParent() {
|
| + if (parent_)
|
| + parent_->RemoveChildOrDependent(this);
|
| }
|
|
|
| -Layer* Layer::childAt(size_t index)
|
| -{
|
| - DCHECK_LT(index, m_children.size());
|
| - return m_children[index].get();
|
| -}
|
| +void Layer::RemoveChildOrDependent(Layer* child) {
|
| + if (mask_layer_ == child) {
|
| + mask_layer_->SetParent(NULL);
|
| + mask_layer_ = NULL;
|
| + SetNeedsFullTreeSync();
|
| + return;
|
| + }
|
| + if (replica_layer_ == child) {
|
| + replica_layer_->SetParent(NULL);
|
| + replica_layer_ = NULL;
|
| + SetNeedsFullTreeSync();
|
| + return;
|
| + }
|
|
|
| -void Layer::setAnchorPoint(const gfx::PointF& anchorPoint)
|
| -{
|
| - if (m_anchorPoint == anchorPoint)
|
| - return;
|
| - m_anchorPoint = anchorPoint;
|
| - setNeedsCommit();
|
| -}
|
| + for (LayerList::iterator iter = children_.begin();
|
| + iter != children_.end();
|
| + ++iter) {
|
| + if (*iter != child)
|
| + continue;
|
|
|
| -void Layer::setAnchorPointZ(float anchorPointZ)
|
| -{
|
| - if (m_anchorPointZ == anchorPointZ)
|
| - return;
|
| - m_anchorPointZ = anchorPointZ;
|
| - setNeedsCommit();
|
| + child->SetParent(NULL);
|
| + children_.erase(iter);
|
| + SetNeedsFullTreeSync();
|
| + return;
|
| + }
|
| }
|
|
|
| -void Layer::setBackgroundColor(SkColor backgroundColor)
|
| -{
|
| - if (m_backgroundColor == backgroundColor)
|
| - return;
|
| - m_backgroundColor = backgroundColor;
|
| - setNeedsCommit();
|
| -}
|
| +void Layer::ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer) {
|
| + DCHECK(reference);
|
| + DCHECK_EQ(reference->parent(), this);
|
|
|
| -void Layer::calculateContentsScale(
|
| - float idealContentsScale,
|
| - bool animatingTransformToScreen,
|
| - float* contentsScaleX,
|
| - float* contentsScaleY,
|
| - gfx::Size* contentBounds)
|
| -{
|
| - *contentsScaleX = 1;
|
| - *contentsScaleY = 1;
|
| - *contentBounds = bounds();
|
| -}
|
| + if (reference == new_layer)
|
| + return;
|
|
|
| -void Layer::setMasksToBounds(bool masksToBounds)
|
| -{
|
| - if (m_masksToBounds == masksToBounds)
|
| - return;
|
| - m_masksToBounds = masksToBounds;
|
| - setNeedsCommit();
|
| -}
|
| + int reference_index = IndexOfChild(reference);
|
| + if (reference_index == -1) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
|
|
| -void Layer::setMaskLayer(Layer* maskLayer)
|
| -{
|
| - if (m_maskLayer == maskLayer)
|
| - return;
|
| - if (m_maskLayer) {
|
| - DCHECK_EQ(this, m_maskLayer->parent());
|
| - m_maskLayer->removeFromParent();
|
| - }
|
| - m_maskLayer = maskLayer;
|
| - if (m_maskLayer) {
|
| - DCHECK(!m_maskLayer->parent());
|
| - m_maskLayer->removeFromParent();
|
| - m_maskLayer->setParent(this);
|
| - m_maskLayer->setIsMask(true);
|
| - }
|
| - setNeedsFullTreeSync();
|
| -}
|
| + reference->RemoveFromParent();
|
|
|
| -void Layer::setReplicaLayer(Layer* layer)
|
| -{
|
| - if (m_replicaLayer == layer)
|
| - return;
|
| - if (m_replicaLayer) {
|
| - DCHECK_EQ(this, m_replicaLayer->parent());
|
| - m_replicaLayer->removeFromParent();
|
| - }
|
| - m_replicaLayer = layer;
|
| - if (m_replicaLayer) {
|
| - DCHECK(!m_replicaLayer->parent());
|
| - m_replicaLayer->removeFromParent();
|
| - m_replicaLayer->setParent(this);
|
| - }
|
| - setNeedsFullTreeSync();
|
| + if (new_layer) {
|
| + new_layer->RemoveFromParent();
|
| + InsertChild(new_layer, reference_index);
|
| + }
|
| }
|
|
|
| -void Layer::setFilters(const WebKit::WebFilterOperations& filters)
|
| -{
|
| - if (m_filters == filters)
|
| - return;
|
| - DCHECK(!m_filter);
|
| - m_filters = filters;
|
| - setNeedsCommit();
|
| - if (!filters.isEmpty() && m_layerTreeHost)
|
| - m_layerTreeHost->setNeedsFilterContext();
|
| +int Layer::IndexOfChild(const Layer* reference) {
|
| + for (size_t i = 0; i < children_.size(); ++i) {
|
| + if (children_[i] == reference)
|
| + return i;
|
| + }
|
| + return -1;
|
| }
|
|
|
| -void Layer::setFilter(const skia::RefPtr<SkImageFilter>& filter)
|
| -{
|
| - if (m_filter.get() == filter.get())
|
| - return;
|
| - DCHECK(m_filters.isEmpty());
|
| - m_filter = filter;
|
| - setNeedsCommit();
|
| - if (filter && m_layerTreeHost)
|
| - m_layerTreeHost->setNeedsFilterContext();
|
| -}
|
| +void Layer::SetBounds(gfx::Size size) {
|
| + if (bounds() == size)
|
| + return;
|
|
|
| -void Layer::setBackgroundFilters(const WebKit::WebFilterOperations& backgroundFilters)
|
| -{
|
| - if (m_backgroundFilters == backgroundFilters)
|
| - return;
|
| - m_backgroundFilters = backgroundFilters;
|
| - setNeedsCommit();
|
| - if (!backgroundFilters.isEmpty() && m_layerTreeHost)
|
| - m_layerTreeHost->setNeedsFilterContext();
|
| + bool first_resize = bounds().IsEmpty() && !size.IsEmpty();
|
| +
|
| + bounds_ = size;
|
| +
|
| + if (first_resize)
|
| + SetNeedsDisplay();
|
| + else
|
| + SetNeedsCommit();
|
| +}
|
| +
|
| +Layer* Layer::RootLayer() {
|
| + Layer* layer = this;
|
| + while (layer->parent())
|
| + layer = layer->parent();
|
| + return layer;
|
| +}
|
| +
|
| +void Layer::RemoveAllChildren() {
|
| + while (children_.size()) {
|
| + Layer* layer = children_[0].get();
|
| + DCHECK_EQ(this, layer->parent());
|
| + layer->RemoveFromParent();
|
| + }
|
| +}
|
| +
|
| +void Layer::SetChildren(const LayerList& children) {
|
| + if (children == children_)
|
| + return;
|
| +
|
| + RemoveAllChildren();
|
| + for (size_t i = 0; i < children.size(); ++i)
|
| + AddChild(children[i]);
|
| +}
|
| +
|
| +void Layer::SetAnchorPoint(gfx::PointF anchor_point) {
|
| + if (anchor_point_ == anchor_point)
|
| + return;
|
| + anchor_point_ = anchor_point;
|
| + SetNeedsCommit();
|
| +}
|
| +
|
| +void Layer::SetAnchorPointZ(float anchor_point_z) {
|
| + if (anchor_point_z_ == anchor_point_z)
|
| + return;
|
| + anchor_point_z_ = anchor_point_z;
|
| + SetNeedsCommit();
|
| +}
|
| +
|
| +void Layer::SetBackgroundColor(SkColor background_color) {
|
| + if (background_color_ == background_color)
|
| + return;
|
| + background_color_ = background_color;
|
| + SetNeedsCommit();
|
| }
|
| -
|
| -void Layer::setOpacity(float opacity)
|
| -{
|
| - if (m_opacity == opacity)
|
| - return;
|
| - m_opacity = opacity;
|
| - setNeedsCommit();
|
| +
|
| +void Layer::CalculateContentsScale(
|
| + float ideal_contents_scale,
|
| + bool animating_transform_to_screen,
|
| + float* contents_scale_x,
|
| + float* contents_scale_y,
|
| + gfx::Size* contentBounds) {
|
| + *contents_scale_x = 1;
|
| + *contents_scale_y = 1;
|
| + *contentBounds = bounds();
|
| }
|
|
|
| -float Layer::opacity() const
|
| -{
|
| - return m_opacity;
|
| -}
|
| +void Layer::SetMasksToBounds(bool masks_to_bounds) {
|
| + if (masks_to_bounds_ == masks_to_bounds)
|
| + return;
|
| + masks_to_bounds_ = masks_to_bounds;
|
| + SetNeedsCommit();
|
| +}
|
|
|
| -bool Layer::opacityIsAnimating() const
|
| -{
|
| - return m_layerAnimationController->IsAnimatingProperty(Animation::Opacity);
|
| +void Layer::SetMaskLayer(Layer* mask_layer) {
|
| + if (mask_layer_ == mask_layer)
|
| + return;
|
| + if (mask_layer_) {
|
| + DCHECK_EQ(this, mask_layer_->parent());
|
| + mask_layer_->RemoveFromParent();
|
| + }
|
| + mask_layer_ = mask_layer;
|
| + if (mask_layer_) {
|
| + DCHECK(!mask_layer_->parent());
|
| + mask_layer_->RemoveFromParent();
|
| + mask_layer_->SetParent(this);
|
| + mask_layer_->SetIsMask(true);
|
| + }
|
| + SetNeedsFullTreeSync();
|
| }
|
|
|
| -void Layer::setContentsOpaque(bool opaque)
|
| -{
|
| - if (m_contentsOpaque == opaque)
|
| - return;
|
| - m_contentsOpaque = opaque;
|
| - setNeedsCommit();
|
| +void Layer::SetReplicaLayer(Layer* layer) {
|
| + if (replica_layer_ == layer)
|
| + return;
|
| + if (replica_layer_) {
|
| + DCHECK_EQ(this, replica_layer_->parent());
|
| + replica_layer_->RemoveFromParent();
|
| + }
|
| + replica_layer_ = layer;
|
| + if (replica_layer_) {
|
| + DCHECK(!replica_layer_->parent());
|
| + replica_layer_->RemoveFromParent();
|
| + replica_layer_->SetParent(this);
|
| + }
|
| + SetNeedsFullTreeSync();
|
| +}
|
| +
|
| +void Layer::SetFilters(const WebKit::WebFilterOperations& filters) {
|
| + if (filters_ == filters)
|
| + return;
|
| + DCHECK(!filter_);
|
| + filters_ = filters;
|
| + SetNeedsCommit();
|
| + if (!filters.isEmpty() && layer_tree_host_)
|
| + layer_tree_host_->setNeedsFilterContext();
|
| }
|
|
|
| -void Layer::setPosition(const gfx::PointF& position)
|
| -{
|
| - if (m_position == position)
|
| - return;
|
| - m_position = position;
|
| - setNeedsCommit();
|
| +void Layer::SetFilter(const skia::RefPtr<SkImageFilter>& filter) {
|
| + if (filter_.get() == filter.get())
|
| + return;
|
| + DCHECK(filters_.isEmpty());
|
| + filter_ = filter;
|
| + SetNeedsCommit();
|
| + if (filter && layer_tree_host_)
|
| + layer_tree_host_->setNeedsFilterContext();
|
| }
|
| -
|
| -void Layer::setSublayerTransform(const gfx::Transform& sublayerTransform)
|
| -{
|
| - if (m_sublayerTransform == sublayerTransform)
|
| - return;
|
| - m_sublayerTransform = sublayerTransform;
|
| - setNeedsCommit();
|
| +
|
| +void Layer::SetBackgroundFilters(const WebKit::WebFilterOperations& filters) {
|
| + if (background_filters_ == filters)
|
| + return;
|
| + background_filters_ = filters;
|
| + SetNeedsCommit();
|
| + if (!filters.isEmpty() && layer_tree_host_)
|
| + layer_tree_host_->setNeedsFilterContext();
|
| }
|
|
|
| -void Layer::setTransform(const gfx::Transform& transform)
|
| -{
|
| - if (m_transform == transform)
|
| - return;
|
| - m_transform = transform;
|
| - setNeedsCommit();
|
| +void Layer::SetOpacity(float opacity) {
|
| + if (opacity_ == opacity)
|
| + return;
|
| + opacity_ = opacity;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -const gfx::Transform& Layer::transform() const
|
| -{
|
| - return m_transform;
|
| +bool Layer::OpacityIsAnimating() const {
|
| + return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity);
|
| }
|
|
|
| -bool Layer::transformIsAnimating() const
|
| -{
|
| - return m_layerAnimationController->IsAnimatingProperty(Animation::Transform);
|
| +void Layer::SetContentsOpaque(bool opaque) {
|
| + if (contents_opaque_ == opaque)
|
| + return;
|
| + contents_opaque_ = opaque;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setScrollOffset(gfx::Vector2d scrollOffset)
|
| -{
|
| - if (m_scrollOffset == scrollOffset)
|
| - return;
|
| - m_scrollOffset = scrollOffset;
|
| - if (m_layerScrollClient)
|
| - m_layerScrollClient->didScroll();
|
| - setNeedsCommit();
|
| +void Layer::SetPosition(gfx::PointF position) {
|
| + if (position_ == position)
|
| + return;
|
| + position_ = position;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setMaxScrollOffset(gfx::Vector2d maxScrollOffset)
|
| -{
|
| - if (m_maxScrollOffset == maxScrollOffset)
|
| - return;
|
| - m_maxScrollOffset = maxScrollOffset;
|
| - setNeedsCommit();
|
| +void Layer::SetSublayerTransform(const gfx::Transform& sublayer_transform) {
|
| + if (sublayer_transform_ == sublayer_transform)
|
| + return;
|
| + sublayer_transform_ = sublayer_transform;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setScrollable(bool scrollable)
|
| -{
|
| - if (m_scrollable == scrollable)
|
| - return;
|
| - m_scrollable = scrollable;
|
| - setNeedsCommit();
|
| +void Layer::SetTransform(const gfx::Transform& transform) {
|
| + if (transform_ == transform)
|
| + return;
|
| + transform_ = transform;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setShouldScrollOnMainThread(bool shouldScrollOnMainThread)
|
| -{
|
| - if (m_shouldScrollOnMainThread == shouldScrollOnMainThread)
|
| - return;
|
| - m_shouldScrollOnMainThread = shouldScrollOnMainThread;
|
| - setNeedsCommit();
|
| +bool Layer::TransformIsAnimating() const {
|
| + return layer_animation_controller_->IsAnimatingProperty(Animation::Transform);
|
| }
|
|
|
| -void Layer::setHaveWheelEventHandlers(bool haveWheelEventHandlers)
|
| -{
|
| - if (m_haveWheelEventHandlers == haveWheelEventHandlers)
|
| - return;
|
| - m_haveWheelEventHandlers = haveWheelEventHandlers;
|
| - setNeedsCommit();
|
| +void Layer::SetScrollOffset(gfx::Vector2d scroll_offset) {
|
| + if (scroll_offset_ == scroll_offset)
|
| + return;
|
| + scroll_offset_ = scroll_offset;
|
| + if (layer_scroll_client_)
|
| + layer_scroll_client_->didScroll();
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setNonFastScrollableRegion(const Region& region)
|
| -{
|
| - if (m_nonFastScrollableRegion == region)
|
| - return;
|
| - m_nonFastScrollableRegion = region;
|
| - setNeedsCommit();
|
| +void Layer::SetMaxScrollOffset(gfx::Vector2d max_scroll_offset) {
|
| + if (max_scroll_offset_ == max_scroll_offset)
|
| + return;
|
| + max_scroll_offset_ = max_scroll_offset;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setTouchEventHandlerRegion(const Region& region)
|
| -{
|
| - if (m_touchEventHandlerRegion == region)
|
| - return;
|
| - m_touchEventHandlerRegion = region;
|
| +void Layer::SetScrollable(bool scrollable) {
|
| + if (scrollable_ == scrollable)
|
| + return;
|
| + scrollable_ = scrollable;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setDrawCheckerboardForMissingTiles(bool checkerboard)
|
| -{
|
| - if (m_drawCheckerboardForMissingTiles == checkerboard)
|
| - return;
|
| - m_drawCheckerboardForMissingTiles = checkerboard;
|
| - setNeedsCommit();
|
| +void Layer::SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) {
|
| + if (should_scroll_on_main_thread_ == should_scroll_on_main_thread)
|
| + return;
|
| + should_scroll_on_main_thread_ = should_scroll_on_main_thread;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setForceRenderSurface(bool force)
|
| -{
|
| - if (m_forceRenderSurface == force)
|
| - return;
|
| - m_forceRenderSurface = force;
|
| - setNeedsCommit();
|
| +void Layer::SetHaveWheelEventHandlers(bool have_wheel_event_handlers) {
|
| + if (have_wheel_event_handlers_ == have_wheel_event_handlers)
|
| + return;
|
| + have_wheel_event_handlers_ = have_wheel_event_handlers;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setImplTransform(const gfx::Transform& transform)
|
| -{
|
| - if (m_implTransform == transform)
|
| - return;
|
| - m_implTransform = transform;
|
| - setNeedsCommit();
|
| +void Layer::SetNonFastScrollableRegion(const Region& region) {
|
| + if (non_fast_scrollable_region_ == region)
|
| + return;
|
| + non_fast_scrollable_region_ = region;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setDoubleSided(bool doubleSided)
|
| -{
|
| - if (m_doubleSided == doubleSided)
|
| - return;
|
| - m_doubleSided = doubleSided;
|
| - setNeedsCommit();
|
| +void Layer::SetTouchEventHandlerRegion(const Region& region) {
|
| + if (touch_event_handler_region_ == region)
|
| + return;
|
| + touch_event_handler_region_ = region;
|
| }
|
|
|
| -void Layer::setIsDrawable(bool isDrawable)
|
| -{
|
| - if (m_isDrawable == isDrawable)
|
| - return;
|
| -
|
| - m_isDrawable = isDrawable;
|
| - setNeedsCommit();
|
| +void Layer::SetDrawCheckerboardForMissingTiles(bool checkerboard) {
|
| + if (draw_checkerboard_for_missing_tiles_ == checkerboard)
|
| + return;
|
| + draw_checkerboard_for_missing_tiles_ = checkerboard;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setNeedsDisplayRect(const gfx::RectF& dirtyRect)
|
| -{
|
| - m_updateRect.Union(dirtyRect);
|
| - m_needsDisplay = true;
|
| -
|
| - // Simply mark the contents as dirty. For non-root layers, the call to
|
| - // setNeedsCommit will schedule a fresh compositing pass.
|
| - // For the root layer, setNeedsCommit has no effect.
|
| - if (drawsContent() && !m_updateRect.IsEmpty())
|
| - setNeedsCommit();
|
| +void Layer::SetForceRenderSurface(bool force) {
|
| + if (force_render_surface_ == force)
|
| + return;
|
| + force_render_surface_ = force;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -bool Layer::descendantIsFixedToContainerLayer() const
|
| -{
|
| - for (size_t i = 0; i < m_children.size(); ++i) {
|
| - if (m_children[i]->fixedToContainerLayer() || m_children[i]->descendantIsFixedToContainerLayer())
|
| - return true;
|
| - }
|
| - return false;
|
| -}
|
| -
|
| -void Layer::setIsContainerForFixedPositionLayers(bool isContainerForFixedPositionLayers)
|
| -{
|
| - if (m_isContainerForFixedPositionLayers == isContainerForFixedPositionLayers)
|
| - return;
|
| - m_isContainerForFixedPositionLayers = isContainerForFixedPositionLayers;
|
| -
|
| - if (m_layerTreeHost && m_layerTreeHost->commitRequested())
|
| - return;
|
| -
|
| - // Only request a commit if we have a fixed positioned descendant.
|
| - if (descendantIsFixedToContainerLayer())
|
| - setNeedsCommit();
|
| -}
|
| -
|
| -void Layer::setFixedToContainerLayer(bool fixedToContainerLayer)
|
| -{
|
| - if (m_fixedToContainerLayer == fixedToContainerLayer)
|
| - return;
|
| - m_fixedToContainerLayer = fixedToContainerLayer;
|
| - setNeedsCommit();
|
| -}
|
| -
|
| -void Layer::pushPropertiesTo(LayerImpl* layer)
|
| -{
|
| - layer->setAnchorPoint(m_anchorPoint);
|
| - layer->setAnchorPointZ(m_anchorPointZ);
|
| - layer->setBackgroundColor(m_backgroundColor);
|
| - layer->setBounds(m_bounds);
|
| - layer->setContentBounds(contentBounds());
|
| - layer->setContentsScale(contentsScaleX(), contentsScaleY());
|
| - layer->setDebugName(m_debugName);
|
| - layer->setDoubleSided(m_doubleSided);
|
| - layer->setDrawCheckerboardForMissingTiles(m_drawCheckerboardForMissingTiles);
|
| - layer->setForceRenderSurface(m_forceRenderSurface);
|
| - layer->setDrawsContent(drawsContent());
|
| - layer->setFilters(filters());
|
| - layer->setFilter(filter());
|
| - layer->setBackgroundFilters(backgroundFilters());
|
| - layer->setMasksToBounds(m_masksToBounds);
|
| - layer->setShouldScrollOnMainThread(m_shouldScrollOnMainThread);
|
| - layer->setHaveWheelEventHandlers(m_haveWheelEventHandlers);
|
| - layer->setNonFastScrollableRegion(m_nonFastScrollableRegion);
|
| - layer->setTouchEventHandlerRegion(m_touchEventHandlerRegion);
|
| - layer->setContentsOpaque(m_contentsOpaque);
|
| - if (!opacityIsAnimating())
|
| - layer->setOpacity(m_opacity);
|
| - layer->setPosition(m_position);
|
| - layer->setIsContainerForFixedPositionLayers(m_isContainerForFixedPositionLayers);
|
| - layer->setFixedToContainerLayer(m_fixedToContainerLayer);
|
| - layer->setPreserves3D(preserves3D());
|
| - layer->setUseParentBackfaceVisibility(m_useParentBackfaceVisibility);
|
| - layer->setSublayerTransform(m_sublayerTransform);
|
| - if (!transformIsAnimating())
|
| - layer->setTransform(m_transform);
|
| -
|
| - layer->setScrollable(m_scrollable);
|
| - layer->setScrollOffset(m_scrollOffset);
|
| - layer->setMaxScrollOffset(m_maxScrollOffset);
|
| -
|
| - // If the main thread commits multiple times before the impl thread actually draws, then damage tracking
|
| - // will become incorrect if we simply clobber the updateRect here. The LayerImpl's updateRect needs to
|
| - // accumulate (i.e. union) any update changes that have occurred on the main thread.
|
| - m_updateRect.Union(layer->updateRect());
|
| - layer->setUpdateRect(m_updateRect);
|
| -
|
| - if (layer->layerTreeImpl()->settings().implSidePainting) {
|
| - DCHECK(layer->layerTreeImpl()->IsPendingTree());
|
| - LayerImpl* active_twin = layer->layerTreeImpl()->FindActiveTreeLayerById(id());
|
| - // Update the scroll delta from the active layer, which may have
|
| - // adjusted its scroll delta prior to this pending layer being created.
|
| - // This code is identical to that in LayerImpl::setScrollDelta.
|
| - if (active_twin) {
|
| - DCHECK(layer->sentScrollDelta().IsZero());
|
| - layer->setScrollDelta(active_twin->scrollDelta() - active_twin->sentScrollDelta());
|
| - }
|
| - } else {
|
| - layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta());
|
| - layer->setSentScrollDelta(gfx::Vector2d());
|
| +void Layer::SetImplTransform(const gfx::Transform& transform) {
|
| + if (impl_transform_ == transform)
|
| + return;
|
| + impl_transform_ = transform;
|
| + SetNeedsCommit();
|
| +}
|
| +
|
| +void Layer::SetDoubleSided(bool double_sided) {
|
| + if (double_sided_ == double_sided)
|
| + return;
|
| + double_sided_ = double_sided;
|
| + SetNeedsCommit();
|
| +}
|
| +
|
| +void Layer::SetIsDrawable(bool is_drawable) {
|
| + if (is_drawable_ == is_drawable)
|
| + return;
|
| +
|
| + is_drawable_ = is_drawable;
|
| + SetNeedsCommit();
|
| +}
|
| +
|
| +void Layer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) {
|
| + update_rect_.Union(dirty_rect);
|
| + needs_display_ = true;
|
| +
|
| + // Simply mark the contents as dirty. For non-root layers, the call to
|
| + // setNeedsCommit will schedule a fresh compositing pass.
|
| + // For the root layer, setNeedsCommit has no effect.
|
| + if (DrawsContent() && !update_rect_.IsEmpty())
|
| + SetNeedsCommit();
|
| +}
|
| +
|
| +bool Layer::DescendantIsFixedToContainerLayer() const {
|
| + for (size_t i = 0; i < children_.size(); ++i) {
|
| + if (children_[i]->fixed_to_container_layer() ||
|
| + children_[i]->DescendantIsFixedToContainerLayer())
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +void Layer::SetIsContainerForFixedPositionLayers(bool container) {
|
| + if (is_container_for_fixed_position_layers_ == container)
|
| + return;
|
| + is_container_for_fixed_position_layers_ = container;
|
| +
|
| + if (layer_tree_host_ && layer_tree_host_->commitRequested())
|
| + return;
|
| +
|
| + // Only request a commit if we have a fixed positioned descendant.
|
| + if (DescendantIsFixedToContainerLayer())
|
| + SetNeedsCommit();
|
| +}
|
| +
|
| +void Layer::SetFixedToContainerLayer(bool fixed_to_container_layer) {
|
| + if (fixed_to_container_layer_ == fixed_to_container_layer)
|
| + return;
|
| + fixed_to_container_layer_ = fixed_to_container_layer;
|
| + SetNeedsCommit();
|
| +}
|
| +
|
| +void Layer::PushPropertiesTo(LayerImpl* layer) {
|
| + layer->SetAnchorPoint(anchor_point_);
|
| + layer->SetAnchorPointZ(anchor_point_z_);
|
| + layer->SetBackgroundColor(background_color_);
|
| + layer->SetBounds(bounds_);
|
| + layer->SetContentBounds(content_bounds());
|
| + layer->SetContentsScale(contents_scale_x(), contents_scale_y());
|
| + layer->SetDebugName(debug_name_);
|
| + layer->SetDoubleSided(double_sided_);
|
| + layer->SetDrawCheckerboardForMissingTiles(
|
| + draw_checkerboard_for_missing_tiles_);
|
| + layer->SetForceRenderSurface(force_render_surface_);
|
| + layer->SetDrawsContent(DrawsContent());
|
| + layer->SetFilters(filters());
|
| + layer->SetFilter(filter());
|
| + layer->SetBackgroundFilters(background_filters());
|
| + layer->SetMasksToBounds(masks_to_bounds_);
|
| + layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_);
|
| + layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_);
|
| + layer->SetNonFastScrollableRegion(non_fast_scrollable_region_);
|
| + layer->SetTouchEventHandlerRegion(touch_event_handler_region_);
|
| + layer->SetContentsOpaque(contents_opaque_);
|
| + if (!OpacityIsAnimating())
|
| + layer->SetOpacity(opacity_);
|
| + layer->SetPosition(position_);
|
| + layer->SetIsContainerForFixedPositionLayers(
|
| + is_container_for_fixed_position_layers_);
|
| + layer->SetFixedToContainerLayer(fixed_to_container_layer_);
|
| + layer->SetPreserves3d(preserves_3d());
|
| + layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_);
|
| + layer->SetSublayerTransform(sublayer_transform_);
|
| + if (!TransformIsAnimating())
|
| + layer->SetTransform(transform_);
|
| +
|
| + layer->SetScrollable(scrollable_);
|
| + layer->SetScrollOffset(scroll_offset_);
|
| + layer->SetMaxScrollOffset(max_scroll_offset_);
|
| +
|
| + // If the main thread commits multiple times before the impl thread actually
|
| + // draws, then damage tracking will become incorrect if we simply clobber the
|
| + // updateRect here. The LayerImpl's updateRect needs to accumulate (i.e.
|
| + // union) any update changes that have occurred on the main thread.
|
| + update_rect_.Union(layer->update_rect());
|
| + layer->set_update_rect(update_rect_);
|
| +
|
| + if (layer->layer_tree_impl()->settings().implSidePainting) {
|
| + DCHECK(layer->layer_tree_impl()->IsPendingTree());
|
| + LayerImpl* active_twin =
|
| + layer->layer_tree_impl()->FindActiveTreeLayerById(id());
|
| + // Update the scroll delta from the active layer, which may have
|
| + // adjusted its scroll delta prior to this pending layer being created.
|
| + // This code is identical to that in LayerImpl::setScrollDelta.
|
| + if (active_twin) {
|
| + DCHECK(layer->sent_scroll_delta().IsZero());
|
| + layer->SetScrollDelta(active_twin->scroll_delta() -
|
| + active_twin->sent_scroll_delta());
|
| }
|
| + } else {
|
| + layer->SetScrollDelta(layer->scroll_delta() - layer->sent_scroll_delta());
|
| + layer->SetSentScrollDelta(gfx::Vector2d());
|
| + }
|
|
|
| - layer->setStackingOrderChanged(m_stackingOrderChanged);
|
| + layer->SetStackingOrderChanged(stacking_order_changed_);
|
|
|
| - m_layerAnimationController->PushAnimationUpdatesTo(layer->layerAnimationController());
|
| + layer_animation_controller_->PushAnimationUpdatesTo(
|
| + layer->layer_animation_controller());
|
|
|
| - // Reset any state that should be cleared for the next update.
|
| - m_stackingOrderChanged = false;
|
| - m_updateRect = gfx::RectF();
|
| + // Reset any state that should be cleared for the next update.
|
| + stacking_order_changed_ = false;
|
| + update_rect_ = gfx::RectF();
|
| }
|
|
|
| -scoped_ptr<LayerImpl> Layer::createLayerImpl(LayerTreeImpl* treeImpl)
|
| -{
|
| - return LayerImpl::create(treeImpl, m_layerId);
|
| +scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
|
| + return LayerImpl::Create(tree_impl, layer_id_);
|
| }
|
|
|
| -bool Layer::drawsContent() const
|
| -{
|
| - return m_isDrawable;
|
| +bool Layer::DrawsContent() const {
|
| + return is_drawable_;
|
| }
|
|
|
| -bool Layer::needMoreUpdates()
|
| -{
|
| - return false;
|
| +bool Layer::NeedMoreUpdates() {
|
| + return false;
|
| }
|
|
|
| -void Layer::setDebugName(const std::string& debugName)
|
| -{
|
| - m_debugName = debugName;
|
| - setNeedsCommit();
|
| +void Layer::SetDebugName(const std::string& debug_name) {
|
| + debug_name_ = debug_name;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setRasterScale(float scale)
|
| -{
|
| - if (m_rasterScale == scale)
|
| - return;
|
| - m_rasterScale = scale;
|
| +void Layer::SetRasterScale(float scale) {
|
| + if (raster_scale_ == scale)
|
| + return;
|
| + raster_scale_ = scale;
|
|
|
| - // When automatically computed, this acts like a draw property.
|
| - if (m_automaticallyComputeRasterScale)
|
| - return;
|
| - setNeedsDisplay();
|
| + // When automatically computed, this acts like a draw property.
|
| + if (automatically_compute_raster_scale_)
|
| + return;
|
| + SetNeedsDisplay();
|
| }
|
|
|
| -void Layer::setAutomaticallyComputeRasterScale(bool automatic)
|
| -{
|
| - if (m_automaticallyComputeRasterScale == automatic)
|
| - return;
|
| - m_automaticallyComputeRasterScale = automatic;
|
| +void Layer::SetAutomaticallyComputeRasterScale(bool automatic) {
|
| + if (automatically_compute_raster_scale_ == automatic)
|
| + return;
|
| + automatically_compute_raster_scale_ = automatic;
|
|
|
| - if (m_automaticallyComputeRasterScale)
|
| - forceAutomaticRasterScaleToBeRecomputed();
|
| - else
|
| - setRasterScale(1);
|
| + if (automatically_compute_raster_scale_)
|
| + ForceAutomaticRasterScaleToBeRecomputed();
|
| + else
|
| + SetRasterScale(1);
|
| }
|
|
|
| -void Layer::forceAutomaticRasterScaleToBeRecomputed()
|
| -{
|
| - if (!m_automaticallyComputeRasterScale)
|
| - return;
|
| - if (!m_rasterScale)
|
| - return;
|
| - m_rasterScale = 0;
|
| - setNeedsCommit();
|
| +void Layer::ForceAutomaticRasterScaleToBeRecomputed() {
|
| + if (!automatically_compute_raster_scale_)
|
| + return;
|
| + if (!raster_scale_)
|
| + return;
|
| + raster_scale_ = 0.f;
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setBoundsContainPageScale(bool boundsContainPageScale)
|
| -{
|
| - for (size_t i = 0; i < m_children.size(); ++i)
|
| - m_children[i]->setBoundsContainPageScale(boundsContainPageScale);
|
| +void Layer::SetBoundsContainPageScale(bool bounds_contain_page_scale) {
|
| + for (size_t i = 0; i < children_.size(); ++i)
|
| + children_[i]->SetBoundsContainPageScale(bounds_contain_page_scale);
|
|
|
| - if (boundsContainPageScale == m_boundsContainPageScale)
|
| - return;
|
| + if (bounds_contain_page_scale == bounds_contain_page_scale_)
|
| + return;
|
|
|
| - m_boundsContainPageScale = boundsContainPageScale;
|
| - setNeedsDisplay();
|
| + bounds_contain_page_scale_ = bounds_contain_page_scale;
|
| + SetNeedsDisplay();
|
| }
|
|
|
| -void Layer::createRenderSurface()
|
| -{
|
| - DCHECK(!m_drawProperties.render_surface);
|
| - m_drawProperties.render_surface = make_scoped_ptr(new RenderSurface(this));
|
| - m_drawProperties.render_target = this;
|
| +void Layer::CreateRenderSurface() {
|
| + DCHECK(!draw_properties_.render_surface);
|
| + draw_properties_.render_surface = make_scoped_ptr(new RenderSurface(this));
|
| + draw_properties_.render_target = this;
|
| }
|
|
|
| -int Layer::id() const
|
| -{
|
| - return m_layerId;
|
| +void Layer::OnOpacityAnimated(float opacity) {
|
| + // This is called due to an ongoing accelerated animation. Since this
|
| + // animation is also being run on the impl thread, there is no need to request
|
| + // a commit to push this value over, so set the value directly rather than
|
| + // calling setOpacity.
|
| + opacity_ = opacity;
|
| }
|
|
|
| -void Layer::OnOpacityAnimated(float opacity)
|
| -{
|
| - // This is called due to an ongoing accelerated animation. Since this animation is
|
| - // also being run on the impl thread, there is no need to request a commit to push
|
| - // this value over, so set the value directly rather than calling setOpacity.
|
| - m_opacity = opacity;
|
| +void Layer::OnTransformAnimated(const gfx::Transform& transform) {
|
| + // This is called due to an ongoing accelerated animation. Since this
|
| + // animation is also being run on the impl thread, there is no need to request
|
| + // a commit to push this value over, so set this value directly rather than
|
| + // calling setTransform.
|
| + transform_ = transform;
|
| }
|
|
|
| -void Layer::OnTransformAnimated(const gfx::Transform& transform)
|
| -{
|
| - // This is called due to an ongoing accelerated animation. Since this animation is
|
| - // also being run on the impl thread, there is no need to request a commit to push
|
| - // this value over, so set this value directly rather than calling setTransform.
|
| - m_transform = transform;
|
| +bool Layer::IsActive() const {
|
| + return true;
|
| }
|
|
|
| -bool Layer::IsActive() const
|
| -{
|
| - return true;
|
| -}
|
| -
|
| -bool Layer::AddAnimation(scoped_ptr <Animation> animation)
|
| -{
|
| - if (!m_layerAnimationController->animation_registrar())
|
| - return false;
|
| -
|
| - m_layerAnimationController->AddAnimation(animation.Pass());
|
| - setNeedsCommit();
|
| - return true;
|
| -}
|
| +bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
|
| + if (!layer_animation_controller_->animation_registrar())
|
| + return false;
|
|
|
| -void Layer::PauseAnimation(int animationId, double timeOffset)
|
| -{
|
| - m_layerAnimationController->PauseAnimation(animationId, timeOffset);
|
| - setNeedsCommit();
|
| + layer_animation_controller_->AddAnimation(animation.Pass());
|
| + SetNeedsCommit();
|
| + return true;
|
| }
|
|
|
| -void Layer::RemoveAnimation(int animationId)
|
| -{
|
| - m_layerAnimationController->RemoveAnimation(animationId);
|
| - setNeedsCommit();
|
| +void Layer::PauseAnimation(int animation_id, double time_offset) {
|
| + layer_animation_controller_->PauseAnimation(animation_id, time_offset);
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::suspendAnimations(double monotonicTime)
|
| -{
|
| - m_layerAnimationController->SuspendAnimations(monotonicTime);
|
| - setNeedsCommit();
|
| +void Layer::RemoveAnimation(int animation_id) {
|
| + layer_animation_controller_->RemoveAnimation(animation_id);
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::resumeAnimations(double monotonicTime)
|
| -{
|
| - m_layerAnimationController->ResumeAnimations(monotonicTime);
|
| - setNeedsCommit();
|
| +void Layer::SuspendAnimations(double monotonic_time) {
|
| + layer_animation_controller_->SuspendAnimations(monotonic_time);
|
| + SetNeedsCommit();
|
| }
|
|
|
| -void Layer::setLayerAnimationController(scoped_refptr<LayerAnimationController> layerAnimationController)
|
| -{
|
| - removeLayerAnimationEventObserver(m_layerAnimationController.get());
|
| - m_layerAnimationController->RemoveObserver(this);
|
| - m_layerAnimationController = layerAnimationController;
|
| - m_layerAnimationController->set_force_sync();
|
| - m_layerAnimationController->AddObserver(this);
|
| - addLayerAnimationEventObserver(m_layerAnimationController.get());
|
| - setNeedsCommit();
|
| +void Layer::ResumeAnimations(double monotonic_time) {
|
| + layer_animation_controller_->ResumeAnimations(monotonic_time);
|
| + SetNeedsCommit();
|
| }
|
|
|
| -scoped_refptr<LayerAnimationController> Layer::releaseLayerAnimationController()
|
| -{
|
| - m_layerAnimationController->RemoveObserver(this);
|
| - scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationController;
|
| - m_layerAnimationController = LayerAnimationController::Create(id());
|
| - m_layerAnimationController->AddObserver(this);
|
| - m_layerAnimationController->SetAnimationRegistrar(toReturn->animation_registrar());
|
| - return toReturn;
|
| +void Layer::SetLayerAnimationController(
|
| + scoped_refptr<LayerAnimationController> controller) {
|
| + RemoveLayerAnimationEventObserver(layer_animation_controller_.get());
|
| + layer_animation_controller_->RemoveObserver(this);
|
| + layer_animation_controller_ = controller;
|
| + layer_animation_controller_->set_force_sync();
|
| + layer_animation_controller_->AddObserver(this);
|
| + AddLayerAnimationEventObserver(layer_animation_controller_.get());
|
| + SetNeedsCommit();
|
| }
|
|
|
| -bool Layer::hasActiveAnimation() const
|
| -{
|
| - return m_layerAnimationController->HasActiveAnimation();
|
| +scoped_refptr<LayerAnimationController>
|
| +Layer::ReleaseLayerAnimationController() {
|
| + layer_animation_controller_->RemoveObserver(this);
|
| + scoped_refptr<LayerAnimationController> to_return =
|
| + layer_animation_controller_;
|
| + layer_animation_controller_ = LayerAnimationController::Create(id());
|
| + layer_animation_controller_->AddObserver(this);
|
| + layer_animation_controller_->SetAnimationRegistrar(
|
| + to_return->animation_registrar());
|
| + return to_return;
|
| }
|
|
|
| -void Layer::notifyAnimationStarted(const AnimationEvent& event, double wallClockTime)
|
| -{
|
| - FOR_EACH_OBSERVER(LayerAnimationEventObserver, m_layerAnimationObservers,
|
| - OnAnimationStarted(event));
|
| - if (m_layerAnimationDelegate)
|
| - m_layerAnimationDelegate->notifyAnimationStarted(wallClockTime);
|
| +bool Layer::HasActiveAnimation() const {
|
| + return layer_animation_controller_->HasActiveAnimation();
|
| }
|
|
|
| -void Layer::notifyAnimationFinished(double wallClockTime)
|
| -{
|
| - if (m_layerAnimationDelegate)
|
| - m_layerAnimationDelegate->notifyAnimationFinished(wallClockTime);
|
| +void Layer::NotifyAnimationStarted(const AnimationEvent& event,
|
| + double wall_clock_time) {
|
| + FOR_EACH_OBSERVER(LayerAnimationEventObserver, layer_animation_observers_,
|
| + OnAnimationStarted(event));
|
| + if (layer_animation_delegate_)
|
| + layer_animation_delegate_->notifyAnimationStarted(wall_clock_time);
|
| }
|
|
|
| -void Layer::notifyAnimationPropertyUpdate(const AnimationEvent& event)
|
| -{
|
| - if (event.target_property == Animation::Opacity)
|
| - setOpacity(event.opacity);
|
| - else
|
| - setTransform(event.transform);
|
| +void Layer::NotifyAnimationFinished(double wall_clock_time) {
|
| + if (layer_animation_delegate_)
|
| + layer_animation_delegate_->notifyAnimationFinished(wall_clock_time);
|
| }
|
|
|
| -void Layer::addLayerAnimationEventObserver(LayerAnimationEventObserver* animationObserver)
|
| -{
|
| - if (!m_layerAnimationObservers.HasObserver(animationObserver))
|
| - m_layerAnimationObservers.AddObserver(animationObserver);
|
| +void Layer::NotifyAnimationPropertyUpdate(const AnimationEvent& event) {
|
| + if (event.target_property == Animation::Opacity)
|
| + SetOpacity(event.opacity);
|
| + else
|
| + SetTransform(event.transform);
|
| }
|
|
|
| -void Layer::removeLayerAnimationEventObserver(LayerAnimationEventObserver* animationObserver)
|
| -{
|
| - m_layerAnimationObservers.RemoveObserver(animationObserver);
|
| +void Layer::AddLayerAnimationEventObserver(
|
| + LayerAnimationEventObserver* animation_observer) {
|
| + if (!layer_animation_observers_.HasObserver(animation_observer))
|
| + layer_animation_observers_.AddObserver(animation_observer);
|
| }
|
|
|
| -Region Layer::visibleContentOpaqueRegion() const
|
| -{
|
| - if (contentsOpaque())
|
| - return visibleContentRect();
|
| - return Region();
|
| +void Layer::RemoveLayerAnimationEventObserver(
|
| + LayerAnimationEventObserver* animation_observer) {
|
| + layer_animation_observers_.RemoveObserver(animation_observer);
|
| }
|
|
|
| -ScrollbarLayer* Layer::toScrollbarLayer()
|
| -{
|
| - return 0;
|
| +Region Layer::VisibleContentOpaqueRegion() const {
|
| + if (contents_opaque())
|
| + return visible_content_rect();
|
| + return Region();
|
| }
|
|
|
| -void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped_refptr<Layer> >::iterator, void*)
|
| -{
|
| - // Currently we don't use z-order to decide what to paint, so there's no need to actually sort Layers.
|
| +ScrollbarLayer* Layer::ToScrollbarLayer() {
|
| + return NULL;
|
| }
|
|
|
| } // namespace cc
|
|
|