Changeset 83649 in webkit


Ignore:
Timestamp:
Apr 12, 2011 3:27:04 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-12 Alok Priyadarshi <alokp@chromium.org>

Reviewed by James Robinson.

Remove dependency on chromium skia::PlatformCanvas
https://bugs.webkit.org/show_bug.cgi?id=57563

This patch does not change any functionality, just the type of object skia::PlatformCanvas -> SkCanvas.
The object is still being created by a factory method skia::CreateBitmapCanvas defined in Chromium.
We will eventually define an API that every port using skia will define.

  • platform/graphics/chromium/FontChromiumWin.cpp: (WebCore::TransparencyAwareFontPainter::TransparencyAwareFontPainter::initializeForGDI): (WebCore::TransparencyAwareFontPainter::TransparencyAwareFontPainter::~TransparencyAwareFontPainter): (WebCore::Font::drawComplexText):
  • platform/graphics/chromium/ImageBufferData.h:
  • platform/graphics/chromium/LayerChromium.h:
  • platform/graphics/chromium/LayerRendererChromium.h:
  • platform/graphics/chromium/PlatformCanvas.cpp: (WebCore::PlatformCanvas::resize):
  • platform/graphics/chromium/PlatformCanvas.h:
  • platform/graphics/chromium/TransparencyWin.cpp: (WebCore::TransparencyWin::compositeTextComposite): (WebCore::TransparencyWin::makeLayerOpaque):
  • platform/graphics/skia/ImageBufferSkia.cpp: (WebCore::ImageBuffer::ImageBuffer):
  • platform/graphics/skia/ImageSkia.cpp: (WebCore::paintSkBitmap): (WebCore::Image::drawPattern):
  • platform/graphics/skia/PlatformContextSkia.cpp: (WebCore::PlatformContextSkia::PlatformContextSkia): (WebCore::PlatformContextSkia::setCanvas): (WebCore::PlatformContextSkia::isNativeFontRenderingAllowed):
  • platform/graphics/skia/PlatformContextSkia.h: (WebCore::PlatformContextSkia::canvas): (WebCore::PlatformContextSkia::printing): (WebCore::PlatformContextSkia::setPrinting):

2011-04-12 Alok Priyadarshi <alokp@chromium.org>

Reviewed by James Robinson.

