⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 98596 in webkit


Ignore:
Timestamp:
Oct 27, 2011, 10:19:28 AM (15 years ago)
Author:
reed@google.com
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):

  • platform/graphics/skia/PlatformContextSkia.h:

LayoutTests:

  • platform/chromium/test_expectations.txt:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r98595 r98596  
     12011-10-27  Mike Reed  <reed@google.com>
     2
     3        [skia] replace offscreen technique with native support for antialiased clipping
     4        https://bugs.webkit.org/show_bug.cgi?id=70748
     5
     6        Reviewed by Stephen White.
     7
     8        ~100 layout tests need to be rebaselined, as the native aa-clipping differs sometimes in the low
     9        bits of the result. Other than that, the results should be the same, except that now the drawing
     10        can go directly to the canvas, rather than being direct offscreen and then have that result
     11        "clipped" during the restore. This has the effect of allowing LCD text to be drawing inside a
     12        antialiased clip area.
     13
     14        * platform/chromium/test_expectations.txt:
     15
    1162011-10-27  Leandro Pereira  <leandro@profusion.mobi>
    217
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r98577 r98596  
    997997BUGWK64876 LINUX WIN GPU : fast/canvas/canvas-scale-strokePath-shadow.html = TEXT
    998998
     999
     1000// Rebaseline once native aa-clipping has landed
     1001BUGWK70748 CPU : css2.1/t0805-c5517-brdr-s-00-c.html = IMAGE
     1002BUGWK70748 CPU : fast/backgrounds/border-radius-split-background-image.html = IMAGE
     1003BUGWK70748 CPU : fast/backgrounds/gradient-background-leakage.html = IMAGE
     1004BUGWK70748 CPU : fast/borders/borderRadiusAllStylesAllCorners.html = IMAGE
     1005BUGWK70748 CPU : fast/borders/borderRadiusArcs01.html = IMAGE
     1006BUGWK70748 CPU : fast/borders/border-radius-complex-inner.html = IMAGE
     1007BUGWK70748 CPU : fast/borders/borderRadiusDashed01.html = IMAGE
     1008BUGWK70748 CPU : fast/borders/borderRadiusDashed02.html = IMAGE
     1009BUGWK70748 CPU : fast/borders/borderRadiusDashed03.html = IMAGE
     1010BUGWK70748 CPU : fast/borders/borderRadiusDashed04.html = IMAGE
     1011BUGWK70748 CPU : fast/borders/borderRadiusDashed05.html = IMAGE
     1012BUGWK70748 CPU : fast/borders/border-radius-different-width-001.html = IMAGE
     1013BUGWK70748 CPU : fast/borders/borderRadiusDotted01.html = IMAGE
     1014BUGWK70748 CPU : fast/borders/borderRadiusDotted02.html = IMAGE
     1015BUGWK70748 CPU : fast/borders/borderRadiusDotted03.html = IMAGE
     1016BUGWK70748 CPU : fast/borders/borderRadiusDotted04.html = IMAGE
     1017BUGWK70748 CPU : fast/borders/borderRadiusDotted05.html = IMAGE
     1018BUGWK70748 CPU : fast/borders/borderRadiusDotted06.html = IMAGE
     1019BUGWK70748 CPU : fast/borders/borderRadiusDouble01.html = IMAGE
     1020BUGWK70748 CPU : fast/borders/borderRadiusDouble02.html = IMAGE
     1021BUGWK70748 CPU : fast/borders/borderRadiusDouble03.html = IMAGE
     1022BUGWK70748 CPU : fast/borders/borderRadiusDouble04.html = IMAGE
     1023BUGWK70748 CPU : fast/borders/borderRadiusDouble05.html = IMAGE
     1024BUGWK70748 CPU : fast/borders/borderRadiusDouble06.html = IMAGE
     1025BUGWK70748 CPU : fast/borders/borderRadiusDouble07.html = IMAGE
     1026BUGWK70748 CPU : fast/borders/borderRadiusDouble08.html = IMAGE
     1027BUGWK70748 CPU : fast/borders/borderRadiusDouble09.html = IMAGE
     1028BUGWK70748 CPU : fast/borders/border-radius-groove-01.html = IMAGE
     1029BUGWK70748 CPU : fast/borders/borderRadiusGroove01.html = IMAGE
     1030BUGWK70748 CPU : fast/borders/border-radius-groove-02.html = IMAGE
     1031BUGWK70748 CPU : fast/borders/borderRadiusGroove02.html = IMAGE
     1032BUGWK70748 CPU : fast/borders/border-radius-groove-03.html = IMAGE
     1033BUGWK70748 CPU : fast/borders/borderRadiusInset01.html = IMAGE
     1034BUGWK70748 CPU : fast/borders/border-radius-inset-outset.html = IMAGE
     1035BUGWK70748 CPU : fast/borders/borderRadiusOutset01.html = IMAGE
     1036BUGWK70748 CPU : fast/borders/borderRadiusRidge01.html = IMAGE
     1037BUGWK70748 CPU : fast/borders/border-radius-split-inline.html = IMAGE
     1038BUGWK70748 CPU : fast/borders/border-radius-wide-border-01.html = IMAGE
     1039BUGWK70748 CPU : fast/borders/border-radius-wide-border-02.html = IMAGE
     1040BUGWK70748 CPU : fast/borders/border-radius-wide-border-03.html = IMAGE
     1041BUGWK70748 CPU : fast/borders/border-radius-wide-border-04.html = IMAGE
     1042BUGWK70748 CPU : fast/borders/border-styles-split.html = IMAGE
     1043BUGWK70748 CPU : fast/borders/different-color-borders.html = IMAGE
     1044BUGWK70748 CPU : fast/borders/fieldsetBorderRadius.html = IMAGE
     1045BUGWK70748 CPU : fast/borders/mixed-border-styles-radius2.html = IMAGE
     1046BUGWK70748 CPU : fast/borders/mixed-border-styles-radius.html = IMAGE
     1047BUGWK70748 CPU : fast/box-shadow/basic-shadows.html = IMAGE
     1048BUGWK70748 CPU : fast/box-shadow/border-radius-big.html = IMAGE
     1049BUGWK70748 CPU : fast/box-shadow/inset-box-shadows.html = IMAGE
     1050BUGWK70748 CPU : fast/box-shadow/inset.html = IMAGE
     1051BUGWK70748 CPU : fast/box-shadow/inset-with-extraordinary-radii-and-border.html = IMAGE
     1052BUGWK70748 CPU : fast/box-shadow/spread.html = IMAGE
     1053BUGWK70748 CPU : fast/box-shadow/spread-multiple-inset.html = IMAGE
     1054BUGWK70748 CPU : fast/box-shadow/spread-multiple-normal.html = IMAGE
     1055BUGWK70748 CPU : fast/clip/overflow-border-radius-clip.html = IMAGE
     1056BUGWK70748 CPU : fast/css/box-shadow-and-border-radius.html = IMAGE
     1057BUGWK70748 CPU : fast/css/nested-rounded-corners.html = IMAGE
     1058BUGWK70748 CPU : fast/css/text-input-with-webkit-border-radius.html = IMAGE
     1059BUGWK70748 CPU : fast/forms/basic-selects.html = IMAGE
     1060BUGWK70748 CPU : fast/forms/validation-message-appearance.html = IMAGE
     1061BUGWK70748 CPU : fast/layers/video-layer.html = IMAGE
     1062BUGWK70748 CPU : fast/repaint/shadow-multiple-horizontal.html = IMAGE
     1063BUGWK70748 CPU : fast/repaint/shadow-multiple-strict-horizontal.html = IMAGE
     1064BUGWK70748 CPU : fast/repaint/shadow-multiple-strict-vertical.html = IMAGE
     1065BUGWK70748 CPU : fast/repaint/shadow-multiple-vertical.html = IMAGE
     1066BUGWK70748 CPU : fast/transforms/shadows.html = IMAGE
     1067BUGWK70748 CPU : fast/writing-mode/border-styles-vertical-lr.html = IMAGE
     1068BUGWK70748 CPU : fast/writing-mode/border-styles-vertical-rl.html = IMAGE
     1069BUGWK70748 CPU : fast/writing-mode/box-shadow-horizontal-bt.html = IMAGE
     1070BUGWK70748 CPU : fast/writing-mode/box-shadow-vertical-lr.html = IMAGE
     1071BUGWK70748 CPU : fast/writing-mode/box-shadow-vertical-rl.html = IMAGE
     1072BUGWK70748 CPU : fullscreen/full-screen-stacking-context.html = IMAGE
     1073BUGWK70748 CPU : media/audio-controls-rendering.html = IMAGE
     1074BUGWK70748 CPU : media/controls-after-reload.html = IMAGE
     1075BUGWK70748 CPU : media/controls-strict.html = IMAGE
     1076BUGWK70748 CPU : media/controls-styling.html = IMAGE
     1077BUGWK70748 CPU : media/controls-without-preload.html = IMAGE
     1078BUGWK70748 CPU : media/media-controls-clone.html = IMAGE
     1079BUGWK70748 CPU : media/media-document-audio-repaint.html = IMAGE
     1080BUGWK70748 CPU : media/video-controls-rendering.html = IMAGE
     1081BUGWK70748 CPU : media/video-display-toggle.html = IMAGE
     1082BUGWK70748 CPU : media/video-empty-source.html = IMAGE
     1083BUGWK70748 CPU : media/video-no-audio.html = IMAGE
     1084BUGWK70748 CPU : media/video-playing-and-pause.html = IMAGE
     1085BUGWK70748 CPU : media/video-volume-slider.html = IMAGE
     1086BUGWK70748 CPU : svg/clip-path/clip-in-mask-objectBoundingBox.svg = IMAGE
     1087BUGWK70748 CPU : svg/clip-path/clip-in-mask-userSpaceOnUse.svg = IMAGE
     1088BUGWK70748 CPU : svg/clip-path/clip-path-clipped-evenodd-twice.svg = IMAGE
     1089BUGWK70748 CPU : svg/clip-path/clip-path-clipped-nonzero.svg = IMAGE
     1090BUGWK70748 CPU : svg/clip-path/clip-path-clipped.svg = IMAGE
     1091BUGWK70748 CPU : svg/clip-path/clip-path-objectBoundingBox.svg = IMAGE
     1092BUGWK70748 CPU : svg/clip-path/clip-path-on-clipped-use.svg = IMAGE
     1093BUGWK70748 CPU : svg/clip-path/clip-path-on-g-and-child.svg = IMAGE
     1094BUGWK70748 CPU : svg/clip-path/clip-path-on-g.svg = IMAGE
     1095BUGWK70748 CPU : svg/clip-path/clip-path-on-svg-and-child.svg = IMAGE
     1096BUGWK70748 CPU : svg/clip-path/clip-path-on-svg.svg = IMAGE
     1097BUGWK70748 CPU : svg/clip-path/clip-path-transform-2.svg = IMAGE
     1098BUGWK70748 CPU : svg/clip-path/clip-path-use-as-child.svg = IMAGE
     1099BUGWK70748 CPU : svg/clip-path/clip-path-userSpaceOnUse.svg = IMAGE
     1100BUGWK70748 CPU : svg/clip-path/clip-path-with-text-clipped.svg = IMAGE
     1101BUGWK70748 CPU : svg/css/text-shadow-multiple.xhtml = IMAGE
     1102BUGWK70748 CPU : svg/custom/resource-invalidate-on-target-update.svg = IMAGE
     1103BUGWK70748 CPU : svg/custom/use-on-clip-path-with-transformation.svg = IMAGE
     1104BUGWK70748 CPU : svg/W3C-I18N/tspan-dirLTR-ubOverride-in-rtl-context.svg = IMAGE
     1105BUGWK70748 CPU : svg/W3C-SVG-1.1/painting-marker-02-f.svg = IMAGE
     1106BUGWK70748 CPU : fast/borders/only-one-border-with-width.html = IMAGE
     1107BUGWK70748 CPU : svg/W3C-SVG-1.1/masking-path-05-f.svg = IMAGE
    9991108
    10001109// -----------------------------------------------------------------
     
    13991508// different results than with Skia. When we switch back to Skia, we can
    14001509// reenable these.
    1401 BUGCR99500 WIN RELEASE : media/audio-repaint.html = IMAGE
    14021510BUGCR99500 WIN : svg/as-background-image/animated-svg-as-background.html = IMAGE
    14031511BUGCR99500 WIN : svg/batik/text/textStyles.svg = IMAGE
     
    22032311
    22042312// To be rebaselined when the new gdi-aa-text code finalizes
    2205 BUGCR98248 WIN : fast/repaint/shadow-multiple-horizontal.html = IMAGE
    2206 BUGCR98248 WIN : fast/repaint/shadow-multiple-strict-horizontal.html = IMAGE
    2207 BUGCR98248 WIN : fast/repaint/shadow-multiple-strict-vertical.html = IMAGE
    2208 BUGCR98248 WIN : fast/repaint/shadow-multiple-vertical.html = IMAGE
    22092313BUGCR98248 WIN : fast/text/stroking-decorations.html = IMAGE
    22102314BUGCR98248 WIN : fast/text/stroking.html = IMAGE
    2211 BUGCR98248 WIN : fast/transforms/shadows.html = IMAGE
    22122315BUGCR98248 WIN : fast/writing-mode/english-lr-text.html = IMAGE
    22132316BUGCR98248 WIN : svg/css/group-with-shadow.svg = IMAGE
     
    25802683BUGCR71022 LEOPARD : fast/text/justify-ideograph-vertical.html = IMAGE IMAGE+TEXT
    25812684
    2582 BUGCR71418 LEOPARD : fast/borders/border-radius-split-inline.html = IMAGE
     2685BUGCR71418 LEOPARD CPU-CG : fast/borders/border-radius-split-inline.html = IMAGE
    25832686
    25842687BUGWK53446 DEBUG : http/tests/navigation/forward-and-cancel.html = PASS CRASH TEXT
     
    30023105BUGWK60115 WIN : fast/text/shadow-translucent-fill.html = IMAGE
    30033106BUGWK60115 LEOPARD : fast/text/shadow-translucent-fill.html = IMAGE
    3004 BUGWK60115 MAC : fast/transforms/shadows.html = PASS IMAGE
     3107BUGWK60115 MAC CPU-CG : fast/transforms/shadows.html = PASS IMAGE
    30053108//BUGWK60115 XP : svg/css/group-with-shadow.svg = IMAGE
    30063109BUGWK60115 WIN : transitions/svg-text-shadow-transition.html = IMAGE
     
    36713774BUGWK68747 : media/controls-right-click-on-timebar.html = TIMEOUT PASS
    36723775
    3673 BUGCR96861 WIN DEBUG : media/audio-repaint.html = TIMEOUT IMAGE PASS
    3674 BUGCR97657 MAC CPU DEBUG : media/audio-repaint.html = TIMEOUT IMAGE PASS
     3776BUGCR96861 WIN LINUX : media/audio-repaint.html = TIMEOUT IMAGE PASS
     3777BUGCR97657 MAC CPU-CG : media/audio-repaint.html = TIMEOUT IMAGE PASS
    36753778
    36763779BUGWK68881 DEBUG : svg/text/selection-background-color.xhtml = CRASH IMAGE
  • trunk/Source/WebCore/ChangeLog

    r98594 r98596  
     12011-10-27  Mike Reed  <reed@google.com>
     2
     3        [skia] replace offscreen technique with native support for antialiased clipping
     4        https://bugs.webkit.org/show_bug.cgi?id=70748
     5
     6        Reviewed by Stephen White.
     7
     8        ~100 layout tests need to be rebaselined, as the native aa-clipping differs sometimes in the low
     9        bits of the result. Other than that, the results should be the same, except that now the drawing
     10        can go directly to the canvas, rather than being direct offscreen and then have that result
     11        "clipped" during the restore. This has the effect of allowing LCD text to be drawing inside a
     12        antialiased clip area.
     13
     14        * platform/graphics/skia/PlatformContextSkia.cpp:
     15        (WebCore::PlatformContextSkia::State::State):
     16        (WebCore::PlatformContextSkia::State::cloneInheritedProperties):
     17        (WebCore::PlatformContextSkia::clipPathAntiAliased):
     18        (WebCore::PlatformContextSkia::restore):
     19        * platform/graphics/skia/PlatformContextSkia.h:
     20
    1212011-10-27  Tony Chang  <tony@chromium.org>
    222
  • trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp

    r98527 r98596  
    9999    FloatRect m_clip;
    100100
    101     // This is a list of clipping paths which are currently active, in the
    102     // order in which they were pushed.
    103     WTF::Vector<SkPath> m_antiAliasClipPaths;
    104101    InterpolationQuality m_interpolationQuality;
    105102
     
    147144    , m_imageBufferClip(other.m_imageBufferClip)
    148145    , m_clip(other.m_clip)
    149     , m_antiAliasClipPaths(other.m_antiAliasClipPaths)
    150146    , m_interpolationQuality(other.m_interpolationQuality)
    151147{
     
    164160PlatformContextSkia::State PlatformContextSkia::State::cloneInheritedProperties()
    165161{
    166     PlatformContextSkia::State state(*this);
    167 
    168     // Everything is inherited except for the clip paths.
    169     state.m_antiAliasClipPaths.clear();
    170 
    171     return state;
     162    return PlatformContextSkia::State(*this);
    172163}
    173164
     
    268259void PlatformContextSkia::clipPathAntiAliased(const SkPath& clipPath)
    269260{
    270     if (m_canvas->getTopDevice()->getDeviceCapabilities() & SkDevice::kVector_Capability) {
    271         // When the output is a vector device, like PDF, we don't need antialiased clips.
    272         // It's up to the PDF rendering engine to do that. We can simply disable the
    273         // antialiased clip code if the output is a vector device.
    274         canvas()->clipPath(clipPath);
    275         return;
    276     }
    277 
    278     // If we are currently tracking any anti-alias clip paths, then we already
    279     // have a layer in place and don't need to add another.
    280     bool haveLayerOutstanding = m_state->m_antiAliasClipPaths.size();
    281 
    282     // See comments in applyAntiAliasedClipPaths about how this works.
    283     m_state->m_antiAliasClipPaths.append(clipPath);
    284 
    285     if (!haveLayerOutstanding) {
    286         SkRect bounds = clipPath.getBounds();
    287         // If we are doing a clip outside of clipPath our layer needs to be for the whole
    288         // canvas, otherwise we can create a smaller layer.
    289         SkRect* layerBounds = 0;
    290         if (!clipPath.isInverseFillType())
    291             layerBounds = &bounds;
    292         canvas()->saveLayerAlpha(layerBounds, 255, static_cast<SkCanvas::SaveFlags>(SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag | SkCanvas::kClipToLayer_SaveFlag));
    293         // Guards state modification during clipped operations.
    294         // The state is popped in applyAntiAliasedClipPaths().
    295         canvas()->save();
    296     }
     261    canvas()->clipPath(clipPath, SkRegion::kIntersect_Op, true);
    297262}
    298263
     
    303268        canvas()->restore();
    304269    }
    305 
    306     if (!m_state->m_antiAliasClipPaths.isEmpty())
    307         applyAntiAliasedClipPaths(m_state->m_antiAliasClipPaths);
    308270
    309271    m_stateStack.removeLast();
     
    623585}
    624586
    625 void PlatformContextSkia::applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths)
    626 {
    627     // Anti-aliased clipping:
    628     //
    629     // Skia's clipping is 1-bit only. Consider what would happen if it were 8-bit:
    630     // We have a square canvas, filled with white and we declare a circular
    631     // clipping path. Then we fill twice with a black rectangle. The fractional
    632     // pixels would first get the correct color (white * alpha + black * (1 -
    633     // alpha)), but the second fill would apply the alpha to the already
    634     // modified color and the result would be too dark.
    635     //
    636     // This, anti-aliased clipping needs to be performed after the drawing has
    637     // been done. In order to do this, we create a new layer of the canvas in
    638     // clipPathAntiAliased and store the clipping path. All drawing is done to
    639     // the layer's bitmap while it's in effect. When WebKit calls restore() to
    640     // undo the clipping, this function is called.
    641     //
    642     // Here, we walk the list of clipping paths backwards and, for each, we
    643     // clear outside of the clipping path. We only need a single extra layer
    644     // for any number of clipping paths.
    645     //
    646     // When we call restore on the SkCanvas, the layer's bitmap is composed
    647     // into the layer below and we end up with correct, anti-aliased clipping.
    648 
    649     m_canvas->restore();
    650 
    651     SkPaint paint;
    652     paint.setXfermodeMode(SkXfermode::kClear_Mode);
    653     paint.setAntiAlias(true);
    654     paint.setStyle(SkPaint::kFill_Style);
    655 
    656     for (size_t i = paths.size() - 1; i < paths.size(); --i) {
    657         paths[i].toggleInverseFillType();
    658         m_canvas->drawPath(paths[i], paint);
    659     }
    660 
    661     m_canvas->restore();
    662 }
    663 
    664587void PlatformContextSkia::setGraphicsContext3D(GraphicsContext3D* context)
    665588{
  • trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h

    r98527 r98596  
    186186    // m_canvas that are also in imageBuffer.
    187187    void applyClipFromImage(const FloatRect&, const SkBitmap&);
    188     void applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths);
    189188
    190189    // common code between setupPaintFor[Filling,Stroking]
Note: See TracChangeset for help on using the changeset viewer.