[Skia] Encapsulate access to PlatformContextSkia's SkCanvas
authorfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Nov 2012 13:42:19 +0000 (13:42 +0000)
committerfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Nov 2012 13:42:19 +0000 (13:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102694

Reviewed by Stephen White.

Source/WebCore:

Add SkCanvas-equivalent methods to PlatformContextSkia, and refactor direct canvas call
sites to use these wrappers instead. This reduces the number of canvas() users from 90+
to 22 (mostly theme/ui code).

No new tests: refactoring only.

* platform/chromium/PlatformThemeChromiumLinux.cpp:
(WebCore::PlatformThemeChromiumLinux::paintArrowButton):
* platform/graphics/chromium/FontChromiumWin.cpp:
* platform/graphics/chromium/TransparencyWin.cpp:
(WebCore::TransparencyWin::computeLayerSize):
(WebCore::TransparencyWin::compositeOpaqueComposite):
(WebCore::TransparencyWin::compositeTextComposite):
(WebCore::TransparencyWin::makeLayerOpaque):
* platform/graphics/filters/skia/FEBlendSkia.cpp:
(WebCore::FEBlend::platformApplySkia):
* platform/graphics/filters/skia/FEColorMatrixSkia.cpp:
(WebCore::FEColorMatrix::platformApplySkia):
* platform/graphics/filters/skia/FEComponentTransferSkia.cpp:
(WebCore::FEComponentTransfer::platformApplySkia):
* platform/graphics/filters/skia/FELightingSkia.cpp:
(WebCore::FELighting::platformApplySkia):
* platform/graphics/harfbuzz/FontHarfBuzz.cpp:
(WebCore::Font::drawGlyphs):
(WebCore::Font::drawComplexText):
* platform/graphics/skia/FontSkia.cpp:
(WebCore::Font::drawGlyphs):
* platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContext::addInnerRoundedRectClip):
(WebCore::GraphicsContext::clearRect):
(WebCore::GraphicsContext::clip):
(WebCore::GraphicsContext::clipOut):
(WebCore::GraphicsContext::clipPath):
(WebCore::GraphicsContext::concatCTM):
(WebCore::GraphicsContext::setCTM):
(WebCore::GraphicsContext::drawConvexPolygon):
(WebCore::GraphicsContext::clipConvexPolygon):
(WebCore::GraphicsContext::drawEllipse):
(WebCore::drawOuterPath):
(WebCore::GraphicsContext::drawLine):
(WebCore::GraphicsContext::drawLineForDocumentMarker):
(WebCore::GraphicsContext::drawLineForText):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::fillRoundedRect):
(WebCore::GraphicsContext::getCTM):
(WebCore::GraphicsContext::scale):
(WebCore::GraphicsContext::strokeArc):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::strokeRect):
(WebCore::GraphicsContext::rotate):
(WebCore::GraphicsContext::translate):
(WebCore::GraphicsContext::platformFillEllipse):
(WebCore::GraphicsContext::platformStrokeEllipse):
* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::getImageData):
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::ImageBuffer::putByteArray):
(WebCore::ImageBuffer::toDataURL):
* platform/graphics/skia/ImageSkia.cpp:
(WebCore::drawResampledBitmap):
(WebCore::hasNon90rotation):
(WebCore::paintSkBitmap):
(WebCore::Image::drawPattern):
* platform/graphics/skia/PlatformContextSkia.cpp:
(WebCore::PlatformContextSkia::save):
(WebCore::PlatformContextSkia::beginLayerClippedToImage):
(WebCore::PlatformContextSkia::restore):
(WebCore::PlatformContextSkia::drawRect):
(WebCore::PlatformContextSkia::couldUseLCDRenderedText):
* platform/graphics/skia/PlatformContextSkia.h:
(PlatformContextSkia):
(WebCore::PlatformContextSkia::layerBitmap):
(WebCore):
(WebCore::PlatformContextSkia::readPixels):
(WebCore::PlatformContextSkia::writePixels):
(WebCore::PlatformContextSkia::isDrawingToLayer):
(WebCore::PlatformContextSkia::isVector):
(WebCore::PlatformContextSkia::clipPath):
(WebCore::PlatformContextSkia::clipRect):
(WebCore::PlatformContextSkia::getClipBounds):
(WebCore::PlatformContextSkia::setMatrix):
(WebCore::PlatformContextSkia::getTotalMatrix):
(WebCore::PlatformContextSkia::concat):
(WebCore::PlatformContextSkia::rotate):
(WebCore::PlatformContextSkia::scale):
(WebCore::PlatformContextSkia::translate):
(WebCore::PlatformContextSkia::drawBitmap):
(WebCore::PlatformContextSkia::drawBitmapRect):
(WebCore::PlatformContextSkia::drawOval):
(WebCore::PlatformContextSkia::drawPath):
(WebCore::PlatformContextSkia::drawPoints):
(WebCore::PlatformContextSkia::drawRect):
(WebCore::PlatformContextSkia::drawIRect):
(WebCore::PlatformContextSkia::drawPosText):
(WebCore::PlatformContextSkia::drawPosTextH):
(WebCore::PlatformContextSkia::drawTextOnPath):
* platform/graphics/skia/SkiaFontWin.cpp:
(WebCore::skiaDrawText):
(WebCore::paintSkiaText):
* platform/graphics/skia/SkiaUtils.cpp:
(WebCore::ClipRectToCanvas):
* platform/graphics/skia/SkiaUtils.h:
(WebCore):

Source/WebKit/chromium:

Use PlatformContextSkia's wrapper methods instead of accessing the canvas directly.

