Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Side by Side Diff: Source/core/rendering/RenderLayer.cpp

Issue 23643003: ImageBuffer-less SVG masking and clipping. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed Linux rebaselines. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 3656 matching lines...) Expand 10 before | Expand all | Expand 10 after
3667 3667
3668 LayoutPoint offsetFromRoot; 3668 LayoutPoint offsetFromRoot;
3669 convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); 3669 convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot);
3670 3670
3671 IntRect rootRelativeBounds; 3671 IntRect rootRelativeBounds;
3672 bool rootRelativeBoundsComputed = false; 3672 bool rootRelativeBoundsComputed = false;
3673 3673
3674 // Apply clip-path to context. 3674 // Apply clip-path to context.
3675 bool hasClipPath = false; 3675 bool hasClipPath = false;
3676 RenderStyle* style = renderer()->style(); 3676 RenderStyle* style = renderer()->style();
3677 RenderSVGResourceClipper* resourceClipper = 0;
3677 if (renderer()->hasClipPath() && !context->paintingDisabled() && style) { 3678 if (renderer()->hasClipPath() && !context->paintingDisabled() && style) {
3678 ASSERT(style->clipPath()); 3679 ASSERT(style->clipPath());
3679 if (style->clipPath()->getOperationType() == ClipPathOperation::SHAPE) { 3680 if (style->clipPath()->getOperationType() == ClipPathOperation::SHAPE) {
3680 hasClipPath = true; 3681 hasClipPath = true;
3681 context->save(); 3682 context->save();
3682 ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperatio n*>(style->clipPath()); 3683 ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperatio n*>(style->clipPath());
3683 3684
3684 if (!rootRelativeBoundsComputed) { 3685 if (!rootRelativeBoundsComputed) {
3685 rootRelativeBounds = calculateLayerBounds(paintingInfo.rootLayer , &offsetFromRoot, 0); 3686 rootRelativeBounds = calculateLayerBounds(paintingInfo.rootLayer , &offsetFromRoot, 0);
3686 rootRelativeBoundsComputed = true; 3687 rootRelativeBoundsComputed = true;
3687 } 3688 }
3688 3689
3689 context->clipPath(clipPath->path(rootRelativeBounds), clipPath->wind Rule()); 3690 context->clipPath(clipPath->path(rootRelativeBounds), clipPath->wind Rule());
3690 } else if (style->clipPath()->getOperationType() == ClipPathOperation::R EFERENCE) { 3691 } else if (style->clipPath()->getOperationType() == ClipPathOperation::R EFERENCE) {
3691 ReferenceClipPathOperation* referenceClipPathOperation = static_cast <ReferenceClipPathOperation*>(style->clipPath()); 3692 ReferenceClipPathOperation* referenceClipPathOperation = static_cast <ReferenceClipPathOperation*>(style->clipPath());
3692 Document* document = renderer()->document(); 3693 Document* document = renderer()->document();
3693 // FIXME: It doesn't work with forward or external SVG references (h ttps://bugs.webkit.org/show_bug.cgi?id=90405) 3694 // FIXME: It doesn't work with forward or external SVG references (h ttps://bugs.webkit.org/show_bug.cgi?id=90405)
3694 Element* element = document ? document->getElementById(referenceClip PathOperation->fragment()) : 0; 3695 Element* element = document ? document->getElementById(referenceClip PathOperation->fragment()) : 0;
3695 if (element && element->hasTagName(SVGNames::clipPathTag) && element ->renderer()) { 3696 if (element && element->hasTagName(SVGNames::clipPathTag) && element ->renderer()) {
3696 if (!rootRelativeBoundsComputed) { 3697 if (!rootRelativeBoundsComputed) {
3697 rootRelativeBounds = calculateLayerBounds(paintingInfo.rootL ayer, &offsetFromRoot, 0); 3698 rootRelativeBounds = calculateLayerBounds(paintingInfo.rootL ayer, &offsetFromRoot, 0);
3698 rootRelativeBoundsComputed = true; 3699 rootRelativeBoundsComputed = true;
3699 } 3700 }
3700 3701
3701 // FIXME: This should use a safer cast such as toRenderSVGResour ceContainer(). 3702 // FIXME: This should use a safer cast such as toRenderSVGResour ceContainer().
3702 static_cast<RenderSVGResourceClipper*>(element->renderer())->app lyClippingToContext(renderer(), rootRelativeBounds, paintingInfo.paintDirtyRect, context); 3703 resourceClipper = static_cast<RenderSVGResourceClipper*>(element ->renderer());
3704 if (!resourceClipper->applyClippingToContext(renderer(), rootRel ativeBounds, paintingInfo.paintDirtyRect, context)) {
3705 // No need to post-apply the clipper if this failed.
3706 resourceClipper = 0;
3707 }
3703 } 3708 }
3704 } 3709 }
3705 } 3710 }
3706 3711
3707 LayerPaintingInfo localPaintingInfo(paintingInfo); 3712 LayerPaintingInfo localPaintingInfo(paintingInfo);
3708 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte rs()); 3713 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte rs());
3709 if (filterPainter.haveFilterEffect() && !context->paintingDisabled()) { 3714 if (filterPainter.haveFilterEffect() && !context->paintingDisabled()) {
3710 RenderLayerFilterInfo* filterInfo = this->filterInfo(); 3715 RenderLayerFilterInfo* filterInfo = this->filterInfo();
3711 ASSERT(filterInfo); 3716 ASSERT(filterInfo);
3712 LayoutRect filterRepaintRect = filterInfo->dirtySourceRect(); 3717 LayoutRect filterRepaintRect = filterInfo->dirtySourceRect();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3818 if (shouldPaintMask) 3823 if (shouldPaintMask)
3819 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForRenderer); 3824 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForRenderer);
3820 3825
3821 // End our transparency layer 3826 // End our transparency layer
3822 if (haveTransparency && m_usedTransparency && !m_paintingInsideReflection) { 3827 if (haveTransparency && m_usedTransparency && !m_paintingInsideReflection) {
3823 context->endTransparencyLayer(); 3828 context->endTransparencyLayer();
3824 context->restore(); 3829 context->restore();
3825 m_usedTransparency = false; 3830 m_usedTransparency = false;
3826 } 3831 }
3827 3832
3833 if (resourceClipper)
3834 resourceClipper->postApplyResource(renderer(), context, ApplyToDefaultMo de, 0, 0);
3835
3828 if (hasClipPath) 3836 if (hasClipPath)
3829 context->restore(); 3837 context->restore();
3830 } 3838 }
3831 3839
3832 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint& translationOffset) 3840 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint& translationOffset)
3833 { 3841 {
3834 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving 3842 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving
3835 // the accumulated error for sub-pixel layout. 3843 // the accumulated error for sub-pixel layout.
3836 LayoutPoint delta; 3844 LayoutPoint delta;
3837 convertToLayerCoords(paintingInfo.rootLayer, delta); 3845 convertToLayerCoords(paintingInfo.rootLayer, delta);
(...skipping 2629 matching lines...) Expand 10 before | Expand all | Expand 10 after
6467 } 6475 }
6468 } 6476 }
6469 6477
6470 void showLayerTree(const WebCore::RenderObject* renderer) 6478 void showLayerTree(const WebCore::RenderObject* renderer)
6471 { 6479 {
6472 if (!renderer) 6480 if (!renderer)
6473 return; 6481 return;
6474 showLayerTree(renderer->enclosingLayer()); 6482 showLayerTree(renderer->enclosingLayer());
6475 } 6483 }
6476 #endif 6484 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698