Title: [98486] trunk
Revision
98486
Author
r...@google.com
Date
2011-10-26 08:48:38 -0700 (Wed, 26 Oct 2011)

Log Message

[skia] replace offscreen technique with native support for antialiased clipping
https://bugs.webkit.org/show_bug.cgi?id=70748

Reviewed by Stephen White.

~100 layout tests need to be rebaselined, as the native aa-clipping differs sometimes in the low
bits of the result. Other than that, the results should be the same, except that now the drawing
can go directly to the canvas, rather than being direct offscreen and then have that result
"clipped" during the restore. This has the effect of allowing LCD text to be drawing inside a
antialiased clip area.

Source/WebCore:

* platform/graphics/skia/PlatformContextSkia.cpp:
(WebCore::PlatformContextSkia::State::State):
(WebCore::PlatformContextSkia::State::cloneInheritedProperties):
(WebCore::PlatformContextSkia::clipPathAntiAliased):
(WebCore::PlatformContextSkia::restore):

LayoutTests:

* platform/chromium/test_expectations.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (98485 => 98486)


--- trunk/LayoutTests/ChangeLog	2011-10-26 15:43:52 UTC (rev 98485)
+++ trunk/LayoutTests/ChangeLog	2011-10-26 15:48:38 UTC (rev 98486)
@@ -1,3 +1,18 @@
+2011-10-26  Mike Reed  <r...@google.com>
+
+        [skia] replace offscreen technique with native support for antialiased clipping
+        https://bugs.webkit.org/show_bug.cgi?id=70748
+
+        Reviewed by Stephen White.
+
+        ~100 layout tests need to be rebaselined, as the native aa-clipping differs sometimes in the low
+        bits of the result. Other than that, the results should be the same, except that now the drawing
+        can go directly to the canvas, rather than being direct offscreen and then have that result
+        "clipped" during the restore. This has the effect of allowing LCD text to be drawing inside a
+        antialiased clip area.
+
+        * platform/chromium/test_expectations.txt:
+
 2011-10-26  Nikolas Zimmermann  <nzimmerm...@rim.com>
 
         CSS 2.1 failure: background-intrinsic-*

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (98485 => 98486)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-10-26 15:43:52 UTC (rev 98485)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-10-26 15:48:38 UTC (rev 98486)
@@ -1008,6 +1008,116 @@
 BUGWK64876 LINUX WIN GPU : fast/canvas/canvas-scale-strokePath-shadow.html = TEXT
 
 