* tests/TransparencyWinTest.cpp:
(WebCore::getPixelAt):
(WebCore::clearTopLayerAlphaChannel):
(WebCore::clearTopLayerAlphaPixel):
(WebCore::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135390 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/chromium/PlatformThemeChromiumLinux.cpp
Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp
Source/WebCore/platform/graphics/filters/skia/FEBlendSkia.cpp
Source/WebCore/platform/graphics/filters/skia/FEColorMatrixSkia.cpp
Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp
Source/WebCore/platform/graphics/filters/skia/FELightingSkia.cpp
Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp
Source/WebCore/platform/graphics/skia/FontSkia.cpp
Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
Source/WebCore/platform/graphics/skia/ImageSkia.cpp
Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
Source/WebCore/platform/graphics/skia/PlatformContextSkia.h
Source/WebCore/platform/graphics/skia/SkiaFontWin.cpp
Source/WebCore/platform/graphics/skia/SkiaUtils.cpp
Source/WebCore/platform/graphics/skia/SkiaUtils.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/TransparencyWinTest.cpp

index 93444ff..4cef21a 100644 (file)
@@ -1,3 +1,116 @@
+2012-11-21  Florin Malita  <fmalita@chromium.org>
+
+        [Skia] Encapsulate access to PlatformContextSkia's SkCanvas
+        https://bugs.webkit.org/show_bug.cgi?id=102694
+
+        Reviewed by Stephen White.
+
+        Add SkCanvas-equivalent methods to PlatformContextSkia, and refactor direct canvas call
+        sites to use these wrappers instead. This reduces the number of canvas() users from 90+
+        to 22 (mostly theme/ui code).
+
+        No new tests: refactoring only.
+
+        * platform/chromium/PlatformThemeChromiumLinux.cpp:
+        (WebCore::PlatformThemeChromiumLinux::paintArrowButton):
+        * platform/graphics/chromium/FontChromiumWin.cpp:
+        * platform/graphics/chromium/TransparencyWin.cpp:
+        (WebCore::TransparencyWin::computeLayerSize):
+        (WebCore::TransparencyWin::compositeOpaqueComposite):
+        (WebCore::TransparencyWin::compositeTextComposite):
+        (WebCore::TransparencyWin::makeLayerOpaque):
+        * platform/graphics/filters/skia/FEBlendSkia.cpp:
+        (WebCore::FEBlend::platformApplySkia):
+        * platform/graphics/filters/skia/FEColorMatrixSkia.cpp:
+        (WebCore::FEColorMatrix::platformApplySkia):
+        * platform/graphics/filters/skia/FEComponentTransferSkia.cpp:
+        (WebCore::FEComponentTransfer::platformApplySkia):
+        * platform/graphics/filters/skia/FELightingSkia.cpp:
+        (WebCore::FELighting::platformApplySkia):
+        * platform/graphics/harfbuzz/FontHarfBuzz.cpp:
+        (WebCore::Font::drawGlyphs):
+        (WebCore::Font::drawComplexText):
+        * platform/graphics/skia/FontSkia.cpp:
+        (WebCore::Font::drawGlyphs):
+        * platform/graphics/skia/GraphicsContextSkia.cpp:
+        (WebCore::GraphicsContext::addInnerRoundedRectClip):
+        (WebCore::GraphicsContext::clearRect):
+        (WebCore::GraphicsContext::clip):
+        (WebCore::GraphicsContext::clipOut):
+        (WebCore::GraphicsContext::clipPath):
+        (WebCore::GraphicsContext::concatCTM):
+        (WebCore::GraphicsContext::setCTM):
+        (WebCore::GraphicsContext::drawConvexPolygon):
+        (WebCore::GraphicsContext::clipConvexPolygon):
+        (WebCore::GraphicsContext::drawEllipse):
+        (WebCore::drawOuterPath):
+        (WebCore::GraphicsContext::drawLine):
+        (WebCore::GraphicsContext::drawLineForDocumentMarker):
+        (WebCore::GraphicsContext::drawLineForText):
+        (WebCore::GraphicsContext::fillPath):
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::fillRoundedRect):
+        (WebCore::GraphicsContext::getCTM):
+        (WebCore::GraphicsContext::scale):
+        (WebCore::GraphicsContext::strokeArc):
+        (WebCore::GraphicsContext::strokePath):
+        (WebCore::GraphicsContext::strokeRect):
+        (WebCore::GraphicsContext::rotate):
+        (WebCore::GraphicsContext::translate):
+        (WebCore::GraphicsContext::platformFillEllipse):
+        (WebCore::GraphicsContext::platformStrokeEllipse):
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::getImageData):
+        (WebCore::ImageBuffer::getUnmultipliedImageData):
+        (WebCore::ImageBuffer::getPremultipliedImageData):
+        (WebCore::ImageBuffer::putByteArray):
+        (WebCore::ImageBuffer::toDataURL):
+        * platform/graphics/skia/ImageSkia.cpp:
+        (WebCore::drawResampledBitmap):
+        (WebCore::hasNon90rotation):
+        (WebCore::paintSkBitmap):
+        (WebCore::Image::drawPattern):
+        * platform/graphics/skia/PlatformContextSkia.cpp:
+        (WebCore::PlatformContextSkia::save):
+        (WebCore::PlatformContextSkia::beginLayerClippedToImage):
+        (WebCore::PlatformContextSkia::restore):
+        (WebCore::PlatformContextSkia::drawRect):
+        (WebCore::PlatformContextSkia::couldUseLCDRenderedText):
+        * platform/graphics/skia/PlatformContextSkia.h:
+        (PlatformContextSkia):
+        (WebCore::PlatformContextSkia::layerBitmap):
+        (WebCore):
+        (WebCore::PlatformContextSkia::readPixels):
+        (WebCore::PlatformContextSkia::writePixels):
+        (WebCore::PlatformContextSkia::isDrawingToLayer):
+        (WebCore::PlatformContextSkia::isVector):
+        (WebCore::PlatformContextSkia::clipPath):
+        (WebCore::PlatformContextSkia::clipRect):
+        (WebCore::PlatformContextSkia::getClipBounds):
+        (WebCore::PlatformContextSkia::setMatrix):
+        (WebCore::PlatformContextSkia::getTotalMatrix):
+        (WebCore::PlatformContextSkia::concat):
+        (WebCore::PlatformContextSkia::rotate):
+        (WebCore::PlatformContextSkia::scale):
+        (WebCore::PlatformContextSkia::translate):
+        (WebCore::PlatformContextSkia::drawBitmap):
+        (WebCore::PlatformContextSkia::drawBitmapRect):
+        (WebCore::PlatformContextSkia::drawOval):
+        (WebCore::PlatformContextSkia::drawPath):
+        (WebCore::PlatformContextSkia::drawPoints):
+        (WebCore::PlatformContextSkia::drawRect):
+        (WebCore::PlatformContextSkia::drawIRect):
+        (WebCore::PlatformContextSkia::drawPosText):
+        (WebCore::PlatformContextSkia::drawPosTextH):
+        (WebCore::PlatformContextSkia::drawTextOnPath):
+        * platform/graphics/skia/SkiaFontWin.cpp:
+        (WebCore::skiaDrawText):
+        (WebCore::paintSkiaText):
+        * platform/graphics/skia/SkiaUtils.cpp:
+        (WebCore::ClipRectToCanvas):
+        * platform/graphics/skia/SkiaUtils.h:
+        (WebCore):
+
 2012-11-21  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Reset the slider thumb location before every layout of the slider container
