Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1035)

Unified Diff: Source/core/platform/graphics/skia/ImageBufferSkia.cpp

Issue 14550002: Making GraphicsContext the owner of PlatformContext. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixing tests and addressing comments. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/graphics/skia/ImageBufferSkia.cpp
diff --git a/Source/core/platform/graphics/skia/ImageBufferSkia.cpp b/Source/core/platform/graphics/skia/ImageBufferSkia.cpp
index 72efc6e387ee5773210bf22b96345fe677d0fb9e..87255321edb553058621a1876d1b78da22e9d45e 100644
--- a/Source/core/platform/graphics/skia/ImageBufferSkia.cpp
+++ b/Source/core/platform/graphics/skia/ImageBufferSkia.cpp
@@ -66,7 +66,6 @@ namespace WebCore {
// PlatformContext doesn't actually need to use the object, and this makes all
// the ownership easier to manage.
ImageBufferData::ImageBufferData(const IntSize& size)
- : m_platformContext(0) // Canvas is set in ImageBuffer constructor.
{
}
@@ -93,7 +92,6 @@ static SkCanvas* createAcceleratedCanvas(const IntSize& size, ImageBufferData* d
data->m_layerBridge = Canvas2DLayerBridge::create(context3D.release(), canvas, bridgeOpacityMode, threadMode);
// If canvas buffer allocation failed, debug build will have asserted
// For release builds, we must verify whether the device has a render target
- data->m_platformContext.setAccelerated(true);
return canvas;
}
@@ -137,8 +135,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace,
}
m_data.m_canvas = adoptPtr(new SkCanvas(device));
- m_data.m_platformContext.setCanvas(m_data.m_canvas.get());
- m_context = adoptPtr(new GraphicsContext(&m_data.m_platformContext));
+ m_context = adoptPtr(new GraphicsContext(m_data.m_canvas.get()));
m_context->setShouldSmoothFonts(false);
m_context->scale(FloatSize(m_resolutionScale, m_resolutionScale));
@@ -153,8 +150,11 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace,
{
OwnPtr<SkCanvas> canvas;
- if (renderingMode == Accelerated)
+ bool isAccelerated = false;
jamesr 2013/04/30 19:57:08 nit: isAccelerated is the same as renderingMode ==
+ if (renderingMode == Accelerated) {
canvas = adoptPtr(createAcceleratedCanvas(size, &m_data, opacityMode));
+ isAccelerated = true;
+ }
else if (renderingMode == UnacceleratedNonPlatformBuffer)
canvas = adoptPtr(createNonPlatformCanvas(size));
@@ -167,9 +167,9 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace,
}
m_data.m_canvas = canvas.release();
- m_data.m_platformContext.setCanvas(m_data.m_canvas.get());
- m_context = adoptPtr(new GraphicsContext(&m_data.m_platformContext));
+ m_context = adoptPtr(new GraphicsContext(m_data.m_canvas.get()));
m_context->setShouldSmoothFonts(opacityMode == Opaque);
+ m_context->platformContext()->setAccelerated(isAccelerated);
m_context->scale(FloatSize(m_resolutionScale, m_resolutionScale));
// Clear the background transparent or opaque, as required. It would be nice if this wasn't
@@ -208,7 +208,7 @@ static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap)
PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior) const
{
- const SkBitmap& bitmap = *m_data.m_platformContext.bitmap();
+ const SkBitmap& bitmap = *context()->platformContext()->bitmap();
// FIXME: Start honoring ScaleBehavior to scale 2x buffers down to 1x.
return BitmapImage::create(NativeImageSkia::create(copyBehavior == CopyBackingStore ? deepSkBitmapCopy(bitmap) : bitmap, m_resolutionScale));
}
@@ -264,7 +264,7 @@ static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst)
void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
CompositeOperator op, BlendMode, bool useLowQualityScale)
{
- const SkBitmap& bitmap = *m_data.m_platformContext.bitmap();
+ const SkBitmap& bitmap = *m_context->platformContext()->bitmap();
RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsCopy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap));
context->drawImage(image.get(), styleColorSpace, destRect, srcRect, op, DoNotRespectImageOrientation, useLowQualityScale);
}
@@ -272,7 +272,7 @@ void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, con
void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
{
- const SkBitmap& bitmap = *m_data.m_platformContext.bitmap();
+ const SkBitmap& bitmap = *m_context->platformContext()->bitmap();
RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsCopy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap));
image->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
}
@@ -280,7 +280,7 @@ void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect
void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
{
// FIXME: Disable color space conversions on accelerated canvases (for now).
- if (m_data.m_platformContext.isAccelerated())
+ if (context()->platformContext()->isAccelerated())
return;
const SkBitmap& bitmap = *context()->platformContext()->bitmap();
@@ -430,7 +430,6 @@ void ImageBufferData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) cons
{
MemoryClassInfo info(memoryObjectInfo, this);
info.addMember(m_canvas, "canvas");
- info.addMember(m_platformContext, "platformContext");
info.addMember(m_layerBridge, "layerBridge");
}

Powered by Google App Engine
This is Rietveld 408576698