diff options
author | Ben Murdoch <benm@google.com> | 2010-10-22 13:02:20 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-10-26 15:21:41 +0100 |
commit | a94275402997c11dd2e778633dacf4b7e630a35d (patch) | |
tree | e66f56c67e3b01f22c9c23cd932271ee9ac558ed /WebCore/html/canvas | |
parent | 09e26c78506587b3f5d930d7bc72a23287ffbec0 (diff) | |
download | external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.zip external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.gz external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.bz2 |
Merge WebKit at r70209: Initial merge by Git
Change-Id: Id23a68efa36e9d1126bcce0b137872db00892c8e
Diffstat (limited to 'WebCore/html/canvas')
29 files changed, 218 insertions, 102 deletions
diff --git a/WebCore/html/canvas/ArrayBuffer.cpp b/WebCore/html/canvas/ArrayBuffer.cpp index 3b204ff..014cc1e 100644 --- a/WebCore/html/canvas/ArrayBuffer.cpp +++ b/WebCore/html/canvas/ArrayBuffer.cpp @@ -25,7 +25,7 @@ #include "config.h" -#if ENABLE(3D_CANVAS) +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) #include "ArrayBuffer.h" @@ -93,4 +93,4 @@ void* ArrayBuffer::tryAllocate(unsigned numElements, unsigned elementByteSize) } -#endif // ENABLE(3D_CANVAS) +#endif // ENABLE(3D_CANVAS) || ENABLE(BLOB) diff --git a/WebCore/html/canvas/ArrayBuffer.idl b/WebCore/html/canvas/ArrayBuffer.idl index 92098e5..79a4685 100644 --- a/WebCore/html/canvas/ArrayBuffer.idl +++ b/WebCore/html/canvas/ArrayBuffer.idl @@ -26,10 +26,11 @@ module html { interface [ - Conditional=3D_CANVAS, + Conditional=3D_CANVAS|BLOB, CanBeConstructed, CustomConstructFunction, - V8CustomConstructor + NoStaticTables, + V8CustomConstructor, ] ArrayBuffer { readonly attribute int byteLength; }; diff --git a/WebCore/html/canvas/ArrayBufferView.cpp b/WebCore/html/canvas/ArrayBufferView.cpp index 485d18b..7f41bda 100644 --- a/WebCore/html/canvas/ArrayBufferView.cpp +++ b/WebCore/html/canvas/ArrayBufferView.cpp @@ -25,7 +25,7 @@ #include "config.h" -#if ENABLE(3D_CANVAS) +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) #include "ArrayBufferView.h" @@ -106,4 +106,4 @@ void ArrayBufferView::calculateOffsetAndLength(int start, int end, unsigned arra } -#endif // ENABLE(3D_CANVAS) +#endif // ENABLE(3D_CANVAS) || ENABLE(BLOB) diff --git a/WebCore/html/canvas/ArrayBufferView.idl b/WebCore/html/canvas/ArrayBufferView.idl index 450345e..74a3fe3 100644 --- a/WebCore/html/canvas/ArrayBufferView.idl +++ b/WebCore/html/canvas/ArrayBufferView.idl @@ -24,7 +24,7 @@ */ module html { - interface [Conditional=3D_CANVAS, CustomToJS, OmitConstructor] ArrayBufferView { + interface [Conditional=3D_CANVAS|BLOB, CustomToJS, NoStaticTables, OmitConstructor] ArrayBufferView { readonly attribute ArrayBuffer buffer; readonly attribute unsigned long byteOffset; readonly attribute unsigned long byteLength; diff --git a/WebCore/html/canvas/CanvasGradient.cpp b/WebCore/html/canvas/CanvasGradient.cpp index fd48194..7c98a82 100644 --- a/WebCore/html/canvas/CanvasGradient.cpp +++ b/WebCore/html/canvas/CanvasGradient.cpp @@ -27,6 +27,8 @@ #include "config.h" #include "CanvasGradient.h" +#include "CanvasPattern.h" +#include "CanvasStyle.h" #include "CSSParser.h" #include "ExceptionCode.h" @@ -52,7 +54,7 @@ void CanvasGradient::addColorStop(float value, const String& color, ExceptionCod } RGBA32 rgba = 0; - if (!CSSParser::parseColor(rgba, color)) { + if (!parseColorOrCurrentColor(rgba, color, 0 /*canvas*/)) { if (!m_dashbardCompatibilityMode) ec = SYNTAX_ERR; return; diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp index 161a891..b1d7b23 100644 --- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp +++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp @@ -128,10 +128,10 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bo return; if (!p->settings()->accelerated2dCanvasEnabled()) return; - m_context3D = p->chrome()->client()->getSharedGraphicsContext3D(); - if (m_context3D) { - if (GraphicsContext* c = drawingContext()) { - m_drawingBuffer = DrawingBuffer::create(m_context3D.get(), IntSize(canvas->width(), canvas->height())); + if (GraphicsContext* c = drawingContext()) { + m_context3D = p->sharedGraphicsContext3D(); + if (m_context3D) { + m_drawingBuffer = m_context3D->graphicsContext3D()->createDrawingBuffer(IntSize(canvas->width(), canvas->height())); c->setSharedGraphicsContext3D(m_context3D.get(), m_drawingBuffer.get(), IntSize(canvas->width(), canvas->height())); } } @@ -167,8 +167,8 @@ void CanvasRenderingContext2D::reset() m_stateStack.first() = State(); m_path.clear(); #if ENABLE(ACCELERATED_2D_CANVAS) - if (m_context3D) { - if (GraphicsContext* c = drawingContext()) { + if (GraphicsContext* c = drawingContext()) { + if (m_context3D) { m_drawingBuffer->reset(IntSize(canvas()->width(), canvas()->height())); c->setSharedGraphicsContext3D(m_context3D.get(), m_drawingBuffer.get(), IntSize(canvas()->width(), canvas()->height())); } @@ -231,7 +231,7 @@ void CanvasRenderingContext2D::setAllAttributesToDefault() if (!context) return; - context->setShadow(FloatSize(), 0, Color::transparent, DeviceColorSpace); + context->setShadow(FloatSize(), 0, Color::transparent, ColorSpaceDeviceRGB); context->setAlpha(1); context->setCompositeOperation(CompositeSourceOver); } @@ -249,7 +249,13 @@ void CanvasRenderingContext2D::setStrokeStyle(PassRefPtr<CanvasStyle> style) if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentColor(*style)) return; - checkOrigin(style->canvasPattern()); + if (style->isCurrentColor()) { + if (style->hasOverrideAlpha()) + style = CanvasStyle::createFromRGBA(colorWithOverrideAlpha(currentColor(canvas()), style->overrideAlpha())); + else + style = CanvasStyle::createFromRGBA(currentColor(canvas())); + } else + checkOrigin(style->canvasPattern()); state().m_strokeStyle = style; GraphicsContext* c = drawingContext(); @@ -272,7 +278,13 @@ void CanvasRenderingContext2D::setFillStyle(PassRefPtr<CanvasStyle> style) if (state().m_fillStyle && state().m_fillStyle->isEquivalentColor(*style)) return; - checkOrigin(style->canvasPattern()); + if (style->isCurrentColor()) { + if (style->hasOverrideAlpha()) + style = CanvasStyle::createFromRGBA(colorWithOverrideAlpha(currentColor(canvas()), style->overrideAlpha())); + else + style = CanvasStyle::createFromRGBA(currentColor(canvas())); + } else + checkOrigin(style->canvasPattern()); state().m_fillStyle = style; GraphicsContext* c = drawingContext(); @@ -394,7 +406,7 @@ String CanvasRenderingContext2D::shadowColor() const void CanvasRenderingContext2D::setShadowColor(const String& color) { - if (!CSSParser::parseColor(state().m_shadowColor, color)) + if (!parseColorOrCurrentColor(state().m_shadowColor, color, canvas())) return; applyShadow(); @@ -982,7 +994,7 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur) void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& color) { - if (!CSSParser::parseColor(state().m_shadowColor, color)) + if (!parseColorOrCurrentColor(state().m_shadowColor, color, canvas())) return; state().m_shadowOffset = FloatSize(width, height); @@ -1000,14 +1012,14 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur, if (!c) return; - c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, DeviceColorSpace); + c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB); } void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& color, float alpha) { RGBA32 rgba; - if (!CSSParser::parseColor(rgba, color)) + if (!parseColorOrCurrentColor(rgba, color, canvas())) return; state().m_shadowColor = colorWithOverrideAlpha(rgba, alpha); @@ -1018,7 +1030,7 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur, if (!c) return; - c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, DeviceColorSpace); + c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB); } void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float grayLevel, float alpha) @@ -1031,7 +1043,7 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur, if (!c) return; - c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, DeviceColorSpace); + c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB); } void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float r, float g, float b, float a) @@ -1044,7 +1056,7 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur, if (!c) return; - c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, DeviceColorSpace); + c->setShadow(IntSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB); } void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float c, float m, float y, float k, float a) @@ -1064,7 +1076,7 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur, CGContextSetShadowWithColor(dc->platformContext(), adjustedShadowSize(width, -height), blur, shadowColor); CGColorRelease(shadowColor); #else - dc->setShadow(IntSize(width, -height), blur, state().m_shadowColor, DeviceColorSpace); + dc->setShadow(IntSize(width, -height), blur, state().m_shadowColor, ColorSpaceDeviceRGB); #endif } @@ -1084,7 +1096,7 @@ void CanvasRenderingContext2D::applyShadow() float width = state().m_shadowOffset.width(); float height = state().m_shadowOffset.height(); - c->setShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, DeviceColorSpace); + c->setShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB); } static IntSize size(HTMLImageElement* image) @@ -1186,7 +1198,7 @@ void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, const FloatRec FloatRect sourceRect = c->roundToDevicePixels(normalizedSrcRect); FloatRect destRect = c->roundToDevicePixels(normalizedDstRect); - c->drawImage(cachedImage->image(), DeviceColorSpace, destRect, sourceRect, state().m_globalComposite); + c->drawImage(cachedImage->image(), ColorSpaceDeviceRGB, destRect, sourceRect, state().m_globalComposite); didDraw(destRect); } @@ -1268,7 +1280,7 @@ void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas, const sourceCanvas->makeRenderingResultsAvailable(); #endif - c->drawImageBuffer(buffer, DeviceColorSpace, destRect, sourceRect, state().m_globalComposite); + c->drawImageBuffer(buffer, ColorSpaceDeviceRGB, destRect, sourceRect, state().m_globalComposite); didDraw(destRect); } @@ -1371,7 +1383,7 @@ void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement* image, op = CompositeSourceOver; FloatRect destRect = FloatRect(dx, dy, dw, dh); - c->drawImage(cachedImage->image(), DeviceColorSpace, destRect, FloatRect(sx, sy, sw, sh), op); + c->drawImage(cachedImage->image(), ColorSpaceDeviceRGB, destRect, FloatRect(sx, sy, sw, sh), op); didDraw(destRect); } @@ -1402,9 +1414,9 @@ PassRefPtr<CanvasGradient> CanvasRenderingContext2D::createLinearGradient(float return 0; } - PassRefPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0), FloatPoint(x1, y1)); + RefPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0), FloatPoint(x1, y1)); prepareGradientForDashboard(gradient.get()); - return gradient; + return gradient.release(); } PassRefPtr<CanvasGradient> CanvasRenderingContext2D::createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionCode& ec) @@ -1413,9 +1425,15 @@ PassRefPtr<CanvasGradient> CanvasRenderingContext2D::createRadialGradient(float ec = NOT_SUPPORTED_ERR; return 0; } - PassRefPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0), r0, FloatPoint(x1, y1), r1); + + if (r0 < 0 || r1 < 0) { + ec = INDEX_SIZE_ERR; + return 0; + } + + RefPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0), r0, FloatPoint(x1, y1), r1); prepareGradientForDashboard(gradient.get()); - return gradient; + return gradient.release(); } PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageElement* image, @@ -1513,7 +1531,7 @@ static PassRefPtr<ImageData> createEmptyImageData(const IntSize& size) { RefPtr<ImageData> data = ImageData::create(size.width(), size.height()); memset(data->data()->data()->data(), 0, data->data()->data()->length()); - return data.get(); + return data.release(); } PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(PassRefPtr<ImageData> imageData, ExceptionCode& ec) const @@ -1614,16 +1632,16 @@ void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy, FloatRect clipRect(dirtyX, dirtyY, dirtyWidth, dirtyHeight); clipRect.intersect(IntRect(0, 0, data->width(), data->height())); IntSize destOffset(static_cast<int>(dx), static_cast<int>(dy)); - IntRect sourceRect = enclosingIntRect(clipRect); - sourceRect.move(destOffset); - sourceRect.intersect(IntRect(IntPoint(), buffer->size())); - if (sourceRect.isEmpty()) + IntRect destRect = enclosingIntRect(clipRect); + destRect.move(destOffset); + destRect.intersect(IntRect(IntPoint(), buffer->size())); + if (destRect.isEmpty()) return; + IntRect sourceRect(destRect); sourceRect.move(-destOffset); - IntPoint destPoint(destOffset.width(), destOffset.height()); - buffer->putUnmultipliedImageData(data, sourceRect, destPoint); - didDraw(sourceRect, CanvasDidDrawApplyNone); // ignore transform, shadow and clip + buffer->putUnmultipliedImageData(data, sourceRect, IntPoint(destOffset)); + didDraw(destRect, CanvasDidDrawApplyNone); // ignore transform, shadow and clip } String CanvasRenderingContext2D::font() const @@ -1732,7 +1750,7 @@ PassRefPtr<TextMetrics> CanvasRenderingContext2D::measureText(const String& text Font::setCodePath(oldCodePath); #endif - return metrics; + return metrics.release(); } void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, bool fill, float /*maxWidth*/, bool /*useMaxWidth*/) @@ -1749,7 +1767,7 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo // FIXME: Need to turn off font smoothing. RenderStyle* computedStyle = canvas()->computedStyle(); - bool rtl = computedStyle ? computedStyle->direction() == RTL : false; + bool rtl = computedStyle ? !computedStyle->isLeftToRightDirection() : false; bool override = computedStyle ? computedStyle->unicodeBidi() == Override : false; unsigned length = text.length(); @@ -1812,9 +1830,9 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo GraphicsContext* maskImageContext = maskImage->context(); if (fill) - maskImageContext->setFillColor(Color::black, DeviceColorSpace); + maskImageContext->setFillColor(Color::black, ColorSpaceDeviceRGB); else { - maskImageContext->setStrokeColor(Color::black, DeviceColorSpace); + maskImageContext->setStrokeColor(Color::black, ColorSpaceDeviceRGB); maskImageContext->setStrokeThickness(c->strokeThickness()); } diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.h b/WebCore/html/canvas/CanvasRenderingContext2D.h index 2c88a31..f51c5e9 100644 --- a/WebCore/html/canvas/CanvasRenderingContext2D.h +++ b/WebCore/html/canvas/CanvasRenderingContext2D.h @@ -294,7 +294,7 @@ private: #endif #if ENABLE(ACCELERATED_2D_CANVAS) - OwnPtr<DrawingBuffer> m_drawingBuffer; + RefPtr<DrawingBuffer> m_drawingBuffer; RefPtr<SharedGraphicsContext3D> m_context3D; #endif }; diff --git a/WebCore/html/canvas/CanvasStyle.cpp b/WebCore/html/canvas/CanvasStyle.cpp index fd3c6e5..a4e87e3 100644 --- a/WebCore/html/canvas/CanvasStyle.cpp +++ b/WebCore/html/canvas/CanvasStyle.cpp @@ -30,9 +30,11 @@ #include "CanvasStyle.h" #include "CSSParser.h" +#include "CSSPropertyNames.h" #include "CanvasGradient.h" #include "CanvasPattern.h" #include "GraphicsContext.h" +#include "HTMLCanvasElement.h" #include <wtf/Assertions.h> #include <wtf/PassRefPtr.h> @@ -49,6 +51,49 @@ namespace WebCore { +enum ColorParseResult { ParsedRGBA, ParsedCurrentColor, ParseFailed }; + +static ColorParseResult parseColor(RGBA32& parsedColor, const String& colorString) +{ + if (equalIgnoringCase(colorString, "currentcolor")) + return ParsedCurrentColor; + if (CSSParser::parseColor(parsedColor, colorString)) + return ParsedRGBA; + return ParseFailed; +} + +RGBA32 currentColor(HTMLCanvasElement* canvas) +{ + if (!canvas || !canvas->inDocument()) + return Color::black; + RGBA32 rgba = Color::black; + CSSParser::parseColor(rgba, canvas->style()->getPropertyValue(CSSPropertyColor)); + return rgba; +} + +bool parseColorOrCurrentColor(RGBA32& parsedColor, const String& colorString, HTMLCanvasElement* canvas) +{ + ColorParseResult parseResult = parseColor(parsedColor, colorString); + switch (parseResult) { + case ParsedRGBA: + return true; + case ParsedCurrentColor: + parsedColor = currentColor(canvas); + return true; + case ParseFailed: + return false; + default: + ASSERT_NOT_REACHED(); + return false; + } +} + +CanvasStyle::CanvasStyle(Type type, float overrideAlpha) + : m_type(type) + , m_overrideAlpha(overrideAlpha) +{ +} + CanvasStyle::CanvasStyle(RGBA32 rgba) : m_type(RGBA) , m_rgba(rgba) @@ -89,17 +134,35 @@ CanvasStyle::CanvasStyle(PassRefPtr<CanvasPattern> pattern) PassRefPtr<CanvasStyle> CanvasStyle::createFromString(const String& color) { RGBA32 rgba; - if (!CSSParser::parseColor(rgba, color)) + ColorParseResult parseResult = parseColor(rgba, color); + switch (parseResult) { + case ParsedRGBA: + return adoptRef(new CanvasStyle(rgba)); + case ParsedCurrentColor: + return adoptRef(new CanvasStyle(CurrentColor)); + case ParseFailed: return 0; - return adoptRef(new CanvasStyle(rgba)); + default: + ASSERT_NOT_REACHED(); + return 0; + } } PassRefPtr<CanvasStyle> CanvasStyle::createFromStringWithOverrideAlpha(const String& color, float alpha) { RGBA32 rgba; - if (!CSSParser::parseColor(rgba, color)) + ColorParseResult parseResult = parseColor(rgba, color); + switch (parseResult) { + case ParsedRGBA: + return adoptRef(new CanvasStyle(colorWithOverrideAlpha(rgba, alpha))); + case ParsedCurrentColor: + return adoptRef(new CanvasStyle(CurrentColorWithOverrideAlpha, alpha)); + case ParseFailed: + return 0; + default: + ASSERT_NOT_REACHED(); return 0; - return adoptRef(new CanvasStyle(colorWithOverrideAlpha(rgba, alpha))); + } } PassRefPtr<CanvasStyle> CanvasStyle::createFromGradient(PassRefPtr<CanvasGradient> gradient) @@ -121,16 +184,18 @@ bool CanvasStyle::isEquivalentColor(const CanvasStyle& other) const return false; switch (m_type) { - case CanvasStyle::RGBA: + case RGBA: return m_rgba == other.m_rgba; - case CanvasStyle::CMYKA: + case CMYKA: return m_cmyka.c == other.m_cmyka.c && m_cmyka.m == other.m_cmyka.m && m_cmyka.y == other.m_cmyka.y && m_cmyka.k == other.m_cmyka.k && m_cmyka.a == other.m_cmyka.a; - case CanvasStyle::Gradient: - case CanvasStyle::ImagePattern: + case Gradient: + case ImagePattern: + case CurrentColor: + case CurrentColorWithOverrideAlpha: return false; } @@ -164,7 +229,7 @@ void CanvasStyle::applyStrokeColor(GraphicsContext* context) return; switch (m_type) { case RGBA: - context->setStrokeColor(m_rgba, DeviceColorSpace); + context->setStrokeColor(m_rgba, ColorSpaceDeviceRGB); break; case CMYKA: { // FIXME: Do this through platform-independent GraphicsContext API. @@ -178,7 +243,7 @@ void CanvasStyle::applyStrokeColor(GraphicsContext* context) currentPen.setColor(clr); context->platformContext()->setPen(currentPen); #else - context->setStrokeColor(m_rgba, DeviceColorSpace); + context->setStrokeColor(m_rgba, ColorSpaceDeviceRGB); #endif break; } @@ -188,6 +253,10 @@ void CanvasStyle::applyStrokeColor(GraphicsContext* context) case ImagePattern: context->setStrokePattern(canvasPattern()->pattern()); break; + case CurrentColor: + case CurrentColorWithOverrideAlpha: + ASSERT_NOT_REACHED(); + break; } } @@ -197,7 +266,7 @@ void CanvasStyle::applyFillColor(GraphicsContext* context) return; switch (m_type) { case RGBA: - context->setFillColor(m_rgba, DeviceColorSpace); + context->setFillColor(m_rgba, ColorSpaceDeviceRGB); break; case CMYKA: { // FIXME: Do this through platform-independent GraphicsContext API. @@ -211,7 +280,7 @@ void CanvasStyle::applyFillColor(GraphicsContext* context) currentBrush.setColor(clr); context->platformContext()->setBrush(currentBrush); #else - context->setFillColor(m_rgba, DeviceColorSpace); + context->setFillColor(m_rgba, ColorSpaceDeviceRGB); #endif break; } @@ -221,6 +290,10 @@ void CanvasStyle::applyFillColor(GraphicsContext* context) case ImagePattern: context->setFillPattern(canvasPattern()->pattern()); break; + case CurrentColor: + case CurrentColorWithOverrideAlpha: + ASSERT_NOT_REACHED(); + break; } } diff --git a/WebCore/html/canvas/CanvasStyle.h b/WebCore/html/canvas/CanvasStyle.h index 3ca760a..91dc923 100644 --- a/WebCore/html/canvas/CanvasStyle.h +++ b/WebCore/html/canvas/CanvasStyle.h @@ -29,12 +29,14 @@ #include "Color.h" #include "PlatformString.h" +#include <wtf/Assertions.h> namespace WebCore { class CanvasGradient; class CanvasPattern; class GraphicsContext; + class HTMLCanvasElement; class CanvasStyle : public RefCounted<CanvasStyle> { public: @@ -47,7 +49,11 @@ namespace WebCore { static PassRefPtr<CanvasStyle> createFromGradient(PassRefPtr<CanvasGradient>); static PassRefPtr<CanvasStyle> createFromPattern(PassRefPtr<CanvasPattern>); - String color() const { return Color(m_rgba).serialized(); } + bool isCurrentColor() const { return m_type == CurrentColor || m_type == CurrentColorWithOverrideAlpha; } + bool hasOverrideAlpha() const { return m_type == CurrentColorWithOverrideAlpha; } + float overrideAlpha() const { ASSERT(m_type == CurrentColorWithOverrideAlpha); return m_overrideAlpha; } + + String color() const { ASSERT(m_type == RGBA || m_type == CMYKA); return Color(m_rgba).serialized(); } CanvasGradient* canvasGradient() const { return m_gradient.get(); } CanvasPattern* canvasPattern() const { return m_pattern.get(); } @@ -59,6 +65,9 @@ namespace WebCore { bool isEquivalentCMYKA(float c, float m, float y, float k, float a) const; private: + enum Type { RGBA, CMYKA, Gradient, ImagePattern, CurrentColor, CurrentColorWithOverrideAlpha }; + + CanvasStyle(Type, float overrideAlpha = 0); CanvasStyle(RGBA32 rgba); CanvasStyle(float grayLevel, float alpha); CanvasStyle(float r, float g, float b, float a); @@ -66,11 +75,12 @@ namespace WebCore { CanvasStyle(PassRefPtr<CanvasGradient>); CanvasStyle(PassRefPtr<CanvasPattern>); - enum Type { RGBA, CMYKA, Gradient, ImagePattern }; - Type m_type; - RGBA32 m_rgba; + union { + RGBA32 m_rgba; + float m_overrideAlpha; + }; RefPtr<CanvasGradient> m_gradient; RefPtr<CanvasPattern> m_pattern; @@ -86,6 +96,9 @@ namespace WebCore { } m_cmyka; }; + RGBA32 currentColor(HTMLCanvasElement*); + bool parseColorOrCurrentColor(RGBA32& parsedColor, const String& colorString, HTMLCanvasElement*); + } // namespace WebCore #endif diff --git a/WebCore/html/canvas/Float32Array.cpp b/WebCore/html/canvas/Float32Array.cpp index e6e8439..e918d8f 100644 --- a/WebCore/html/canvas/Float32Array.cpp +++ b/WebCore/html/canvas/Float32Array.cpp @@ -26,7 +26,7 @@ #include "config.h" -#if ENABLE(3D_CANVAS) +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) #include "Float32Array.h" @@ -59,4 +59,4 @@ PassRefPtr<ArrayBufferView> Float32Array::slice(int start, int end) const } -#endif // ENABLE(3D_CANVAS) +#endif // ENABLE(3D_CANVAS) || ENABLE(BLOB) diff --git a/WebCore/html/canvas/Float32Array.idl b/WebCore/html/canvas/Float32Array.idl index 5a939ca..c3c0a2d 100644 --- a/WebCore/html/canvas/Float32Array.idl +++ b/WebCore/html/canvas/Float32Array.idl @@ -26,13 +26,14 @@ module html { interface [ - Conditional=3D_CANVAS, + Conditional=3D_CANVAS|BLOB, CanBeConstructed, CustomConstructFunction, V8CustomConstructor, HasNumericIndexGetter, HasCustomIndexSetter, GenerateNativeConverter, + NoStaticTables, CustomToJS, DontCheckEnums ] Float32Array : ArrayBufferView { diff --git a/WebCore/html/canvas/Int16Array.cpp b/WebCore/html/canvas/Int16Array.cpp index f3f9742..635ea5e 100644 --- a/WebCore/html/canvas/Int16Array.cpp +++ b/WebCore/html/canvas/Int16Array.cpp @@ -25,7 +25,7 @@ #include "config.h" -#if ENABLE(3D_CANVAS) +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) #include "Int16Array.h" @@ -58,4 +58,4 @@ PassRefPtr<ArrayBufferView> Int16Array::slice(int start, int end) const } -#endif // ENABLE(3D_CANVAS) +#endif // ENABLE(3D_CANVAS) || ENABLE(BLOB) diff --git a/WebCore/html/canvas/Int16Array.idl b/WebCore/html/canvas/Int16Array.idl index 02417f8..7980a69 100644 --- a/WebCore/html/canvas/Int16Array.idl +++ b/WebCore/html/canvas/Int16Array.idl @@ -25,13 +25,14 @@ module html { interface [ - Conditional=3D_CANVAS, + Conditional=3D_CANVAS|BLOB, CanBeConstructed, CustomConstructFunction, V8CustomConstructor, HasNumericIndexGetter, HasCustomIndexSetter, GenerateNativeConverter, + NoStaticTables, CustomToJS, DontCheckEnums ] Int16Array : ArrayBufferView { diff --git a/WebCore/html/canvas/Int32Array.cpp b/WebCore/html/canvas/Int32Array.cpp index 423c36b..cc926a3 100644 --- a/WebCore/html/canvas/Int32Array.cpp +++ b/WebCore/html/canvas/Int32Array.cpp @@ -26,7 +26,7 @@ #include "config.h" -#if ENABLE(3D_CANVAS) +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) #include "Int32Array.h" @@ -59,4 +59,4 @@ PassRefPtr<ArrayBufferView> Int32Array::slice(int start, int end) const } -#endif // ENABLE(3D_CANVAS) +#endif // ENABLE(3D_CANVAS) || ENABLE(BLOB) diff --git a/WebCore/html/canvas/Int32Array.h b/WebCore/html/canvas/Int32Array.h index 72fb579..bd05450 100644 --- a/WebCore/html/canvas/Int32Array.h +++ b/WebCore/html/canvas/Int32Array.h @@ -37,8 +37,10 @@ class Int32Array : public IntegralTypedArrayBase<int> { static PassRefPtr<Int32Array> create(int* array, unsigned length); static PassRefPtr<Int32Array> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length); +#if !COMPILER(RVCT) using TypedArrayBase<int>::set; using IntegralTypedArrayBase<int>::set; +#endif private: Int32Array(PassRefPtr<ArrayBuffer> buffer, diff --git a/WebCore/html/canvas/Int32Array.idl b/WebCore/html/canvas/Int32Array.idl index 6977d00..bd1554d 100644 --- a/WebCore/html/canvas/Int32Array.idl +++ b/WebCore/html/canvas/Int32Array.idl @@ -26,13 +26,14 @@ module html { interface [ - Conditional=3D_CANVAS, + Conditional=3D_CANVAS|BLOB, CanBeConstructed, CustomConstructFunction, V8CustomConstructor, HasNumericIndexGetter, HasCustomIndexSetter, GenerateNativeConverter, + NoStaticTables, CustomToJS, DontCheckEnums ] Int32Array : ArrayBufferView { diff --git a/WebCore/html/canvas/Int8Array.cpp b/WebCore/html/canvas/Int8Array.cpp index 20ff32a..c2dd2fa 100644 --- a/WebCore/html/canvas/Int8Array.cpp +++ b/WebCore/html/canvas/Int8Array.cpp @@ -26,7 +26,7 @@ #include "config.h" -#if ENABLE(3D_CANVAS) +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) #include "Int8Array.h" @@ -59,4 +59,4 @@ PassRefPtr<ArrayBufferView> Int8Array::slice(int start, int end) const } -#endif // ENABLE(3D_CANVAS) +#endif // ENABLE(3D_CANVAS) || ENABLE(BLOB) diff --git a/WebCore/html/canvas/Int8Array.idl b/WebCore/html/canvas/Int8Array.idl index 4dba9e4..ec0bdb7 100644 --- a/WebCore/html/canvas/Int8Array.idl +++ b/WebCore/html/canvas/Int8Array.idl @@ -26,13 +26,14 @@ module html { interface [ - Conditional=3D_CANVAS, + Conditional=3D_CANVAS|BLOB, CanBeConstructed, CustomConstructFunction, V8CustomConstructor, HasNumericIndexGetter, HasCustomIndexSetter, GenerateNativeConverter, + NoStaticTables, CustomToJS, DontCheckEnums ] Int8Array : ArrayBufferView { diff --git a/WebCore/html/canvas/Uint16Array.cpp b/WebCore/html/canvas/Uint16Array.cpp index 4656173..a0f891c 100644 --- a/WebCore/html/canvas/Uint16Array.cpp +++ b/WebCore/html/canvas/Uint16Array.cpp @@ -26,7 +26,7 @@ #include "config.h" -#if ENABLE(3D_CANVAS) +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) #include "Uint16Array.h" @@ -59,4 +59,4 @@ PassRefPtr<ArrayBufferView> Uint16Array::slice(int start, int end) const } -#endif // ENABLE(3D_CANVAS) +#endif // ENABLE(3D_CANVAS) || ENABLE(BLOB) diff --git a/WebCore/html/canvas/Uint16Array.idl b/WebCore/html/canvas/Uint16Array.idl index de1e5e0..75a7499 100644 --- a/WebCore/html/canvas/Uint16Array.idl +++ b/WebCore/html/canvas/Uint16Array.idl @@ -26,13 +26,14 @@ module html { interface [ - Conditional=3D_CANVAS, + Conditional=3D_CANVAS|BLOB, CanBeConstructed, CustomConstructFunction, V8CustomConstructor, HasNumericIndexGetter, HasCustomIndexSetter, GenerateNativeConverter, + NoStaticTables, CustomToJS, DontCheckEnums ] Uint16Array : ArrayBufferView { diff --git a/WebCore/html/canvas/Uint32Array.cpp b/WebCore/html/canvas/Uint32Array.cpp index 3f43bef..f49a83a 100644 --- a/WebCore/html/canvas/Uint32Array.cpp +++ b/WebCore/html/canvas/Uint32Array.cpp @@ -26,7 +26,7 @@ #include "config.h" -#if ENABLE(3D_CANVAS) +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) #include "Uint32Array.h" @@ -59,4 +59,4 @@ PassRefPtr<ArrayBufferView> Uint32Array::slice(int start, int end) const } -#endif // ENABLE(3D_CANVAS) +#endif // ENABLE(3D_CANVAS) || ENABLE(BLOB) diff --git a/WebCore/html/canvas/Uint32Array.idl b/WebCore/html/canvas/Uint32Array.idl index ce632dd..06e17c6 100644 --- a/WebCore/html/canvas/Uint32Array.idl +++ b/WebCore/html/canvas/Uint32Array.idl @@ -26,13 +26,14 @@ module html { interface [ - Conditional=3D_CANVAS, + Conditional=3D_CANVAS|BLOB, CanBeConstructed, CustomConstructFunction, V8CustomConstructor, HasNumericIndexGetter, HasCustomIndexSetter, GenerateNativeConverter, + NoStaticTables, CustomToJS, DontCheckEnums ] Uint32Array : ArrayBufferView { diff --git a/WebCore/html/canvas/Uint8Array.cpp b/WebCore/html/canvas/Uint8Array.cpp index 13b7022..6c785f9 100644 --- a/WebCore/html/canvas/Uint8Array.cpp +++ b/WebCore/html/canvas/Uint8Array.cpp @@ -26,7 +26,7 @@ #include "config.h" -#if ENABLE(3D_CANVAS) +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) #include "Uint8Array.h" @@ -59,4 +59,4 @@ PassRefPtr<ArrayBufferView> Uint8Array::slice(int start, int end) const } -#endif // ENABLE(3D_CANVAS) +#endif // ENABLE(3D_CANVAS) || ENABLE(BLOB) diff --git a/WebCore/html/canvas/Uint8Array.h b/WebCore/html/canvas/Uint8Array.h index 6e20b42..fce63da 100644 --- a/WebCore/html/canvas/Uint8Array.h +++ b/WebCore/html/canvas/Uint8Array.h @@ -39,8 +39,10 @@ class Uint8Array : public IntegralTypedArrayBase<unsigned char> { static PassRefPtr<Uint8Array> create(unsigned char* array, unsigned length); static PassRefPtr<Uint8Array> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length); +#if !COMPILER(RVCT) using TypedArrayBase<unsigned char>::set; using IntegralTypedArrayBase<unsigned char>::set; +#endif private: Uint8Array(PassRefPtr<ArrayBuffer> buffer, diff --git a/WebCore/html/canvas/Uint8Array.idl b/WebCore/html/canvas/Uint8Array.idl index c520844..bd28023 100644 --- a/WebCore/html/canvas/Uint8Array.idl +++ b/WebCore/html/canvas/Uint8Array.idl @@ -26,13 +26,14 @@ module html { interface [ - Conditional=3D_CANVAS, + Conditional=3D_CANVAS|BLOB, CanBeConstructed, CustomConstructFunction, V8CustomConstructor, HasNumericIndexGetter, HasCustomIndexSetter, GenerateNativeConverter, + NoStaticTables, CustomToJS, DontCheckEnums ] Uint8Array : ArrayBufferView { diff --git a/WebCore/html/canvas/WebGLProgram.cpp b/WebCore/html/canvas/WebGLProgram.cpp index 0853b67..e4ffa80 100644 --- a/WebCore/html/canvas/WebGLProgram.cpp +++ b/WebCore/html/canvas/WebGLProgram.cpp @@ -40,7 +40,7 @@ PassRefPtr<WebGLProgram> WebGLProgram::create(WebGLRenderingContext* ctx) WebGLProgram::WebGLProgram(WebGLRenderingContext* ctx) : WebGLObject(ctx) - , m_linkFailure(false) + , m_linkStatus(false) { setObject(context()->graphicsContext3D()->createProgram()); } diff --git a/WebCore/html/canvas/WebGLProgram.h b/WebCore/html/canvas/WebGLProgram.h index e5548eb..3b88fdd 100644 --- a/WebCore/html/canvas/WebGLProgram.h +++ b/WebCore/html/canvas/WebGLProgram.h @@ -50,11 +50,8 @@ public: bool isUsingVertexAttrib0() const; - // Return true means getProgramParameter(LINK_STATUS) should return - // false; return false means we should actually call - // getProgramParameter(LINK_STATUS) to find out. - bool isLinkFailureFlagSet() const { return m_linkFailure; } - void setLinkFailureFlag(bool failed) { m_linkFailure = failed; } + bool getLinkStatus() const { return m_linkStatus; } + void setLinkStatus(bool status) { m_linkStatus = status; } WebGLShader* getAttachedShader(GraphicsContext3D::WebGLEnumType); bool attachShader(WebGLShader*); @@ -70,7 +67,7 @@ private: Vector<int> m_activeAttribLocations; - bool m_linkFailure; + bool m_linkStatus; RefPtr<WebGLShader> m_vertexShader; RefPtr<WebGLShader> m_fragmentShader; diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp index d1bb0cd..a8751da 100644 --- a/WebCore/html/canvas/WebGLRenderingContext.cpp +++ b/WebCore/html/canvas/WebGLRenderingContext.cpp @@ -88,15 +88,15 @@ PassOwnPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElemen { HostWindow* hostWindow = canvas->document()->view()->root()->hostWindow(); GraphicsContext3D::Attributes emptyAttributes; - OwnPtr<GraphicsContext3D> context(GraphicsContext3D::create(attrs ? attrs->attributes() : emptyAttributes, hostWindow)); + RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(attrs ? attrs->attributes() : emptyAttributes, hostWindow)); if (!context) return 0; - return new WebGLRenderingContext(canvas, context.release()); + return new WebGLRenderingContext(canvas, context); } -WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassOwnPtr<GraphicsContext3D> context) +WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassRefPtr<GraphicsContext3D> context) : CanvasRenderingContext(passedCanvas) , m_context(context) , m_needsUpdate(true) @@ -1484,10 +1484,7 @@ WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, u m_context->getProgramiv(objectOrZero(program), pname, &value); return WebGLGetInfo(static_cast<bool>(value)); case GraphicsContext3D::LINK_STATUS: - if (program->isLinkFailureFlagSet()) - return WebGLGetInfo(false); - m_context->getProgramiv(objectOrZero(program), pname, &value); - return WebGLGetInfo(static_cast<bool>(value)); + return WebGLGetInfo(program->getLinkStatus()); case GraphicsContext3D::INFO_LOG_LENGTH: case GraphicsContext3D::ATTACHED_SHADERS: case GraphicsContext3D::ACTIVE_ATTRIBUTES: @@ -1897,14 +1894,17 @@ void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode& ec return; if (!isGLES2Compliant()) { if (!program->getAttachedShader(GraphicsContext3D::VERTEX_SHADER) || !program->getAttachedShader(GraphicsContext3D::FRAGMENT_SHADER)) { - program->setLinkFailureFlag(true); + program->setLinkStatus(false); return; } - program->setLinkFailureFlag(false); } m_context->linkProgram(objectOrZero(program)); program->cacheActiveAttribLocations(); + // cache link status + int value = 0; + m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::LINK_STATUS, &value); + program->setLinkStatus(static_cast<bool>(value)); cleanupAfterGraphicsCall(false); } @@ -2714,11 +2714,12 @@ void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* locatio void WebGLRenderingContext::useProgram(WebGLProgram* program, ExceptionCode& ec) { + UNUSED_PARAM(ec); if (program && program->context() != this) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); return; } - if (program && program->object() && !getProgramParameter(program, GraphicsContext3D::LINK_STATUS, ec).getBool()) { + if (program && program->object() && !program->getLinkStatus()) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); cleanupAfterGraphicsCall(false); return; diff --git a/WebCore/html/canvas/WebGLRenderingContext.h b/WebCore/html/canvas/WebGLRenderingContext.h index f507054..c4c856c 100644 --- a/WebCore/html/canvas/WebGLRenderingContext.h +++ b/WebCore/html/canvas/WebGLRenderingContext.h @@ -291,7 +291,7 @@ public: private: friend class WebGLObject; - WebGLRenderingContext(HTMLCanvasElement*, PassOwnPtr<GraphicsContext3D>); + WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>); void addObject(WebGLObject*); void detachAndRemoveAllObjects(); @@ -329,7 +329,7 @@ public: PassRefPtr<Image> videoFrameToImage(HTMLVideoElement* video); - OwnPtr<GraphicsContext3D> m_context; + RefPtr<GraphicsContext3D> m_context; bool m_needsUpdate; bool m_markedCanvasDirty; // FIXME: I think this is broken -- it does not increment any |