diff options
author | Steve Block <steveblock@google.com> | 2010-08-24 07:50:47 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-08-24 07:50:47 -0700 |
commit | c570a147a94b126d4172c30914f53dea17b4c8f5 (patch) | |
tree | 99c11741887d21f65d67c5bbdab58b7ba2a5d4d5 /WebCore/html/canvas/CanvasRenderingContext2D.cpp | |
parent | c952714bc6809a5ad081baaf9fcc04107b92ea3f (diff) | |
parent | 6c65f16005b91786c2b7c0791b9ea1dd684d57f4 (diff) | |
download | external_webkit-c570a147a94b126d4172c30914f53dea17b4c8f5.zip external_webkit-c570a147a94b126d4172c30914f53dea17b4c8f5.tar.gz external_webkit-c570a147a94b126d4172c30914f53dea17b4c8f5.tar.bz2 |
Merge changes I2e7e2317,Ie6ccde3a,I3e89f231,Id06ff339,I268dfe7d,Icaf70d9f,Ie234f1a0,Iff5c7aaa,I69b75bf0,Ifbf384f4
* changes:
Merge WebKit at r65615 : Update WebKit revision number
Merge WebKit at r65615 : Ignore http/tests/appcache/origin-quota.html
Merge WebKit at r65615 : Android-specific results for Geolocation tests.
Merge WebKit at r65615 : Fix GraphicsContext and ImageBuffer.
Merge WebKit at r65615 : processingUserGesture() is now static.
Merge WebKit at r65615 : UTF8String() becomes utf8().
Merge WebKit at r65615 : Fix include paths for string headers.
Merge WebKit at r65615 : Fix Makefiles.
Merge WebKit at r65615 : Fix conflicts.
Merge WebKit at r65615 : Initial merge by git.
Diffstat (limited to 'WebCore/html/canvas/CanvasRenderingContext2D.cpp')
-rw-r--r-- | WebCore/html/canvas/CanvasRenderingContext2D.cpp | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp index 559ddda..58ec1d0 100644 --- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp +++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp @@ -126,7 +126,7 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bo return; if (FrameView* view = canvas->document()->view()) { if (ScrollView* rootView = view->root()) { - if (HostWindow* hostWindow = view->root()->hostWindow()) { + if (HostWindow* hostWindow = rootView->hostWindow()) { // Set up our context GraphicsContext3D::Attributes attr; attr.stencil = true; @@ -167,8 +167,8 @@ void CanvasRenderingContext2D::reset() } CanvasRenderingContext2D::State::State() - : m_strokeStyle(CanvasStyle::create(Color::black)) - , m_fillStyle(CanvasStyle::create(Color::black)) + : m_strokeStyle(CanvasStyle::createFromRGBA(Color::black)) + , m_fillStyle(CanvasStyle::createFromRGBA(Color::black)) , m_lineWidth(1) , m_lineCap(ButtCap) , m_lineJoin(MiterJoin) @@ -550,82 +550,82 @@ void CanvasRenderingContext2D::setStrokeColor(const String& color) { if (color == state().m_unparsedStrokeColor) return; - setStrokeStyle(CanvasStyle::create(color)); + setStrokeStyle(CanvasStyle::createFromString(color)); state().m_unparsedStrokeColor = color; } void CanvasRenderingContext2D::setStrokeColor(float grayLevel) { - if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentColor(grayLevel, grayLevel, grayLevel, 1.0f)) + if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentRGBA(grayLevel, grayLevel, grayLevel, 1.0f)) return; - setStrokeStyle(CanvasStyle::create(grayLevel, 1)); + setStrokeStyle(CanvasStyle::createFromGrayLevelWithAlpha(grayLevel, 1.0f)); } void CanvasRenderingContext2D::setStrokeColor(const String& color, float alpha) { - setStrokeStyle(CanvasStyle::create(color, alpha)); + setStrokeStyle(CanvasStyle::createFromStringWithOverrideAlpha(color, alpha)); } void CanvasRenderingContext2D::setStrokeColor(float grayLevel, float alpha) { - if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentColor(grayLevel, grayLevel, grayLevel, alpha)) + if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentRGBA(grayLevel, grayLevel, grayLevel, alpha)) return; - setStrokeStyle(CanvasStyle::create(grayLevel, alpha)); + setStrokeStyle(CanvasStyle::createFromGrayLevelWithAlpha(grayLevel, alpha)); } void CanvasRenderingContext2D::setStrokeColor(float r, float g, float b, float a) { - if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentColor(r, g, b, a)) + if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentRGBA(r, g, b, a)) return; - setStrokeStyle(CanvasStyle::create(r, g, b, a)); + setStrokeStyle(CanvasStyle::createFromRGBAChannels(r, g, b, a)); } void CanvasRenderingContext2D::setStrokeColor(float c, float m, float y, float k, float a) { - if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentColor(c, m, y, k, a)) + if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentCMYKA(c, m, y, k, a)) return; - setStrokeStyle(CanvasStyle::create(c, m, y, k, a)); + setStrokeStyle(CanvasStyle::createFromCMYKAChannels(c, m, y, k, a)); } void CanvasRenderingContext2D::setFillColor(const String& color) { if (color == state().m_unparsedFillColor) return; - setFillStyle(CanvasStyle::create(color)); + setFillStyle(CanvasStyle::createFromString(color)); state().m_unparsedFillColor = color; } void CanvasRenderingContext2D::setFillColor(float grayLevel) { - if (state().m_fillStyle && state().m_fillStyle->isEquivalentColor(grayLevel, grayLevel, grayLevel, 1.0f)) + if (state().m_fillStyle && state().m_fillStyle->isEquivalentRGBA(grayLevel, grayLevel, grayLevel, 1.0f)) return; - setFillStyle(CanvasStyle::create(grayLevel, 1)); + setFillStyle(CanvasStyle::createFromGrayLevelWithAlpha(grayLevel, 1.0f)); } void CanvasRenderingContext2D::setFillColor(const String& color, float alpha) { - setFillStyle(CanvasStyle::create(color, alpha)); + setFillStyle(CanvasStyle::createFromStringWithOverrideAlpha(color, alpha)); } void CanvasRenderingContext2D::setFillColor(float grayLevel, float alpha) { - if (state().m_fillStyle && state().m_fillStyle->isEquivalentColor(grayLevel, grayLevel, grayLevel, alpha)) + if (state().m_fillStyle && state().m_fillStyle->isEquivalentRGBA(grayLevel, grayLevel, grayLevel, alpha)) return; - setFillStyle(CanvasStyle::create(grayLevel, alpha)); + setFillStyle(CanvasStyle::createFromGrayLevelWithAlpha(grayLevel, alpha)); } void CanvasRenderingContext2D::setFillColor(float r, float g, float b, float a) { - if (state().m_fillStyle && state().m_fillStyle->isEquivalentColor(r, g, b, a)) + if (state().m_fillStyle && state().m_fillStyle->isEquivalentRGBA(r, g, b, a)) return; - setFillStyle(CanvasStyle::create(r, g, b, a)); + setFillStyle(CanvasStyle::createFromRGBAChannels(r, g, b, a)); } void CanvasRenderingContext2D::setFillColor(float c, float m, float y, float k, float a) { - if (state().m_fillStyle && state().m_fillStyle->isEquivalentColor(c, m, y, k, a)) + if (state().m_fillStyle && state().m_fillStyle->isEquivalentCMYKA(c, m, y, k, a)) return; - setFillStyle(CanvasStyle::create(c, m, y, k, a)); + setFillStyle(CanvasStyle::createFromCMYKAChannels(c, m, y, k, a)); } void CanvasRenderingContext2D::beginPath() @@ -825,8 +825,16 @@ void CanvasRenderingContext2D::stroke() c->beginPath(); c->addPath(m_path); +#if PLATFORM(QT) + // Fast approximation of the stroke's bounding rect. + // This yields a slightly oversized rect but is very fast + // compared to Path::strokeBoundingRect(). + FloatRect boundingRect = m_path.platformPath().controlPointRect(); + boundingRect.inflate(state().m_miterLimit + state().m_lineWidth); +#else CanvasStrokeStyleApplier strokeApplier(this); FloatRect boundingRect = m_path.strokeBoundingRect(&strokeApplier); +#endif willDraw(boundingRect); c->strokePath(); @@ -1264,7 +1272,7 @@ void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas, const sourceCanvas->makeRenderingResultsAvailable(); - c->drawImage(buffer->image(), DeviceColorSpace, destRect, sourceRect, state().m_globalComposite); + c->drawImageBuffer(buffer, DeviceColorSpace, 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. // FIXME: Arguably willDraw should become didDraw and occur after drawing calls and not before them to avoid problems like this. } @@ -1464,7 +1472,7 @@ PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLCanvasElem CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, ec); if (ec) return 0; - return CanvasPattern::create(canvas->buffer()->image(), repeatX, repeatY, canvas->originClean()); + return CanvasPattern::create(canvas->copiedImage(), repeatX, repeatY, canvas->originClean()); } void CanvasRenderingContext2D::willDraw(const FloatRect& r, unsigned options) @@ -1820,7 +1828,7 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo maskImageContext->drawBidiText(font, textRun, location); c->save(); - c->clipToImageBuffer(maskRect, maskImage.get()); + c->clipToImageBuffer(maskImage.get(), maskRect); drawStyle->applyFillColor(c); c->fillRect(maskRect); c->restore(); |