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

Unified Diff: src/gpu/SkGr.cpp

Issue 1382753002: Fix drawVertices when there is a paint alpha (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment Created 5 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 | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/SkGrPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGr.cpp
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index a726939788ba8db4b7b23183a7d65df38f7ff7aa..ce1ce32eb33dac2e8f42c20adfef45ef06682fba 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -677,6 +677,14 @@ bool GrPixelConfig2ColorAndProfileType(GrPixelConfig config, SkColorType* ctOut,
////////////////////////////////////////////////////////////////////////////////////////////////
+static inline bool blend_requires_shader(const SkXfermode::Mode mode, bool primitiveIsSrc) {
+ if (primitiveIsSrc) {
+ return SkXfermode::kSrc_Mode != mode;
+ } else {
+ return SkXfermode::kDst_Mode != mode;
+ }
+}
+
static inline bool skpaint_to_grpaint_impl(GrContext* context,
const SkPaint& skPaint,
const SkMatrix& viewM,
@@ -689,15 +697,18 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
// Setup the initial color considering the shader, the SkPaint color, and the presence or not
// of per-vertex colors.
SkAutoTUnref<const GrFragmentProcessor> aufp;
- const GrFragmentProcessor* shaderFP = NULL;
- if (shaderProcessor) {
- shaderFP = *shaderProcessor;
- } else if (const SkShader* shader = skPaint.getShader()) {
- aufp.reset(shader->asFragmentProcessor(context, viewM, NULL, skPaint.getFilterQuality(),
- grPaint->getProcessorDataManager()));
- shaderFP = aufp;
- if (!shaderFP) {
- return false;
+ const GrFragmentProcessor* shaderFP = nullptr;
+ if (!primColorMode || blend_requires_shader(*primColorMode, primitiveIsSrc)) {
+ if (shaderProcessor) {
+ shaderFP = *shaderProcessor;
+ } else if (const SkShader* shader = skPaint.getShader()) {
+ aufp.reset(shader->asFragmentProcessor(context, viewM, nullptr,
+ skPaint.getFilterQuality(),
+ grPaint->getProcessorDataManager()));
+ shaderFP = aufp;
+ if (!shaderFP) {
+ return false;
+ }
}
}
@@ -761,11 +772,13 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
grPaint->addColorFragmentProcessor(processor);
}
- grPaint->setColor(SkColorToUnpremulGrColor(skPaint.getColor()) | 0xFF000000);
+ grPaint->setColor(SkColorToOpaqueGrColor(skPaint.getColor()));
GrColor paintAlpha = SkColorAlphaToGrColor(skPaint.getColor());
- grPaint->addColorFragmentProcessor(GrConstColorProcessor::Create(
- paintAlpha, GrConstColorProcessor::kModulateRGBA_InputMode))->unref();
+ if (GrColor_WHITE != paintAlpha) {
+ grPaint->addColorFragmentProcessor(GrConstColorProcessor::Create(
+ paintAlpha, GrConstColorProcessor::kModulateRGBA_InputMode))->unref();
+ }
} else {
// No shader, no primitive color.
grPaint->setColor(SkColorToPremulGrColor(skPaint.getColor()));
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/SkGrPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698