Remove dependency on chromium skia::PlatformCanvas
https://bugs.webkit.org/show_bug.cgi?id=57563

  • public/WebCanvas.h:
  • src/WebFrameImpl.cpp: (WebKit::WebFrameImpl::printPage):
  • tests/TransparencyWinTest.cpp: (WebCore::drawNativeRect): (WebCore::getPixelAt): (WebCore::clearTopLayerAlphaChannel): (WebCore::clearTopLayerAlphaPixel): (WebCore::TEST):
Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r83645 r83649  
     12011-04-12  Alok Priyadarshi  <alokp@chromium.org>
     2
     3        Reviewed by James Robinson.
     4
     5        Remove dependency on chromium skia::PlatformCanvas
     6        https://bugs.webkit.org/show_bug.cgi?id=57563
     7
     8        This patch does not change any functionality, just the type of object skia::PlatformCanvas -> SkCanvas.
     9        The object is still being created by a factory method skia::CreateBitmapCanvas defined in Chromium.
     10        We will eventually define an API that every port using skia will define.
     11
     12        * platform/graphics/chromium/FontChromiumWin.cpp:
     13        (WebCore::TransparencyAwareFontPainter::TransparencyAwareFontPainter::initializeForGDI):
     14        (WebCore::TransparencyAwareFontPainter::TransparencyAwareFontPainter::~TransparencyAwareFontPainter):
     15        (WebCore::Font::drawComplexText):
     16        * platform/graphics/chromium/ImageBufferData.h:
     17        * platform/graphics/chromium/LayerChromium.h:
     18        * platform/graphics/chromium/LayerRendererChromium.h:
     19        * platform/graphics/chromium/PlatformCanvas.cpp:
     20        (WebCore::PlatformCanvas::resize):
     21        * platform/graphics/chromium/PlatformCanvas.h:
     22        * platform/graphics/chromium/TransparencyWin.cpp:
     23        (WebCore::TransparencyWin::compositeTextComposite):
     24        (WebCore::TransparencyWin::makeLayerOpaque):
     25        * platform/graphics/skia/ImageBufferSkia.cpp:
     26        (WebCore::ImageBuffer::ImageBuffer):
     27        * platform/graphics/skia/ImageSkia.cpp:
     28        (WebCore::paintSkBitmap):
     29        (WebCore::Image::drawPattern):
     30        * platform/graphics/skia/PlatformContextSkia.cpp:
     31        (WebCore::PlatformContextSkia::PlatformContextSkia):
     32        (WebCore::PlatformContextSkia::setCanvas):
     33        (WebCore::PlatformContextSkia::isNativeFontRenderingAllowed):
     34        * platform/graphics/skia/PlatformContextSkia.h:
     35        (WebCore::PlatformContextSkia::canvas):
     36        (WebCore::PlatformContextSkia::printing):
     37        (WebCore::PlatformContextSkia::setPrinting):
     38
    1392011-04-11  Stephanie Lewis  <slewis@apple.com>
    240
  • trunk/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp

    r83541 r83649  
    166166    // Set up the DC, using the one from the transparency helper.
    167167    if (m_transparency.platformContext()) {
    168         m_hdc = m_transparency.platformContext()->canvas()->beginPlatformPaint();
     168        m_hdc = skia::BeginPlatformPaint(m_transparency.platformContext()->canvas());
    169169        SetTextColor(m_hdc, skia::SkColorToCOLORREF(color));
    170170        SetBkMode(m_hdc, TRANSPARENT);
     
    180180        m_graphicsContext->endTransparencyLayer();
    181181    m_graphicsContext->restore();
    182     m_platformContext->canvas()->endPlatformPaint();
     182    skia::EndPlatformPaint(m_platformContext->canvas());
    183183}
    184184
     
    543543    state.draw(graphicsContext, hdc, lroundf(point.x()), lroundf(point.y() - fontMetrics().ascent()), from, to);
    544544
    545     context->canvas()->endPlatformPaint();
     545    skia::EndPlatformPaint(context->canvas());
    546546}
    547547
  • trunk/Source/WebCore/platform/graphics/chromium/ImageBufferData.h

    r39899 r83649  
    3434#include "PlatformContextSkia.h"
    3535
    36 #include "skia/ext/platform_canvas.h"
    37 
    3836namespace WebCore {
    3937
     
    4240    ImageBufferData(const IntSize&);
    4341
    44     skia::PlatformCanvas m_canvas;
     42    OwnPtr<SkCanvas> m_canvas;
    4543    PlatformContextSkia m_platformContext;
    4644};
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h

    r83511 r83649  
    5151#include <wtf/text/WTFString.h>
    5252
    53 
    54 namespace skia {
    55 class PlatformCanvas;
    56 }
    57 
    5853namespace WebCore {
    5954
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r83552 r83649  
    195195
    196196#if USE(SKIA)
    197     OwnPtr<skia::PlatformCanvas> m_rootLayerCanvas;
     197    OwnPtr<SkCanvas> m_rootLayerCanvas;
    198198    OwnPtr<PlatformContextSkia> m_rootLayerSkiaContext;
    199199    OwnPtr<GraphicsContext> m_rootLayerGraphicsContext;
  • trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.cpp

    r83511 r83649  
    5353    m_size = size;
    5454#if USE(SKIA)
    55     m_skiaCanvas = new skia::PlatformCanvas(size.width(), size.height(), false);
     55    m_skiaCanvas = skia::CreateBitmapCanvas(size.width(), size.height(), false);
    5656#elif PLATFORM(CG)
    5757    size_t bufferSize = size.width() * size.height() * 4;
  • trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.h

    r83511 r83649  
    4040
    4141#if USE(SKIA)
    42 namespace skia { class PlatformCanvas; }
    4342class SkBitmap;
     43class SkCanvas;
    4444#endif
    4545
     
    9898private:
    9999#if USE(SKIA)
    100     OwnPtr<skia::PlatformCanvas> m_skiaCanvas;
     100    OwnPtr<SkCanvas> m_skiaCanvas;
    101101#elif PLATFORM(CG)
    102102    OwnArrayPtr<uint8_t> m_pixelData;
  • trunk/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp

    r77402 r83649  
    5050const int maxCachedBufferPixelSize = 65536;
    5151
    52 inline skia::PlatformCanvas* canvasForContext(const GraphicsContext& context)
     52inline SkCanvas* canvasForContext(const GraphicsContext& context)
    5353{
    5454    return context.platformContext()->canvas();
     
    5757inline const SkBitmap& bitmapForContext(const GraphicsContext& context)
    5858{
    59     return canvasForContext(context)->getTopPlatformDevice().accessBitmap(false);
     59    return canvasForContext(context)->getTopDevice()->accessBitmap(false);
    6060}
    6161
     
    467467        return;
    468468
    469     const SkBitmap& bitmap = m_layerBuffer->context()->platformContext()->canvas()->getTopPlatformDevice().accessBitmap(true);
     469    const SkBitmap& bitmap = m_layerBuffer->context()->platformContext()->canvas()->getTopDevice()->accessBitmap(true);
    470470    SkColor textColor = m_textCompositeColor.rgb();
    471471    for (int y = 0; y < m_layerSize.height(); y++) {
     
    503503
    504504    SkBitmap& bitmap = const_cast<SkBitmap&>(m_drawContext->platformContext()->
    505         canvas()->getTopPlatformDevice().accessBitmap(true));
     505        canvas()->getTopDevice()->accessBitmap(true));
    506506    for (int y = 0; y < m_layerSize.height(); y++) {
    507507        uint32_t* row = bitmap.getAddr32(0, y);
  • trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

    r83582 r83649  
    6767    , m_size(size)
    6868{
    69     if (!m_data.m_canvas.initialize(size.width(), size.height(), false)) {
     69    SkCanvas* canvas = skia::CreateBitmapCanvas(size.width(), size.height(), false);
     70    if (!canvas) {
    7071        success = false;
    7172        return;
    7273    }
    7374
    74     m_data.m_platformContext.setCanvas(&m_data.m_canvas);
     75    m_data.m_canvas = canvas;
     76    m_data.m_platformContext.setCanvas(m_data.m_canvas.get());
    7577    m_context.set(new GraphicsContext(&m_data.m_platformContext));
    7678    m_context->platformContext()->setDrawingToImageBuffer(true);
     
    7981    // required, but the canvas is currently filled with the magic transparency
    8082    // color. Can we have another way to manage this?
    81     m_data.m_canvas.drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);
     83    m_data.m_canvas->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);
    8284    success = true;
    8385}
  • trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp

    r81489 r83649  
    263263    paint.setLooper(platformContext->getDrawLooper());
    264264
    265     skia::PlatformCanvas* canvas = platformContext->canvas();
    266 
    267     ResamplingMode resampling = platformContext->isPrinting() ? RESAMPLE_NONE :
     265    SkCanvas* canvas = platformContext->canvas();
     266
     267    ResamplingMode resampling;
     268#if ENABLE(SKIA_GPU)
     269    resampling = RESAMPLE_LINEAR;
     270#else
     271    resampling = platformContext->printing() ? RESAMPLE_NONE :
    268272        computeResamplingMode(platformContext, bitmap, srcRect.width(), srcRect.height(),
    269273                              SkScalarToFloat(destRect.width()),
    270274                              SkScalarToFloat(destRect.height()));
     275#endif
    271276    if (resampling == RESAMPLE_AWESOME) {
    272277        drawResampledBitmap(*canvas, paint, bitmap, srcRect, destRect);
     
    364369    // Compute the resampling mode.
    365370    ResamplingMode resampling;
    366     if (context->platformContext()->isPrinting())
     371#if ENABLE(SKIA_GPU)
     372    resampling = RESAMPLE_LINEAR;
     373#else
     374    if (context->platformContext()->printing())
    367375      resampling = RESAMPLE_LINEAR;
    368376    else {
     
    371379                                         destBitmapWidth, destBitmapHeight);
    372380    }
     381#endif
    373382
    374383    // Load the transform WebKit requested.
  • trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp

    r82751 r83649  
    214214
    215215// Danger: canvas can be NULL.
    216 PlatformContextSkia::PlatformContextSkia(skia::PlatformCanvas* canvas)
     216PlatformContextSkia::PlatformContextSkia(SkCanvas* canvas)
    217217    : m_canvas(canvas)
     218    , m_printing(false)
    218219    , m_drawingToImageBuffer(false)
    219220    , m_useGPU(false)
     
    241242}
    242243
    243 void PlatformContextSkia::setCanvas(skia::PlatformCanvas* canvas)
     244void PlatformContextSkia::setCanvas(SkCanvas* canvas)
    244245{
    245246    m_canvas = canvas;
     
    610611}
    611612
    612 bool PlatformContextSkia::isPrinting()
    613 {
    614 #if ENABLE(SKIA_GPU)
    615     return true;
    616 #else
    617     return m_canvas->getTopPlatformDevice().IsVectorial();
    618 #endif
    619 }
    620 
    621613bool PlatformContextSkia::isNativeFontRenderingAllowed()
    622614{
     
    624616    return false;
    625617#else
    626     return m_canvas->getTopPlatformDevice().IsNativeFontRenderingAllowed();
     618    return skia::SupportsPlatformPaint(m_canvas);
    627619#endif
    628620}
  • trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h

    r83409 r83649  
    7373    // For printing, there shouldn't be any canvas. canvas can be NULL. If you
    7474    // supply a NULL canvas, you can also call setCanvas later.
    75     PlatformContextSkia(skia::PlatformCanvas*);
     75    PlatformContextSkia(SkCanvas*);
    7676    ~PlatformContextSkia();
    7777
    7878    // Sets the canvas associated with this context. Use when supplying NULL
    7979    // to the constructor.
    80     void setCanvas(skia::PlatformCanvas*);
     80    void setCanvas(SkCanvas*);
    8181
    8282    // If false we're rendering to a GraphicsContext for a web page, if false
     
    148148
    149149    // Returns the canvas used for painting, NOT guaranteed to be non-null.
    150     skia::PlatformCanvas* canvas() { return m_canvas; }
     150    SkCanvas* canvas() { return m_canvas; }
    151151
    152152    InterpolationQuality interpolationQuality() const;
     
    164164    // context. Bitmap shouldn't be resampled when printing to keep the best
    165165    // possible quality.
    166     bool isPrinting();
     166    bool printing() const { return m_printing; }
     167    void setPrinting(bool p) { m_printing = p; }
    167168
    168169    // Returns if the context allows rendering of fonts using native platform
     
    186187#endif
    187188    // Call these before making a call that manipulates the underlying
    188     // skia::PlatformCanvas or WebCore::GLES2Canvas
     189    // SkCanvas or WebCore::GLES2Canvas
    189190    void prepareForSoftwareDraw() const;
    190191    void prepareForHardwareDraw() const;
    191     // Call to force the skia::PlatformCanvas to contain all rendering results.
     192    // Call to force the SkCanvas to contain all rendering results.
    192193    void syncSoftwareCanvas() const;
    193194    void markDirtyRect(const IntRect& rect);
     
    206207
    207208    // NULL indicates painting is disabled. Never delete this object.
    208     skia::PlatformCanvas* m_canvas;
     209    SkCanvas* m_canvas;
    209210
    210211    // States stack. Enables local drawing state change with save()/restore()
     
    219220    IntSize m_imageResamplingHintSrcSize;
    220221    FloatSize m_imageResamplingHintDstSize;
     222    bool m_printing;
    221223    bool m_drawingToImageBuffer;
    222224    bool m_useGPU;
  • trunk/Source/WebKit/chromium/ChangeLog

    r83642 r83649  
     12011-04-12  Alok Priyadarshi  <alokp@chromium.org>
     2
     3        Reviewed by James Robinson.
     4
     5        Remove dependency on chromium skia::PlatformCanvas
     6        https://bugs.webkit.org/show_bug.cgi?id=57563
     7
     8        * public/WebCanvas.h:
     9        * src/WebFrameImpl.cpp:
     10        (WebKit::WebFrameImpl::printPage):
     11        * tests/TransparencyWinTest.cpp:
     12        (WebCore::drawNativeRect):
     13        (WebCore::getPixelAt):
     14        (WebCore::clearTopLayerAlphaChannel):
     15        (WebCore::clearTopLayerAlphaPixel):
     16        (WebCore::TEST):
     17
    1182011-04-12  Adam Barth  <abarth@webkit.org>
    219
  • trunk/Source/WebKit/chromium/public/WebCanvas.h

    r50668 r83649  
    3535
    3636#if WEBKIT_USING_SKIA
    37 namespace skia { class PlatformCanvas; }
     37class SkCanvas;
    3838#elif WEBKIT_USING_CG
    3939struct CGContext;
     
    4343
    4444#if WEBKIT_USING_SKIA
    45 typedef skia::PlatformCanvas WebCanvas;
     45typedef SkCanvas WebCanvas;
    4646#elif WEBKIT_USING_CG
    4747typedef struct CGContext WebCanvas;
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp

    r83366 r83649  
    14101410    }
    14111411
    1412     return m_printContext->spoolPage(GraphicsContextBuilder(canvas).context(), page);
     1412    GraphicsContextBuilder builder(canvas);
     1413    GraphicsContext& gc = builder.context();
     1414#if WEBKIT_USING_SKIA
     1415    gc.platformContext()->setPrinting(true);
     1416#endif
     1417
     1418    return m_printContext->spoolPage(gc, page);
    14131419}
    14141420
  • trunk/Source/WebKit/chromium/tests/TransparencyWinTest.cpp

    r77402 r83649  
    5151                           int x, int y, int w, int h)
    5252{
    53     skia::PlatformCanvas* canvas = context->platformContext()->canvas();
    54     HDC dc = canvas->beginPlatformPaint();
     53    SkCanvas* canvas = context->platformContext()->canvas();
     54    HDC dc = skia::BeginPlatformPaint(canvas);
    5555
    5656    RECT innerRc;
     
    6262             reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)));
    6363
    64     canvas->endPlatformPaint();
     64    skia::EndPlatformPaint(canvas);
    6565}
    6666
    6767static Color getPixelAt(GraphicsContext* context, int x, int y)
    6868{
    69     const SkBitmap& bitmap = context->platformContext()->canvas()->
    70         getTopPlatformDevice().accessBitmap(false);
     69    const SkBitmap& bitmap = context->platformContext()->canvas()->getTopDevice()->accessBitmap(false);
    7170    return Color(*reinterpret_cast<const RGBA32*>(bitmap.getAddr32(x, y)));
    7271}
     
    7675static void clearTopLayerAlphaChannel(GraphicsContext* context)
    7776{
    78     SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()->
    79         canvas()->getTopPlatformDevice().accessBitmap(false));
     77    SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()->canvas()->getTopDevice()->accessBitmap(false));
    8078    for (int y = 0; y < bitmap.height(); y++) {
    8179        uint32_t* row = bitmap.getAddr32(0, y);
     
    8886static void clearTopLayerAlphaPixel(GraphicsContext* context, int x, int y)
    8987{
    90     SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()->
    91         canvas()->getTopPlatformDevice().accessBitmap(false));
     88    SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()->canvas()->getTopDevice()->accessBitmap(false));
    9289    *bitmap.getAddr32(x, y) &= 0x00FFFFFF;
    9390}
     
    560557        // clearTopLayerAlphaChannel because that will actually clear the whole
    561558        // canvas (since we have no extra layer!).
    562         SkBitmap& bitmap = const_cast<SkBitmap&>(helper.context()->
    563             platformContext()->canvas()->getTopPlatformDevice().
    564             accessBitmap(false));
     559        SkBitmap& bitmap = const_cast<SkBitmap&>(helper.context()->platformContext()->canvas()->getTopDevice()->accessBitmap(false));
    565560        *bitmap.getAddr32(2, 2) &= 0x00FFFFFF;
    566561        helper.composite();
Note: See TracChangeset for help on using the changeset viewer.