Skip to content
Permalink
Browse files
2010-07-14 Andreas Kling <andreas.kling@nokia.com>
        Reviewed by Kenneth Rohde Christiansen.

        Canvas: Rename operator==(CanvasStyle,CanvasStyle) since it isn't a proper equality check
        https://bugs.webkit.org/show_bug.cgi?id=42284

        New name is isEquivalentColor(CanvasStyle).

        * html/canvas/CanvasRenderingContext2D.cpp:
        (WebCore::CanvasRenderingContext2D::setStrokeStyle):
        (WebCore::CanvasRenderingContext2D::setFillStyle):
        * html/canvas/CanvasStyle.cpp:
        (WebCore::CanvasStyle::isEquivalentColor):
        * html/canvas/CanvasStyle.h:


Canonical link: https://commits.webkit.org/54499@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63659 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Jul 19, 2010
1 parent dea4707 commit 6e391876e2b2d4d914aef8e23eb83bb141298ff9
Showing with 29 additions and 14 deletions.
  1. +16 −0 WebCore/ChangeLog
  2. +2 −2 WebCore/html/canvas/CanvasRenderingContext2D.cpp
  3. +10 −11 WebCore/html/canvas/CanvasStyle.cpp
  4. +1 −1 WebCore/html/canvas/CanvasStyle.h
@@ -1,3 +1,19 @@
2010-07-14 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

Canvas: Rename operator==(CanvasStyle,CanvasStyle) since it isn't a proper equality check
https://bugs.webkit.org/show_bug.cgi?id=42284

New name is isEquivalentColor(CanvasStyle).

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setStrokeStyle):
(WebCore::CanvasRenderingContext2D::setFillStyle):
* html/canvas/CanvasStyle.cpp:
(WebCore::CanvasStyle::isEquivalentColor):
* html/canvas/CanvasStyle.h:

2010-07-19 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Kenneth Rohde Christiansen.
@@ -172,7 +172,7 @@ void CanvasRenderingContext2D::setStrokeStyle(PassRefPtr<CanvasStyle> style)
if (!style)
return;

if (state().m_strokeStyle && *style == *state().m_strokeStyle)
if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentColor(*style))
return;

if (canvas()->originClean()) {
@@ -200,7 +200,7 @@ void CanvasRenderingContext2D::setFillStyle(PassRefPtr<CanvasStyle> style)
if (!style)
return;

if (state().m_fillStyle && *style == *state().m_fillStyle)
if (state().m_fillStyle && state().m_fillStyle->isEquivalentColor(*style))
return;

if (canvas()->originClean()) {
@@ -121,24 +121,23 @@ PassRefPtr<CanvasStyle> CanvasStyle::create(PassRefPtr<CanvasPattern> pattern)
return adoptRef(new CanvasStyle(pattern));
}

bool operator==(const CanvasStyle& s1, const CanvasStyle& s2)
bool CanvasStyle::isEquivalentColor(const CanvasStyle& other) const
{
if (s1.m_type != s2.m_type)
if (m_type != other.m_type)
return false;

switch (s1.m_type) {
switch (m_type) {
case CanvasStyle::RGBA:
return s1.m_rgba == s2.m_rgba;
return m_rgba == other.m_rgba;
case CanvasStyle::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:
return false;
case CanvasStyle::ImagePattern:
return false;
case CanvasStyle::CMYKA:
return s1.m_cmyka.c == s2.m_cmyka.c
&& s1.m_cmyka.m == s2.m_cmyka.m
&& s1.m_cmyka.y == s2.m_cmyka.y
&& s1.m_cmyka.k == s2.m_cmyka.k
&& s1.m_cmyka.a == s2.m_cmyka.a;
}

ASSERT_NOT_REACHED();
@@ -55,7 +55,7 @@ namespace WebCore {
void applyFillColor(GraphicsContext*);
void applyStrokeColor(GraphicsContext*);

friend bool operator==(const CanvasStyle&, const CanvasStyle&);
bool isEquivalentColor(const CanvasStyle&) const;

private:
CanvasStyle(RGBA32 rgba);

0 comments on commit 6e39187

Please sign in to comment.