+// Rebaseline once native aa-clipping has landed
+BUGWK70748 CPU : css2.1/t0805-c5517-brdr-s-00-c.html = IMAGE
+BUGWK70748 CPU : fast/backgrounds/border-radius-split-background-image.html = IMAGE
+BUGWK70748 CPU : fast/backgrounds/gradient-background-leakage.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusAllStylesAllCorners.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusArcs01.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-radius-complex-inner.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDashed01.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDashed02.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDashed03.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDashed04.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDashed05.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-radius-different-width-001.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDotted01.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDotted02.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDotted03.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDotted04.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDotted05.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDotted06.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDouble01.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDouble02.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDouble03.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDouble04.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDouble05.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDouble06.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDouble07.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDouble08.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusDouble09.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-radius-groove-01.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusGroove01.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-radius-groove-02.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusGroove02.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-radius-groove-03.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusInset01.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-radius-inset-outset.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusOutset01.html = IMAGE
+BUGWK70748 CPU : fast/borders/borderRadiusRidge01.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-radius-split-inline.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-radius-wide-border-01.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-radius-wide-border-02.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-radius-wide-border-03.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-radius-wide-border-04.html = IMAGE
+BUGWK70748 CPU : fast/borders/border-styles-split.html = IMAGE
+BUGWK70748 CPU : fast/borders/different-color-borders.html = IMAGE
+BUGWK70748 CPU : fast/borders/fieldsetBorderRadius.html = IMAGE
+BUGWK70748 CPU : fast/borders/mixed-border-styles-radius2.html = IMAGE
+BUGWK70748 CPU : fast/borders/mixed-border-styles-radius.html = IMAGE
+BUGWK70748 CPU : fast/box-shadow/basic-shadows.html = IMAGE
+BUGWK70748 CPU : fast/box-shadow/border-radius-big.html = IMAGE
+BUGWK70748 CPU : fast/box-shadow/inset-box-shadows.html = IMAGE
+BUGWK70748 CPU : fast/box-shadow/inset.html = IMAGE
+BUGWK70748 CPU : fast/box-shadow/inset-with-extraordinary-radii-and-border.html = IMAGE
+BUGWK70748 CPU : fast/box-shadow/spread.html = IMAGE
+BUGWK70748 CPU : fast/box-shadow/spread-multiple-inset.html = IMAGE
+BUGWK70748 CPU : fast/box-shadow/spread-multiple-normal.html = IMAGE
+BUGWK70748 CPU : fast/clip/overflow-border-radius-clip.html = IMAGE
+BUGWK70748 CPU : fast/css/box-shadow-and-border-radius.html = IMAGE
+BUGWK70748 CPU : fast/css/nested-rounded-corners.html = IMAGE
+BUGWK70748 CPU : fast/css/text-input-with-webkit-border-radius.html = IMAGE
+BUGWK70748 CPU : fast/forms/basic-selects.html = IMAGE
+BUGWK70748 CPU : fast/forms/validation-message-appearance.html = IMAGE
+BUGWK70748 CPU : fast/layers/video-layer.html = IMAGE
+BUGWK70748 CPU : fast/repaint/shadow-multiple-horizontal.html = IMAGE
+BUGWK70748 CPU : fast/repaint/shadow-multiple-strict-horizontal.html = IMAGE
+BUGWK70748 CPU : fast/repaint/shadow-multiple-strict-vertical.html = IMAGE
+BUGWK70748 CPU : fast/repaint/shadow-multiple-vertical.html = IMAGE
+BUGWK70748 CPU : fast/transforms/shadows.html = IMAGE
+BUGWK70748 CPU : fast/writing-mode/border-styles-vertical-lr.html = IMAGE
+BUGWK70748 CPU : fast/writing-mode/border-styles-vertical-rl.html = IMAGE
+BUGWK70748 CPU : fast/writing-mode/box-shadow-horizontal-bt.html = IMAGE
+BUGWK70748 CPU : fast/writing-mode/box-shadow-vertical-lr.html = IMAGE
+BUGWK70748 CPU : fast/writing-mode/box-shadow-vertical-rl.html = IMAGE
+BUGWK70748 CPU : fullscreen/full-screen-stacking-context.html = IMAGE
+BUGWK70748 CPU : media/audio-controls-rendering.html = IMAGE
+BUGWK70748 CPU : media/audio-repaint.html = IMAGE
+BUGWK70748 CPU : media/controls-after-reload.html = IMAGE
+BUGWK70748 CPU : media/controls-strict.html = IMAGE
+BUGWK70748 CPU : media/controls-styling.html = IMAGE
+BUGWK70748 CPU : media/controls-without-preload.html = IMAGE
+BUGWK70748 CPU : media/media-controls-clone.html = IMAGE
+BUGWK70748 CPU : media/media-document-audio-repaint.html = IMAGE
+BUGWK70748 CPU : media/video-controls-rendering.html = IMAGE
+BUGWK70748 CPU : media/video-display-toggle.html = IMAGE
+BUGWK70748 CPU : media/video-empty-source.html = IMAGE
+BUGWK70748 CPU : media/video-no-audio.html = IMAGE
+BUGWK70748 CPU : media/video-playing-and-pause.html = IMAGE
+BUGWK70748 CPU : media/video-volume-slider.html = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-in-mask-objectBoundingBox.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-in-mask-userSpaceOnUse.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-clipped-evenodd-twice.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-clipped-nonzero.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-clipped.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-objectBoundingBox.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-on-clipped-use.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-on-g-and-child.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-on-g.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-on-svg-and-child.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-on-svg.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-transform-2.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-use-as-child.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-userSpaceOnUse.svg = IMAGE
+BUGWK70748 CPU : svg/clip-path/clip-path-with-text-clipped.svg = IMAGE
+BUGWK70748 CPU : svg/css/text-shadow-multiple.xhtml = IMAGE
+BUGWK70748 CPU : svg/custom/resource-invalidate-on-target-update.svg = IMAGE
+BUGWK70748 CPU : svg/custom/use-on-clip-path-with-transformation.svg = IMAGE
+BUGWK70748 CPU : svg/W3C-I18N/tspan-dirLTR-ubOverride-in-rtl-context.svg = IMAGE
+BUGWK70748 CPU : svg/W3C-SVG-1.1/painting-marker-02-f.svg = IMAGE
+BUGWK70748 CPU : fast/borders/only-one-border-with-width.html = IMAGE
+BUGWK70748 CPU : svg/W3C-SVG-1.1/masking-path-05-f.svg = IMAGE
+
 // -----------------------------------------------------------------
 // Other failures
 // -----------------------------------------------------------------