index be4f850..70cc64b 100644 (file)
@@ -99,7 +99,7 @@ SkColor PlatformThemeChromiumLinux::outlineColor(const SkScalar hsv1[3], const S
 
 void PlatformThemeChromiumLinux::paintArrowButton(GraphicsContext* gc, const IntRect& rect, ArrowDirection direction, ControlStates states)
 {
-    SkCanvas* const canvas = gc->platformContext()->canvas();
+    PlatformContextSkia* platformContext = gc->platformContext();
     int widthMiddle, lengthMiddle;
     SkPaint paint;
     if (direction == North || direction == South) {
@@ -129,7 +129,7 @@ void PlatformThemeChromiumLinux::paintArrowButton(GraphicsContext* gc, const Int
     skrect.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
     // Paint the background (the area visible behind the rounded corners).
     paint.setColor(backgroundColor);
-    canvas->drawIRect(skrect, paint);
+    platformContext->drawIRect(skrect, paint);
 
     // Paint the button's outline and fill the middle
     SkPath outline;
@@ -171,14 +171,14 @@ void PlatformThemeChromiumLinux::paintArrowButton(GraphicsContext* gc, const Int
 
     paint.setStyle(SkPaint::kFill_Style);
     paint.setColor(buttonColor);
-    canvas->drawPath(outline, paint);
+    platformContext->drawPath(outline, paint);
 
     paint.setAntiAlias(true);
     paint.setStyle(SkPaint::kStroke_Style);
     SkScalar thumbHSV[3];
     SkColorToHSV(thumbInactiveColor(), thumbHSV);
     paint.setColor(outlineColor(trackHSV, thumbHSV));
-    canvas->drawPath(outline, paint);
+    platformContext->drawPath(outline, paint);
 
     // If the button is disabled or read-only, the arrow is drawn with the outline color.
     if (states & EnabledState && !(states & ReadOnlyState))
@@ -214,7 +214,7 @@ void PlatformThemeChromiumLinux::paintArrowButton(GraphicsContext* gc, const Int
     }
     path.close();
 
-    canvas->drawPath(path, paint);
+    platformContext->drawPath(path, paint);
 }
 
 } // namespace WebCore
index afd08db..2efc2a4 100644 (file)
@@ -140,7 +140,7 @@ void TransparencyAwareFontPainter::initializeForGDI()
         // this mode and it will apply the color.
         m_transparency.setTextCompositeColor(color);
         color = SkColorSetRGB(0, 0, 0);
-    } else if (m_createdTransparencyLayer || m_platformContext->canvas()->isDrawingToLayer()) {
+    } else if (m_createdTransparencyLayer || m_platformContext->isDrawingToLayer()) {
         // When we're drawing a web page, we know the background is opaque,
         // but if we're drawing to a layer, we still need extra work.
         layerMode = TransparencyWin::OpaqueCompositeLayer;
index 28b1b8e..88c153e 100644 (file)
@@ -49,14 +49,9 @@ namespace {
 // into. Buffers larger than this will be destroyed when we're done with them.
 const int maxCachedBufferPixelSize = 65536;
 
-inline SkCanvas* canvasForContext(const GraphicsContext& context)
-{
-    return context.platformContext()->canvas();
-}
-
 inline const SkBitmap& bitmapForContext(const GraphicsContext& context)
 {
-    return canvasForContext(context)->getTopDevice()->accessBitmap(false);
+    return context.platformContext()->layerBitmap();
 }
 
 void compositeToCopy(const GraphicsContext& sourceLayers,
@@ -76,7 +71,7 @@ void compositeToCopy(const GraphicsContext& sourceLayers,
         int y;
     };
     Vector<DeviceInfo> devices;
-    SkCanvas* sourceCanvas = canvasForContext(sourceLayers);
+    SkCanvas* sourceCanvas = sourceLayers.platformContext()->canvas();
     SkCanvas::LayerIter iter(sourceCanvas, false);
     while (!iter.done()) {
         devices.append(DeviceInfo(iter.device(), iter.x(), iter.y()));
@@ -214,7 +209,7 @@ void TransparencyWin::computeLayerSize()
         // FIXME: support clipping for other modes
         IntRect clippedSourceRect = m_sourceRect;
         SkRect clipBounds;
-        if (m_destContext->platformContext()->canvas()->getClipBounds(&clipBounds)) {
+        if (m_destContext->platformContext()->getClipBounds(&clipBounds)) {
             FloatRect clipRect(clipBounds.left(), clipBounds.top(), clipBounds.width(), clipBounds.height());
             clippedSourceRect.intersect(enclosingIntRect(clipRect));
         }
@@ -416,8 +411,8 @@ void TransparencyWin::compositeOpaqueComposite()
     if (!m_validLayer)
         return;
 
-    SkCanvas* destCanvas = canvasForContext(*m_destContext);
-    destCanvas->save();
+    PlatformContextSkia* destPlatformContext = m_destContext->platformContext();
+    destPlatformContext->save();
 
     SkBitmap* bitmap = const_cast<SkBitmap*>(
         &bitmapForContext(*m_layerBuffer->context()));
@@ -452,7 +447,7 @@ void TransparencyWin::compositeOpaqueComposite()
         // just draw the image from inside the destination context.
         SkMatrix identity;
         identity.reset();
-        destCanvas->setMatrix(identity);
+        destPlatformContext->setMatrix(identity);
 
         destRect.set(m_transformedSourceRect.x(), m_transformedSourceRect.y(), m_transformedSourceRect.maxX(), m_transformedSourceRect.maxY());
     } else
@@ -465,8 +460,8 @@ void TransparencyWin::compositeOpaqueComposite()
     // Note that we need to specify the source layer subset, since the bitmap
     // may have been cached and it could be larger than what we're using.
     SkIRect sourceRect = { 0, 0, m_layerSize.width(), m_layerSize.height() };
-    destCanvas->drawBitmapRect(*bitmap, &sourceRect, destRect, &paint);
-    destCanvas->restore();
+    destPlatformContext->drawBitmapRect(*bitmap, &sourceRect, destRect, &paint);
+    destPlatformContext->restore();
 }
 
 void TransparencyWin::compositeTextComposite()
@@ -474,7 +469,7 @@ void TransparencyWin::compositeTextComposite()
     if (!m_validLayer)
         return;
 
-    const SkBitmap& bitmap = m_layerBuffer->context()->platformContext()->canvas()->getTopDevice()->accessBitmap(true);
+    const SkBitmap& bitmap = m_layerBuffer->context()->platformContext()->layerBitmap(PlatformContextSkia::ReadWrite);
     SkColor textColor = m_textCompositeColor.rgb();
     for (int y = 0; y < m_layerSize.height(); y++) {
         uint32_t* row = bitmap.getAddr32(0, y);
@@ -488,20 +483,20 @@ void TransparencyWin::compositeTextComposite()
     }
 
     // Now the layer has text with the proper color and opacity.
-    SkCanvas* destCanvas = canvasForContext(*m_destContext);
-    destCanvas->save();
+    PlatformContextSkia* destPlatformContext = m_destContext->platformContext();
+    destPlatformContext->save();
 
     // We want to use Untransformed space (see above)
     SkMatrix identity;
     identity.reset();
-    destCanvas->setMatrix(identity);
+    destPlatformContext->setMatrix(identity);
     SkRect destRect = { m_transformedSourceRect.x(), m_transformedSourceRect.y(), m_transformedSourceRect.maxX(), m_transformedSourceRect.maxY() };
 
     // Note that we need to specify the source layer subset, since the bitmap
     // may have been cached and it could be larger than what we're using.
     SkIRect sourceRect = { 0, 0, m_layerSize.width(), m_layerSize.height() };
-    destCanvas->drawBitmapRect(bitmap, &sourceRect, destRect, 0);
-    destCanvas->restore();
+    destPlatformContext->drawBitmapRect(bitmap, &sourceRect, destRect, 0);
+    destPlatformContext->restore();
 }
 
 void TransparencyWin::makeLayerOpaque()
@@ -509,8 +504,7 @@ void TransparencyWin::makeLayerOpaque()
     if (!m_validLayer)
         return;
 
-    SkBitmap& bitmap = const_cast<SkBitmap&>(m_drawContext->platformContext()->
-        canvas()->getTopDevice()->accessBitmap(true));
+    SkBitmap& bitmap = const_cast<SkBitmap&>(m_drawContext->platformContext()->layerBitmap(PlatformContextSkia::ReadWrite));
     for (int y = 0; y < m_layerSize.height(); y++) {
         uint32_t* row = bitmap.getAddr32(0, y);
         for (int x = 0; x < m_layerSize.width(); x++)
index 8089f3b..b597ba2 100644 (file)
@@ -80,8 +80,7 @@ bool FEBlend::platformApplySkia()
     SkAutoTUnref<SkImageFilter> blend(new SkBlendImageFilter(mode, backgroundSource));
     SkPaint paint;
     paint.setImageFilter(blend);
-    SkCanvas* canvas = resultImage->context()->platformContext()->canvas();
-    canvas->drawBitmap(foregroundBitmap, 0, 0, &paint);
+    resultImage->context()->platformContext()->drawBitmap(foregroundBitmap, 0, 0, &paint);
     return true;
 }
 
index affbaea..3228cd8 100644 (file)
@@ -127,11 +127,10 @@ bool FEColorMatrix::platformApplySkia()
     if (!nativeImage)
         return false;
 
-    SkCanvas* canvas = resultImage->context()->platformContext()->canvas();
     SkPaint paint;
     paint.setColorFilter(filter);
     paint.setXfermodeMode(SkXfermode::kSrc_Mode);
-    canvas->drawBitmap(nativeImage->bitmap(), 0, 0, &paint);
+    resultImage->context()->platformContext()->drawBitmap(nativeImage->bitmap(), 0, 0, &paint);
     return true;
 }
 
index 86d5d7e..6b5fb69 100644 (file)
@@ -48,11 +48,10 @@ bool FEComponentTransfer::platformApplySkia()
     unsigned char rValues[256], gValues[256], bValues[256], aValues[256];
     getValues(rValues, gValues, bValues, aValues);
 
-    SkCanvas* canvas = resultImage->context()->platformContext()->canvas();
     SkPaint paint;
     paint.setColorFilter(SkTableColorFilter::CreateARGB(aValues, rValues, gValues, bValues))->unref();
     paint.setXfermodeMode(SkXfermode::kSrc_Mode);
-    canvas->drawBitmap(bitmap, 0, 0, &paint);
+    resultImage->context()->platformContext()->drawBitmap(bitmap, 0, 0, &paint);
 
     return true;
 }
index 167234d..5f33727 100644 (file)
@@ -103,7 +103,7 @@ bool FELighting::platformApplySkia()
 
     SkPaint paint;
     paint.setImageFilter(createImageFilter(0))->unref();
-    dstContext->platformContext()->canvas()->drawBitmap(nativeImage->bitmap(), drawingRegion.location().x(), drawingRegion.location().y(), &paint);
+    dstContext->platformContext()->drawBitmap(nativeImage->bitmap(), drawingRegion.location().x(), drawingRegion.location().y(), &paint);
     return true;
 }
 
index 97add62..5c79004 100644 (file)
@@ -98,7 +98,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
         y += SkFloatToScalar(adv[i].height());
     }
 
-    SkCanvas* canvas = gc->platformContext()->canvas();
+    PlatformContextSkia* platformContext = gc->platformContext();
     TextDrawingModeFlags textMode = gc->platformContext()->getTextDrawingMode();
 
     // We draw text up to two times (once for fill, once for stroke).
@@ -115,10 +115,10 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
                 path.reset();
                 path.moveTo(vPosBegin[i]);
                 path.lineTo(vPosEnd[i]);
-                canvas->drawTextOnPath(glyphs + i, 2, path, 0, paint);
+                platformContext->drawTextOnPath(glyphs + i, 2, path, 0, paint);
             }
         } else
-            canvas->drawPosText(glyphs, numGlyphs << 1, pos, paint);
+            platformContext->drawPosText(glyphs, numGlyphs << 1, pos, paint);
     }
 
     if ((textMode & TextModeStroke)
@@ -144,10 +144,10 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
                 path.reset();
                 path.moveTo(vPosBegin[i]);
                 path.lineTo(vPosEnd[i]);
-                canvas->drawTextOnPath(glyphs + i, 2, path, 0, paint);
+                platformContext->drawTextOnPath(glyphs + i, 2, path, 0, paint);
             }
         } else
-            canvas->drawPosText(glyphs, numGlyphs << 1, pos, paint);
+            platformContext->drawPosText(glyphs, numGlyphs << 1, pos, paint);
     }
 }
 
@@ -191,7 +191,7 @@ void Font::drawComplexText(GraphicsContext* gc, const TextRun& run,
     FloatPoint adjustedPoint = shaper.adjustStartPoint(point);
     drawGlyphBuffer(gc, run, glyphBuffer, adjustedPoint);
 #else
-    SkCanvas* canvas = gc->platformContext()->canvas();
+    PlatformContextSkia* platformContext = gc->platformContext();
     ComplexTextController controller(this, run, point.x(), point.y());
     if (run.rtl())
         controller.setupForRTL();
@@ -206,13 +206,13 @@ void Font::drawComplexText(GraphicsContext* gc, const TextRun& run,
         if (fill) {
             controller.fontPlatformDataForScriptRun()->setupPaint(&fillPaint);
             gc->platformContext()->adjustTextRenderMode(&fillPaint);
-            canvas->drawPosText(controller.glyphs() + fromGlyph, glyphLength << 1, controller.positions() + fromGlyph, fillPaint);
+            platformContext->drawPosText(controller.glyphs() + fromGlyph, glyphLength << 1, controller.positions() + fromGlyph, fillPaint);
         }
 
         if (stroke) {
             controller.fontPlatformDataForScriptRun()->setupPaint(&strokePaint);
             gc->platformContext()->adjustTextRenderMode(&strokePaint);
-            canvas->drawPosText(controller.glyphs() + fromGlyph, glyphLength << 1, controller.positions() + fromGlyph, strokePaint);
+            platformContext->drawPosText(controller.glyphs() + fromGlyph, glyphLength << 1, controller.positions() + fromGlyph, strokePaint);
         }
     }
 #endif
index c8097e3..655a74b 100644 (file)
@@ -135,10 +135,10 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
         y += SkFloatToScalar(adv[i].height());
     }
 
