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

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: Address reviewer comments Created 5 years, 10 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/skia/SkiaUtils.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 a87bafe2a852ecdb0f916795e79e5982ed1f8cec..1dc94d67a50d4da0c9522c686aeb138a2dfad931 100644
--- a/Source/platform/graphics/GraphicsContextState.cpp
+++ b/Source/platform/graphics/GraphicsContextState.cpp
@@ -5,8 +5,6 @@
#include "config.h"
#include "platform/graphics/GraphicsContextState.h"
-#include "platform/graphics/skia/SkiaUtils.h"
-
namespace blink {
GraphicsContextState::GraphicsContextState()
@@ -99,12 +97,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 alpha)
{
m_strokeColor = Color::black;
m_strokePattern.clear();
m_strokeGradient = gradient;
- m_strokePaint.setColor(applyAlpha(SK_ColorBLACK));
+ m_strokePaint.setColor(multiplyAlpha(applyAlpha(SK_ColorBLACK), alpha));
m_strokePaint.setShader(m_strokeGradient->shader());
}
@@ -115,12 +113,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 alpha)
{
m_strokeColor = Color::black;
m_strokeGradient.clear();
m_strokePattern = pattern;
- m_strokePaint.setColor(applyAlpha(SK_ColorBLACK));
+ m_strokePaint.setColor(multiplyAlpha(applyAlpha(SK_ColorBLACK), alpha));
m_strokePaint.setShader(m_strokePattern->shader());
}
@@ -158,12 +156,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 alpha)
{
m_fillColor = Color::black;
m_fillPattern.clear();
m_fillGradient = gradient;
- m_fillPaint.setColor(applyAlpha(SK_ColorBLACK));
+ m_fillPaint.setColor(multiplyAlpha(applyAlpha(SK_ColorBLACK), alpha));
m_fillPaint.setShader(m_fillGradient->shader());
}
@@ -174,12 +172,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 alpha)
{
m_fillColor = Color::black;
m_fillGradient.clear();
m_fillPattern = pattern;
- m_fillPaint.setColor(applyAlpha(SK_ColorBLACK));
+ m_fillPaint.setColor(multiplyAlpha(applyAlpha(SK_ColorBLACK), alpha));
m_fillPaint.setShader(m_fillPattern->shader());
}
@@ -217,13 +215,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);
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/skia/SkiaUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698