From a1bc0f8df743e553d30b5564f1807f5fa678e2f5 Mon Sep 17 00:00:00 2001 From: John Reck Date: Tue, 22 May 2012 14:45:14 -0700 Subject: Don't use an ImageBuffer for scratchContext() Bug: 6509450 Change-Id: I6d952b92062e96772663824839b0229062c3a524 --- .../platform/graphics/android/PathAndroid.cpp | 2 +- Source/WebCore/platform/graphics/skia/SkiaUtils.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'Source/WebCore/platform/graphics') diff --git a/Source/WebCore/platform/graphics/android/PathAndroid.cpp b/Source/WebCore/platform/graphics/android/PathAndroid.cpp index 436da59..554e187 100644 --- a/Source/WebCore/platform/graphics/android/PathAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/PathAndroid.cpp @@ -286,7 +286,7 @@ void Path::transform(const AffineTransform& xform) /////////////////////////////////////////////////////////////////////////////// FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const -{ +{ GraphicsContext* scratch = scratchContext(); scratch->save(); diff --git a/Source/WebCore/platform/graphics/skia/SkiaUtils.cpp b/Source/WebCore/platform/graphics/skia/SkiaUtils.cpp index da83793..ebd9f0d 100644 --- a/Source/WebCore/platform/graphics/skia/SkiaUtils.cpp +++ b/Source/WebCore/platform/graphics/skia/SkiaUtils.cpp @@ -40,6 +40,11 @@ #include "SkRegion.h" #include "SkUnPreMultiply.h" +#if PLATFORM(ANDROID) +#include "GraphicsContext.h" +#include "PlatformGraphicsContextSkia.h" +#endif + namespace WebCore { #if PLATFORM(ANDROID) @@ -246,6 +251,20 @@ bool SkPathContainsPoint(SkPath* originalPath, const FloatPoint& point, SkPath:: return contains; } +#if PLATFORM(ANDROID) +GraphicsContext* scratchContext() +{ + static GraphicsContext* scratch = 0; + if (!scratch) { + SkBitmap bm; + bm.setConfig(SkBitmap::kNo_Config, 1, 1); + SkCanvas* canvas = new SkCanvas(bm); + PlatformGraphicsContextSkia* pgc = new PlatformGraphicsContextSkia(canvas); + scratch = new GraphicsContext(pgc); + } + return scratch; +} +#else GraphicsContext* scratchContext() { static ImageBuffer* scratch = ImageBuffer::create(IntSize(1, 1)).leakPtr(); @@ -253,5 +272,6 @@ GraphicsContext* scratchContext() // ImageBuffer initializer won't fail. return scratch->context(); } +#endif } // namespace WebCore -- cgit v1.1