-    SkCanvas* canvas = gc->platformContext()->canvas();
+    PlatformContextSkia* platformContext = gc->platformContext();
     if (font->platformData().orientation() == Vertical) {
-        canvas->save();
-        canvas->rotate(-90);
+        platformContext->save();
+        platformContext->rotate(-90);
         SkMatrix rotator;
         rotator.reset();
         rotator.setRotate(90);
@@ -154,7 +154,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
         gc->platformContext()->adjustTextRenderMode(&paint);
         paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
 
-        canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
+        platformContext->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
     }
 
     if ((textMode & TextModeStroke)
@@ -173,10 +173,10 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
             paint.setLooper(0);
         }
 
-        canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
+        platformContext->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
     }
     if (font->platformData().orientation() == Vertical)
-        canvas->restore();
+        platformContext->restore();
 }
 
 } // namespace WebCore
index fc97146..3cf431b 100644 (file)
@@ -291,7 +291,7 @@ void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness
         r.inset(SkIntToScalar(thickness + 1), SkIntToScalar(thickness + 1));
         path.addOval(r, SkPath::kCCW_Direction);
     }
-    platformContext()->clipPathAntiAliased(path);
+    platformContext()->clipPath(path, PlatformContextSkia::AntiAliased);
 }
 
 void GraphicsContext::clearPlatformShadow()
@@ -310,8 +310,7 @@ void GraphicsContext::clearRect(const FloatRect& rect)
     SkPaint paint;
     platformContext()->setupPaintForFilling(&paint);
     paint.setXfermodeMode(SkXfermode::kClear_Mode);
-    platformContext()->canvas()->drawRect(r, paint);
-    platformContext()->didDrawRect(r, paint);
+    platformContext()->drawRect(r, paint);
 }
 
 void GraphicsContext::clip(const FloatRect& rect)
@@ -319,7 +318,7 @@ void GraphicsContext::clip(const FloatRect& rect)
     if (paintingDisabled())
         return;
 
-    platformContext()->canvas()->clipRect(rect);
+    platformContext()->clipRect(rect);
 }
 
 void GraphicsContext::clip(const Path& path)
@@ -327,7 +326,7 @@ void GraphicsContext::clip(const Path& path)
     if (paintingDisabled() || path.isEmpty())
         return;
 
-    platformContext()->clipPathAntiAliased(*path.platformPath());
+    platformContext()->clipPath(*path.platformPath(), PlatformContextSkia::AntiAliased);
 }
 
 void GraphicsContext::canvasClip(const Path& path)
@@ -343,7 +342,7 @@ void GraphicsContext::clipOut(const IntRect& rect)
     if (paintingDisabled())
         return;
 
-    platformContext()->canvas()->clipRect(rect, SkRegion::kDifference_Op);
+    platformContext()->clipRect(rect, PlatformContextSkia::NotAntiAliased, SkRegion::kDifference_Op);
 }
 
 void GraphicsContext::clipOut(const Path& p)
@@ -354,7 +353,7 @@ void GraphicsContext::clipOut(const Path& p)
     // We must make a copy of the path, to mark it as inverse-filled.
     SkPath path(p.isNull() ? SkPath() : *p.platformPath());
     path.toggleInverseFillType();
-    platformContext()->clipPathAntiAliased(path);
+    platformContext()->clipPath(path, PlatformContextSkia::AntiAliased);
 }
 
 void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule)
@@ -372,7 +371,7 @@ void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule)
         storage.setFillType(ftype);
         path = &storage;
     }
-    platformContext()->clipPathAntiAliased(*path);
+    platformContext()->clipPath(*path, PlatformContextSkia::AntiAliased);
 }
 
 void GraphicsContext::concatCTM(const AffineTransform& affine)
@@ -380,7 +379,7 @@ void GraphicsContext::concatCTM(const AffineTransform& affine)
     if (paintingDisabled())
         return;
 
-    platformContext()->canvas()->concat(affine);
+    platformContext()->concat(affine);
 }
 
 void GraphicsContext::setCTM(const AffineTransform& affine)
@@ -388,7 +387,7 @@ void GraphicsContext::setCTM(const AffineTransform& affine)
     if (paintingDisabled())
         return;
 
-    platformContext()->canvas()->setMatrix(affine);
+    platformContext()->setMatrix(affine);
 }
 
 static void setPathFromConvexPoints(SkPath* path, size_t numPoints, const FloatPoint* points)
@@ -429,14 +428,12 @@ void GraphicsContext::drawConvexPolygon(size_t numPoints,
     SkPaint paint;
     platformContext()->setupPaintForFilling(&paint);
     paint.setAntiAlias(shouldAntialias);
-    platformContext()->canvas()->drawPath(path, paint);
-    platformContext()->didDrawPath(path, paint);
+    platformContext()->drawPath(path, paint);
 
     if (strokeStyle() != NoStroke) {
         paint.reset();
         platformContext()->setupPaintForStroking(&paint, 0, 0);
-        platformContext()->canvas()->drawPath(path, paint);
-        platformContext()->didDrawPath(path, paint);
+        platformContext()->drawPath(path, paint);
     }
 }
 
@@ -450,10 +447,9 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin
 
     SkPath path;
     setPathFromConvexPoints(&path, numPoints, points);
-    if (antialiased)
-        platformContext()->clipPathAntiAliased(path);
-    else
-        platformContext()->canvas()->clipPath(path);
+    platformContext()->clipPath(path, antialiased
+        ? PlatformContextSkia::AntiAliased
+        : PlatformContextSkia::NotAntiAliased);
 }
 
 // This method is only used to draw the little circles used in lists.
@@ -465,14 +461,12 @@ void GraphicsContext::drawEllipse(const IntRect& elipseRect)
     SkRect rect = elipseRect;
     SkPaint paint;
     platformContext()->setupPaintForFilling(&paint);
-    platformContext()->canvas()->drawOval(rect, paint);
-    platformContext()->didDrawBounded(rect, paint);
+    platformContext()->drawOval(rect, paint);
 
     if (strokeStyle() != NoStroke) {
         paint.reset();
         platformContext()->setupPaintForStroking(&paint, &rect, 0);
-        platformContext()->canvas()->drawOval(rect, paint);
-        platformContext()->didDrawBounded(rect, paint);
+        platformContext()->drawOval(rect, paint);
     }
 }
 
@@ -491,8 +485,7 @@ static inline void drawOuterPath(PlatformContextSkia* context, const SkPath& pat
     paint.setStrokeWidth(1);
     paint.setPathEffect(new SkCornerPathEffect(1))->unref();
 #endif
-    context->canvas()->drawPath(path, paint);
-    context->didDrawPath(path, paint);
+    context->drawPath(path, paint);
 }
 
 static inline void drawInnerPath(PlatformContextSkia* context, const SkPath& path, SkPaint& paint, int width)
@@ -582,17 +575,14 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
         }
         SkPaint fillPaint;
         fillPaint.setColor(paint.getColor());
-        platformContext()->canvas()->drawRect(r1, fillPaint);
-        platformContext()->canvas()->drawRect(r2, fillPaint);
-        platformContext()->didDrawRect(r1, fillPaint);
-        platformContext()->didDrawRect(r2, fillPaint);
+        platformContext()->drawRect(r1, fillPaint);
+        platformContext()->drawRect(r2, fillPaint);
     }
 
     adjustLineToPixelBoundaries(p1, p2, width, penStyle);
     SkPoint pts[2] = { (SkPoint)p1, (SkPoint)p2 };
 
-    platformContext()->canvas()->drawPoints(SkCanvas::kLines_PointMode, 2, pts, paint);
-    platformContext()->didDrawPoints(SkCanvas::kLines_PointMode, 2, pts, paint);
+    platformContext()->drawPoints(SkCanvas::kLines_PointMode, 2, pts, paint);
 }
 
 void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& pt, float width, DocumentMarkerLineStyle style)
@@ -721,14 +711,12 @@ void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& pt, float widt
     rect.set(originX, originY, originX + WebCoreFloatToSkScalar(width) * deviceScaleFactor, originY + SkIntToScalar(misspellBitmap[index]->height()));
 
     if (deviceScaleFactor == 2) {
-        platformContext()->canvas()->save();
-        platformContext()->canvas()->scale(SK_ScalarHalf, SK_ScalarHalf);
+        platformContext()->save();
+        platformContext()->scale(SK_ScalarHalf, SK_ScalarHalf);
     }
-    platformContext()->canvas()->drawRect(rect, paint);
+    platformContext()->drawRect(rect, paint);
     if (deviceScaleFactor == 2)
-        platformContext()->canvas()->restore();
-
-    platformContext()->didDrawRect(rect, paint);
+        platformContext()->restore();
 }
 
 void GraphicsContext::drawLineForText(const FloatPoint& pt,
@@ -753,8 +741,7 @@ void GraphicsContext::drawLineForText(const FloatPoint& pt,
     platformContext()->setupPaintForFilling(&paint);
     // Text lines are drawn using the stroke color.
     paint.setColor(platformContext()->effectiveStrokeColor());
-    platformContext()->canvas()->drawRect(r, paint);
-    platformContext()->didDrawRect(r, paint);
+    platformContext()->drawRect(r, paint);
 }
 
 // Draws a filled rectangle with a stroked border.
@@ -790,8 +777,7 @@ void GraphicsContext::fillPath(const Path& pathToFill)
     SkPaint paint;
     platformContext()->setupPaintForFilling(&paint);
 
-    platformContext()->canvas()->drawPath(*path, paint);
-    platformContext()->didDrawPath(*path, paint);
+    platformContext()->drawPath(*path, paint);
 }
 
 void GraphicsContext::fillRect(const FloatRect& rect)
