Flutter Engine
The Flutter Engine
Static Public Member Functions | Friends | List of all members
GrPorterDuffXPFactory Class Reference

#include <GrPorterDuffXferProcessor.h>

Inheritance diagram for GrPorterDuffXPFactory:
GrXPFactory

Static Public Member Functions

static const GrXPFactoryGet (SkBlendMode blendMode)
 
static sk_sp< const GrXferProcessorMakeSrcOverXferProcessor (const GrProcessorAnalysisColor &, GrProcessorAnalysisCoverage, const GrCaps &)
 
static sk_sp< const GrXferProcessorMakeNoCoverageXP (SkBlendMode)
 
static const GrXferProcessorSimpleSrcOverXP ()
 
static AnalysisProperties SrcOverAnalysisProperties (const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage &, const GrCaps &, GrClampType)
 
- Static Public Member Functions inherited from GrXPFactory
static sk_sp< const GrXferProcessorMakeXferProcessor (const GrXPFactory *, const GrProcessorAnalysisColor &, GrProcessorAnalysisCoverage, const GrCaps &caps, GrClampType)
 
static AnalysisProperties GetAnalysisProperties (const GrXPFactory *, const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage &, const GrCaps &, GrClampType)
 
static const GrXPFactoryFromBlendMode (SkBlendMode)
 

Friends

class GrPorterDuffTest
 

Additional Inherited Members

- Public Types inherited from GrXPFactory
enum class  AnalysisProperties : unsigned {
  kNone = 0x0 , kReadsDstInShader = 0x1 , kCompatibleWithCoverageAsAlpha = 0x2 , kIgnoresInputColor = 0x4 ,
  kRequiresDstTexture = 0x10 , kRequiresNonOverlappingDraws = 0x20 , kUsesNonCoherentHWBlending = 0x40 , kUnaffectedByDstValue = 0x80
}
 
- Public Member Functions inherited from GrXPFactory
 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (AnalysisProperties)
 
- Protected Member Functions inherited from GrXPFactory
constexpr GrXPFactory ()
 

Detailed Description

Definition at line 29 of file GrPorterDuffXferProcessor.h.

Member Function Documentation

◆ Get()

const GrXPFactory * GrPorterDuffXPFactory::Get ( SkBlendMode  blendMode)
static

Definition at line 309 of file GrPorterDuffXferProcessor.cpp.

309 {
310 SkASSERT((unsigned)blendMode <= (unsigned)SkBlendMode::kLastCoeffMode);
311
312 static constexpr const GrPorterDuffXPFactory gClearPDXPF(SkBlendMode::kClear);
313 static constexpr const GrPorterDuffXPFactory gSrcPDXPF(SkBlendMode::kSrc);
314 static constexpr const GrPorterDuffXPFactory gDstPDXPF(SkBlendMode::kDst);
315 static constexpr const GrPorterDuffXPFactory gSrcOverPDXPF(SkBlendMode::kSrcOver);
316 static constexpr const GrPorterDuffXPFactory gDstOverPDXPF(SkBlendMode::kDstOver);
317 static constexpr const GrPorterDuffXPFactory gSrcInPDXPF(SkBlendMode::kSrcIn);
318 static constexpr const GrPorterDuffXPFactory gDstInPDXPF(SkBlendMode::kDstIn);
319 static constexpr const GrPorterDuffXPFactory gSrcOutPDXPF(SkBlendMode::kSrcOut);
320 static constexpr const GrPorterDuffXPFactory gDstOutPDXPF(SkBlendMode::kDstOut);
321 static constexpr const GrPorterDuffXPFactory gSrcATopPDXPF(SkBlendMode::kSrcATop);
322 static constexpr const GrPorterDuffXPFactory gDstATopPDXPF(SkBlendMode::kDstATop);
323 static constexpr const GrPorterDuffXPFactory gXorPDXPF(SkBlendMode::kXor);
324 static constexpr const GrPorterDuffXPFactory gPlusPDXPF(SkBlendMode::kPlus);
325 static constexpr const GrPorterDuffXPFactory gModulatePDXPF(SkBlendMode::kModulate);
326 static constexpr const GrPorterDuffXPFactory gScreenPDXPF(SkBlendMode::kScreen);
327
328 switch (blendMode) {
330 return &gClearPDXPF;
332 return &gSrcPDXPF;
334 return &gDstPDXPF;
336 return &gSrcOverPDXPF;
338 return &gDstOverPDXPF;
340 return &gSrcInPDXPF;
342 return &gDstInPDXPF;
344 return &gSrcOutPDXPF;
346 return &gDstOutPDXPF;
348 return &gSrcATopPDXPF;
350 return &gDstATopPDXPF;
352 return &gXorPDXPF;
354 return &gPlusPDXPF;
356 return &gModulatePDXPF;
358 return &gScreenPDXPF;
359 default:
360 SK_ABORT("Unexpected blend mode.");
361 }
362}
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
#define SkASSERT(cond)
Definition: SkAssert.h:116
@ kSrcOut
r = s * (1-da)
@ kPlus
r = min(s + d, 1)
@ kDstIn
r = d * sa
@ kModulate
r = s*d
@ kLastCoeffMode
last porter duff blend mode
@ kScreen
r = s + d - s*d
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kDstOut
r = d * (1-sa)
@ kSrcIn
r = s * da
@ kClear
r = 0

