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

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

Issue 900463002: Make SVG painting independent of GraphicsContext's alpha state (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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
Index: Source/platform/graphics/GraphicsContextState.cpp
diff --git a/Source/platform/graphics/GraphicsContextState.cpp b/Source/platform/graphics/GraphicsContextState.cpp
index a87bafe2a852ecdb0f916795e79e5982ed1f8cec..39fbf89eb777a7d04d525a3e7f735a17696ebbe2 100644
--- a/Source/platform/graphics/GraphicsContextState.cpp
+++ b/Source/platform/graphics/GraphicsContextState.cpp
@@ -99,12 +99,12 @@ void GraphicsContextState::setStrokeColor(const Color& color)
m_strokePaint.setShader(0);
}
-void GraphicsContextState::setStrokeGradient(const PassRefPtr<Gradient> gradient)
+void GraphicsContextState::setStrokeGradient(const PassRefPtr<Gradient> gradient, float additionalAlpha)
{
m_strokeColor = Color::black;
m_strokePattern.clear();
m_strokeGradient = gradient;
- m_strokePaint.setColor(applyAlpha(SK_ColorBLACK));
+ m_strokePaint.setColor(combineWithAlpha(applyAlpha(SK_ColorBLACK), additionalAlpha));
m_strokePaint.setShader(m_strokeGradient->shader());
}
@@ -115,12 +115,12 @@ void GraphicsContextState::clearStrokeGradient()
m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb()));
}
-void GraphicsContextState::setStrokePattern(const PassRefPtr<Pattern> pattern)
+void GraphicsContextState::setStrokePattern(const PassRefPtr<Pattern> pattern, float additionalAlpha)
{
m_strokeColor = Color::black;
m_strokeGradient.clear();
m_strokePattern = pattern;
- m_strokePaint.setColor(applyAlpha(SK_ColorBLACK));
+ m_strokePaint.setColor(combineWithAlpha(applyAlpha(SK_ColorBLACK), additionalAlpha));
m_strokePaint.setShader(m_strokePattern->shader());
}
@@ -158,12 +158,12 @@ void GraphicsContextState::setFillColor(const Color& color)
m_fillPaint.setShader(0);
}
-void GraphicsContextState::setFillGradient(const PassRefPtr<Gradient> gradient)
+void GraphicsContextState::setFillGradient(const PassRefPtr<Gradient> gradient, float additionalAlpha)
{
m_fillColor = Color::black;
m_fillPattern.clear();
m_fillGradient = gradient;
- m_fillPaint.setColor(applyAlpha(SK_ColorBLACK));
+ m_fillPaint.setColor(combineWithAlpha(applyAlpha(SK_ColorBLACK), additionalAlpha));
m_fillPaint.setShader(m_fillGradient->shader());
}
@@ -174,12 +174,12 @@ void GraphicsContextState::clearFillGradient()
m_fillPaint.setColor(applyAlpha(m_fillColor.rgb()));
}
-void GraphicsContextState::setFillPattern(const PassRefPtr<Pattern> pattern)
+void GraphicsContextState::setFillPattern(const PassRefPtr<Pattern> pattern, float additionalAlpha)
{
m_fillColor = Color::black;
m_fillGradient.clear();
m_fillPattern = pattern;
- m_fillPaint.setColor(applyAlpha(SK_ColorBLACK));
+ m_fillPaint.setColor(combineWithAlpha(applyAlpha(SK_ColorBLACK), additionalAlpha));
m_fillPaint.setShader(m_fillPattern->shader());
}
@@ -217,13 +217,7 @@ void GraphicsContextState::clearDropShadowImageFilter()
void GraphicsContextState::setAlphaAsFloat(float alpha)
{
- if (alpha < 0) {
- m_alpha = 0;
- } else {
- m_alpha = roundf(alpha * 256);
- if (m_alpha > 256)
- m_alpha = 256;
- }
+ m_alpha = clampedAlphaForBlending(alpha);
chrishtr 2015/02/02 23:14:54 This is the one place that reads m_alpha it seems:
pdr. 2015/02/03 00:09:48 GraphicsContext::preparePaintForDrawRectToRect is
m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb()));
m_fillPaint.setColor(applyAlpha(m_fillColor.rgb()));
}

Powered by Google App Engine
This is Rietveld 408576698