@@ -803,8 +789,7 @@ void GraphicsContext::fillRect(const FloatRect& rect)
 
     SkPaint paint;
     platformContext()->setupPaintForFilling(&paint);
-    platformContext()->canvas()->drawRect(r, paint);
-    platformContext()->didDrawRect(r, paint);
+    platformContext()->drawRect(r, paint);
 }
 
 void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
@@ -816,8 +801,7 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS
     SkPaint paint;
     platformContext()->setupPaintCommon(&paint);
     paint.setColor(color.rgb());
-    platformContext()->canvas()->drawRect(r, paint);
-    platformContext()->didDrawRect(r, paint);
+    platformContext()->drawRect(r, paint);
 }
 
 void GraphicsContext::fillRoundedRect(const IntRect& rect,
@@ -852,8 +836,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect,
     SkPaint paint;
     platformContext()->setupPaintForFilling(&paint);
     paint.setColor(color.rgb());
-    platformContext()->canvas()->drawPath(path, paint);
-    platformContext()->didDrawPath(path, paint);
+    platformContext()->drawPath(path, paint);
 }
 
 AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
@@ -861,7 +844,7 @@ AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
     if (paintingDisabled())
         return AffineTransform();
 
-    const SkMatrix& m = platformContext()->canvas()->getTotalMatrix();
+    const SkMatrix& m = platformContext()->getTotalMatrix();
     return AffineTransform(SkScalarToDouble(m.getScaleX()),
                            SkScalarToDouble(m.getSkewY()),
                            SkScalarToDouble(m.getSkewX()),
@@ -880,7 +863,7 @@ void GraphicsContext::scale(const FloatSize& size)
     if (paintingDisabled())
         return;
 
-    platformContext()->canvas()->scale(WebCoreFloatToSkScalar(size.width()),
+    platformContext()->scale(WebCoreFloatToSkScalar(size.width()),
         WebCoreFloatToSkScalar(size.height()));
 }
 
@@ -1140,8 +1123,7 @@ void GraphicsContext::strokeArc(const IntRect& r, int startAngle, int angleSpan)
 
     SkPath path;
     path.addArc(oval, SkIntToScalar(-startAngle), SkIntToScalar(-angleSpan));
-    platformContext()->canvas()->drawPath(path, paint);
-    platformContext()->didDrawPath(path, paint);
+    platformContext()->drawPath(path, paint);
 }
 
 void GraphicsContext::strokePath(const Path& pathToStroke)
@@ -1152,8 +1134,7 @@ void GraphicsContext::strokePath(const Path& pathToStroke)
     const SkPath& path = *pathToStroke.platformPath();
     SkPaint paint;
     platformContext()->setupPaintForStroking(&paint, 0, 0);
-    platformContext()->canvas()->drawPath(path, paint);
-    platformContext()->didDrawPath(path, paint);
+    platformContext()->drawPath(path, paint);
 }
 
 void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
@@ -1170,10 +1151,8 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
     SkRect r(rect);
     bool validW = r.width() > 0;
     bool validH = r.height() > 0;
-    SkCanvas* canvas = platformContext()->canvas();
     if (validW && validH) {
-        canvas->drawRect(r, paint);
-        platformContext()->didDrawRect(r, paint);
+        platformContext()->drawRect(r, paint);
     } else if (validW || validH) {
         // we are expected to respect the lineJoin, so we can't just call
         // drawLine -- we have to create a path that doubles back on itself.
@@ -1181,8 +1160,7 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
         path.moveTo(r.fLeft, r.fTop);
         path.lineTo(r.fRight, r.fBottom);
         path.close();
-        canvas->drawPath(path, paint);
-        platformContext()->didDrawPath(path, paint);
+        platformContext()->drawPath(path, paint);
     }
 }
 
@@ -1191,8 +1169,7 @@ void GraphicsContext::rotate(float angleInRadians)
     if (paintingDisabled())
         return;
 
-    platformContext()->canvas()->rotate(WebCoreFloatToSkScalar(
-        angleInRadians * (180.0f / 3.14159265f)));
+    platformContext()->rotate(WebCoreFloatToSkScalar(angleInRadians * (180.0f / 3.14159265f)));
 }
 
 void GraphicsContext::translate(float w, float h)
@@ -1200,8 +1177,7 @@ void GraphicsContext::translate(float w, float h)
     if (paintingDisabled())
         return;
 
-    platformContext()->canvas()->translate(WebCoreFloatToSkScalar(w),
-                                           WebCoreFloatToSkScalar(h));
+    platformContext()->translate(WebCoreFloatToSkScalar(w), WebCoreFloatToSkScalar(h));
 }
 
 bool GraphicsContext::isAcceleratedContext() const
@@ -1225,8 +1201,7 @@ void GraphicsContext::platformFillEllipse(const FloatRect& ellipse)
     SkRect rect = ellipse;
     SkPaint paint;
     platformContext()->setupPaintForFilling(&paint);
-    platformContext()->canvas()->drawOval(rect, paint);
-    platformContext()->didDrawBounded(rect, paint);
+    platformContext()->drawOval(rect, paint);
 }
 
 void GraphicsContext::platformStrokeEllipse(const FloatRect& ellipse)
@@ -1237,8 +1212,7 @@ void GraphicsContext::platformStrokeEllipse(const FloatRect& ellipse)
     SkRect rect(ellipse);
     SkPaint paint;
     platformContext()->setupPaintForStroking(&paint, 0, 0);
-    platformContext()->canvas()->drawOval(rect, paint);
-    platformContext()->didDrawBounded(rect, paint);
+    platformContext()->drawOval(rect, paint);
 }
 
 }  // namespace WebCore
index 25f343e..17e91db 100644 (file)
@@ -248,7 +248,7 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
 }
 
 template <Multiply multiplied>
-PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, SkCanvas* canvas,
+PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, PlatformContextSkia* context,
                                    const IntSize& size)
 {
     float area = 4.0f * rect.width() * rect.height();
@@ -276,23 +276,22 @@ PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, SkCanvas* canvas
     else
         config8888 = SkCanvas::kRGBA_Unpremul_Config8888;
 
-    canvas->readPixels(&destBitmap, rect.x(), rect.y(), config8888);
+    context->readPixels(&destBitmap, rect.x(), rect.y(), config8888);
     return result.release();
 }
 
 PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const
 {
-    return getImageData<Unmultiplied>(rect, context()->platformContext()->canvas(), m_size);
+    return getImageData<Unmultiplied>(rect, context()->platformContext(), m_size);
 }
 
 PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const
 {
-    return getImageData<Premultiplied>(rect, context()->platformContext()->canvas(), m_size);
+    return getImageData<Premultiplied>(rect, context()->platformContext(), m_size);
 }
 
 void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)
 {
-    SkCanvas* canvas = context()->platformContext()->canvas();
     ASSERT(sourceRect.width() > 0);
     ASSERT(sourceRect.height() > 0);
 
@@ -330,7 +329,7 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
     else
         config8888 = SkCanvas::kRGBA_Unpremul_Config8888;
 
-    canvas->writePixels(srcBitmap, destX, destY, config8888);
+    context()->platformContext()->writePixels(srcBitmap, destX, destY, config8888);
 }
 
 template <typename T>
@@ -366,8 +365,7 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality, Coo
     ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
 
     Vector<char> encodedImage;
-    SkDevice* device = context()->platformContext()->canvas()->getDevice();
-    if (!encodeImage(device->accessBitmap(false), mimeType, quality, &encodedImage))
+    if (!encodeImage(*context()->platformContext()->bitmap(), mimeType, quality, &encodedImage))
         return "data:,";
 
     Vector<char> base64Data;