◆ MakeNoCoverageXP()

sk_sp< const GrXferProcessor > GrPorterDuffXPFactory::MakeNoCoverageXP ( SkBlendMode  blendmode)
static

Returns a simple non-LCD porter duff blend XP with no optimizations or coverage.

Definition at line 547 of file GrPorterDuffXferProcessor.cpp.

547 {
548 BlendFormula formula = skgpu::GetBlendFormula(false, false, blendmode);
549 return sk_make_sp<PorterDuffXferProcessor>(formula, GrProcessorAnalysisCoverage::kNone);
550}
BlendFormula GetBlendFormula(bool isOpaque, bool hasCoverage, SkBlendMode xfermode)

◆ MakeSrcOverXferProcessor()

sk_sp< const GrXferProcessor > GrPorterDuffXPFactory::MakeSrcOverXferProcessor ( const GrProcessorAnalysisColor color,
GrProcessorAnalysisCoverage  coverage,
const GrCaps caps 
)
static

Because src-over is so common we special case it for performance reasons. If this returns null then the SimpleSrcOverXP() below should be used.

color.isOpaque() ||

Definition at line 500 of file GrPorterDuffXferProcessor.cpp.

502 {
503 // We want to not make an xfer processor if possible. Thus for the simple case where we are not
504 // doing lcd blending we will just use our global SimpleSrcOverXP. This slightly differs from
505 // the general case where we convert a src-over blend that has solid coverage and an opaque
506 // color to src-mode, which allows disabling of blending.
510 BlendFormula blendFormula = skgpu::GetBlendFormula(true, false, SkBlendMode::kSrc);
512 }
513 // We return nullptr here, which our caller interprets as meaning "use SimpleSrcOverXP".
514 // We don't simply return the address of that XP here because our caller would have to unref
515 // it and since it is a global object and GrProgramElement's ref-cnting system is not thread
516 // safe.
517 return nullptr;
518 }
519
520 // Currently up the stack Skia is requiring that the dst is opaque or that the client has said
521 // the opaqueness doesn't matter. Thus for src-over we don't need to worry about the src color
522 // being opaque or not. This allows us to use faster code paths as well as avoid various bugs
523 // that occur with dst reads in the shader blending. For now we disable the check for
524 // opaqueness, but in the future we should pass down the knowledge about dst opaqueness and make
525 // the correct decision here.
526 //
527 // This also fixes a chrome bug on macs where we are getting random fuzziness when doing
528 // blending in the shader for non opaque sources.
529 if (color.isConstant() && /*color.isOpaque() &&*/
532 // If we don't have dual source blending or in shader dst reads, we fall
533 // back to this trick for rendering SrcOver LCD text instead of doing a
534 // dst copy.
536 }
537
539 // See comment above regarding why the opaque check is commented out here.
540 if (/*!color.isOpaque() ||*/
541 (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->fDualSourceBlendingSupport)) {
543 }
545}
const GrShaderCaps * shaderCaps() const
Definition: GrCaps.h:63
bool shouldCollapseSrcOverToSrcWhenAble() const
Definition: GrCaps.h:179
static sk_sp< const GrXferProcessor > Make(SkBlendMode mode, const GrProcessorAnalysisColor &inputColor)
bool hasSecondaryOutput() const
Definition: BlendFormula.h:66
DlColor color
BlendFormula GetLCDBlendFormula(SkBlendMode xfermode)
bool fDstReadInShaderSupport
Definition: GrShaderCaps.h:34
bool fDualSourceBlendingSupport
Definition: SkSLUtil.h:84

◆ SimpleSrcOverXP()

const GrXferProcessor & GrPorterDuffXPFactory::SimpleSrcOverXP ( )
static

This XP implements non-LCD src-over using hw blend with no optimizations. It is returned by reference because it is global and its ref-cnting methods are not thread safe.

Definition at line 492 of file GrPorterDuffXferProcessor.cpp.

492 {
493 static BlendFormula kSrcOverBlendFormula = skgpu::GetBlendFormula(
494 /*isOpaque=*/false, /*hasCoverage=*/false, SkBlendMode::kSrcOver);
495 static PorterDuffXferProcessor gSrcOverXP(kSrcOverBlendFormula,
497 return gSrcOverXP;
498}

◆ SrcOverAnalysisProperties()

GrXPFactory::AnalysisProperties GrPorterDuffXPFactory::SrcOverAnalysisProperties ( const GrProcessorAnalysisColor color,
const GrProcessorAnalysisCoverage coverage,
const GrCaps caps,
GrClampType  clampType 
)
static

Definition at line 552 of file GrPorterDuffXferProcessor.cpp.

556 {
557 return analysis_properties(color, coverage, caps, clampType, SkBlendMode::kSrcOver);
558}
static GrXPFactory::AnalysisProperties analysis_properties(const GrProcessorAnalysisColor &color, const GrProcessorAnalysisCoverage &coverage, const GrCaps &caps, GrClampType clampType, SkBlendMode mode)

Friends And Related Function Documentation

◆ GrPorterDuffTest

friend class GrPorterDuffTest
friend

Definition at line 69 of file GrPorterDuffXferProcessor.h.


The documentation for this class was generated from the following files: