Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
GrPaint Class Reference

#include <GrPaint.h>

Public Member Functions

 GrPaint ()=default
 
 ~GrPaint ()=default
 
void setColor4f (const SkPMColor4f &color)
 
const SkPMColor4fgetColor4f () const
 
void setXPFactory (const GrXPFactory *xpFactory)
 
void setPorterDuffXPFactory (SkBlendMode mode)
 
void setCoverageSetOpXPFactory (SkRegion::Op, bool invertCoverage=false)
 
void setColorFragmentProcessor (std::unique_ptr< GrFragmentProcessor > fp)
 
void setCoverageFragmentProcessor (std::unique_ptr< GrFragmentProcessor > fp)
 
bool hasColorFragmentProcessor () const
 
int hasCoverageFragmentProcessor () const
 
int numTotalFragmentProcessors () const
 
const GrXPFactorygetXPFactory () const
 
GrFragmentProcessorgetColorFragmentProcessor () const
 
GrFragmentProcessorgetCoverageFragmentProcessor () const
 
bool usesLocalCoords () const
 
bool isConstantBlendedColor (SkPMColor4f *constantColor) const
 
bool isTrivial () const
 

Static Public Member Functions

static GrPaint Clone (const GrPaint &src)
 

Friends

class GrProcessorSet
 
void assert_alive (GrPaint &p)
 

Detailed Description

The paint describes how color and coverage are computed at each pixel by GrContext draw functions and the how color is blended with the destination pixel.

The paint allows installation of custom color and coverage stages. New types of stages are created by subclassing GrProcessor.

The primitive color computation starts with the color specified by setColor(). This color is the input to the first color stage. Each color stage feeds its output to the next color stage.

Fractional pixel coverage follows a similar flow. The GrGeometryProcessor (specified elsewhere) provides the initial coverage which is passed to the first coverage fragment processor, which feeds its output to next coverage fragment processor.

setXPFactory is used to control blending between the output color and dest. It also implements the application of fractional coverage from the coverage pipeline.

Definition at line 40 of file GrPaint.h.

Constructor & Destructor Documentation

◆ GrPaint()

GrPaint::GrPaint ( )
default

◆ ~GrPaint()

GrPaint::~GrPaint ( )
default

Member Function Documentation

◆ Clone()

static GrPaint GrPaint::Clone ( const GrPaint src)
inlinestatic

Definition at line 45 of file GrPaint.h.

45{ return GrPaint(src); }
GrPaint()=default

◆ getColor4f()

const SkPMColor4f & GrPaint::getColor4f ( ) const
inline

Definition at line 51 of file GrPaint.h.

51{ return fColor; }

◆ getColorFragmentProcessor()

GrFragmentProcessor * GrPaint::getColorFragmentProcessor ( ) const
inline

Definition at line 91 of file GrPaint.h.

91 {
92 return fColorFragmentProcessor.get();
93 }

◆ getCoverageFragmentProcessor()

GrFragmentProcessor * GrPaint::getCoverageFragmentProcessor ( ) const
inline

Definition at line 94 of file GrPaint.h.

94 {
95 return fCoverageFragmentProcessor.get();
96 }

◆ getXPFactory()

const GrXPFactory * GrPaint::getXPFactory ( ) const
inline

Definition at line 89 of file GrPaint.h.

89{ return fXPFactory; }

◆ hasColorFragmentProcessor()

bool GrPaint::hasColorFragmentProcessor ( ) const
inline

Definition at line 82 of file GrPaint.h.

82{ return fColorFragmentProcessor ? true : false; }

◆ hasCoverageFragmentProcessor()

int GrPaint::hasCoverageFragmentProcessor ( ) const
inline

Definition at line 83 of file GrPaint.h.

83{ return fCoverageFragmentProcessor ? true : false; }

◆ isConstantBlendedColor()

bool GrPaint::isConstantBlendedColor ( SkPMColor4f constantColor) const

Returns true if the paint's output color will be constant after blending. If the result is true, constantColor will be updated to contain the constant color. Note that we can conflate coverage and color, so the actual values written to pixels with partial coverage may still not seem constant, even if this function returns true.

Definition at line 36 of file GrPaint.cpp.