index 1dbda0f..cccbd90 100644 (file)
@@ -295,7 +295,7 @@ static SkBitmap extractScaledImageFragment(const NativeImageSkia& bitmap, const
 //
 // Note: this code is only used when the canvas transformation is limited to
 // scaling or translation.
-static void drawResampledBitmap(SkCanvas& canvas, SkPaint& paint, const NativeImageSkia& bitmap, const SkRect& srcRect, const SkRect& destRect)
+static void drawResampledBitmap(PlatformContextSkia* context, SkPaint& paint, const NativeImageSkia& bitmap, const SkRect& srcRect, const SkRect& destRect)
 {
 #if PLATFORM(CHROMIUM)
     TRACE_EVENT0("skia", "drawResampledBitmap");
@@ -304,13 +304,13 @@ static void drawResampledBitmap(SkCanvas& canvas, SkPaint& paint, const NativeIm
     // the final scale. The final scale is a combination of scale transform
     // in canvas and explicit scaling (srcRect and destRect).
     SkRect screenRect;
-    canvas.getTotalMatrix().mapRect(&screenRect, destRect);
+    context->getTotalMatrix().mapRect(&screenRect, destRect);
     float realScaleX = screenRect.width() / srcRect.width();
     float realScaleY = screenRect.height() / srcRect.height();
 
     // This part of code limits scaling only to visible portion in the
     SkRect destRectVisibleSubset;
-    ClipRectToCanvas(canvas, destRect, &destRectVisibleSubset);
+    ClipRectToCanvas(context, destRect, &destRectVisibleSubset);
 
     // ClipRectToCanvas often overshoots, resulting in a larger region than our
     // original destRect. Intersecting gets us back inside.
@@ -340,8 +340,8 @@ static void drawResampledBitmap(SkCanvas& canvas, SkPaint& paint, const NativeIm
     // When Skia supports then use this as the source rect to replace 0.
     //
     // scaledSrcRect.offset(-enclosingScaledSrcRect.x(), -enclosingScaledSrcRect.y());
-    canvas.save();
-    canvas.clipRect(destRectVisibleSubset);
+    context->save();
+    context->clipRect(destRectVisibleSubset);
 
     // Because the image fragment is generated with an approxmiated scaling
     // factor. This draw will perform a close to 1 scaling.
@@ -349,13 +349,13 @@ static void drawResampledBitmap(SkCanvas& canvas, SkPaint& paint, const NativeIm
     // NOTE: For future optimization. If the difference in scale is so small
     // that Skia doesn't produce a difference then we can just blit it directly
     // to enhance performance.
-    canvas.drawBitmapRect(scaledImageFragment, 0, enclosingDestRect, &paint);
-    canvas.restore();
+    context->drawBitmapRect(scaledImageFragment, 0, enclosingDestRect, &paint);
+    context->restore();
 }
 
 static bool hasNon90rotation(PlatformContextSkia* context)
 {
-    return !context->canvas()->getTotalMatrix().rectStaysRect();
+    return !context->getTotalMatrix().rectStaysRect();
 }
 
 static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImageSkia& bitmap, const SkRect& srcRect, const SkRect& destRect, const SkXfermode::Mode& compOp)
@@ -370,8 +370,6 @@ static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImag
     // only antialias if we're rotated or skewed
     paint.setAntiAlias(hasNon90rotation(platformContext));
 
-    SkCanvas* canvas = platformContext->canvas();
-
     ResamplingMode resampling;
     if (platformContext->isAccelerated())
         resampling = RESAMPLE_LINEAR;
@@ -380,10 +378,10 @@ static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImag
     else {
         // Take into account scale applied to the canvas when computing sampling mode (e.g. CSS scale or page scale).
         SkRect destRectTarget = destRect;
-        if (!(canvas->getTotalMatrix().getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)))
-            canvas->getTotalMatrix().mapRect(&destRectTarget, destRect);
+        if (!(platformContext->getTotalMatrix().getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)))
+            platformContext->getTotalMatrix().mapRect(&destRectTarget, destRect);
 
-        resampling = computeResamplingMode(canvas->getTotalMatrix(), bitmap,
+        resampling = computeResamplingMode(platformContext->getTotalMatrix(), bitmap,
             SkScalarToFloat(srcRect.width()), SkScalarToFloat(srcRect.height()),
             SkScalarToFloat(destRectTarget.width()), SkScalarToFloat(destRectTarget.height()));
     }
@@ -397,7 +395,7 @@ static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImag
     resampling = limitResamplingMode(platformContext, resampling);
     paint.setFilterBitmap(resampling == RESAMPLE_LINEAR);
     if (resampling == RESAMPLE_AWESOME)
-        drawResampledBitmap(*canvas, paint, bitmap, srcRect, destRect);
+        drawResampledBitmap(platformContext, paint, bitmap, srcRect, destRect);
     else {
         // No resampling necessary, we can just draw the bitmap. We want to
         // filter it if we decided to do linear interpolation above, or if there
@@ -418,10 +416,10 @@ static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImag
         // See http://crbug.com/145540.
         if (needsClipping) {
             platformContext->save();
-            platformContext->canvas()->clipRect(destRect);
+            platformContext->clipRect(destRect);
         }
 
-        canvas->drawBitmapRect(bitmap.bitmap(), &enclosingSrcRect, enclosingDestRect, &paint);
+        platformContext->drawBitmapRect(bitmap.bitmap(), &enclosingSrcRect, enclosingDestRect, &paint);
 
         if (needsClipping)
             platformContext->restore();
@@ -481,7 +479,7 @@ void Image::drawPattern(GraphicsContext* context,
     if (destRect.isEmpty() || normSrcRect.isEmpty())
         return; // nothing to draw
 
-    SkMatrix ctm = context->platformContext()->canvas()->getTotalMatrix();
+    SkMatrix ctm = context->platformContext()->getTotalMatrix();
     SkMatrix totalMatrix;
     totalMatrix.setConcat(ctm, patternTransform);
 
@@ -552,7 +550,7 @@ void Image::drawPattern(GraphicsContext* context,
     paint.setXfermodeMode(WebCoreCompositeToSkiaComposite(compositeOp));
     paint.setFilterBitmap(resampling == RESAMPLE_LINEAR);
 
-    context->platformContext()->paintSkPaint(destRect, paint);
+    context->platformContext()->drawRect(destRect, paint);
 }
 
 // ================================================
index 344bc17..b466469 100644 (file)
@@ -229,7 +229,7 @@ void PlatformContextSkia::save()
     m_state->m_imageBufferClip.reset();
 
     // Save our native canvas.
-    canvas()->save();
+    m_canvas->save();
 }
 
 void PlatformContextSkia::saveLayer(const SkRect* bounds, const SkPaint* paint)
@@ -275,7 +275,7 @@ void PlatformContextSkia::beginLayerClippedToImage(const FloatRect& rect,
     m_state->m_clip = bounds;
     // Get the absolute coordinates of the stored clipping rectangle to make it
     // independent of any transform changes.
-    canvas()->getTotalMatrix().mapRect(&m_state->m_clip);
+    getTotalMatrix().mapRect(&m_state->m_clip);
 
     SkCanvas::SaveFlags saveFlags = static_cast<SkCanvas::SaveFlags>(SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag);
     saveLayer(&bounds, 0, saveFlags);
@@ -297,23 +297,18 @@ void PlatformContextSkia::beginLayerClippedToImage(const FloatRect& rect,
     }
 }
 
-void PlatformContextSkia::clipPathAntiAliased(const SkPath& clipPath)
-{
-    canvas()->clipPath(clipPath, SkRegion::kIntersect_Op, true);
-}
-
 void PlatformContextSkia::restore()
 {
     if (!m_state->m_imageBufferClip.empty()) {
         applyClipFromImage(m_state->m_clip, m_state->m_imageBufferClip);
-        canvas()->restore();
+        m_canvas->restore();
     }
 
     m_stateStack.removeLast();
     m_state = &m_stateStack.last();
 
     // Restore our native canvas.
-    canvas()->restore();
+    m_canvas->restore();
 }
 
 void PlatformContextSkia::drawRect(SkRect rect)
@@ -322,8 +317,7 @@ void PlatformContextSkia::drawRect(SkRect rect)
     int fillcolorNotTransparent = m_state->m_fillColor & 0xFF000000;
     if (fillcolorNotTransparent) {
         setupPaintForFilling(&paint);
-        canvas()->drawRect(rect, paint);
-        didDrawRect(rect, paint);
+        drawRect(rect, paint);
     }
 
     if (m_state->m_strokeStyle != NoStroke
@@ -335,17 +329,13 @@ void PlatformContextSkia::drawRect(SkRect rect)
         paint.setColor(this->effectiveStrokeColor());
 
         SkRect topBorder = { rect.fLeft, rect.fTop, rect.fRight, rect.fTop + 1 };
-        canvas()->drawRect(topBorder, paint);
-        didDrawRect(topBorder, paint);
+        drawRect(topBorder, paint);
         SkRect bottomBorder = { rect.fLeft, rect.fBottom - 1, rect.fRight, rect.fBottom };
-        canvas()->drawRect(bottomBorder, paint);
-        didDrawRect(bottomBorder, paint);
+        drawRect(bottomBorder, paint);
         SkRect leftBorder = { rect.fLeft, rect.fTop + 1, rect.fLeft + 1, rect.fBottom - 1 };
-        canvas()->drawRect(leftBorder, paint);
-        didDrawRect(leftBorder, paint);
+        drawRect(leftBorder, paint);
         SkRect rightBorder = { rect.fRight - 1, rect.fTop + 1, rect.fRight, rect.fBottom - 1 };
-        canvas()->drawRect(rightBorder, paint);
-        didDrawRect(rightBorder, paint);
+        drawRect(rightBorder, paint);
     }
 }
 
@@ -581,13 +571,6 @@ void PlatformContextSkia::setDashPathEffect(SkDashPathEffect* dash)
     }
 }
 
