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

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

Issue 900883002: Revert of Move DstCopy on gpu into the GrXferProcessor. (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
« no previous file with comments | « src/gpu/effects/GrDisableColorXP.cpp ('k') | src/gpu/gl/GrGLGpu.h » ('j') | 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 20 matching lines...) Expand all
31 kISA_GrBlendCoeff == dstCoeff || 31 kISA_GrBlendCoeff == dstCoeff ||
32 kISC_GrBlendCoeff == dstCoeff; 32 kISC_GrBlendCoeff == dstCoeff;
33 } 33 }
34 34
35 class GrGLPorterDuffXferProcessor : public GrGLXferProcessor { 35 class GrGLPorterDuffXferProcessor : public GrGLXferProcessor {
36 public: 36 public:
37 GrGLPorterDuffXferProcessor(const GrProcessor&) {} 37 GrGLPorterDuffXferProcessor(const GrProcessor&) {}
38 38
39 virtual ~GrGLPorterDuffXferProcessor() {} 39 virtual ~GrGLPorterDuffXferProcessor() {}
40 40
41 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps, 41 void emitCode(const EmitArgs& args) SK_OVERRIDE {
42 GrProcessorKeyBuilder* b) {
43 const GrPorterDuffXferProcessor& xp = processor.cast<GrPorterDuffXferPro cessor>();
44 b->add32(xp.primaryOutputType());
45 b->add32(xp.secondaryOutputType());
46 };
47
48 private:
49 void onEmitCode(const EmitArgs& args) SK_OVERRIDE {
50 const GrPorterDuffXferProcessor& xp = args.fXP.cast<GrPorterDuffXferProc essor>(); 42 const GrPorterDuffXferProcessor& xp = args.fXP.cast<GrPorterDuffXferProc essor>();
51 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 43 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
52 if (xp.hasSecondaryOutput()) { 44 if (xp.hasSecondaryOutput()) {
53 switch(xp.secondaryOutputType()) { 45 switch(xp.secondaryOutputType()) {
54 case GrPorterDuffXferProcessor::kCoverage_SecondaryOutputType: 46 case GrPorterDuffXferProcessor::kCoverage_SecondaryOutputType:
55 fsBuilder->codeAppendf("%s = %s;", args.fOutputSecondary, ar gs.fInputCoverage); 47 fsBuilder->codeAppendf("%s = %s;", args.fOutputSecondary, ar gs.fInputCoverage);
56 break; 48 break;
57 case GrPorterDuffXferProcessor::kCoverageISA_SecondaryOutputType : 49 case GrPorterDuffXferProcessor::kCoverageISA_SecondaryOutputType :
58 fsBuilder->codeAppendf("%s = (1.0 - %s.a) * %s;", 50 fsBuilder->codeAppendf("%s = (1.0 - %s.a) * %s;",
59 args.fOutputSecondary, args.fInputCol or, 51 args.fOutputSecondary, args.fInputCol or,
(...skipping 21 matching lines...) Expand all
81 break; 73 break;
82 case GrPorterDuffXferProcessor::kModulate_PrimaryOutputType: 74 case GrPorterDuffXferProcessor::kModulate_PrimaryOutputType:
83 fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputPrimary, arg s.fInputColor, 75 fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputPrimary, arg s.fInputColor,
84 args.fInputCoverage); 76 args.fInputCoverage);
85 break; 77 break;
86 default: 78 default:
87 SkFAIL("Unexpected Primary Output"); 79 SkFAIL("Unexpected Primary Output");
88 } 80 }
89 } 81 }
90 82
91 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVE RRIDE {}; 83 void setData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVERR IDE {};
92 84
85 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps,
86 GrProcessorKeyBuilder* b) {
87 const GrPorterDuffXferProcessor& xp = processor.cast<GrPorterDuffXferPro cessor>();
88 b->add32(xp.primaryOutputType());
89 b->add32(xp.secondaryOutputType());
90 };
91
92 private:
93 typedef GrGLXferProcessor INHERITED; 93 typedef GrGLXferProcessor INHERITED;
94 }; 94 };
95 95
96 /////////////////////////////////////////////////////////////////////////////// 96 ///////////////////////////////////////////////////////////////////////////////
97 97
98 GrPorterDuffXferProcessor::GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, 98 GrPorterDuffXferProcessor::GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBl endCoeff dstBlend,
99 GrBlendCoeff dstBlend, 99 GrColor constant)
100 GrColor constant,
101 const GrDeviceCoordTexture* dstCopy,
102 bool willReadDstColor)
103 : fSrcBlend(srcBlend) 100 : fSrcBlend(srcBlend)
104 , fDstBlend(dstBlend) 101 , fDstBlend(dstBlend)
105 , fBlendConstant(constant) 102 , fBlendConstant(constant)
106 , fPrimaryOutputType(kModulate_PrimaryOutputType) 103 , fPrimaryOutputType(kModulate_PrimaryOutputType)
107 , fSecondaryOutputType(kNone_SecondaryOutputType) { 104 , fSecondaryOutputType(kNone_SecondaryOutputType) {
108 this->initClassID<GrPorterDuffXferProcessor>(); 105 this->initClassID<GrPorterDuffXferProcessor>();
109 } 106 }
110 107
111 GrPorterDuffXferProcessor::~GrPorterDuffXferProcessor() { 108 GrPorterDuffXferProcessor::~GrPorterDuffXferProcessor() {
112 } 109 }
113 110
114 void GrPorterDuffXferProcessor::onGetGLProcessorKey(const GrGLCaps& caps, 111 void GrPorterDuffXferProcessor::getGLProcessorKey(const GrGLCaps& caps,
115 GrProcessorKeyBuilder* b) co nst { 112 GrProcessorKeyBuilder* b) cons t {
116 GrGLPorterDuffXferProcessor::GenKey(*this, caps, b); 113 GrGLPorterDuffXferProcessor::GenKey(*this, caps, b);
117 } 114 }
118 115
119 GrGLXferProcessor* GrPorterDuffXferProcessor::createGLInstance() const { 116 GrGLXferProcessor* GrPorterDuffXferProcessor::createGLInstance() const {
120 return SkNEW_ARGS(GrGLPorterDuffXferProcessor, (*this)); 117 return SkNEW_ARGS(GrGLPorterDuffXferProcessor, (*this));
121 } 118 }
122 119
123 GrXferProcessor::OptFlags 120 GrXferProcessor::OptFlags
124 GrPorterDuffXferProcessor::getOptimizations(const GrProcOptInfo& colorPOI, 121 GrPorterDuffXferProcessor::getOptimizations(const GrProcOptInfo& colorPOI,
125 const GrProcOptInfo& coveragePOI, 122 const GrProcOptInfo& coveragePOI,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 case SkXfermode::kScreen_Mode: { 346 case SkXfermode::kScreen_Mode: {
350 static GrPorterDuffXPFactory gScreenPDXPF(kOne_GrBlendCoeff, kISC_Gr BlendCoeff); 347 static GrPorterDuffXPFactory gScreenPDXPF(kOne_GrBlendCoeff, kISC_Gr BlendCoeff);
351 return SkRef(&gScreenPDXPF); 348 return SkRef(&gScreenPDXPF);
352 break; 349 break;
353 } 350 }
354 default: 351 default:
355 return NULL; 352 return NULL;
356 } 353 }
357 } 354 }
358 355
359 GrXferProcessor* 356 GrXferProcessor* GrPorterDuffXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI,
360 GrPorterDuffXPFactory::onCreateXferProcessor(const GrProcOptInfo& colorPOI, 357 const GrProcOptInfo& covPOI) const {
361 const GrProcOptInfo& covPOI,
362 const GrDeviceCoordTexture* dstCopy ) const {
363 if (!covPOI.isFourChannelOutput()) { 358 if (!covPOI.isFourChannelOutput()) {
364 return GrPorterDuffXferProcessor::Create(fSrcCoeff, fDstCoeff, 0, dstCop y, 359 return GrPorterDuffXferProcessor::Create(fSrcCoeff, fDstCoeff);
365 this->willReadDstColor());
366 } else { 360 } else {
367 if (this->supportsRGBCoverage(colorPOI.color(), colorPOI.validFlags())) { 361 if (this->supportsRGBCoverage(colorPOI.color(), colorPOI.validFlags())) {
368 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); 362 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags());
369 GrColor blendConstant = GrUnPreMulColor(colorPOI.color()); 363 GrColor blendConstant = GrUnPreMulColor(colorPOI.color());
370 return GrPorterDuffXferProcessor::Create(kConstC_GrBlendCoeff, kISC_ GrBlendCoeff, 364 return GrPorterDuffXferProcessor::Create(kConstC_GrBlendCoeff, kISC_ GrBlendCoeff,
371 blendConstant, dstCopy, 365 blendConstant);
372 this->willReadDstColor());
373 } else { 366 } else {
374 return NULL; 367 return NULL;
375 } 368 }
376 } 369 }
377 } 370 }
378 371
379 bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/, 372 bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/,
380 uint32_t knownColorFlags) const { 373 uint32_t knownColorFlags) const {
381 if (kOne_GrBlendCoeff == fSrcCoeff && kISA_GrBlendCoeff == fDstCoeff && 374 if (kOne_GrBlendCoeff == fSrcCoeff && kISA_GrBlendCoeff == fDstCoeff &&
382 kRGBA_GrColorComponentFlags == knownColorFlags) { 375 kRGBA_GrColorComponentFlags == knownColorFlags) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 case kIConstC_GrBlendCoeff: 477 case kIConstC_GrBlendCoeff:
485 case kConstA_GrBlendCoeff: 478 case kConstA_GrBlendCoeff:
486 case kIConstA_GrBlendCoeff: 479 case kIConstA_GrBlendCoeff:
487 output->fBlendedColorFlags = 0; 480 output->fBlendedColorFlags = 0;
488 break; 481 break;
489 } 482 }
490 483
491 output->fWillBlendWithDst = false; 484 output->fWillBlendWithDst = false;
492 } 485 }
493 486
494 bool GrPorterDuffXPFactory::willReadDstColor() const {
495 return false;
496 }
497
498 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); 487 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory);
499 488
500 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, 489 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random,
501 GrContext*, 490 GrContext*,
502 const GrDrawTargetCaps&, 491 const GrDrawTargetCaps&,
503 GrTexture*[]) { 492 GrTexture*[]) {
504 GrBlendCoeff src; 493 GrBlendCoeff src;
505 do { 494 do {
506 src = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub licGrBlendCoeff)); 495 src = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub licGrBlendCoeff));
507 } while (GrBlendCoeffRefsSrc(src)); 496 } while (GrBlendCoeffRefsSrc(src));
508 497
509 GrBlendCoeff dst; 498 GrBlendCoeff dst;
510 do { 499 do {
511 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub licGrBlendCoeff)); 500 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub licGrBlendCoeff));
512 } while (GrBlendCoeffRefsDst(dst)); 501 } while (GrBlendCoeffRefsDst(dst));
513 502
514 return GrPorterDuffXPFactory::Create(src, dst); 503 return GrPorterDuffXPFactory::Create(src, dst);
515 } 504 }
516 505
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDisableColorXP.cpp ('k') | src/gpu/gl/GrGLGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698