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

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

Issue 1001503002: Implement support for mixed sampled render targets (Closed) Base URL: https://skia.googlesource.com/skia.git@mix1
Patch Set: Multisampling and other fixes Created 5 years, 9 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
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"
11 #include "GrDrawTargetCaps.h" 11 #include "GrDrawTargetCaps.h"
12 #include "GrProcessor.h" 12 #include "GrProcessor.h"
13 #include "GrProcOptInfo.h" 13 #include "GrProcOptInfo.h"
14 #include "GrTypes.h" 14 #include "GrTypes.h"
15 #include "GrXferProcessor.h" 15 #include "GrXferProcessor.h"
16 #include "gl/GrGLXferProcessor.h" 16 #include "gl/GrGLXferProcessor.h"
17 #include "gl/builders/GrGLFragmentShaderBuilder.h" 17 #include "gl/builders/GrGLFragmentShaderBuilder.h"
18 #include "gl/builders/GrGLProgramBuilder.h" 18 #include "gl/builders/GrGLProgramBuilder.h"
19 19
20 static bool can_tweak_alpha_for_coverage(GrBlendCoeff dstCoeff) { 20 static bool can_tweak_alpha_for_coverage(GrBlendCoeff dstCoeff) {
Chris Dalton 2015/03/17 00:39:35 This looks like the magic function that tells us i
21 /* 21 /*
22 The fractional coverage is f. 22 The fractional coverage is f.
23 The src and dst coeffs are Cs and Cd. 23 The src and dst coeffs are Cs and Cd.
24 The dst and src colors are S and D. 24 The dst and src colors are S and D.
25 We want the blend to compute: f*Cs*S + (f*Cd + (1-f))D. By tweaking the sou rce color's alpha 25 We want the blend to compute: f*Cs*S + (f*Cd + (1-f))D. By tweaking the sou rce color's alpha
26 we're replacing S with S'=fS. It's obvious that that first term will always be ok. The second 26 we're replacing S with S'=fS. It's obvious that that first term will always be ok. The second
27 term can be rearranged as [1-(1-Cd)f]D. By substituting in the various poss ibilities for Cd we 27 term can be rearranged as [1-(1-Cd)f]D. By substituting in the various poss ibilities for Cd we
28 find that only 1, ISA, and ISC produce the correct destination when applied to S' and D. 28 find that only 1, ISA, and ISC produce the correct destination when applied to S' and D.
29 */ 29 */
30 return kOne_GrBlendCoeff == dstCoeff || 30 return kOne_GrBlendCoeff == dstCoeff ||
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } else { 395 } else {
396 fDstBlend = kOne_GrBlendCoeff; 396 fDstBlend = kOne_GrBlendCoeff;
397 return GrXferProcessor::kSkipDraw_OptFlag; 397 return GrXferProcessor::kSkipDraw_OptFlag;
398 } 398 }
399 } 399 }
400 400
401 // if we don't have coverage we can check whether the dst 401 // if we don't have coverage we can check whether the dst
402 // has to read at all. If not, we'll disable blending. 402 // has to read at all. If not, we'll disable blending.
403 if (!hasCoverage) { 403 if (!hasCoverage) {
404 if (dstCoeffIsZero) { 404 if (dstCoeffIsZero) {
405 if (kOne_GrBlendCoeff == fSrcBlend) { 405 if (kOne_GrBlendCoeff == fSrcBlend &&
406 !colorPOI.needsCoverageModulation()) {
406 // if there is no coverage and coeffs are (1,0) then we 407 // if there is no coverage and coeffs are (1,0) then we
407 // won't need to read the dst at all, it gets replaced by src 408 // won't need to read the dst at all, it gets replaced by src
408 fDstBlend = kZero_GrBlendCoeff; 409 fDstBlend = kZero_GrBlendCoeff;
409 return GrXferProcessor::kNone_Opt; 410 return GrXferProcessor::kNone_Opt;
410 } else if (kZero_GrBlendCoeff == fSrcBlend) { 411 } else if (kZero_GrBlendCoeff == fSrcBlend) {
411 // if the op is "clear" then we don't need to emit a color 412 // if the op is "clear" then we don't need to emit a color
412 // or blend, just write transparent black into the dst. 413 // or blend, just write transparent black into the dst.
413 fSrcBlend = kOne_GrBlendCoeff; 414 fSrcBlend = kOne_GrBlendCoeff;
414 fDstBlend = kZero_GrBlendCoeff; 415 fDstBlend = kZero_GrBlendCoeff;
415 return GrXferProcessor::kIgnoreColor_OptFlag | 416 return GrXferProcessor::kIgnoreColor_OptFlag |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); 701 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory);
701 702
702 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, 703 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random,
703 GrContext*, 704 GrContext*,
704 const GrDrawTargetCaps&, 705 const GrDrawTargetCaps&,
705 GrTexture*[]) { 706 GrTexture*[]) {
706 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k LastCoeffMode)); 707 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k LastCoeffMode));
707 return GrPorterDuffXPFactory::Create(mode); 708 return GrPorterDuffXPFactory::Create(mode);
708 } 709 }
709 710
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698