Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1973)

Unified Diff: Source/platform/graphics/GraphicsContextState.cpp

Issue 597053003: Move color/gradient/pattern out of StrokeData (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/graphics/GraphicsContextState.h ('k') | Source/platform/graphics/StrokeData.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/GraphicsContextState.cpp
diff --git a/Source/platform/graphics/GraphicsContextState.cpp b/Source/platform/graphics/GraphicsContextState.cpp
index ee7d5ac67bbed8bec384e24d93843cadab8f969c..657d0df5fb03942dbf1f6e356445b25f861889f6 100644
--- a/Source/platform/graphics/GraphicsContextState.cpp
+++ b/Source/platform/graphics/GraphicsContextState.cpp
@@ -10,7 +10,8 @@
namespace blink {
GraphicsContextState::GraphicsContextState()
- : m_fillColor(Color::black)
+ : m_strokeColor(Color::black)
+ , m_fillColor(Color::black)
, m_fillRule(RULE_NONZERO)
, m_textDrawingMode(TextModeFill)
, m_alpha(256)
@@ -23,7 +24,7 @@ GraphicsContextState::GraphicsContextState()
{
m_strokePaint.setStyle(SkPaint::kStroke_Style);
m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness()));
- m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb()));
+ m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb()));
m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap);
m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join);
m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit()));
@@ -38,6 +39,9 @@ GraphicsContextState::GraphicsContextState(const GraphicsContextState& other)
: m_strokePaint(other.m_strokePaint)
, m_fillPaint(other.m_fillPaint)
, m_strokeData(other.m_strokeData)
+ , m_strokeColor(other.m_strokeColor)
+ , m_strokeGradient(other.m_strokeGradient)
+ , m_strokePattern(other.m_strokePattern)
, m_fillColor(other.m_fillColor)
, m_fillRule(other.m_fillRule)
, m_fillGradient(other.m_fillGradient)
@@ -61,8 +65,8 @@ void GraphicsContextState::copy(const GraphicsContextState& source)
const SkPaint& GraphicsContextState::strokePaint(int strokedPathLength) const
{
- if (m_strokeData.gradient() && m_strokeData.gradient()->shaderChanged())
- m_strokePaint.setShader(m_strokeData.gradient()->shader());
+ if (m_strokeGradient && m_strokeGradient->shaderChanged())
+ m_strokePaint.setShader(m_strokeGradient->shader());
m_strokeData.setupPaintDashPathEffect(&m_strokePaint, strokedPathLength);
return m_strokePaint;
}
@@ -87,43 +91,43 @@ void GraphicsContextState::setStrokeThickness(float thickness)
void GraphicsContextState::setStrokeColor(const Color& color)
{
- m_strokeData.clearGradient();
- m_strokeData.clearPattern();
- m_strokeData.setColor(color);
+ m_strokeGradient.clear();
+ m_strokePattern.clear();
+ m_strokeColor = color;
m_strokePaint.setColor(applyAlpha(color.rgb()));
m_strokePaint.setShader(0);
}
void GraphicsContextState::setStrokeGradient(const PassRefPtr<Gradient> gradient)
{
- m_strokeData.setColor(Color::black);
- m_strokeData.clearPattern();
- m_strokeData.setGradient(gradient);
+ m_strokeColor = Color::black;
+ m_strokePattern.clear();
+ m_strokeGradient = gradient;
m_strokePaint.setColor(applyAlpha(SK_ColorBLACK));
- m_strokePaint.setShader(m_strokeData.gradient()->shader());
+ m_strokePaint.setShader(m_strokeGradient->shader());
}
void GraphicsContextState::clearStrokeGradient()
{
- m_strokeData.clearGradient();
- ASSERT(!m_strokeData.pattern());
- m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb()));
+ m_strokeGradient.clear();
+ ASSERT(!m_strokePattern);
+ m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb()));
}
void GraphicsContextState::setStrokePattern(const PassRefPtr<Pattern> pattern)
{
- m_strokeData.setColor(Color::black);
- m_strokeData.clearGradient();
- m_strokeData.setPattern(pattern);
+ m_strokeColor = Color::black;
+ m_strokeGradient.clear();
+ m_strokePattern = pattern;
m_strokePaint.setColor(applyAlpha(SK_ColorBLACK));
- m_strokePaint.setShader(m_strokeData.pattern()->shader());
+ m_strokePaint.setShader(m_strokePattern->shader());
}
void GraphicsContextState::clearStrokePattern()
{
- m_strokeData.clearPattern();
- ASSERT(!m_strokeData.gradient());
- m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb()));
+ m_strokePattern.clear();
+ ASSERT(!m_strokeGradient);
+ m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb()));
}
void GraphicsContextState::setLineCap(LineCap cap)
@@ -209,7 +213,7 @@ void GraphicsContextState::setAlphaAsFloat(float alpha)
if (m_alpha > 256)
m_alpha = 256;
}
- m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb()));
+ m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb()));
m_fillPaint.setColor(applyAlpha(m_fillColor.rgb()));
}
« no previous file with comments | « Source/platform/graphics/GraphicsContextState.h ('k') | Source/platform/graphics/StrokeData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698