diff options
author | Steve Block <steveblock@google.com> | 2010-02-02 14:57:50 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-02-04 15:06:55 +0000 |
commit | d0825bca7fe65beaee391d30da42e937db621564 (patch) | |
tree | 7461c49eb5844ffd1f35d1ba2c8b7584c1620823 /WebCore/html/HTMLCanvasElement.cpp | |
parent | 3db770bd97c5a59b6c7574ca80a39e5a51c1defd (diff) | |
download | external_webkit-d0825bca7fe65beaee391d30da42e937db621564.zip external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.gz external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.bz2 |
Merge webkit.org at r54127 : Initial merge by git
Change-Id: Ib661abb595522f50ea406f72d3a0ce17f7193c82
Diffstat (limited to 'WebCore/html/HTMLCanvasElement.cpp')
-rw-r--r-- | WebCore/html/HTMLCanvasElement.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/WebCore/html/HTMLCanvasElement.cpp b/WebCore/html/HTMLCanvasElement.cpp index be0fa36..4cbbb65 100644 --- a/WebCore/html/HTMLCanvasElement.cpp +++ b/WebCore/html/HTMLCanvasElement.cpp @@ -27,10 +27,12 @@ #include "config.h" #include "HTMLCanvasElement.h" +#include "CanvasContextAttributes.h" #include "CanvasGradient.h" #include "CanvasPattern.h" #include "CanvasRenderingContext2D.h" #if ENABLE(3D_CANVAS) +#include "WebGLContextAttributes.h" #include "WebGLRenderingContext.h" #endif #include "CanvasStyle.h" @@ -147,7 +149,7 @@ String HTMLCanvasElement::toDataURL(const String& mimeType, ExceptionCode& ec) return buffer()->toDataURL(mimeType); } -CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type) +CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, CanvasContextAttributes* attrs) { // A Canvas can either be "2D" or "webgl" but never both. If you request a 2D canvas and the existing // context is already 2D, just return that. If the existing context is WebGL, then destroy it @@ -174,7 +176,7 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type) if (m_context && !m_context->is3d()) return 0; if (!m_context) { - m_context = WebGLRenderingContext::create(this); + m_context = WebGLRenderingContext::create(this, static_cast<WebGLContextAttributes*>(attrs)); if (m_context) { // Need to make sure a RenderLayer and compositing layer get created for the Canvas setNeedsStyleRecalc(SyntheticStyleChange); @@ -183,6 +185,8 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type) return m_context.get(); } } +#else + UNUSED_PARAM(attrs); #endif return 0; } @@ -223,6 +227,11 @@ void HTMLCanvasElement::reset() IntSize oldSize = m_size; m_size = IntSize(w, h); +#if ENABLE(3D_CANVAS) + if (m_context && m_context->is3d()) + static_cast<WebGLRenderingContext*>(m_context.get())->reshape(width(), height()); +#endif + bool hadImageBuffer = m_createdImageBuffer; m_createdImageBuffer = false; m_imageBuffer.clear(); @@ -251,7 +260,7 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r) return; #if ENABLE(3D_CANVAS) - WebGLRenderingContext* context3D = NULL; + WebGLRenderingContext* context3D = 0; if (m_context && m_context->is3d()) { context3D = static_cast<WebGLRenderingContext*>(m_context.get()); context3D->beginPaint(); @@ -265,10 +274,8 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r) } #if ENABLE(3D_CANVAS) - if (context3D != NULL) { - context3D->reshape(r.width(), r.height()); + if (context3D) context3D->endPaint(); - } #endif } |