Changeset 64227 in webkit


Ignore:
Timestamp:
Jul 28, 2010 1:21:04 PM (14 years ago)
Author:
senorblanco@chromium.org
Message:

2010-07-28 Stephen White <senorblanco@chromium.org>

Reviewed by Darin Fisher.

Hook the GLES2 rendering path up to GraphicsContextSkia.
https://bugs.webkit.org/show_bug.cgi?id=43119


This connects the state-setting and drawing calls implemented in
so far in GLES2Canvas, and calls PlatformContextSkia's
prepareForSoftwareDraw() for all the non-accelerated paths.

  • platform/graphics/skia/GraphicsContextSkia.cpp: (WebCore::GraphicsContext::addInnerRoundedRectClip): (WebCore::GraphicsContext::addPath): (WebCore::GraphicsContext::beginPath): (WebCore::GraphicsContext::clip): (WebCore::GraphicsContext::drawConvexPolygon): (WebCore::GraphicsContext::drawEllipse): (WebCore::GraphicsContext::drawFocusRing): (WebCore::GraphicsContext::drawLine): (WebCore::GraphicsContext::drawLineForMisspellingOrBadGrammar): (WebCore::GraphicsContext::drawLineForText): (WebCore::GraphicsContext::drawRect): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::fillRoundedRect): (WebCore::GraphicsContext::strokeArc): (WebCore::GraphicsContext::strokePath): (WebCore::GraphicsContext::strokeRect): These calls are software-only; call preSoftwareDraw() for these. (WebCore::GraphicsContext::savePlatformState): (WebCore::GraphicsContext::restorePlatformState): (WebCore::GraphicsContext::setAlpha): (WebCore::GraphicsContext::setCompositeOperation): (WebCore::GraphicsContext::setPlatformFillColor): (WebCore::GraphicsContext::scale): (WebCore::GraphicsContext::rotate): (WebCore::GraphicsContext::translate): (WebCore::GraphicsContext::concatCTM): These ones set state on both Skia and GLES2Canvas. (WebCore::GraphicsContext::clearRect): (WebCore::GraphicsContext::fillRect): These ones have a GLES2 implementation; call through to it if PlatformContextSkia's useGPU() flag is set and the state permits.
  • platform/graphics/skia/PlatformContextSkia.cpp: (PlatformContextSkia::prepareForSoftwareDraw): (PlatformContextSkia::prepareForHardwareDraw): Rename preXXXDraw() -> prepareForXXXDraw().
  • platform/graphics/skia/PlatformContextSkia.h: (PlatformContextSkia::prepareForSoftwareDraw): (PlatformContextSkia::prepareForHardwareDraw): Rename preXXXDraw() -> prepareForXXXDraw().
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64225 r64227  
     12010-07-28  Stephen White  <senorblanco@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Hook the GLES2 rendering path up to GraphicsContextSkia.
     6        https://bugs.webkit.org/show_bug.cgi?id=43119
     7       
     8        This connects the state-setting and drawing calls implemented in
     9        so far in GLES2Canvas, and calls PlatformContextSkia's
     10        prepareForSoftwareDraw() for all the non-accelerated paths.
     11
     12        * platform/graphics/skia/GraphicsContextSkia.cpp:
     13        (WebCore::GraphicsContext::addInnerRoundedRectClip):
     14        (WebCore::GraphicsContext::addPath):
     15        (WebCore::GraphicsContext::beginPath):
     16        (WebCore::GraphicsContext::clip):
     17        (WebCore::GraphicsContext::drawConvexPolygon):
     18        (WebCore::GraphicsContext::drawEllipse):
     19        (WebCore::GraphicsContext::drawFocusRing):
     20        (WebCore::GraphicsContext::drawLine):
     21        (WebCore::GraphicsContext::drawLineForMisspellingOrBadGrammar):
     22        (WebCore::GraphicsContext::drawLineForText):
     23        (WebCore::GraphicsContext::drawRect):
     24        (WebCore::GraphicsContext::fillPath):
     25        (WebCore::GraphicsContext::fillRoundedRect):
     26        (WebCore::GraphicsContext::strokeArc):
     27        (WebCore::GraphicsContext::strokePath):
     28        (WebCore::GraphicsContext::strokeRect):
     29        These calls are software-only; call preSoftwareDraw() for these.
     30        (WebCore::GraphicsContext::savePlatformState):
     31        (WebCore::GraphicsContext::restorePlatformState):
     32        (WebCore::GraphicsContext::setAlpha):
     33        (WebCore::GraphicsContext::setCompositeOperation):
     34        (WebCore::GraphicsContext::setPlatformFillColor):
     35        (WebCore::GraphicsContext::scale):
     36        (WebCore::GraphicsContext::rotate):
     37        (WebCore::GraphicsContext::translate):
     38        (WebCore::GraphicsContext::concatCTM):
     39        These ones set state on both Skia and GLES2Canvas.
     40        (WebCore::GraphicsContext::clearRect):
     41        (WebCore::GraphicsContext::fillRect):
     42        These ones have a GLES2 implementation; call through to it if PlatformContextSkia's useGPU() flag is set and the state permits.
     43        * platform/graphics/skia/PlatformContextSkia.cpp:
     44        (PlatformContextSkia::prepareForSoftwareDraw):
     45        (PlatformContextSkia::prepareForHardwareDraw):
     46        Rename preXXXDraw() -> prepareForXXXDraw().
     47        * platform/graphics/skia/PlatformContextSkia.h:
     48        (PlatformContextSkia::prepareForSoftwareDraw):
     49        (PlatformContextSkia::prepareForHardwareDraw):
     50        Rename preXXXDraw() -> prepareForXXXDraw().
     51
    1522010-07-28  fsamuel@chromium.org  <fsamuel@chromium.org>
    253
  • trunk/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp

    r63864 r64227  
    5454#include <wtf/Assertions.h>
    5555#include <wtf/MathExtras.h>
     56
     57#if USE(GLES2_RENDERING)
     58#include "GLES2Canvas.h"
     59#endif
    5660
    5761using namespace std;
     
    244248        return;
    245249
     250#if USE(GLES2_RENDERING)
     251    if (platformContext()->useGPU())
     252        platformContext()->gpuCanvas()->save();
     253#endif
     254
    246255    // Save our private State.
    247256    platformContext()->save();
     
    252261    if (paintingDisabled())
    253262        return;
     263
     264#if USE(GLES2_RENDERING)
     265    if (platformContext()->useGPU())
     266        platformContext()->gpuCanvas()->restore();
     267#endif
    254268
    255269    // Restore our private State.
     
    291305        return;
    292306
     307    platformContext()->prepareForSoftwareDraw();
    293308    SkPath path;
    294309    path.addOval(r, SkPath::kCW_Direction);
     
    308323    if (paintingDisabled())
    309324        return;
     325    platformContext()->prepareForSoftwareDraw();
    310326    platformContext()->addPath(*path.platformPath());
    311327}
     
    315331    if (paintingDisabled())
    316332        return;
     333    platformContext()->prepareForSoftwareDraw();
    317334    platformContext()->beginPath();
    318335}
     
    329346    if (paintingDisabled())
    330347        return;
     348
     349#if USE(GLES2_RENDERING)
     350    if (platformContext()->useGPU()) {
     351        platformContext()->prepareForHardwareDraw();
     352        platformContext()->gpuCanvas()->clearRect(rect);
     353        return;
     354    }
     355#endif
     356
     357    platformContext()->prepareForSoftwareDraw();
    331358
    332359    SkRect r = rect;
     
    349376        return;
    350377
     378    platformContext()->prepareForSoftwareDraw();
    351379    platformContext()->canvas()->clipRect(r);
    352380}
     
    361389        return;
    362390
     391    platformContext()->prepareForSoftwareDraw();
    363392    platformContext()->clipPathAntiAliased(p);
    364393}
     
    442471    if (paintingDisabled())
    443472        return;
     473
     474#if USE(GLES2_RENDERING)
     475    if (platformContext()->useGPU())
     476        platformContext()->gpuCanvas()->concatCTM(affine);
     477#endif
     478
    444479    platformContext()->canvas()->concat(affine);
    445480}
     
    454489    if (numPoints <= 1)
    455490        return;
     491
     492    platformContext()->prepareForSoftwareDraw();
    456493
    457494    SkPath path;
     
    500537        return;
    501538
     539    platformContext()->prepareForSoftwareDraw();
    502540    SkPaint paint;
    503541    platformContext()->setupPaintForFilling(&paint);
     
    525563        return;
    526564
     565    platformContext()->prepareForSoftwareDraw();
    527566    SkRegion focusRingRegion;
    528567    const SkScalar focusRingOutset = WebCoreFloatToSkScalar(0.5);
     
    558597    if (!isPointSkiaSafe(getCTM(), point1) || !isPointSkiaSafe(getCTM(), point2))
    559598        return;
     599
     600    platformContext()->prepareForSoftwareDraw();
    560601
    561602    FloatPoint p1 = point1;
     
    604645    if (paintingDisabled())
    605646        return;
     647
     648    platformContext()->prepareForSoftwareDraw();
    606649
    607650    // Create the pattern we'll use to draw the underline.
     
    685728        return;
    686729
     730    platformContext()->prepareForSoftwareDraw();
     731
    687732    int thickness = SkMax32(static_cast<int>(strokeThickness()), 1);
    688733    SkRect r;
     
    705750        return;
    706751
     752    platformContext()->prepareForSoftwareDraw();
     753
    707754    SkRect r = rect;
    708755    if (!isRectSkiaSafe(getCTM(), r)) {
     
    723770      return;
    724771
     772    platformContext()->prepareForSoftwareDraw();
     773
    725774    const GraphicsContextState& state = m_common->state;
    726775    path.setFillType(state.fillRule == RULE_EVENODD ?
     
    746795    }
    747796
     797#if USE(GLES2_RENDERING)
     798    if (platformContext()->useGPU() && !m_common->state.fillPattern && !m_common->state.fillGradient) {
     799        platformContext()->prepareForHardwareDraw();
     800        platformContext()->gpuCanvas()->fillRect(rect);
     801        return;
     802    }
     803#endif
     804
     805    platformContext()->prepareForSoftwareDraw();
     806
    748807    SkPaint paint;
    749808    platformContext()->setupPaintForFilling(&paint);
     
    757816    if (paintingDisabled())
    758817        return;
     818
     819#if USE(GLES2_RENDERING)
     820    if (platformContext()->useGPU() && !m_common->state.fillPattern && !m_common->state.fillGradient) {
     821        platformContext()->prepareForHardwareDraw();
     822        platformContext()->gpuCanvas()->fillRect(rect, color, colorSpace);
     823        return;
     824    }
     825#endif
     826
     827    platformContext()->prepareForSoftwareDraw();
    759828
    760829    SkRect r = rect;
     
    790859        return;
    791860
     861    platformContext()->prepareForSoftwareDraw();
     862
    792863    SkRect r = rect;
    793864    if (!isRectSkiaSafe(getCTM(), r))
     
    873944    if (paintingDisabled())
    874945        return;
     946
     947#if USE(GLES2_RENDERING)
     948    if (platformContext()->useGPU())
     949        platformContext()->gpuCanvas()->scale(size);
     950#endif
     951
    875952    platformContext()->canvas()->scale(WebCoreFloatToSkScalar(size.width()),
    876953        WebCoreFloatToSkScalar(size.height()));
     
    881958    if (paintingDisabled())
    882959        return;
     960#if USE(GLES2_RENDERING)
     961    if (platformContext()->useGPU())
     962        platformContext()->gpuCanvas()->setAlpha(alpha);
     963#endif
    883964    platformContext()->setAlpha(alpha);
    884965}
     
    888969    if (paintingDisabled())
    889970        return;
     971#if USE(GLES2_RENDERING)
     972    if (platformContext()->useGPU())
     973        platformContext()->gpuCanvas()->setCompositeOperation(op);
     974#endif
    890975    platformContext()->setXfermodeMode(WebCoreCompositeToSkiaComposite(op));
    891976}
     
    9741059    if (paintingDisabled())
    9751060        return;
     1061#if USE(GLES2_RENDERING)
     1062    if (platformContext()->useGPU())
     1063        platformContext()->gpuCanvas()->setFillColor(color, colorSpace);
     1064#endif
     1065
    9761066    platformContext()->setFillColor(color.rgb());
    9771067}
     
    11031193        return;
    11041194
     1195    platformContext()->prepareForSoftwareDraw();
     1196
    11051197    SkPaint paint;
    11061198    SkRect oval = r;
     
    11341226        return;
    11351227
     1228    platformContext()->prepareForSoftwareDraw();
     1229
    11361230    SkPaint paint;
    11371231    platformContext()->setupPaintForStroking(&paint, 0, 0);
     
    11461240    if (!isRectSkiaSafe(getCTM(), rect))
    11471241        return;
     1242
     1243    platformContext()->prepareForSoftwareDraw();
    11481244
    11491245    SkPaint paint;
     
    11581254        return;
    11591255
     1256#if USE(GLES2_RENDERING)
     1257    if (platformContext()->useGPU())
     1258        platformContext()->gpuCanvas()->rotate(angleInRadians);
     1259#endif
     1260
    11601261    platformContext()->canvas()->rotate(WebCoreFloatToSkScalar(
    11611262        angleInRadians * (180.0f / 3.14159265f)));
     
    11671268        return;
    11681269
     1270#if USE(GLES2_RENDERING)
     1271    if (platformContext()->useGPU())
     1272        platformContext()->gpuCanvas()->translate(w, h);
     1273#endif
     1274
    11691275    platformContext()->canvas()->translate(WebCoreFloatToSkScalar(w),
    11701276                                           WebCoreFloatToSkScalar(h));
  • trunk/WebCore/platform/graphics/skia/PlatformContextSkia.cpp

    r64161 r64227  
    683683}
    684684
    685 void PlatformContextSkia::preSoftwareDraw() const
     685void PlatformContextSkia::prepareForSoftwareDraw() const
    686686{
    687687    if (!m_useGPU)
     
    725725}
    726726
    727 void PlatformContextSkia::preHardwareDraw() const
     727void PlatformContextSkia::prepareForHardwareDraw() const
    728728{
    729729    if (!m_useGPU)
  • trunk/WebCore/platform/graphics/skia/PlatformContextSkia.h

    r64161 r64227  
    192192    // Call these before making a call that manipulates the underlying
    193193    // skia::PlatformCanvas or WebCore::GLES2Canvas
    194     void preSoftwareDraw() const;
    195     void preHardwareDraw() const;
     194    void prepareForSoftwareDraw() const;
     195    void prepareForHardwareDraw() const;
    196196    // Call to force the skia::PlatformCanvas to contain all rendering results.
    197197    void syncSoftwareCanvas() const;
    198198#else
    199     void preSoftwareDraw() const {}
    200     void preHardwareDraw() const {}
     199    void prepareForSoftwareDraw() const {}
     200    void prepareForHardwareDraw() const {}
    201201    void syncSoftwareCanvas() const {}
    202202#endif
Note: See TracChangeset for help on using the changeset viewer.