summaryrefslogtreecommitdiffstats
path: root/WebCore/html/HTMLCanvasElement.cpp
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-08-19 17:55:56 +0100
committerIain Merrick <husky@google.com>2010-08-23 11:05:40 +0100
commitf486d19d62f1bc33246748b14b14a9dfa617b57f (patch)
tree195485454c93125455a30e553a73981c3816144d /WebCore/html/HTMLCanvasElement.cpp
parent6ba0b43722d16bc295606bec39f396f596e4fef1 (diff)
downloadexternal_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.zip
external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.tar.gz
external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.tar.bz2
Merge WebKit at r65615 : Initial merge by git.
Change-Id: Ifbf384f4531e3b58475a662e38195c2d9152ae79
Diffstat (limited to 'WebCore/html/HTMLCanvasElement.cpp')
-rw-r--r--WebCore/html/HTMLCanvasElement.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/WebCore/html/HTMLCanvasElement.cpp b/WebCore/html/HTMLCanvasElement.cpp
index ef5574a..84ab227 100644
--- a/WebCore/html/HTMLCanvasElement.cpp
+++ b/WebCore/html/HTMLCanvasElement.cpp
@@ -209,8 +209,7 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas
void HTMLCanvasElement::willDraw(const FloatRect& rect)
{
- if (m_imageBuffer)
- m_imageBuffer->clearImage();
+ m_copiedImage.clear(); // Clear our image snapshot if we have one.
if (RenderBox* ro = renderBox()) {
FloatRect destRect = ro->contentBoxRect();
@@ -233,6 +232,7 @@ void HTMLCanvasElement::reset()
return;
bool ok;
+ bool hadImageBuffer = hasCreatedImageBuffer();
int w = getAttribute(widthAttr).toInt(&ok);
if (!ok || w < 0)
w = DefaultWidth;
@@ -241,14 +241,13 @@ void HTMLCanvasElement::reset()
h = DefaultHeight;
IntSize oldSize = size();
- setSurfaceSize(IntSize(w, h));
+ setSurfaceSize(IntSize(w, h)); // The image buffer gets cleared here.
#if ENABLE(3D_CANVAS)
- if (m_context && m_context->is3d())
+ if (m_context && m_context->is3d() && oldSize != size())
static_cast<WebGLRenderingContext*>(m_context.get())->reshape(width(), height());
#endif
- bool hadImageBuffer = hasCreatedImageBuffer();
if (m_context && m_context->is2d())
static_cast<CanvasRenderingContext2D*>(m_context.get())->reset();
@@ -277,23 +276,21 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r)
WebGLRenderingContext* context3D = 0;
if (m_context && m_context->is3d()) {
context3D = static_cast<WebGLRenderingContext*>(m_context.get());
- context3D->beginPaint();
+ if (!context3D->paintsIntoCanvasBuffer())
+ return;
+ context3D->paintRenderingResultsToCanvas();
}
#endif
if (hasCreatedImageBuffer()) {
ImageBuffer* imageBuffer = buffer();
if (imageBuffer) {
- Image* image = imageBuffer->imageForRendering();
- if (image)
- context->drawImage(image, DeviceColorSpace, r);
+ if (imageBuffer->drawsUsingCopy())
+ context->drawImage(copiedImage(), DeviceColorSpace, r);
+ else
+ context->drawImageBuffer(imageBuffer, DeviceColorSpace, r);
}
}
-
-#if ENABLE(3D_CANVAS)
- if (context3D)
- context3D->endPaint();
-#endif
}
#if ENABLE(3D_CANVAS)
@@ -325,6 +322,7 @@ void HTMLCanvasElement::setSurfaceSize(const IntSize& size)
m_size = size;
m_hasCreatedImageBuffer = false;
m_imageBuffer.clear();
+ m_copiedImage.clear();
}
String HTMLCanvasElement::toDataURL(const String& mimeType, const double* quality, ExceptionCode& ec)
@@ -405,6 +403,7 @@ void HTMLCanvasElement::createImageBuffer() const
return;
m_imageBuffer->context()->scale(FloatSize(size.width() / unscaledSize.width(), size.height() / unscaledSize.height()));
m_imageBuffer->context()->setShadowsIgnoreTransforms(true);
+ m_imageBuffer->context()->setImageInterpolationQuality(CanvasInterpolationQuality);
}
GraphicsContext* HTMLCanvasElement::drawingContext() const
@@ -419,6 +418,18 @@ ImageBuffer* HTMLCanvasElement::buffer() const
return m_imageBuffer.get();
}
+Image* HTMLCanvasElement::copiedImage() const
+{
+ if (!m_copiedImage && buffer())
+ m_copiedImage = buffer()->copyImage();
+ return m_copiedImage.get();
+}
+
+void HTMLCanvasElement::clearCopiedImage()
+{
+ m_copiedImage.clear();
+}
+
AffineTransform HTMLCanvasElement::baseTransform() const
{
ASSERT(m_hasCreatedImageBuffer);