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

Side by Side Diff: src/gpu/effects/GrPorterDuffXferProcessor.cpp

Issue 926593005: Use SkXfermode as public facing enum for GrPorterDuffXP (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 unified diff | Download patch
« include/gpu/GrXferProcessor.h ('K') | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "effects/GrPorterDuffXferProcessor.h" 8 #include "effects/GrPorterDuffXferProcessor.h"
9 9
10 #include "GrBlend.h" 10 #include "GrBlend.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 // If we do have coverage determine whether it matters. Dual source blendin g is expensive so 260 // If we do have coverage determine whether it matters. Dual source blendin g is expensive so
261 // we don't do it if we are doing coverage drawing. If we aren't then We al ways do dual source 261 // we don't do it if we are doing coverage drawing. If we aren't then We al ways do dual source
262 // blending if we have any effective coverage stages OR the geometry process or doesn't emits 262 // blending if we have any effective coverage stages OR the geometry process or doesn't emits
263 // solid coverage. 263 // solid coverage.
264 if (!(optFlags & kSetCoverageDrawing_OptFlag) && !hasSolidCoverage) { 264 if (!(optFlags & kSetCoverageDrawing_OptFlag) && !hasSolidCoverage) {
265 if (caps.dualSourceBlendingSupport()) { 265 if (caps.dualSourceBlendingSupport()) {
266 if (kZero_GrBlendCoeff == fDstBlend) { 266 if (kZero_GrBlendCoeff == fDstBlend) {
267 // write the coverage value to second color 267 // write the coverage value to second color
268 fSecondaryOutputType = kCoverage_SecondaryOutputType; 268 fSecondaryOutputType = kCoverage_SecondaryOutputType;
269 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; 269 fDstBlend = kIS2C_GrBlendCoeff;
270 } else if (kSA_GrBlendCoeff == fDstBlend) { 270 } else if (kSA_GrBlendCoeff == fDstBlend) {
271 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. 271 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
272 fSecondaryOutputType = kCoverageISA_SecondaryOutputType; 272 fSecondaryOutputType = kCoverageISA_SecondaryOutputType;
273 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; 273 fDstBlend = kIS2C_GrBlendCoeff;
274 } else if (kSC_GrBlendCoeff == fDstBlend) { 274 } else if (kSC_GrBlendCoeff == fDstBlend) {
275 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. 275 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
276 fSecondaryOutputType = kCoverageISC_SecondaryOutputType; 276 fSecondaryOutputType = kCoverageISC_SecondaryOutputType;
277 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; 277 fDstBlend = kIS2C_GrBlendCoeff;
278 } 278 }
279 } 279 }
280 } 280 }
281 } 281 }
282 282
283 GrXferProcessor::OptFlags 283 GrXferProcessor::OptFlags
284 PorterDuffXferProcessor::internalGetOptimizations(const GrProcOptInfo& colorPOI, 284 PorterDuffXferProcessor::internalGetOptimizations(const GrProcOptInfo& colorPOI,
285 const GrProcOptInfo& coverageP OI, 285 const GrProcOptInfo& coverageP OI,
286 bool doesStencilWrite) { 286 bool doesStencilWrite) {
287 bool srcAIsOne; 287 bool srcAIsOne;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 output->fWillBlendWithDst = false; 587 output->fWillBlendWithDst = false;
588 } 588 }
589 589
590 bool GrPorterDuffXPFactory::willReadDstColor(const GrProcOptInfo& colorPOI, 590 bool GrPorterDuffXPFactory::willReadDstColor(const GrProcOptInfo& colorPOI,
591 const GrProcOptInfo& coveragePOI) c onst { 591 const GrProcOptInfo& coveragePOI) c onst {
592 return false; 592 return false;
593 } 593 }
594 594
595 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); 595 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory);
596 596
597
598 static bool blend_coeff_refs_src(SkXfermode::Coeff coeff) {
599 return (SkXfermode::kSC_Coeff == coeff || SkXfermode::kISC_Coeff == coeff ||
600 SkXfermode::kSA_Coeff == coeff || SkXfermode::kISA_Coeff == coeff);
601 }
602
603 static bool blend_coeff_refs_dst(SkXfermode::Coeff coeff) {
604 return (SkXfermode::kDC_Coeff == coeff || SkXfermode::kIDC_Coeff == coeff ||
605 SkXfermode::kDA_Coeff == coeff || SkXfermode::kIDA_Coeff == coeff);
606 }
607
597 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, 608 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random,
598 GrContext*, 609 GrContext*,
599 const GrDrawTargetCaps&, 610 const GrDrawTargetCaps&,
600 GrTexture*[]) { 611 GrTexture*[]) {
601 GrBlendCoeff src; 612 SkXfermode::Coeff src;
602 do { 613 do {
603 src = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub licGrBlendCoeff)); 614 src = SkXfermode::Coeff(random->nextULessThan(SkXfermode::kCoeffCount));
604 } while (GrBlendCoeffRefsSrc(src)); 615 } while (blend_coeff_refs_src(src));
605 616
606 GrBlendCoeff dst; 617 SkXfermode::Coeff dst;
607 do { 618 do {
608 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub licGrBlendCoeff)); 619 dst = SkXfermode::Coeff(random->nextULessThan(SkXfermode::kCoeffCount));
609 } while (GrBlendCoeffRefsDst(dst)); 620 } while (blend_coeff_refs_dst(dst));
610 621
611 return GrPorterDuffXPFactory::Create(src, dst); 622 return GrPorterDuffXPFactory::Create(src, dst);
612 } 623 }
613 624
OLDNEW
« include/gpu/GrXferProcessor.h ('K') | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698