-void PlatformContextSkia::paintSkPaint(const SkRect& rect,
-                                       const SkPaint& paint)
-{
-    m_canvas->drawRect(rect, paint);
-    didDrawRect(rect, paint);
-}
-
 const SkBitmap* PlatformContextSkia::bitmap() const
 {
 #if PLATFORM(CHROMIUM)
@@ -625,24 +608,6 @@ void PlatformContextSkia::didDrawRect(const SkRect& rect, const SkPaint& paint,
         m_opaqueRegion.didDrawRect(this, rect, paint, bitmap);
 }
 
-void PlatformContextSkia::didDrawPath(const SkPath& path, const SkPaint& paint)
-{
-    if (m_trackOpaqueRegion)
-        m_opaqueRegion.didDrawPath(this, path, paint);
-}
-
-void PlatformContextSkia::didDrawPoints(SkCanvas::PointMode mode, int numPoints, const SkPoint points[], const SkPaint& paint)
-{
-    if (m_trackOpaqueRegion)
-        m_opaqueRegion.didDrawPoints(this, mode, numPoints, points, paint);
-}
-
-void PlatformContextSkia::didDrawBounded(const SkRect& rect, const SkPaint& paint)
-{
-    if (m_trackOpaqueRegion)
-        m_opaqueRegion.didDrawBounded(this, rect, paint);
-}
-
 void PlatformContextSkia::adjustTextRenderMode(SkPaint* paint)
 {
     if (!paint->isLCDRenderText())
@@ -657,7 +622,7 @@ bool PlatformContextSkia::couldUseLCDRenderedText()
     // rendered text cannot be composited correctly when the layer is
     // collapsed. Therefore, subpixel text is disabled when we are drawing
     // onto a layer.
-    if (canvas()->isDrawingToLayer())
+    if (isDrawingToLayer())
         return false;
 
     // If this text is not in an image buffer and so won't be externally
index 2369f32..494a138 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "SkCanvas.h"
 #include "SkDashPathEffect.h"
+#include "SkDevice.h"
 #include "SkDrawLooper.h"
 #include "SkPaint.h"
 #include "SkPath.h"
@@ -101,7 +102,6 @@ public:
     // invoked.
     // NOTE: |imageBuffer| may be deleted before the |restore| is invoked.
     void beginLayerClippedToImage(const FloatRect&, const ImageBuffer*);
-    void clipPathAntiAliased(const SkPath&);
 
     // Sets up the common flags on a paint for antialiasing, effects, etc.
     // This is implicitly called by setupPaintFill and setupPaintStroke, but
@@ -161,11 +161,6 @@ public:
     // FIXME: This should be pushed down to GraphicsContext.
     void drawRect(SkRect rect);
 
-    // FIXME: I'm still unsure how I will serialize this call.
-    void paintSkPaint(const SkRect&, const SkPaint&);
-
-    const SkBitmap* bitmap() const;
-
     // Returns if the context is a printing context instead of a display
     // context. Bitmap shouldn't be resampled when printing to keep the best
     // possible quality.
@@ -195,17 +190,61 @@ public:
     // This will be an empty region unless tracking is enabled.
     const OpaqueRegionSkia& opaqueRegion() const { return m_opaqueRegion; }
 
-    // After drawing in the context's canvas, use these functions to notify the context so it can track the opaque region.
+    // After drawing directly to the context's canvas, use this function to notify the context so
+    // it can track the opaque region.
+    // FIXME: this is still needed only because ImageSkia::paintSkBitmap() may need to notify for a
+    //        smaller rect than the one drawn to, due to its clipping logic.
     void didDrawRect(const SkRect&, const SkPaint&, const SkBitmap* = 0);
-    void didDrawPath(const SkPath&, const SkPaint&);
-    void didDrawPoints(SkCanvas::PointMode, int numPoints, const SkPoint[], const SkPaint&);
-    // For drawing operations that do not fill the entire rect.
-    void didDrawBounded(const SkRect&, const SkPaint&);
 
     // Turn off LCD text for the paint if not supported on this context.
     void adjustTextRenderMode(SkPaint*);
     bool couldUseLCDRenderedText();
 
+    enum AntiAliasingMode {
+        NotAntiAliased,
+        AntiAliased
+    };
+    enum AccessMode {
+        ReadOnly,
+        ReadWrite
+    };
+
+    // SkCanvas wrappers.
+    const SkBitmap* bitmap() const;
+    const SkBitmap& layerBitmap(AccessMode = ReadOnly) const;
+    bool readPixels(SkBitmap*, int x, int y,
+        SkCanvas::Config8888 = SkCanvas::kNative_Premul_Config8888);
+    void writePixels(const SkBitmap&, int x, int y,
+        SkCanvas::Config8888 = SkCanvas::kNative_Premul_Config8888);
+    bool isDrawingToLayer() const;
+    bool isVector() const;
+
+    bool clipPath(const SkPath&, AntiAliasingMode = NotAntiAliased,
+        SkRegion::Op = SkRegion::kIntersect_Op);
+    bool clipRect(const SkRect&, AntiAliasingMode = NotAntiAliased,
+        SkRegion::Op = SkRegion::kIntersect_Op);
+    bool getClipBounds(SkRect*) const;
+
+    void setMatrix(const SkMatrix&);
+    const SkMatrix& getTotalMatrix() const;
+    bool concat(const SkMatrix&);
+    bool rotate(SkScalar degrees);
+    bool scale(SkScalar sx, SkScalar sy);
+    bool translate(SkScalar dx, SkScalar dy);
+
+    void drawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint* = 0);
+    void drawBitmapRect(const SkBitmap&, const SkIRect*, const SkRect&, const SkPaint* = 0);
+    void drawOval(const SkRect&, const SkPaint&);
+    void drawPath(const SkPath&, const SkPaint&);
+    void drawPoints(SkCanvas::PointMode, size_t count, const SkPoint pts[], const SkPaint&);
+    void drawRect(const SkRect&, const SkPaint&);
+    void drawIRect(const SkIRect&, const SkPaint&);
+    void drawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint&);
+    void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY,
+        const SkPaint&);
+    void drawTextOnPath(const void* text, size_t byteLength, const SkPath&,
+        const SkMatrix*, const SkPaint&);
+
 #if defined(SK_SUPPORT_HINTING_SCALE_FACTOR)
     void setHintingScaleFactor(SkScalar factor) { m_hintingScaleFactor = factor; }
     SkScalar hintingScaleFactor() const { return m_hintingScaleFactor; }
@@ -248,5 +287,145 @@ private:
 #endif
 };
 
+inline const SkBitmap& PlatformContextSkia::layerBitmap(AccessMode access) const
+{
+    return m_canvas->getTopDevice()->accessBitmap(access == ReadWrite);
+}
+
+inline bool PlatformContextSkia::readPixels(SkBitmap* bitmap, int x, int y,
+    SkCanvas::Config8888 config8888)
+{
+    return m_canvas->readPixels(bitmap, x, y, config8888);
+}
+
+inline void PlatformContextSkia::writePixels(const SkBitmap& bitmap, int x, int y,
+    SkCanvas::Config8888 config8888)
+{
+    m_canvas->writePixels(bitmap, x, y, config8888);
+}
+
+inline bool PlatformContextSkia::isDrawingToLayer() const
+{
+    return m_canvas->isDrawingToLayer();
+}
+
+inline bool PlatformContextSkia::isVector() const
+{
+    return m_canvas->getTopDevice()->getDeviceCapabilities() & SkDevice::kVector_Capability;
+}
+
+inline bool PlatformContextSkia::clipPath(const SkPath& path, AntiAliasingMode aa, SkRegion::Op op)
+{
+    return m_canvas->clipPath(path, op, aa == AntiAliased);
+}
+
+inline bool PlatformContextSkia::clipRect(const SkRect& rect, AntiAliasingMode aa, SkRegion::Op op)
+{
+    return m_canvas->clipRect(rect, op, aa == AntiAliased);
+}
+
+inline bool PlatformContextSkia::getClipBounds(SkRect* bounds) const
+{
+    return m_canvas->getClipBounds(bounds);
+}
+
+inline void PlatformContextSkia::setMatrix(const SkMatrix& matrix)
+{
+    m_canvas->setMatrix(matrix);
+}
+
+inline const SkMatrix& PlatformContextSkia::getTotalMatrix() const
+{
+    return m_canvas->getTotalMatrix();
+}
+
+inline bool PlatformContextSkia::concat(const SkMatrix& matrix)
+{
+    return m_canvas->concat(matrix);
+}
+
+inline bool PlatformContextSkia::rotate(SkScalar degrees)
+{
+    return m_canvas->rotate(degrees);
+}
+
+inline bool PlatformContextSkia::scale(SkScalar sx, SkScalar sy)
+{
+    return m_canvas->scale(sx, sy);
+}
+
+inline bool PlatformContextSkia::translate(SkScalar dx, SkScalar dy)
+{
+    return m_canvas->translate(dx, dy);
+}
+
+inline void PlatformContextSkia::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
+    const SkPaint* paint)
+{
+    m_canvas->drawBitmap(bitmap, left, top, paint);
+}
+
+inline void PlatformContextSkia::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc,
+    const SkRect& dst, const SkPaint* paint)
+{
+    m_canvas->drawBitmapRect(bitmap, isrc, dst, paint);
+}
+
+inline void PlatformContextSkia::drawOval(const SkRect& oval, const SkPaint& paint)
+{
+    m_canvas->drawOval(oval, paint);
+
+    if (m_trackOpaqueRegion)
+        m_opaqueRegion.didDrawBounded(this, oval, paint);
+}
+
+inline void PlatformContextSkia::drawPath(const SkPath& path, const SkPaint& paint)
+{
+    m_canvas->drawPath(path, paint);
+
+    if (m_trackOpaqueRegion)
+        m_opaqueRegion.didDrawPath(this, path, paint);
+}
+
+inline void PlatformContextSkia::drawPoints(SkCanvas::PointMode mode, size_t count,
+    const SkPoint pts[], const SkPaint& paint)
+{
+    m_canvas->drawPoints(mode, count, pts, paint);
+
+    if (m_trackOpaqueRegion)
+        m_opaqueRegion.didDrawPoints(this, mode, count, pts, paint);
+}
+
+inline void PlatformContextSkia::drawRect(const SkRect& rect, const SkPaint& paint)
+{
+    m_canvas->drawRect(rect, paint);
+
+    if (m_trackOpaqueRegion)
+        m_opaqueRegion.didDrawRect(this, rect, paint, 0);
+}
+
+inline void PlatformContextSkia::drawIRect(const SkIRect& rect, const SkPaint& paint)
+{
+    m_canvas->drawIRect(rect, paint);
+}
+
+inline void PlatformContextSkia::drawPosText(const void* text, size_t byteLength,
+    const SkPoint pos[], const SkPaint& paint)
+{
+    m_canvas->drawPosText(text, byteLength, pos, paint);
+}
+
+inline void PlatformContextSkia::drawPosTextH(const void* text, size_t byteLength,
+    const SkScalar xpos[], SkScalar constY, const SkPaint& paint)
+{
+    m_canvas->drawPosTextH(text, byteLength, xpos, constY, paint);
+}
+
+inline void PlatformContextSkia::drawTextOnPath(const void* text, size_t byteLength,
+    const SkPath& path, const SkMatrix* matrix, const SkPaint& paint)
+{
+    m_canvas->drawTextOnPath(text, byteLength, path, matrix, paint);
+}
+
 }
 #endif // PlatformContextSkia_h
