diff options
Diffstat (limited to 'WebCore/html/canvas')
-rw-r--r-- | WebCore/html/canvas/CanvasActiveInfo.h | 62 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasActiveInfo.idl | 36 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasArray.h | 8 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasArray.idl | 2 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasByteArray.h | 2 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasFloatArray.h | 2 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasIntArray.h | 2 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasObject.h | 6 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasRenderingContext.h | 3 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasRenderingContext2D.cpp | 82 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasRenderingContext3D.cpp | 382 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasRenderingContext3D.h | 22 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasRenderingContext3D.idl | 10 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasShortArray.h | 2 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasUnsignedByteArray.h | 2 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasUnsignedIntArray.h | 2 | ||||
-rw-r--r-- | WebCore/html/canvas/CanvasUnsignedShortArray.h | 2 |
17 files changed, 398 insertions, 229 deletions
diff --git a/WebCore/html/canvas/CanvasActiveInfo.h b/WebCore/html/canvas/CanvasActiveInfo.h new file mode 100644 index 0000000..b04b0d0 --- /dev/null +++ b/WebCore/html/canvas/CanvasActiveInfo.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CanvasActiveInfo_h +#define CanvasActiveInfo_h + +#include "PlatformString.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + +class CanvasActiveInfo : public RefCounted<CanvasActiveInfo> { +public: + static PassRefPtr<CanvasActiveInfo> create(const String& name, unsigned type, int size) + { + return adoptRef(new CanvasActiveInfo(name, type, size)); + } + String name() const { return m_name; } + unsigned type() const { return m_type; } + int size() const { return m_size; } + +private: + CanvasActiveInfo(const String& name, unsigned type, int size) + : m_name(name) + , m_type(type) + , m_size(size) + { + ASSERT(name.length()); + ASSERT(type); + ASSERT(size); + } + String m_name; + unsigned m_type; + int m_size; +}; + +} + +#endif // CanvasActiveInfo_h diff --git a/WebCore/html/canvas/CanvasActiveInfo.idl b/WebCore/html/canvas/CanvasActiveInfo.idl new file mode 100644 index 0000000..6ceae29 --- /dev/null +++ b/WebCore/html/canvas/CanvasActiveInfo.idl @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +module html { + + interface [ + Conditional=3D_CANVAS, + ] CanvasActiveInfo { + readonly attribute int size; + readonly attribute unsigned int type; + readonly attribute DOMString name; + }; + +} diff --git a/WebCore/html/canvas/CanvasArray.h b/WebCore/html/canvas/CanvasArray.h index e34ad8c..8cedbbe 100644 --- a/WebCore/html/canvas/CanvasArray.h +++ b/WebCore/html/canvas/CanvasArray.h @@ -34,6 +34,14 @@ namespace WebCore { class CanvasArray : public RefCounted<CanvasArray> { public: + virtual bool isByteArray() const { return false; } + virtual bool isUnsignedByteArray() const { return false; } + virtual bool isShortArray() const { return false; } + virtual bool isUnsignedShortArray() const { return false; } + virtual bool isIntArray() const { return false; } + virtual bool isUnsignedIntArray() const { return false; } + virtual bool isFloatArray() const { return false; } + PassRefPtr<CanvasArrayBuffer> buffer() { return m_buffer; } diff --git a/WebCore/html/canvas/CanvasArray.idl b/WebCore/html/canvas/CanvasArray.idl index 01bb37e..63b2dcd 100644 --- a/WebCore/html/canvas/CanvasArray.idl +++ b/WebCore/html/canvas/CanvasArray.idl @@ -24,7 +24,7 @@ */ module html { - interface [Conditional=3D_CANVAS] CanvasArray { + interface [Conditional=3D_CANVAS, CustomToJS] CanvasArray { readonly attribute long length; int sizeInBytes(); int alignedSizeInBytes(); diff --git a/WebCore/html/canvas/CanvasByteArray.h b/WebCore/html/canvas/CanvasByteArray.h index 329f396..69cadf7 100644 --- a/WebCore/html/canvas/CanvasByteArray.h +++ b/WebCore/html/canvas/CanvasByteArray.h @@ -38,6 +38,8 @@ namespace WebCore { class CanvasByteArray : public CanvasArray { public: + virtual bool isByteArray() const { return true; } + static PassRefPtr<CanvasByteArray> create(unsigned length); static PassRefPtr<CanvasByteArray> create(signed char* array, unsigned length); static PassRefPtr<CanvasByteArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length); diff --git a/WebCore/html/canvas/CanvasFloatArray.h b/WebCore/html/canvas/CanvasFloatArray.h index 49bd897..d2dc4ff 100644 --- a/WebCore/html/canvas/CanvasFloatArray.h +++ b/WebCore/html/canvas/CanvasFloatArray.h @@ -35,6 +35,8 @@ namespace WebCore { class CanvasFloatArray : public CanvasArray { public: + virtual bool isFloatArray() const { return true; } + static PassRefPtr<CanvasFloatArray> create(unsigned length); static PassRefPtr<CanvasFloatArray> create(float* array, unsigned length); static PassRefPtr<CanvasFloatArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length); diff --git a/WebCore/html/canvas/CanvasIntArray.h b/WebCore/html/canvas/CanvasIntArray.h index 8846be7..4977034 100644 --- a/WebCore/html/canvas/CanvasIntArray.h +++ b/WebCore/html/canvas/CanvasIntArray.h @@ -36,6 +36,8 @@ namespace WebCore { class CanvasIntArray : public CanvasArray { public: + virtual bool isIntArray() const { return true; } + static PassRefPtr<CanvasIntArray> create(unsigned length); static PassRefPtr<CanvasIntArray> create(int* array, unsigned length); static PassRefPtr<CanvasIntArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length); diff --git a/WebCore/html/canvas/CanvasObject.h b/WebCore/html/canvas/CanvasObject.h index 413da71..748278d 100644 --- a/WebCore/html/canvas/CanvasObject.h +++ b/WebCore/html/canvas/CanvasObject.h @@ -48,12 +48,12 @@ namespace WebCore { deleteObject(); m_context = 0; } - + + CanvasRenderingContext3D* context() const { return m_context; } + protected: CanvasObject(CanvasRenderingContext3D*); virtual void _deleteObject(Platform3DObject) = 0; - - CanvasRenderingContext3D* context() const { return m_context; } private: Platform3DObject m_object; diff --git a/WebCore/html/canvas/CanvasRenderingContext.h b/WebCore/html/canvas/CanvasRenderingContext.h index 9ac9e57..f752377 100644 --- a/WebCore/html/canvas/CanvasRenderingContext.h +++ b/WebCore/html/canvas/CanvasRenderingContext.h @@ -38,6 +38,7 @@ namespace WebCore { CanvasRenderingContext(HTMLCanvasElement*); virtual ~CanvasRenderingContext() { } + // Ref and deref the m_canvas void ref(); void deref(); @@ -46,7 +47,7 @@ namespace WebCore { virtual bool is2d() const { return false; } virtual bool is3d() const { return false; } - protected: + private: HTMLCanvasElement* m_canvas; }; diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp index ed462fc..3341901 100644 --- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp +++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp @@ -165,10 +165,10 @@ void CanvasRenderingContext2D::setStrokeStyle(PassRefPtr<CanvasStyle> style) if (!style) return; - if (m_canvas->originClean()) { + if (canvas()->originClean()) { if (CanvasPattern* pattern = style->canvasPattern()) { if (!pattern->originClean()) - m_canvas->setOriginTainted(); + canvas()->setOriginTainted(); } } @@ -189,10 +189,10 @@ void CanvasRenderingContext2D::setFillStyle(PassRefPtr<CanvasStyle> style) if (!style) return; - if (m_canvas->originClean()) { + if (canvas()->originClean()) { if (CanvasPattern* pattern = style->canvasPattern()) { if (!pattern->originClean()) - m_canvas->setOriginTainted(); + canvas()->setOriginTainted(); } } @@ -447,7 +447,7 @@ void CanvasRenderingContext2D::setTransform(float m11, float m12, float m21, flo if (!ctm.isInvertible()) return; c->concatCTM(c->getCTM().inverse()); - c->concatCTM(m_canvas->baseTransform()); + c->concatCTM(canvas()->baseTransform()); state().m_transform.multiply(ctm.inverse()); m_path.transform(ctm); @@ -630,7 +630,7 @@ void CanvasRenderingContext2D::rect(float x, float y, float width, float height) #if ENABLE(DASHBOARD_SUPPORT) void CanvasRenderingContext2D::clearPathForDashboardBackwardCompatibilityMode() { - if (Settings* settings = m_canvas->document()->settings()) + if (Settings* settings = canvas()->document()->settings()) if (settings->usesDashboardBackwardCompatibilityMode()) m_path.clear(); } @@ -687,7 +687,7 @@ void CanvasRenderingContext2D::clip() return; if (!state().m_invertibleCTM) return; - c->clip(m_path); + c->canvasClip(m_path); #if ENABLE(DASHBOARD_SUPPORT) clearPathForDashboardBackwardCompatibilityMode(); #endif @@ -935,8 +935,8 @@ static inline FloatRect normalizeRect(const FloatRect& rect) void CanvasRenderingContext2D::checkOrigin(const KURL& url) { - if (m_canvas->document()->securityOrigin()->taintsCanvas(url)) - m_canvas->setOriginTainted(); + if (canvas()->document()->securityOrigin()->taintsCanvas(url)) + canvas()->setOriginTainted(); } void CanvasRenderingContext2D::checkOrigin(const String& url) @@ -986,11 +986,11 @@ void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, const FloatRec if (!cachedImage) return; - if (m_canvas->originClean()) + if (canvas()->originClean()) checkOrigin(cachedImage->response().url()); - if (m_canvas->originClean() && !cachedImage->image()->hasSingleSecurityOrigin()) - m_canvas->setOriginTainted(); + if (canvas()->originClean() && !cachedImage->image()->hasSingleSecurityOrigin()) + canvas()->setOriginTainted(); FloatRect sourceRect = c->roundToDevicePixels(srcRect); FloatRect destRect = c->roundToDevicePixels(dstRect); @@ -1012,14 +1012,14 @@ void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, drawImage(canvas, FloatRect(0, 0, canvas->width(), canvas->height()), FloatRect(x, y, width, height), ec); } -void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, const FloatRect& srcRect, +void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode& ec) { - ASSERT(canvas); + ASSERT(sourceCanvas); ec = 0; - FloatRect srcCanvasRect = FloatRect(FloatPoint(), canvas->size()); + FloatRect srcCanvasRect = FloatRect(FloatPoint(), sourceCanvas->size()); if (!srcCanvasRect.contains(normalizeRect(srcRect)) || srcRect.width() == 0 || srcRect.height() == 0) { ec = INDEX_SIZE_ERR; return; @@ -1038,12 +1038,12 @@ void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, const FloatR FloatRect destRect = c->roundToDevicePixels(dstRect); // FIXME: Do this through platform-independent GraphicsContext API. - ImageBuffer* buffer = canvas->buffer(); + ImageBuffer* buffer = sourceCanvas->buffer(); if (!buffer) return; - if (!canvas->originClean()) - m_canvas->setOriginTainted(); + if (!sourceCanvas->originClean()) + canvas()->setOriginTainted(); c->drawImage(buffer->image(), destRect, sourceRect, state().m_globalComposite); willDraw(destRect); // This call comes after drawImage, since the buffer we draw into may be our own, and we need to make sure it is dirty. @@ -1088,11 +1088,11 @@ void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, const FloatRec if (!state().m_invertibleCTM) return; - if (m_canvas->originClean()) + if (canvas()->originClean()) checkOrigin(video->currentSrc()); - if (m_canvas->originClean() && !video->hasSingleSecurityOrigin()) - m_canvas->setOriginTainted(); + if (canvas()->originClean() && !video->hasSingleSecurityOrigin()) + canvas()->setOriginTainted(); FloatRect sourceRect = c->roundToDevicePixels(srcRect); FloatRect destRect = c->roundToDevicePixels(dstRect); @@ -1121,11 +1121,11 @@ void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement* image, if (!cachedImage) return; - if (m_canvas->originClean()) + if (canvas()->originClean()) checkOrigin(cachedImage->response().url()); - if (m_canvas->originClean() && !cachedImage->image()->hasSingleSecurityOrigin()) - m_canvas->setOriginTainted(); + if (canvas()->originClean() && !cachedImage->image()->hasSingleSecurityOrigin()) + canvas()->setOriginTainted(); GraphicsContext* c = drawingContext(); if (!c) @@ -1155,7 +1155,7 @@ void CanvasRenderingContext2D::setCompositeOperation(const String& operation) void CanvasRenderingContext2D::prepareGradientForDashboard(CanvasGradient* gradient) const { #if ENABLE(DASHBOARD_SUPPORT) - if (Settings* settings = m_canvas->document()->settings()) + if (Settings* settings = canvas()->document()->settings()) if (settings->usesDashboardBackwardCompatibilityMode()) gradient->setDashboardCompatibilityMode(); #else @@ -1205,7 +1205,7 @@ PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageEleme if (!cachedImage || !image->cachedImage()->image()) return CanvasPattern::create(Image::nullImage(), repeatX, repeatY, true); - bool originClean = !m_canvas->document()->securityOrigin()->taintsCanvas(KURL(KURL(), cachedImage->url())); + bool originClean = !canvas()->document()->securityOrigin()->taintsCanvas(KURL(KURL(), cachedImage->url())); return CanvasPattern::create(cachedImage->image(), repeatX, repeatY, originClean); } @@ -1253,12 +1253,12 @@ void CanvasRenderingContext2D::willDraw(const FloatRect& r, unsigned options) // we'd have to keep the clip path around. } - m_canvas->willDraw(dirtyRect); + canvas()->willDraw(dirtyRect); } GraphicsContext* CanvasRenderingContext2D::drawingContext() const { - return m_canvas->drawingContext(); + return canvas()->drawingContext(); } static PassRefPtr<ImageData> createEmptyImageData(const IntSize& size) @@ -1276,7 +1276,7 @@ PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(float sw, float return 0; } FloatSize unscaledSize(sw, sh); - IntSize scaledSize = m_canvas->convertLogicalToDevice(unscaledSize); + IntSize scaledSize = canvas()->convertLogicalToDevice(unscaledSize); if (scaledSize.width() < 1) scaledSize.setWidth(1); if (scaledSize.height() < 1) @@ -1287,18 +1287,18 @@ PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(float sw, float PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(float sx, float sy, float sw, float sh, ExceptionCode& ec) const { - if (!m_canvas->originClean()) { + if (!canvas()->originClean()) { ec = SECURITY_ERR; return 0; } FloatRect unscaledRect(sx, sy, sw, sh); - IntRect scaledRect = m_canvas->convertLogicalToDevice(unscaledRect); + IntRect scaledRect = canvas()->convertLogicalToDevice(unscaledRect); if (scaledRect.width() < 1) scaledRect.setWidth(1); if (scaledRect.height() < 1) scaledRect.setHeight(1); - ImageBuffer* buffer = m_canvas ? m_canvas->buffer() : 0; + ImageBuffer* buffer = canvas() ? canvas()->buffer() : 0; if (!buffer) return createEmptyImageData(scaledRect.size()); return buffer->getUnmultipliedImageData(scaledRect); @@ -1326,7 +1326,7 @@ void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy, return; } - ImageBuffer* buffer = m_canvas->buffer(); + ImageBuffer* buffer = canvas()->buffer(); if (!buffer) return; @@ -1363,7 +1363,7 @@ String CanvasRenderingContext2D::font() const void CanvasRenderingContext2D::setFont(const String& newFont) { RefPtr<CSSMutableStyleDeclaration> tempDecl = CSSMutableStyleDeclaration::create(); - CSSParser parser(!m_canvas->document()->inCompatMode()); // Use the parse mode of the canvas' document when parsing CSS. + CSSParser parser(!canvas()->document()->inCompatMode()); // Use the parse mode of the canvas' document when parsing CSS. String declarationText("font: "); declarationText += newFont; @@ -1377,11 +1377,11 @@ void CanvasRenderingContext2D::setFont(const String& newFont) // Map the <canvas> font into the text style. If the font uses keywords like larger/smaller, these will work // relative to the canvas. RefPtr<RenderStyle> newStyle = RenderStyle::create(); - if (m_canvas->computedStyle()) - newStyle->setFontDescription(m_canvas->computedStyle()->fontDescription()); + if (canvas()->computedStyle()) + newStyle->setFontDescription(canvas()->computedStyle()->fontDescription()); // Now map the font property into the style. - CSSStyleSelector* styleSelector = m_canvas->document()->styleSelector(); + CSSStyleSelector* styleSelector = canvas()->document()->styleSelector(); styleSelector->applyPropertyToStyle(CSSPropertyFont, tempDecl->getPropertyCSSValue(CSSPropertyFont).get(), newStyle.get()); state().m_font = newStyle->font(); @@ -1455,8 +1455,8 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo // FIXME: Handle maxWidth. // FIXME: Need to turn off font smoothing. - bool rtl = m_canvas->computedStyle() ? m_canvas->computedStyle()->direction() == RTL : false; - bool override = m_canvas->computedStyle() ? m_canvas->computedStyle()->unicodeBidi() == Override : false; + bool rtl = canvas()->computedStyle() ? canvas()->computedStyle()->direction() == RTL : false; + bool override = canvas()->computedStyle() ? canvas()->computedStyle()->unicodeBidi() == Override : false; unsigned length = text.length(); const UChar* string = text.characters(); @@ -1508,11 +1508,11 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo textRect.inflate(c->strokeThickness() / 2); if (fill) - m_canvas->willDraw(textRect); + canvas()->willDraw(textRect); else { // When stroking text, pointy miters can extend outside of textRect, so we // punt and dirty the whole canvas. - m_canvas->willDraw(FloatRect(0, 0, m_canvas->width(), m_canvas->height())); + canvas()->willDraw(FloatRect(0, 0, canvas()->width(), canvas()->height())); } #if PLATFORM(CG) diff --git a/WebCore/html/canvas/CanvasRenderingContext3D.cpp b/WebCore/html/canvas/CanvasRenderingContext3D.cpp index b810500..612b4c3 100644 --- a/WebCore/html/canvas/CanvasRenderingContext3D.cpp +++ b/WebCore/html/canvas/CanvasRenderingContext3D.cpp @@ -28,6 +28,8 @@ #if ENABLE(3D_CANVAS) #include "CanvasRenderingContext3D.h" + +#include "CanvasActiveInfo.h" #include "CanvasBuffer.h" #include "CanvasFramebuffer.h" #include "CanvasProgram.h" @@ -40,12 +42,23 @@ namespace WebCore { -CanvasRenderingContext3D::CanvasRenderingContext3D(HTMLCanvasElement* canvas) - : CanvasRenderingContext(canvas) +PassOwnPtr<CanvasRenderingContext3D> CanvasRenderingContext3D::create(HTMLCanvasElement* canvas) +{ + OwnPtr<GraphicsContext3D> context(GraphicsContext3D::create()); + if (!context) + return 0; + + return new CanvasRenderingContext3D(canvas, context.release()); +} + +CanvasRenderingContext3D::CanvasRenderingContext3D(HTMLCanvasElement* passedCanvas, PassOwnPtr<GraphicsContext3D> context) + : CanvasRenderingContext(passedCanvas) + , m_context(context) , m_needsUpdate(true) , m_markedCanvasDirty(false) { - m_context.reshape(m_canvas->width(), m_canvas->height()); + ASSERT(m_context); + m_context->reshape(canvas()->width(), canvas()->height()); } CanvasRenderingContext3D::~CanvasRenderingContext3D() @@ -56,14 +69,14 @@ CanvasRenderingContext3D::~CanvasRenderingContext3D() void CanvasRenderingContext3D::markContextChanged() { #if USE(ACCELERATED_COMPOSITING) - if (m_canvas->renderBox() && m_canvas->renderBox()->hasLayer()) { - m_canvas->renderBox()->layer()->rendererContentChanged(); + if (canvas()->renderBox() && canvas()->renderBox()->hasLayer()) { + canvas()->renderBox()->layer()->rendererContentChanged(); } else { #endif if (!m_markedCanvasDirty) { // Make sure the canvas's image buffer is allocated. - m_canvas->buffer(); - m_canvas->willDraw(FloatRect(0, 0, m_canvas->width(), m_canvas->height())); + canvas()->buffer(); + canvas()->willDraw(FloatRect(0, 0, canvas()->width(), canvas()->height())); m_markedCanvasDirty = true; } #if USE(ACCELERATED_COMPOSITING) @@ -74,7 +87,7 @@ void CanvasRenderingContext3D::markContextChanged() void CanvasRenderingContext3D::beginPaint() { if (m_markedCanvasDirty) { - m_context.beginPaint(this); + m_context->beginPaint(this); } } @@ -82,7 +95,7 @@ void CanvasRenderingContext3D::endPaint() { if (m_markedCanvasDirty) { m_markedCanvasDirty = false; - m_context.endPaint(); + m_context->endPaint(); } } @@ -90,18 +103,18 @@ void CanvasRenderingContext3D::reshape(int width, int height) { if (m_needsUpdate) { #if USE(ACCELERATED_COMPOSITING) - if (m_canvas->renderBox() && m_canvas->renderBox()->hasLayer()) - m_canvas->renderBox()->layer()->rendererContentChanged(); + if (canvas()->renderBox() && canvas()->renderBox()->hasLayer()) + canvas()->renderBox()->layer()->rendererContentChanged(); #endif m_needsUpdate = false; } - m_context.reshape(width, height); + m_context->reshape(width, height); } int CanvasRenderingContext3D::sizeInBytes(int type, ExceptionCode& ec) { - int result = m_context.sizeInBytes(type); + int result = m_context->sizeInBytes(type); if (result <= 0) { ec = SYNTAX_ERR; } @@ -110,7 +123,7 @@ int CanvasRenderingContext3D::sizeInBytes(int type, ExceptionCode& ec) void CanvasRenderingContext3D::activeTexture(unsigned long texture) { - m_context.activeTexture(texture); + m_context->activeTexture(texture); cleanupAfterGraphicsCall(false); } @@ -118,7 +131,7 @@ void CanvasRenderingContext3D::attachShader(CanvasProgram* program, CanvasShader { if (!program || !shader) return; - m_context.attachShader(program, shader); + m_context->attachShader(program, shader); cleanupAfterGraphicsCall(false); } @@ -126,94 +139,94 @@ void CanvasRenderingContext3D::bindAttribLocation(CanvasProgram* program, unsign { if (!program) return; - m_context.bindAttribLocation(program, index, name); + m_context->bindAttribLocation(program, index, name); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::bindBuffer(unsigned long target, CanvasBuffer* buffer) { - m_context.bindBuffer(target, buffer); + m_context->bindBuffer(target, buffer); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::bindFramebuffer(unsigned long target, CanvasFramebuffer* buffer) { - m_context.bindFramebuffer(target, buffer); + m_context->bindFramebuffer(target, buffer); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::bindRenderbuffer(unsigned long target, CanvasRenderbuffer* renderbuffer) { - m_context.bindRenderbuffer(target, renderbuffer); + m_context->bindRenderbuffer(target, renderbuffer); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::bindTexture(unsigned long target, CanvasTexture* texture) { - m_context.bindTexture(target, texture); + m_context->bindTexture(target, texture); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::blendColor(double red, double green, double blue, double alpha) { - m_context.blendColor(red, green, blue, alpha); + m_context->blendColor(red, green, blue, alpha); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::blendEquation( unsigned long mode ) { - m_context.blendEquation(mode); + m_context->blendEquation(mode); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha) { - m_context.blendEquationSeparate(modeRGB, modeAlpha); + m_context->blendEquationSeparate(modeRGB, modeAlpha); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::blendFunc(unsigned long sfactor, unsigned long dfactor) { - m_context.blendFunc(sfactor, dfactor); + m_context->blendFunc(sfactor, dfactor); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha) { - m_context.blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); + m_context->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::bufferData(unsigned long target, int size, unsigned long usage) { - m_context.bufferData(target, size, usage); + m_context->bufferData(target, size, usage); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::bufferData(unsigned long target, CanvasArray* data, unsigned long usage) { - m_context.bufferData(target, data, usage); + m_context->bufferData(target, data, usage); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::bufferSubData(unsigned long target, long offset, CanvasArray* data) { - m_context.bufferSubData(target, offset, data); + m_context->bufferSubData(target, offset, data); cleanupAfterGraphicsCall(false); } unsigned long CanvasRenderingContext3D::checkFramebufferStatus(unsigned long target) { - return m_context.checkFramebufferStatus(target); + return m_context->checkFramebufferStatus(target); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::clear(unsigned long mask) { - m_context.clear(mask); + m_context->clear(mask); cleanupAfterGraphicsCall(true); } @@ -227,43 +240,43 @@ void CanvasRenderingContext3D::clearColor(double r, double g, double b, double a b = 0; if (isnan(a)) a = 1; - m_context.clearColor(r, g, b, a); + m_context->clearColor(r, g, b, a); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::clearDepth(double depth) { - m_context.clearDepth(depth); + m_context->clearDepth(depth); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::clearStencil(long s) { - m_context.clearStencil(s); + m_context->clearStencil(s); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::colorMask(bool red, bool green, bool blue, bool alpha) { - m_context.colorMask(red, green, blue, alpha); + m_context->colorMask(red, green, blue, alpha); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::compileShader(CanvasShader* shader) { - m_context.compileShader(shader); + m_context->compileShader(shader); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border) { - m_context.copyTexImage2D(target, level, internalformat, x, y, width, height, border); + m_context->copyTexImage2D(target, level, internalformat, x, y, width, height, border); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height) { - m_context.copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); + m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); cleanupAfterGraphicsCall(false); } @@ -317,7 +330,7 @@ PassRefPtr<CanvasShader> CanvasRenderingContext3D::createShader(unsigned long ty void CanvasRenderingContext3D::cullFace(unsigned long mode) { - m_context.cullFace(mode); + m_context->cullFace(mode); cleanupAfterGraphicsCall(false); } @@ -371,19 +384,19 @@ void CanvasRenderingContext3D::deleteTexture(CanvasTexture* texture) void CanvasRenderingContext3D::depthFunc(unsigned long func) { - m_context.depthFunc(func); + m_context->depthFunc(func); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::depthMask(bool flag) { - m_context.depthMask(flag); + m_context->depthMask(flag); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::depthRange(double zNear, double zFar) { - m_context.depthRange(zNear, zFar); + m_context->depthRange(zNear, zFar); cleanupAfterGraphicsCall(false); } @@ -392,58 +405,58 @@ void CanvasRenderingContext3D::detachShader(CanvasProgram* program, CanvasShader if (!program || !shader) return; - m_context.detachShader(program, shader); + m_context->detachShader(program, shader); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::disable(unsigned long cap) { - m_context.disable(cap); + m_context->disable(cap); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::disableVertexAttribArray(unsigned long index) { - m_context.disableVertexAttribArray(index); + m_context->disableVertexAttribArray(index); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::drawArrays(unsigned long mode, long first, long count) { - m_context.drawArrays(mode, first, count); + m_context->drawArrays(mode, first, count); cleanupAfterGraphicsCall(true); } void CanvasRenderingContext3D::drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset) { - m_context.drawElements(mode, count, type, offset); + m_context->drawElements(mode, count, type, offset); cleanupAfterGraphicsCall(true); } void CanvasRenderingContext3D::enable(unsigned long cap) { - m_context.enable(cap); + m_context->enable(cap); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::enableVertexAttribArray(unsigned long index) { - m_context.enableVertexAttribArray(index); + m_context->enableVertexAttribArray(index); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::finish() { - m_context.finish(); + m_context->finish(); cleanupAfterGraphicsCall(true); } void CanvasRenderingContext3D::flush() { - m_context.flush(); + m_context->flush(); cleanupAfterGraphicsCall(true); } @@ -452,7 +465,7 @@ void CanvasRenderingContext3D::framebufferRenderbuffer(unsigned long target, uns if (!buffer) return; - m_context.framebufferRenderbuffer(target, attachment, renderbuffertarget, buffer); + m_context->framebufferRenderbuffer(target, attachment, renderbuffertarget, buffer); cleanupAfterGraphicsCall(false); } @@ -461,269 +474,289 @@ void CanvasRenderingContext3D::framebufferTexture2D(unsigned long target, unsign if (!texture) return; - m_context.framebufferTexture2D(target, attachment, textarget, texture, level); + m_context->framebufferTexture2D(target, attachment, textarget, texture, level); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::frontFace(unsigned long mode) { - m_context.frontFace(mode); + m_context->frontFace(mode); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::generateMipmap(unsigned long target) { - m_context.generateMipmap(target); + m_context->generateMipmap(target); cleanupAfterGraphicsCall(false); } +PassRefPtr<CanvasActiveInfo> CanvasRenderingContext3D::getActiveAttrib(CanvasProgram* program, unsigned long index, ExceptionCode& ec) +{ + ActiveInfo info; + if (!program || program->context() != this || !m_context->getActiveAttrib(program, index, info)) { + ec = INDEX_SIZE_ERR; + return 0; + } + return CanvasActiveInfo::create(info.name, info.type, info.size); +} + +PassRefPtr<CanvasActiveInfo> CanvasRenderingContext3D::getActiveUniform(CanvasProgram* program, unsigned long index, ExceptionCode& ec) +{ + ActiveInfo info; + if (!program || program->context() != this || !m_context->getActiveUniform(program, index, info)) { + ec = INDEX_SIZE_ERR; + return 0; + } + return CanvasActiveInfo::create(info.name, info.type, info.size); +} + int CanvasRenderingContext3D::getAttribLocation(CanvasProgram* program, const String& name) { - return m_context.getAttribLocation(program, name); + return m_context->getAttribLocation(program, name); } bool CanvasRenderingContext3D::getBoolean(unsigned long pname) { - bool result = m_context.getBoolean(pname); + bool result = m_context->getBoolean(pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasUnsignedByteArray> CanvasRenderingContext3D::getBooleanv(unsigned long pname) { - RefPtr<CanvasUnsignedByteArray> array = m_context.getBooleanv(pname); + RefPtr<CanvasUnsignedByteArray> array = m_context->getBooleanv(pname); cleanupAfterGraphicsCall(false); return array; } int CanvasRenderingContext3D::getBufferParameteri(unsigned long target, unsigned long pname) { - int result = m_context.getBufferParameteri(target, pname); + int result = m_context->getBufferParameteri(target, pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getBufferParameteriv(unsigned long target, unsigned long pname) { - RefPtr<CanvasIntArray> array = m_context.getBufferParameteriv(target, pname); + RefPtr<CanvasIntArray> array = m_context->getBufferParameteriv(target, pname); cleanupAfterGraphicsCall(false); return array; } unsigned long CanvasRenderingContext3D::getError() { - return m_context.getError(); + return m_context->getError(); } float CanvasRenderingContext3D::getFloat(unsigned long pname) { - float result = m_context.getFloat(pname); + float result = m_context->getFloat(pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasFloatArray> CanvasRenderingContext3D::getFloatv(unsigned long pname) { - RefPtr<CanvasFloatArray> array = m_context.getFloatv(pname); + RefPtr<CanvasFloatArray> array = m_context->getFloatv(pname); cleanupAfterGraphicsCall(false); return array; } int CanvasRenderingContext3D::getFramebufferAttachmentParameteri(unsigned long target, unsigned long attachment, unsigned long pname) { - int result = m_context.getFramebufferAttachmentParameteri(target, attachment, pname); + int result = m_context->getFramebufferAttachmentParameteri(target, attachment, pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getFramebufferAttachmentParameteriv(unsigned long target, unsigned long attachment, unsigned long pname) { - RefPtr<CanvasIntArray> array = m_context.getFramebufferAttachmentParameteriv(target, attachment, pname); + RefPtr<CanvasIntArray> array = m_context->getFramebufferAttachmentParameteriv(target, attachment, pname); cleanupAfterGraphicsCall(false); return array; } int CanvasRenderingContext3D::getInteger(unsigned long pname) { - float result = m_context.getInteger(pname); + float result = m_context->getInteger(pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getIntegerv(unsigned long pname) { - RefPtr<CanvasIntArray> array = m_context.getIntegerv(pname); + RefPtr<CanvasIntArray> array = m_context->getIntegerv(pname); cleanupAfterGraphicsCall(false); return array; } int CanvasRenderingContext3D::getProgrami(CanvasProgram* program, unsigned long pname) { - int result = m_context.getProgrami(program, pname); + int result = m_context->getProgrami(program, pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getProgramiv(CanvasProgram* program, unsigned long pname) { - RefPtr<CanvasIntArray> array = m_context.getProgramiv(program, pname); + RefPtr<CanvasIntArray> array = m_context->getProgramiv(program, pname); cleanupAfterGraphicsCall(false); return array; } String CanvasRenderingContext3D::getProgramInfoLog(CanvasProgram* program) { - String s = m_context.getProgramInfoLog(program); + String s = m_context->getProgramInfoLog(program); cleanupAfterGraphicsCall(false); return s; } int CanvasRenderingContext3D::getRenderbufferParameteri(unsigned long target, unsigned long pname) { - int result = m_context.getRenderbufferParameteri(target, pname); + int result = m_context->getRenderbufferParameteri(target, pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getRenderbufferParameteriv(unsigned long target, unsigned long pname) { - RefPtr<CanvasIntArray> array = m_context.getRenderbufferParameteriv(target, pname); + RefPtr<CanvasIntArray> array = m_context->getRenderbufferParameteriv(target, pname); cleanupAfterGraphicsCall(false); return array; } int CanvasRenderingContext3D::getShaderi(CanvasShader* shader, unsigned long pname) { - int result = m_context.getShaderi(shader, pname); + int result = m_context->getShaderi(shader, pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getShaderiv(CanvasShader* shader, unsigned long pname) { - RefPtr<CanvasIntArray> array = m_context.getShaderiv(shader, pname); + RefPtr<CanvasIntArray> array = m_context->getShaderiv(shader, pname); cleanupAfterGraphicsCall(false); return array; } String CanvasRenderingContext3D::getShaderInfoLog(CanvasShader* shader) { - String s = m_context.getShaderInfoLog(shader); + String s = m_context->getShaderInfoLog(shader); cleanupAfterGraphicsCall(false); return s; } String CanvasRenderingContext3D::getShaderSource(CanvasShader* shader) { - String s = m_context.getShaderSource(shader); + String s = m_context->getShaderSource(shader); cleanupAfterGraphicsCall(false); return s; } String CanvasRenderingContext3D::getString(unsigned long name) { - return m_context.getString(name); + return m_context->getString(name); } float CanvasRenderingContext3D::getTexParameterf(unsigned long target, unsigned long pname) { - float result = m_context.getTexParameterf(target, pname); + float result = m_context->getTexParameterf(target, pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasFloatArray> CanvasRenderingContext3D::getTexParameterfv(unsigned long target, unsigned long pname) { - RefPtr<CanvasFloatArray> array = m_context.getTexParameterfv(target, pname); + RefPtr<CanvasFloatArray> array = m_context->getTexParameterfv(target, pname); cleanupAfterGraphicsCall(false); return array; } int CanvasRenderingContext3D::getTexParameteri(unsigned long target, unsigned long pname) { - int result = m_context.getTexParameteri(target, pname); + int result = m_context->getTexParameteri(target, pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getTexParameteriv(unsigned long target, unsigned long pname) { - RefPtr<CanvasIntArray> array = m_context.getTexParameteriv(target, pname); + RefPtr<CanvasIntArray> array = m_context->getTexParameteriv(target, pname); cleanupAfterGraphicsCall(false); return array; } float CanvasRenderingContext3D::getUniformf(CanvasProgram* program, long location) { - float result = m_context.getUniformf(program, location); + float result = m_context->getUniformf(program, location); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasFloatArray> CanvasRenderingContext3D::getUniformfv(CanvasProgram* program, long location) { - RefPtr<CanvasFloatArray> array = m_context.getUniformfv(program, location); + RefPtr<CanvasFloatArray> array = m_context->getUniformfv(program, location); cleanupAfterGraphicsCall(false); return array; } long CanvasRenderingContext3D::getUniformi(CanvasProgram* program, long location) { - long result = m_context.getUniformi(program, location); + long result = m_context->getUniformi(program, location); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getUniformiv(CanvasProgram* program, long location) { - RefPtr<CanvasIntArray> array = m_context.getUniformiv(program, location); + RefPtr<CanvasIntArray> array = m_context->getUniformiv(program, location); cleanupAfterGraphicsCall(false); return array; } long CanvasRenderingContext3D::getUniformLocation(CanvasProgram* program, const String& name) { - return m_context.getUniformLocation(program, name); + return m_context->getUniformLocation(program, name); } float CanvasRenderingContext3D::getVertexAttribf(unsigned long index, unsigned long pname) { - float result = m_context.getVertexAttribf(index, pname); + float result = m_context->getVertexAttribf(index, pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasFloatArray> CanvasRenderingContext3D::getVertexAttribfv(unsigned long index, unsigned long pname) { - RefPtr<CanvasFloatArray> array = m_context.getVertexAttribfv(index, pname); + RefPtr<CanvasFloatArray> array = m_context->getVertexAttribfv(index, pname); cleanupAfterGraphicsCall(false); return array; } long CanvasRenderingContext3D::getVertexAttribi(unsigned long index, unsigned long pname) { - long result = m_context.getVertexAttribi(index, pname); + long result = m_context->getVertexAttribi(index, pname); cleanupAfterGraphicsCall(false); return result; } PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getVertexAttribiv(unsigned long index, unsigned long pname) { - RefPtr<CanvasIntArray> array = m_context.getVertexAttribiv(index, pname); + RefPtr<CanvasIntArray> array = m_context->getVertexAttribiv(index, pname); cleanupAfterGraphicsCall(false); return array; } long CanvasRenderingContext3D::getVertexAttribOffset(unsigned long index, unsigned long pname) { - long result = m_context.getVertexAttribOffset(index, pname); + long result = m_context->getVertexAttribOffset(index, pname); cleanupAfterGraphicsCall(false); return result; } void CanvasRenderingContext3D::hint(unsigned long target, unsigned long mode) { - m_context.hint(target, mode); + m_context->hint(target, mode); cleanupAfterGraphicsCall(false); } @@ -732,42 +765,42 @@ bool CanvasRenderingContext3D::isBuffer(CanvasBuffer* buffer) if (!buffer) return false; - return m_context.isBuffer(buffer); + return m_context->isBuffer(buffer); } bool CanvasRenderingContext3D::isEnabled(unsigned long cap) { - return m_context.isEnabled(cap); + return m_context->isEnabled(cap); } bool CanvasRenderingContext3D::isFramebuffer(CanvasFramebuffer* framebuffer) { - return m_context.isFramebuffer(framebuffer); + return m_context->isFramebuffer(framebuffer); } bool CanvasRenderingContext3D::isProgram(CanvasProgram* program) { - return m_context.isProgram(program); + return m_context->isProgram(program); } bool CanvasRenderingContext3D::isRenderbuffer(CanvasRenderbuffer* renderbuffer) { - return m_context.isRenderbuffer(renderbuffer); + return m_context->isRenderbuffer(renderbuffer); } bool CanvasRenderingContext3D::isShader(CanvasShader* shader) { - return m_context.isShader(shader); + return m_context->isShader(shader); } bool CanvasRenderingContext3D::isTexture(CanvasTexture* texture) { - return m_context.isTexture(texture); + return m_context->isTexture(texture); } void CanvasRenderingContext3D::lineWidth(double width) { - m_context.lineWidth((float) width); + m_context->lineWidth((float) width); cleanupAfterGraphicsCall(false); } @@ -776,85 +809,92 @@ void CanvasRenderingContext3D::linkProgram(CanvasProgram* program) if (!program) return; - m_context.linkProgram(program); + m_context->linkProgram(program); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::pixelStorei(unsigned long pname, long param) { - m_context.pixelStorei(pname, param); + m_context->pixelStorei(pname, param); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::polygonOffset(double factor, double units) { - m_context.polygonOffset((float) factor, (float) units); + m_context->polygonOffset((float) factor, (float) units); cleanupAfterGraphicsCall(false); } +PassRefPtr<CanvasArray> CanvasRenderingContext3D::readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type) +{ + RefPtr<CanvasArray> array = m_context->readPixels(x, y, width, height, format, type); + cleanupAfterGraphicsCall(false); + return array; +} + void CanvasRenderingContext3D::releaseShaderCompiler() { - m_context.releaseShaderCompiler(); + m_context->releaseShaderCompiler(); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height) { - m_context.renderbufferStorage(target, internalformat, width, height); + m_context->renderbufferStorage(target, internalformat, width, height); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::sampleCoverage(double value, bool invert) { - m_context.sampleCoverage((float) value, invert); + m_context->sampleCoverage((float) value, invert); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::scissor(long x, long y, unsigned long width, unsigned long height) { - m_context.scissor(x, y, width, height); + m_context->scissor(x, y, width, height); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::shaderSource(CanvasShader* shader, const String& string) { - m_context.shaderSource(shader, string); + m_context->shaderSource(shader, string); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::stencilFunc(unsigned long func, long ref, unsigned long mask) { - m_context.stencilFunc(func, ref, mask); + m_context->stencilFunc(func, ref, mask); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask) { - m_context.stencilFuncSeparate(face, func, ref, mask); + m_context->stencilFuncSeparate(face, func, ref, mask); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::stencilMask(unsigned long mask) { - m_context.stencilMask(mask); + m_context->stencilMask(mask); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::stencilMaskSeparate(unsigned long face, unsigned long mask) { - m_context.stencilMaskSeparate(face, mask); + m_context->stencilMaskSeparate(face, mask); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass) { - m_context.stencilOp(fail, zfail, zpass); + m_context->stencilOp(fail, zfail, zpass); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass) { - m_context.stencilOpSeparate(face, fail, zfail, zpass); + m_context->stencilOpSeparate(face, fail, zfail, zpass); cleanupAfterGraphicsCall(false); } @@ -864,7 +904,7 @@ void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, unsig { // FIXME: For now we ignore any errors returned ec = 0; - m_context.texImage2D(target, level, internalformat, width, height, + m_context->texImage2D(target, level, internalformat, width, height, border, format, type, pixels); cleanupAfterGraphicsCall(false); } @@ -875,7 +915,7 @@ void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, unsig { // FIXME: For now we ignore any errors returned ec = 0; - m_context.texImage2D(target, level, internalformat, width, height, + m_context->texImage2D(target, level, internalformat, width, height, border, format, type, pixels); cleanupAfterGraphicsCall(false); } @@ -885,7 +925,7 @@ void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, HTMLI { // FIXME: For now we ignore any errors returned ec = 0; - m_context.texImage2D(target, level, image, flipY, premultiplyAlpha); + m_context->texImage2D(target, level, image, flipY, premultiplyAlpha); cleanupAfterGraphicsCall(false); } @@ -894,7 +934,7 @@ void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, HTMLC { // FIXME: For now we ignore any errors returned ec = 0; - m_context.texImage2D(target, level, canvas, flipY, premultiplyAlpha); + m_context->texImage2D(target, level, canvas, flipY, premultiplyAlpha); cleanupAfterGraphicsCall(false); } @@ -903,19 +943,19 @@ void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, HTMLV { // FIXME: For now we ignore any errors returned ec = 0; - m_context.texImage2D(target, level, video, flipY, premultiplyAlpha); + m_context->texImage2D(target, level, video, flipY, premultiplyAlpha); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::texParameterf(unsigned target, unsigned pname, float param) { - m_context.texParameterf(target, pname, param); + m_context->texParameterf(target, pname, param); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::texParameteri(unsigned target, unsigned pname, int param) { - m_context.texParameteri(target, pname, param); + m_context->texParameteri(target, pname, param); cleanupAfterGraphicsCall(false); } @@ -925,7 +965,7 @@ void CanvasRenderingContext3D::texSubImage2D(unsigned target, unsigned level, un { // FIXME: For now we ignore any errors returned ec = 0; - m_context.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); cleanupAfterGraphicsCall(false); } @@ -935,7 +975,7 @@ void CanvasRenderingContext3D::texSubImage2D(unsigned target, unsigned level, un { // FIXME: For now we ignore any errors returned ec = 0; - m_context.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); cleanupAfterGraphicsCall(false); } @@ -945,7 +985,7 @@ void CanvasRenderingContext3D::texSubImage2D(unsigned target, unsigned level, un { // FIXME: For now we ignore any errors returned ec = 0; - m_context.texSubImage2D(target, level, xoffset, yoffset, width, height, image, flipY, premultiplyAlpha); + m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, image, flipY, premultiplyAlpha); cleanupAfterGraphicsCall(false); } @@ -955,7 +995,7 @@ void CanvasRenderingContext3D::texSubImage2D(unsigned target, unsigned level, un { // FIXME: For now we ignore any errors returned ec = 0; - m_context.texSubImage2D(target, level, xoffset, yoffset, width, height, canvas, flipY, premultiplyAlpha); + m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, canvas, flipY, premultiplyAlpha); cleanupAfterGraphicsCall(false); } @@ -965,13 +1005,13 @@ void CanvasRenderingContext3D::texSubImage2D(unsigned target, unsigned level, un { // FIXME: For now we ignore any errors returned ec = 0; - m_context.texSubImage2D(target, level, xoffset, yoffset, width, height, video, flipY, premultiplyAlpha); + m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, video, flipY, premultiplyAlpha); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::uniform1f(long location, float x) { - m_context.uniform1f(location, x); + m_context->uniform1f(location, x); cleanupAfterGraphicsCall(false); } @@ -981,7 +1021,7 @@ void CanvasRenderingContext3D::uniform1fv(long location, CanvasFloatArray* v) if (!v) return; - m_context.uniform1fv(location, v->data(), v->length()); + m_context->uniform1fv(location, v->data(), v->length()); cleanupAfterGraphicsCall(false); } @@ -991,13 +1031,13 @@ void CanvasRenderingContext3D::uniform1fv(long location, float* v, int size) if (!v) return; - m_context.uniform1fv(location, v, size); + m_context->uniform1fv(location, v, size); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::uniform1i(long location, int x) { - m_context.uniform1i(location, x); + m_context->uniform1i(location, x); cleanupAfterGraphicsCall(false); } @@ -1007,7 +1047,7 @@ void CanvasRenderingContext3D::uniform1iv(long location, CanvasIntArray* v) if (!v) return; - m_context.uniform1iv(location, v->data(), v->length()); + m_context->uniform1iv(location, v->data(), v->length()); cleanupAfterGraphicsCall(false); } @@ -1017,13 +1057,13 @@ void CanvasRenderingContext3D::uniform1iv(long location, int* v, int size) if (!v) return; - m_context.uniform1iv(location, v, size); + m_context->uniform1iv(location, v, size); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::uniform2f(long location, float x, float y) { - m_context.uniform2f(location, x, y); + m_context->uniform2f(location, x, y); cleanupAfterGraphicsCall(false); } @@ -1034,7 +1074,7 @@ void CanvasRenderingContext3D::uniform2fv(long location, CanvasFloatArray* v) return; // FIXME: length needs to be a multiple of 2 - m_context.uniform2fv(location, v->data(), v->length() / 2); + m_context->uniform2fv(location, v->data(), v->length() / 2); cleanupAfterGraphicsCall(false); } @@ -1045,13 +1085,13 @@ void CanvasRenderingContext3D::uniform2fv(long location, float* v, int size) return; // FIXME: length needs to be a multiple of 2 - m_context.uniform2fv(location, v, size / 2); + m_context->uniform2fv(location, v, size / 2); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::uniform2i(long location, int x, int y) { - m_context.uniform2i(location, x, y); + m_context->uniform2i(location, x, y); cleanupAfterGraphicsCall(false); } @@ -1062,7 +1102,7 @@ void CanvasRenderingContext3D::uniform2iv(long location, CanvasIntArray* v) return; // FIXME: length needs to be a multiple of 2 - m_context.uniform2iv(location, v->data(), v->length() / 2); + m_context->uniform2iv(location, v->data(), v->length() / 2); cleanupAfterGraphicsCall(false); } @@ -1073,13 +1113,13 @@ void CanvasRenderingContext3D::uniform2iv(long location, int* v, int size) return; // FIXME: length needs to be a multiple of 2 - m_context.uniform2iv(location, v, size / 2); + m_context->uniform2iv(location, v, size / 2); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::uniform3f(long location, float x, float y, float z) { - m_context.uniform3f(location, x, y, z); + m_context->uniform3f(location, x, y, z); cleanupAfterGraphicsCall(false); } @@ -1090,7 +1130,7 @@ void CanvasRenderingContext3D::uniform3fv(long location, CanvasFloatArray* v) return; // FIXME: length needs to be a multiple of 3 - m_context.uniform3fv(location, v->data(), v->length() / 3); + m_context->uniform3fv(location, v->data(), v->length() / 3); cleanupAfterGraphicsCall(false); } @@ -1101,13 +1141,13 @@ void CanvasRenderingContext3D::uniform3fv(long location, float* v, int size) return; // FIXME: length needs to be a multiple of 3 - m_context.uniform3fv(location, v, size / 3); + m_context->uniform3fv(location, v, size / 3); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::uniform3i(long location, int x, int y, int z) { - m_context.uniform3i(location, x, y, z); + m_context->uniform3i(location, x, y, z); cleanupAfterGraphicsCall(false); } @@ -1118,7 +1158,7 @@ void CanvasRenderingContext3D::uniform3iv(long location, CanvasIntArray* v) return; // FIXME: length needs to be a multiple of 3 - m_context.uniform3iv(location, v->data(), v->length() / 3); + m_context->uniform3iv(location, v->data(), v->length() / 3); cleanupAfterGraphicsCall(false); } @@ -1129,13 +1169,13 @@ void CanvasRenderingContext3D::uniform3iv(long location, int* v, int size) return; // FIXME: length needs to be a multiple of 3 - m_context.uniform3iv(location, v, size / 3); + m_context->uniform3iv(location, v, size / 3); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::uniform4f(long location, float x, float y, float z, float w) { - m_context.uniform4f(location, x, y, z, w); + m_context->uniform4f(location, x, y, z, w); cleanupAfterGraphicsCall(false); } @@ -1146,7 +1186,7 @@ void CanvasRenderingContext3D::uniform4fv(long location, CanvasFloatArray* v) return; // FIXME: length needs to be a multiple of 4 - m_context.uniform4fv(location, v->data(), v->length() / 4); + m_context->uniform4fv(location, v->data(), v->length() / 4); cleanupAfterGraphicsCall(false); } @@ -1157,13 +1197,13 @@ void CanvasRenderingContext3D::uniform4fv(long location, float* v, int size) return; // FIXME: length needs to be a multiple of 4 - m_context.uniform4fv(location, v, size / 4); + m_context->uniform4fv(location, v, size / 4); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::uniform4i(long location, int x, int y, int z, int w) { - m_context.uniform4i(location, x, y, z, w); + m_context->uniform4i(location, x, y, z, w); cleanupAfterGraphicsCall(false); } @@ -1174,7 +1214,7 @@ void CanvasRenderingContext3D::uniform4iv(long location, CanvasIntArray* v) return; // FIXME: length needs to be a multiple of 4 - m_context.uniform4iv(location, v->data(), v->length() / 4); + m_context->uniform4iv(location, v->data(), v->length() / 4); cleanupAfterGraphicsCall(false); } @@ -1185,7 +1225,7 @@ void CanvasRenderingContext3D::uniform4iv(long location, int* v, int size) return; // FIXME: length needs to be a multiple of 4 - m_context.uniform4iv(location, v, size / 4); + m_context->uniform4iv(location, v, size / 4); cleanupAfterGraphicsCall(false); } @@ -1196,7 +1236,7 @@ void CanvasRenderingContext3D::uniformMatrix2fv(long location, bool transpose, C return; // FIXME: length needs to be a multiple of 4 - m_context.uniformMatrix2fv(location, transpose, v->data(), v->length() / 4); + m_context->uniformMatrix2fv(location, transpose, v->data(), v->length() / 4); cleanupAfterGraphicsCall(false); } @@ -1207,7 +1247,7 @@ void CanvasRenderingContext3D::uniformMatrix2fv(long location, bool transpose, f return; // FIXME: length needs to be a multiple of 4 - m_context.uniformMatrix2fv(location, transpose, v, size / 4); + m_context->uniformMatrix2fv(location, transpose, v, size / 4); cleanupAfterGraphicsCall(false); } @@ -1218,7 +1258,7 @@ void CanvasRenderingContext3D::uniformMatrix3fv(long location, bool transpose, C return; // FIXME: length needs to be a multiple of 9 - m_context.uniformMatrix3fv(location, transpose, v->data(), v->length() / 9); + m_context->uniformMatrix3fv(location, transpose, v->data(), v->length() / 9); cleanupAfterGraphicsCall(false); } @@ -1229,7 +1269,7 @@ void CanvasRenderingContext3D::uniformMatrix3fv(long location, bool transpose, f return; // FIXME: length needs to be a multiple of 9 - m_context.uniformMatrix3fv(location, transpose, v, size / 9); + m_context->uniformMatrix3fv(location, transpose, v, size / 9); cleanupAfterGraphicsCall(false); } @@ -1240,7 +1280,7 @@ void CanvasRenderingContext3D::uniformMatrix4fv(long location, bool transpose, C return; // FIXME: length needs to be a multiple of 16 - m_context.uniformMatrix4fv(location, transpose, v->data(), v->length() / 16); + m_context->uniformMatrix4fv(location, transpose, v->data(), v->length() / 16); cleanupAfterGraphicsCall(false); } @@ -1251,32 +1291,32 @@ void CanvasRenderingContext3D::uniformMatrix4fv(long location, bool transpose, f return; // FIXME: length needs to be a multiple of 16 - m_context.uniformMatrix4fv(location, transpose, v, size / 16); + m_context->uniformMatrix4fv(location, transpose, v, size / 16); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::useProgram(CanvasProgram* program) { - m_context.useProgram(program); + m_context->useProgram(program); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::validateProgram(CanvasProgram* program) { - m_context.validateProgram(program); + m_context->validateProgram(program); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::vertexAttrib1f(unsigned long indx, float v0) { - m_context.vertexAttrib1f(indx, v0); + m_context->vertexAttrib1f(indx, v0); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::vertexAttrib1fv(unsigned long indx, CanvasFloatArray* v) { // FIXME: Need to make sure array is big enough for attribute being set - m_context.vertexAttrib1fv(indx, v->data()); + m_context->vertexAttrib1fv(indx, v->data()); cleanupAfterGraphicsCall(false); } @@ -1285,20 +1325,20 @@ void CanvasRenderingContext3D::vertexAttrib1fv(unsigned long indx, float* v, int // FIXME: Need to make sure array is big enough for attribute being set UNUSED_PARAM(size); - m_context.vertexAttrib1fv(indx, v); + m_context->vertexAttrib1fv(indx, v); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::vertexAttrib2f(unsigned long indx, float v0, float v1) { - m_context.vertexAttrib2f(indx, v0, v1); + m_context->vertexAttrib2f(indx, v0, v1); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::vertexAttrib2fv(unsigned long indx, CanvasFloatArray* v) { // FIXME: Need to make sure array is big enough for attribute being set - m_context.vertexAttrib2fv(indx, v->data()); + m_context->vertexAttrib2fv(indx, v->data()); cleanupAfterGraphicsCall(false); } @@ -1307,20 +1347,20 @@ void CanvasRenderingContext3D::vertexAttrib2fv(unsigned long indx, float* v, int // FIXME: Need to make sure array is big enough for attribute being set UNUSED_PARAM(size); - m_context.vertexAttrib2fv(indx, v); + m_context->vertexAttrib2fv(indx, v); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::vertexAttrib3f(unsigned long indx, float v0, float v1, float v2) { - m_context.vertexAttrib3f(indx, v0, v1, v2); + m_context->vertexAttrib3f(indx, v0, v1, v2); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::vertexAttrib3fv(unsigned long indx, CanvasFloatArray* v) { // FIXME: Need to make sure array is big enough for attribute being set - m_context.vertexAttrib3fv(indx, v->data()); + m_context->vertexAttrib3fv(indx, v->data()); cleanupAfterGraphicsCall(false); } @@ -1329,20 +1369,20 @@ void CanvasRenderingContext3D::vertexAttrib3fv(unsigned long indx, float* v, int // FIXME: Need to make sure array is big enough for attribute being set UNUSED_PARAM(size); - m_context.vertexAttrib3fv(indx, v); + m_context->vertexAttrib3fv(indx, v); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::vertexAttrib4f(unsigned long indx, float v0, float v1, float v2, float v3) { - m_context.vertexAttrib4f(indx, v0, v1, v2, v3); + m_context->vertexAttrib4f(indx, v0, v1, v2, v3); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::vertexAttrib4fv(unsigned long indx, CanvasFloatArray* v) { // FIXME: Need to make sure array is big enough for attribute being set - m_context.vertexAttrib4fv(indx, v->data()); + m_context->vertexAttrib4fv(indx, v->data()); cleanupAfterGraphicsCall(false); } @@ -1351,13 +1391,13 @@ void CanvasRenderingContext3D::vertexAttrib4fv(unsigned long indx, float* v, int // FIXME: Need to make sure array is big enough for attribute being set UNUSED_PARAM(size); - m_context.vertexAttrib4fv(indx, v); + m_context->vertexAttrib4fv(indx, v); cleanupAfterGraphicsCall(false); } void CanvasRenderingContext3D::vertexAttribPointer(unsigned long indx, long size, unsigned long type, bool normalized, unsigned long stride, unsigned long offset) { - m_context.vertexAttribPointer(indx, size, type, normalized, stride, offset); + m_context->vertexAttribPointer(indx, size, type, normalized, stride, offset); cleanupAfterGraphicsCall(false); } @@ -1371,7 +1411,7 @@ void CanvasRenderingContext3D::viewport(long x, long y, unsigned long width, uns width = 100; if (isnan(height)) height = 100; - m_context.viewport(x, y, width, height); + m_context->viewport(x, y, width, height); cleanupAfterGraphicsCall(false); } diff --git a/WebCore/html/canvas/CanvasRenderingContext3D.h b/WebCore/html/canvas/CanvasRenderingContext3D.h index a4a68fc..70d9b95 100644 --- a/WebCore/html/canvas/CanvasRenderingContext3D.h +++ b/WebCore/html/canvas/CanvasRenderingContext3D.h @@ -36,6 +36,7 @@ namespace WebCore { +class CanvasActiveInfo; class CanvasBuffer; class CanvasFramebuffer; class CanvasObject; @@ -50,8 +51,8 @@ class WebKitCSSMatrix; class CanvasRenderingContext3D : public CanvasRenderingContext { public: - CanvasRenderingContext3D(HTMLCanvasElement*); - ~CanvasRenderingContext3D(); + static PassOwnPtr<CanvasRenderingContext3D> create(HTMLCanvasElement*); + virtual ~CanvasRenderingContext3D(); virtual bool is3d() const { return true; } @@ -123,7 +124,10 @@ class WebKitCSSMatrix; void framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, CanvasTexture*, long level); void frontFace(unsigned long mode); void generateMipmap(unsigned long target); - + + PassRefPtr<CanvasActiveInfo> getActiveAttrib(CanvasProgram*, unsigned long index, ExceptionCode&); + PassRefPtr<CanvasActiveInfo> getActiveUniform(CanvasProgram*, unsigned long index, ExceptionCode&); + int getAttribLocation(CanvasProgram*, const String& name); bool getBoolean(unsigned long pname); @@ -187,8 +191,7 @@ class WebKitCSSMatrix; void pixelStorei(unsigned long pname, long param); void polygonOffset(double factor, double units); - // TBD - //void readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type, void* pixels); + PassRefPtr<CanvasArray> readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type); void releaseShaderCompiler(); void renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height); @@ -285,7 +288,7 @@ class WebKitCSSMatrix; void viewport(long x, long y, unsigned long width, unsigned long height); - GraphicsContext3D* graphicsContext3D() { return &m_context; } + GraphicsContext3D* graphicsContext3D() const { return m_context.get(); } void reshape(int width, int height); @@ -297,18 +300,21 @@ class WebKitCSSMatrix; private: friend class CanvasObject; + + CanvasRenderingContext3D(HTMLCanvasElement*, PassOwnPtr<GraphicsContext3D>); + void addObject(CanvasObject*); void detachAndRemoveAllObjects(); void markContextChanged(); void cleanupAfterGraphicsCall(bool changed) { - m_context.checkError(); + m_context->checkError(); if (changed) markContextChanged(); } - GraphicsContext3D m_context; + OwnPtr<GraphicsContext3D> m_context; bool m_needsUpdate; bool m_markedCanvasDirty; // FIXME: I think this is broken -- it does not increment any diff --git a/WebCore/html/canvas/CanvasRenderingContext3D.idl b/WebCore/html/canvas/CanvasRenderingContext3D.idl index 4b9a889..db0fff3 100644 --- a/WebCore/html/canvas/CanvasRenderingContext3D.idl +++ b/WebCore/html/canvas/CanvasRenderingContext3D.idl @@ -530,8 +530,11 @@ module html { void generateMipmap(in unsigned long target); // FIXME: these need to be added per the WebGL spec - // CanvasActiveInfo getActiveAttrib(GLuint program, GLuint index); - // CanvasActiveInfo getActiveUniform(GLuint program, GLuint index); + CanvasActiveInfo getActiveAttrib(in CanvasProgram program, in unsigned long index) + raises (DOMException); + CanvasActiveInfo getActiveUniform(in CanvasProgram program, in unsigned long index) + raises (DOMException); + // CanvasShaderArray glGetAttachedShaders(GLuint program); int getAttribLocation(in CanvasProgram program, in DOMString name); @@ -597,8 +600,7 @@ module html { void pixelStorei(in unsigned long pname, in long param); void polygonOffset(in double factor, in double units); - // FIXME - //void readPixels(in long x, in long y, in unsigned long width, in unsigned long height, in unsigned long format, in unsigned long type, void* pixels); + CanvasArray readPixels(in long x, in long y, in unsigned long width, in unsigned long height, in unsigned long format, in unsigned long type); void releaseShaderCompiler(); void renderbufferStorage(in unsigned long target, in unsigned long internalformat, in unsigned long width, in unsigned long height); diff --git a/WebCore/html/canvas/CanvasShortArray.h b/WebCore/html/canvas/CanvasShortArray.h index 00a170f..1eeef0c 100644 --- a/WebCore/html/canvas/CanvasShortArray.h +++ b/WebCore/html/canvas/CanvasShortArray.h @@ -36,6 +36,8 @@ namespace WebCore { class CanvasShortArray : public CanvasArray { public: + virtual bool isShortArray() const { return true; } + static PassRefPtr<CanvasShortArray> create(unsigned length); static PassRefPtr<CanvasShortArray> create(short* array, unsigned length); static PassRefPtr<CanvasShortArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length); diff --git a/WebCore/html/canvas/CanvasUnsignedByteArray.h b/WebCore/html/canvas/CanvasUnsignedByteArray.h index 6293034..d8864e0 100644 --- a/WebCore/html/canvas/CanvasUnsignedByteArray.h +++ b/WebCore/html/canvas/CanvasUnsignedByteArray.h @@ -36,6 +36,8 @@ namespace WebCore { class CanvasUnsignedByteArray : public CanvasArray { public: + virtual bool isUnsignedByteArray() const { return true; } + static PassRefPtr<CanvasUnsignedByteArray> create(unsigned length); static PassRefPtr<CanvasUnsignedByteArray> create(unsigned char* array, unsigned length); static PassRefPtr<CanvasUnsignedByteArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length); diff --git a/WebCore/html/canvas/CanvasUnsignedIntArray.h b/WebCore/html/canvas/CanvasUnsignedIntArray.h index 5b5994c..10b8edf 100644 --- a/WebCore/html/canvas/CanvasUnsignedIntArray.h +++ b/WebCore/html/canvas/CanvasUnsignedIntArray.h @@ -36,6 +36,8 @@ namespace WebCore { class CanvasUnsignedIntArray : public CanvasArray { public: + virtual bool isUnsignedIntArray() const { return true; } + static PassRefPtr<CanvasUnsignedIntArray> create(unsigned length); static PassRefPtr<CanvasUnsignedIntArray> create(unsigned int* array, unsigned length); static PassRefPtr<CanvasUnsignedIntArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length); diff --git a/WebCore/html/canvas/CanvasUnsignedShortArray.h b/WebCore/html/canvas/CanvasUnsignedShortArray.h index 1f6252e..9e27566 100644 --- a/WebCore/html/canvas/CanvasUnsignedShortArray.h +++ b/WebCore/html/canvas/CanvasUnsignedShortArray.h @@ -36,6 +36,8 @@ namespace WebCore { class CanvasUnsignedShortArray : public CanvasArray { public: + virtual bool isUnsignedShortArray() const { return true; } + static PassRefPtr<CanvasUnsignedShortArray> create(unsigned length); static PassRefPtr<CanvasUnsignedShortArray> create(unsigned short* array, unsigned length); static PassRefPtr<CanvasUnsignedShortArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length); |