示例#1
0
WebTransformationMatrix CCLayerImpl::quadTransform() const
{
    WebTransformationMatrix quadTransformation = drawTransform();

    float offsetX = -0.5 * bounds().width();
    float offsetY = -0.5 * bounds().height();
    quadTransformation.translate(offsetX, offsetY);

    return quadTransformation;
}
示例#2
0
void CCDamageTracker::extendDamageForLayer(CCLayerImpl* layer, FloatRect& targetDamageRect)
{
    // There are two ways that a layer can damage a region of the target surface:
    //   1. Property change (e.g. opacity, position, transforms):
    //        - the entire region of the layer itself damages the surface.
    //        - the old layer region also damages the surface, because this region is now exposed.
    //        - note that in many cases the old and new layer rects may overlap, which is fine.
    //
    //   2. Repaint/update: If a region of the layer that was repainted/updated, that
    //      region damages the surface.
    //
    // Property changes take priority over update rects.
    //
    // This method is called when we want to consider how a layer contributes to its
    // targetRenderSurface, even if that layer owns the targetRenderSurface itself.
    // To consider how a layer's targetSurface contributes to the ancestorSurface,
    // extendDamageForRenderSurface() must be called instead.

    // Compute the layer's "originTransform" by translating the drawTransform.
    WebTransformationMatrix originTransform = layer->drawTransform();
    originTransform.translate(-0.5 * layer->bounds().width(), -0.5 * layer->bounds().height());

    bool layerIsNew = false;
    FloatRect oldLayerRect = removeRectFromCurrentFrame(layer->id(), layerIsNew);

    FloatRect layerRectInTargetSpace = CCMathUtil::mapClippedRect(originTransform, FloatRect(FloatPoint::zero(), layer->bounds()));
    saveRectForNextFrame(layer->id(), layerRectInTargetSpace);

    if (layerIsNew || layerNeedsToRedrawOntoItsTargetSurface(layer)) {
        // If a layer is new or has changed, then its entire layer rect affects the target surface.
        targetDamageRect.uniteIfNonZero(layerRectInTargetSpace);

        // The layer's old region is now exposed on the target surface, too.
        // Note oldLayerRect is already in target space.
        targetDamageRect.uniteIfNonZero(oldLayerRect);
    } else if (!layer->updateRect().isEmpty()) {
        // If the layer properties havent changed, then the the target surface is only
        // affected by the layer's update area, which could be empty.
        FloatRect updateRectInTargetSpace = CCMathUtil::mapClippedRect(originTransform, layer->updateRect());
        targetDamageRect.uniteIfNonZero(updateRectInTargetSpace);
    }
}