Modified: trunk/Source/WebCore/ChangeLog (98485 => 98486)


--- trunk/Source/WebCore/ChangeLog	2011-10-26 15:43:52 UTC (rev 98485)
+++ trunk/Source/WebCore/ChangeLog	2011-10-26 15:48:38 UTC (rev 98486)
@@ -1,3 +1,22 @@
+2011-10-26  Mike Reed  <r...@google.com>
+
+        [skia] replace offscreen technique with native support for antialiased clipping
+        https://bugs.webkit.org/show_bug.cgi?id=70748
+
+        Reviewed by Stephen White.
+
+        ~100 layout tests need to be rebaselined, as the native aa-clipping differs sometimes in the low
+        bits of the result. Other than that, the results should be the same, except that now the drawing
+        can go directly to the canvas, rather than being direct offscreen and then have that result
+        "clipped" during the restore. This has the effect of allowing LCD text to be drawing inside a
+        antialiased clip area.
+
+        * platform/graphics/skia/PlatformContextSkia.cpp:
+        (WebCore::PlatformContextSkia::State::State):
+        (WebCore::PlatformContextSkia::State::cloneInheritedProperties):
+        (WebCore::PlatformContextSkia::clipPathAntiAliased):
+        (WebCore::PlatformContextSkia::restore):
+
 2011-10-26  Nikolas Zimmermann  <nzimmerm...@rim.com>
 
         CSS 2.1 failure: background-intrinsic-*

Modified: trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp (98485 => 98486)


--- trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	2011-10-26 15:43:52 UTC (rev 98485)
+++ trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	2011-10-26 15:48:38 UTC (rev 98486)
@@ -98,9 +98,6 @@
     // If m_imageBufferClip is non-empty, this is the region the image is clipped to.
     FloatRect m_clip;
 
-    // This is a list of clipping paths which are currently active, in the
-    // order in which they were pushed.
-    WTF::Vector<SkPath> m_antiAliasClipPaths;
     InterpolationQuality m_interpolationQuality;
 
     PlatformContextSkia::State cloneInheritedProperties();
@@ -146,7 +143,6 @@
     , m_textDrawingMode(other.m_textDrawingMode)
     , m_imageBufferClip(other.m_imageBufferClip)
     , m_clip(other.m_clip)
