Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
GrGLSLColorSpaceXformHelper Class Reference

#include <GrGLSLColorSpaceXformHelper.h>

Inheritance diagram for GrGLSLColorSpaceXformHelper:
SkNoncopyable

Public Member Functions

 GrGLSLColorSpaceXformHelper ()
 
void emitCode (GrGLSLUniformHandler *uniformHandler, const GrColorSpaceXform *colorSpaceXform, uint32_t visibility=kFragment_GrShaderFlag)
 
void setData (const GrGLSLProgramDataManager &pdman, const GrColorSpaceXform *colorSpaceXform)
 
bool isNoop () const
 
bool applyUnpremul () const
 
bool applySrcTF () const
 
bool applyGamutXform () const
 
bool applyDstTF () const
 
bool applyPremul () const
 
skcms_TFType srcTFType () const
 
skcms_TFType dstTFType () const
 
GrGLSLProgramDataManager::UniformHandle srcTFUniform () const
 
GrGLSLProgramDataManager::UniformHandle gamutXformUniform () const
 
GrGLSLProgramDataManager::UniformHandle dstTFUniform () const
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Detailed Description

Helper class to assist with using GrColorSpaceXform within an FP. This manages all of the uniforms needed, and can be passed to shader builder functions to automatically generate the correct color space transformation code.

Definition at line 22 of file GrGLSLColorSpaceXformHelper.h.

Constructor & Destructor Documentation

◆ GrGLSLColorSpaceXformHelper()

GrGLSLColorSpaceXformHelper::GrGLSLColorSpaceXformHelper ( )
inline

Definition at line 24 of file GrGLSLColorSpaceXformHelper.h.

24{}

Member Function Documentation

◆ applyDstTF()

bool GrGLSLColorSpaceXformHelper::applyDstTF ( ) const
inline

Definition at line 65 of file GrGLSLColorSpaceXformHelper.h.

65{ return fFlags.encode; }

◆ applyGamutXform()

bool GrGLSLColorSpaceXformHelper::applyGamutXform ( ) const
inline

Definition at line 64 of file GrGLSLColorSpaceXformHelper.h.

◆ applyPremul()

bool GrGLSLColorSpaceXformHelper::applyPremul ( ) const
inline

Definition at line 66 of file GrGLSLColorSpaceXformHelper.h.

66{ return fFlags.premul; }

◆ applySrcTF()

bool GrGLSLColorSpaceXformHelper::applySrcTF ( ) const
inline

Definition at line 63 of file GrGLSLColorSpaceXformHelper.h.

◆ applyUnpremul()

bool GrGLSLColorSpaceXformHelper::applyUnpremul ( ) const
inline

Definition at line 62 of file GrGLSLColorSpaceXformHelper.h.

◆ dstTFType()

skcms_TFType GrGLSLColorSpaceXformHelper::dstTFType ( ) const
inline

Definition at line 69 of file GrGLSLColorSpaceXformHelper.h.

69{ return fDstTFType; }

◆ dstTFUniform()

GrGLSLProgramDataManager::UniformHandle GrGLSLColorSpaceXformHelper::dstTFUniform ( ) const
inline

Definition at line 73 of file GrGLSLColorSpaceXformHelper.h.

73{ return fDstTFVar; }

◆ emitCode()

void GrGLSLColorSpaceXformHelper::emitCode ( GrGLSLUniformHandler uniformHandler,
const GrColorSpaceXform colorSpaceXform,
uint32_t  visibility = kFragment_GrShaderFlag 
)
inline

Definition at line 26 of file GrGLSLColorSpaceXformHelper.h.

27 {
28 SkASSERT(uniformHandler);
29 if (colorSpaceXform) {
30 fFlags = colorSpaceXform->fSteps.flags;
31 if (this->applySrcTF()) {
32 fSrcTFVar = uniformHandler->addUniformArray(nullptr, visibility, SkSLType::kFloat,
33 "SrcTF", kNumTransferFnCoeffs);
34 fSrcTFType = skcms_TransferFunction_getType(&colorSpaceXform->fSteps.srcTF);
35 }
36 if (this->applyGamutXform()) {
37 fGamutXformVar = uniformHandler->addUniform(nullptr, visibility, SkSLType::kFloat3x3,
38 "ColorXform");
39 }
40 if (this->applyDstTF()) {
41 fDstTFVar = uniformHandler->addUniformArray(nullptr, visibility, SkSLType::kFloat,
42 "DstTF", kNumTransferFnCoeffs);
43 fDstTFType = skcms_TransferFunction_getType(&colorSpaceXform->fSteps.dstTFInv);
44 }
45 }
46 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
UniformHandle addUniformArray(const GrProcessor *owner, uint32_t visibility, SkSLType type, const char *name, int arrayCount, const char **outName=nullptr)
UniformHandle addUniform(const GrProcessor *owner, uint32_t visibility, SkSLType type, const char *name, const char **outName=nullptr)
skcms_TFType skcms_TransferFunction_getType(const skcms_TransferFunction *tf)
Definition: skcms.cc:183
skcms_TransferFunction srcTF
skcms_TransferFunction dstTFInv

◆ gamutXformUniform()

GrGLSLProgramDataManager::UniformHandle GrGLSLColorSpaceXformHelper::gamutXformUniform ( ) const
inline

Definition at line 72 of file GrGLSLColorSpaceXformHelper.h.

72{ return fGamutXformVar; }

◆ isNoop()

bool GrGLSLColorSpaceXformHelper::isNoop ( ) const
inline

Definition at line 60 of file GrGLSLColorSpaceXformHelper.h.

60{ return (0 == fFlags.mask()); }
constexpr uint32_t mask() const

◆ setData()

void GrGLSLColorSpaceXformHelper::setData ( const GrGLSLProgramDataManager pdman,
const GrColorSpaceXform colorSpaceXform 
)
inline

Definition at line 48 of file GrGLSLColorSpaceXformHelper.h.

48 {
49 if (this->applySrcTF()) {
50 pdman.set1fv(fSrcTFVar, kNumTransferFnCoeffs, &colorSpaceXform->fSteps.srcTF.g);
51 }
52 if (this->applyGamutXform()) {
53 pdman.setMatrix3f(fGamutXformVar, colorSpaceXform->fSteps.src_to_dst_matrix);
54 }
55 if (this->applyDstTF()) {
56 pdman.set1fv(fDstTFVar, kNumTransferFnCoeffs, &colorSpaceXform->fSteps.dstTFInv.g);
57 }
58 }
virtual void setMatrix3f(UniformHandle, const float matrix[]) const =0
virtual void set1fv(UniformHandle, int arrayCount, const float v[]) const =0

◆ srcTFType()

skcms_TFType GrGLSLColorSpaceXformHelper::srcTFType ( ) const
inline

Definition at line 68 of file GrGLSLColorSpaceXformHelper.h.

68{ return fSrcTFType; }

◆ srcTFUniform()

GrGLSLProgramDataManager::UniformHandle GrGLSLColorSpaceXformHelper::srcTFUniform ( ) const
inline

Definition at line 71 of file GrGLSLColorSpaceXformHelper.h.

71{ return fSrcTFVar; }

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