index a6f37cf..b8a0550 100644 (file)
@@ -99,7 +99,7 @@ bool windowsCanHandleTextDrawingWithoutShadow(GraphicsContext* context)
 }
 #endif
 
-static void skiaDrawText(SkCanvas* canvas,
+static void skiaDrawText(PlatformContextSkia* context,
                          const SkPoint& point,
                          SkPaint* paint,
                          const WORD* glyphs,
@@ -124,7 +124,7 @@ static void skiaDrawText(SkCanvas* canvas,
                        y + -SkIntToScalar(offsets[i].dv));
             x += SkIntToScalar(advances[i]);
         }
-        canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, *paint);
+        context->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, *paint);
     } else {
         SkAutoSTArray<kLocalGlyphMax * 2, SkScalar> storage(numGlyphs);
         SkScalar* xpos = storage.get();
@@ -132,7 +132,7 @@ static void skiaDrawText(SkCanvas* canvas,
             xpos[i] = x;
             x += SkIntToScalar(advances[i]);
         }
-        canvas->drawPosTextH(glyphs, numGlyphs * sizeof(uint16_t),
+        context->drawPosTextH(glyphs, numGlyphs * sizeof(uint16_t),
                              xpos, y, *paint);
     }
 }
@@ -218,10 +218,9 @@ static void paintSkiaText(GraphicsContext* context, HFONT hfont,
                           const SkPoint* origin)
 {
     PlatformContextSkia* platformContext = context->platformContext();
-    SkCanvas* canvas = platformContext->canvas();
     TextDrawingModeFlags textMode = platformContext->getTextDrawingMode();
     // Ensure font load for printing, because PDF device needs it.
-    if (canvas->getTopDevice()->getDeviceCapabilities() & SkDevice::kVector_Capability)
+    if (platformContext->isVector())
         PlatformSupport::ensureFontLoaded(hfont);
 
     // Filling (if necessary). This is the common case.
@@ -233,7 +232,7 @@ static void paintSkiaText(GraphicsContext* context, HFONT hfont,
     bool didFill = false;
 
     if ((textMode & TextModeFill) && (SkColorGetA(paint.getColor()) || paint.getLooper())) {
-        skiaDrawText(canvas, *origin, &paint, &glyphs[0], &advances[0], &offsets[0], numGlyphs);
+        skiaDrawText(platformContext, *origin, &paint, &glyphs[0], &advances[0], &offsets[0], numGlyphs);
         didFill = true;
     }
 
@@ -260,7 +259,7 @@ static void paintSkiaText(GraphicsContext* context, HFONT hfont,
             paint.setLooper(0);
         }
 
-        skiaDrawText(canvas, *origin, &paint, &glyphs[0], &advances[0], &offsets[0], numGlyphs);
+        skiaDrawText(platformContext, *origin, &paint, &glyphs[0], &advances[0], &offsets[0], numGlyphs);
     }
 }
 
index 1e2c8da..c841994 100644 (file)
@@ -106,9 +106,9 @@ Color SkPMColorToWebCoreColor(SkPMColor pm)
     return SkPMColorToColor(pm);
 }
 
-void ClipRectToCanvas(const SkCanvas& canvas, const SkRect& srcRect, SkRect* destRect)
+void ClipRectToCanvas(const PlatformContextSkia* context, const SkRect& srcRect, SkRect* destRect)
 {
-    if (!canvas.getClipBounds(destRect) || !destRect->intersect(srcRect))
+    if (!context->getClipBounds(destRect) || !destRect->intersect(srcRect))
         destRect->setEmpty();
 }
 
index 681dcd5..358f86d 100644 (file)
@@ -67,7 +67,7 @@ inline SkScalar WebCoreDoubleToSkScalar(double d)
 // clip, doing the necessary coordinate transforms.
 //
 // srcRect and destRect can be the same.
-void ClipRectToCanvas(const SkCanvas&, const SkRect& srcRect, SkRect* destRect);
+void ClipRectToCanvas(const PlatformContextSkia*, const SkRect& srcRect, SkRect* destRect);
 
 // Determine if a given WebKit point is contained in a path
 bool SkPathContainsPoint(SkPath*, const FloatPoint&, SkPath::FillType);
index 7d83eed..f1c4234 100644 (file)
@@ -1,3 +1,18 @@
+2012-11-21  Florin Malita  <fmalita@chromium.org>
+
+        [Skia] Encapsulate access to PlatformContextSkia's SkCanvas
+        https://bugs.webkit.org/show_bug.cgi?id=102694
+
+        Reviewed by Stephen White.
+
+        Use PlatformContextSkia's wrapper methods instead of accessing the canvas directly.
+
+        * tests/TransparencyWinTest.cpp:
+        (WebCore::getPixelAt):
+        (WebCore::clearTopLayerAlphaChannel):
+        (WebCore::clearTopLayerAlphaPixel):
+        (WebCore::TEST):
+
 2012-11-20  Rachel Blum  <groby@chromium.org>
 
         [Chromium] Need spellcheck suggestions even if continuous check is off.
index ae3090d..6d73caf 100644 (file)
@@ -66,7 +66,7 @@ static void drawNativeRect(GraphicsContext* context,
 
 static Color getPixelAt(GraphicsContext* context, int x, int y)
 {
-    const SkBitmap& bitmap = context->platformContext()->canvas()->getTopDevice()->accessBitmap(false);
+    const SkBitmap& bitmap = context->platformContext()->layerBitmap();
     return Color(*reinterpret_cast<const RGBA32*>(bitmap.getAddr32(x, y)));
 }
 
@@ -74,7 +74,7 @@ static Color getPixelAt(GraphicsContext* context, int x, int y)
 // Windows messing it up.
 static void clearTopLayerAlphaChannel(GraphicsContext* context)
 {
-    SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()->canvas()->getTopDevice()->accessBitmap(false));
+    SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()->layerBitmap());
     for (int y = 0; y < bitmap.height(); y++) {
         uint32_t* row = bitmap.getAddr32(0, y);
         for (int x = 0; x < bitmap.width(); x++)
@@ -85,7 +85,7 @@ static void clearTopLayerAlphaChannel(GraphicsContext* context)
 // Clears the alpha channel on the specified pixel.
 static void clearTopLayerAlphaPixel(GraphicsContext* context, int x, int y)
 {
-    SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()->canvas()->getTopDevice()->accessBitmap(false));
+    SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()->layerBitmap());
     *bitmap.getAddr32(x, y) &= 0x00FFFFFF;
 }
 
@@ -616,7 +616,7 @@ TEST(TransparencyWin, Scale)
         // the helper goes out of scope. We don't want to call
         // clearTopLayerAlphaChannel because that will actually clear the whole
         // canvas (since we have no extra layer!).
-        SkBitmap& bitmap = const_cast<SkBitmap&>(helper.context()->platformContext()->canvas()->getTopDevice()->accessBitmap(false));
+        SkBitmap& bitmap = const_cast<SkBitmap&>(helper.context()->platformContext()->layerBitmap());
         *bitmap.getAddr32(2, 2) &= 0x00FFFFFF;
         helper.composite();
     }