36 {
37 // This used to do a more sophisticated analysis but now it just explicitly looks for common
38 // cases.
41 if (kClear == fXPFactory) {
42 *constantColor = SK_PMColor4fTRANSPARENT;
43 return true;
44 }
45 if (this->hasColorFragmentProcessor()) {
46 return false;
47 }
48 if (kSrc == fXPFactory || (!fXPFactory && fColor.isOpaque())) {
49 *constantColor = fColor;
50 return true;
51 }
52 return false;
53}
@ kClear
r = 0
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
bool hasColorFragmentProcessor() const
Definition GrPaint.h:82
static const GrXPFactory * Get(SkBlendMode blendMode)
bool isOpaque() const
Definition SkColor.h:344

◆ isTrivial()

bool GrPaint::isTrivial ( ) const
inline

A trivial paint is one that uses src-over and has no fragment processors. It may have variable sRGB settings.

Definition at line 115 of file GrPaint.h.

115{ return fTrivial; }

◆ numTotalFragmentProcessors()

int GrPaint::numTotalFragmentProcessors ( ) const
inline

Definition at line 84 of file GrPaint.h.

84 {
85 return (this->hasColorFragmentProcessor() ? 1 : 0) +
86 (this->hasCoverageFragmentProcessor() ? 1 : 0);
87 }
int hasCoverageFragmentProcessor() const
Definition GrPaint.h:83

◆ setColor4f()

void GrPaint::setColor4f ( const SkPMColor4f color)
inline

The initial color of the drawn primitive. Defaults to solid white.

Definition at line 50 of file GrPaint.h.

50{ fColor = color; }
SkColor4f color

◆ setColorFragmentProcessor()

void GrPaint::setColorFragmentProcessor ( std::unique_ptr< GrFragmentProcessor fp)
inline

Sets a processor for color computation.

Definition at line 65 of file GrPaint.h.

65 {
66 SkASSERT(fp);
67 SkASSERT(fColorFragmentProcessor == nullptr);
68 fColorFragmentProcessor = std::move(fp);
69 fTrivial = false;
70 }
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ setCoverageFragmentProcessor()

void GrPaint::setCoverageFragmentProcessor ( std::unique_ptr< GrFragmentProcessor fp)
inline

Appends an additional coverage processor to the coverage computation.

Definition at line 75 of file GrPaint.h.

75 {
76 SkASSERT(fp);
77 SkASSERT(fCoverageFragmentProcessor == nullptr);
78 fCoverageFragmentProcessor = std::move(fp);
79 fTrivial = false;
80 }

◆ setCoverageSetOpXPFactory()

void GrPaint::setCoverageSetOpXPFactory ( SkRegion::Op  regionOp,
bool  invertCoverage = false 
)

Definition at line 32 of file GrPaint.cpp.

32 {
33 this->setXPFactory(GrCoverageSetOpXPFactory::Get(regionOp, invertCoverage));
34}
static const GrXPFactory * Get(SkRegion::Op regionOp, bool invertCoverage=false)
void setXPFactory(const GrXPFactory *xpFactory)
Definition GrPaint.h:53

◆ setPorterDuffXPFactory()

void GrPaint::setPorterDuffXPFactory ( SkBlendMode  mode)

Definition at line 28 of file GrPaint.cpp.

28 {
30}

◆ setXPFactory()

void GrPaint::setXPFactory ( const GrXPFactory xpFactory)
inline

Definition at line 53 of file GrPaint.h.

53 {
54 fXPFactory = xpFactory;
55 fTrivial &= !SkToBool(xpFactory);
56 }
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35

◆ usesLocalCoords()

bool GrPaint::usesLocalCoords ( ) const
inline

Definition at line 97 of file GrPaint.h.

97 {
98 // The sample coords for the top level FPs are implicitly the GP's local coords.
99 return (fColorFragmentProcessor && fColorFragmentProcessor->usesSampleCoords()) ||
100 (fCoverageFragmentProcessor && fCoverageFragmentProcessor->usesSampleCoords());
101 }

Friends And Related Symbol Documentation

◆ assert_alive

void assert_alive ( GrPaint p)
friend

Definition at line 117 of file GrPaint.h.

117 {
118 SkASSERT(p.fAlive);
119 }

◆ GrProcessorSet

friend class GrProcessorSet
friend

Definition at line 127 of file GrPaint.h.


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