-    , m_antiAliasClipPaths(other.m_antiAliasClipPaths)
     , m_interpolationQuality(other.m_interpolationQuality)
 {
     // Up the ref count of these. SkSafeRef does nothing if its argument is 0.
@@ -163,12 +159,7 @@
 // Returns a new State with all of this object's inherited properties copied.
 PlatformContextSkia::State PlatformContextSkia::State::cloneInheritedProperties()
 {
-    PlatformContextSkia::State state(*this);
-
-    // Everything is inherited except for the clip paths.
-    state.m_antiAliasClipPaths.clear();
-
-    return state;
+    return PlatformContextSkia::State(*this);
 }
 
 SkColor PlatformContextSkia::State::applyAlpha(SkColor c) const
@@ -267,33 +258,7 @@
 
 void PlatformContextSkia::clipPathAntiAliased(const SkPath& clipPath)
 {
-    if (m_canvas->getTopDevice()->getDeviceCapabilities() & SkDevice::kVector_Capability) {
-        // When the output is a vector device, like PDF, we don't need antialiased clips.
-        // It's up to the PDF rendering engine to do that. We can simply disable the
-        // antialiased clip code if the output is a vector device.
-        canvas()->clipPath(clipPath);
-        return;
-    }
-
-    // If we are currently tracking any anti-alias clip paths, then we already
-    // have a layer in place and don't need to add another.
-    bool haveLayerOutstanding = m_state->m_antiAliasClipPaths.size();
-
-    // See comments in applyAntiAliasedClipPaths about how this works.
-    m_state->m_antiAliasClipPaths.append(clipPath);
-
-    if (!haveLayerOutstanding) {
-        SkRect bounds = clipPath.getBounds();
-        // If we are doing a clip outside of clipPath our layer needs to be for the whole
-        // canvas, otherwise we can create a smaller layer.
-        SkRect* layerBounds = 0;
-        if (!clipPath.isInverseFillType())
-            layerBounds = &bounds;
-        canvas()->saveLayerAlpha(layerBounds, 255, static_cast<SkCanvas::SaveFlags>(SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag | SkCanvas::kClipToLayer_SaveFlag));
-        // Guards state modification during clipped operations.
-        // The state is popped in applyAntiAliasedClipPaths().
-        canvas()->save();
-    }
+    canvas()->clipPath(clipPath, SkRegion::kIntersect_Op, true);
 }
 
 void PlatformContextSkia::restore()
@@ -303,9 +268,6 @@
         canvas()->restore();
     }
 
-    if (!m_state->m_antiAliasClipPaths.isEmpty())
-        applyAntiAliasedClipPaths(m_state->m_antiAliasClipPaths);
-
     m_stateStack.removeLast();
     m_state = &m_stateStack.last();
 
@@ -622,45 +584,6 @@
     m_canvas->drawBitmap(imageBuffer, SkFloatToScalar(rect.x()), SkFloatToScalar(rect.y()), &paint);
 }
 
-void PlatformContextSkia::applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths)
-{
-    // Anti-aliased clipping:
-    //
-    // Skia's clipping is 1-bit only. Consider what would happen if it were 8-bit:
-    // We have a square canvas, filled with white and we declare a circular
-    // clipping path. Then we fill twice with a black rectangle. The fractional
-    // pixels would first get the correct color (white * alpha + black * (1 -
-    // alpha)), but the second fill would apply the alpha to the already
-    // modified color and the result would be too dark.
-    //
-    // This, anti-aliased clipping needs to be performed after the drawing has
-    // been done. In order to do this, we create a new layer of the canvas in
-    // clipPathAntiAliased and store the clipping path. All drawing is done to
-    // the layer's bitmap while it's in effect. When WebKit calls restore() to
-    // undo the clipping, this function is called.
-    //
-    // Here, we walk the list of clipping paths backwards and, for each, we
-    // clear outside of the clipping path. We only need a single extra layer
-    // for any number of clipping paths.
-    //
-    // When we call restore on the SkCanvas, the layer's bitmap is composed
-    // into the layer below and we end up with correct, anti-aliased clipping.
-
-    m_canvas->restore();
-
-    SkPaint paint;
-    paint.setXfermodeMode(SkXfermode::kClear_Mode);
-    paint.setAntiAlias(true);
-    paint.setStyle(SkPaint::kFill_Style);
-
-    for (size_t i = paths.size() - 1; i < paths.size(); --i) {
-        paths[i].toggleInverseFillType();
-        m_canvas->drawPath(paths[i], paint);
-    }
-
-    m_canvas->restore();
-}
-
 void PlatformContextSkia::setGraphicsContext3D(GraphicsContext3D* context)
 {
     m_gpuContext = context;

Modified: trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h (98485 => 98486)


--- trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h	2011-10-26 15:43:52 UTC (rev 98485)
+++ trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h	2011-10-26 15:48:38 UTC (rev 98486)
@@ -185,7 +185,6 @@
     // Used when restoring and the state has an image clip. Only shows the pixels in
     // m_canvas that are also in imageBuffer.
     void applyClipFromImage(const FloatRect&, const SkBitmap&);
-    void applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths);
 
     // common code between setupPaintFor[Filling,Stroking]
     void setupShader(SkPaint*, Gradient*, Pattern*, SkColor) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to