44 if (btgp.fColor != fColor && !btgp.hasVertexColor()) {
45 pdman.
set4fv(fColorUniform, 1, btgp.fColor.
vec());
49 const SkISize& atlasDimensions = btgp.fAtlasDimensions;
52 if (fAtlasDimensions != atlasDimensions) {
53 pdman.
set2f(fAtlasDimensionsInvUniform,
54 1.0f / atlasDimensions.
fWidth,
55 1.0f / atlasDimensions.
fHeight);
56 fAtlasDimensions = atlasDimensions;
59 SetTransform(pdman, shaderCaps, fLocalMatrixUniform, btgp.fLocalMatrix, &fLocalMatrix);
60 fColorSpaceXformHelper.
setData(pdman, btgp.fColorSpaceXform.
get());
64 void onEmitCode(EmitArgs&
args, GrGPArgs* gpArgs)
override {
71 fColorSpaceXformHelper.
emitCode(uniformHandler,
72 btgp.fColorSpaceXform.
get());
77 const char* atlasDimensionsInvName;
84 btgp.fInTextureCoords.
name(),
85 atlasDimensionsInvName,
93 if (btgp.hasVertexColor()) {
101 gpArgs->fPositionVar = btgp.fInPosition.
asShaderVar();
108 &fLocalMatrixUniform);
112 texIdx, uv.
fsIn(),
"texColor");
113 if (!fColorSpaceXformHelper.
isNoop()) {
119 if (btgp.fMaskFormat == MaskFormat::kARGB) {
122 fragBuilder->
codeAppendf(
"const half4 %s = half4(1);",
args.fOutputCoverage);
124 fragBuilder->
codeAppendf(
"half4 %s = texColor;",
args.fOutputCoverage);
130 SkISize fAtlasDimensions = {-1, -1};
142GrBitmapTextGeoProc::GrBitmapTextGeoProc(
const GrShaderCaps& caps,
152 :
INHERITED(kGrBitmapTextGeoProc_ClassID)
154 , fColorSpaceXform(
std::move(colorSpaceXform))
155 , fLocalMatrix(localMatrix)
166 bool hasVertexColor = MaskFormat::kA8 == fMaskFormat || MaskFormat::kA565 == fMaskFormat;
167 if (hasVertexColor) {
175 if (numActiveViews) {
178 for (
int i = 0;
i < numActiveViews; ++
i) {
194 if (!fTextureSamplers[0].isInitialized()) {
198 for (
int i = 0;
i < numActiveViews; ++
i) {
203 if (!fTextureSamplers[
i].isInitialized()) {
211 b->addBool(fUsesW,
"usesW");
213 b->addBits(2,
static_cast<int>(fMaskFormat),
"maskFormat");
223 return std::make_unique<Impl>();
230#if defined(GR_TEST_UTILS)
233 auto [view, ct, at] =
d->randomView();
236 GrTest::TestWrapModes(
d->fRandom, wrapModes);
247 format = MaskFormat::kA565;
251 format = MaskFormat::kARGB;
256 bool wideColor =
d->fRandom->nextBool();
257 SkMatrix localMatrix = GrTest::TestMatrix(
d->fRandom);
258 bool usesW =
d->fRandom->nextBool();
262 &view, 1, samplerState,
format,
static void append_index_uv_varyings(GrGeometryProcessor::ProgramImpl::EmitArgs &args, int numTextureSamplers, const char *inTexCoordsName, const char *atlasDimensionsInvName, GrGLSLVarying *uv, GrGLSLVarying *texIdx, GrGLSLVarying *st)
static void append_multitexture_lookup(GrGeometryProcessor::ProgramImpl::EmitArgs &args, int numTextureSamplers, const GrGLSLVarying &texIdx, const char *coordName, const char *colorName)
#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(...)
@ kFloat2_GrVertexAttribType
@ kUShort2_GrVertexAttribType
@ kFloat3_GrVertexAttribType
constexpr SkPMColor4f SK_PMColor4fILLEGAL
constexpr bool SkIsPow2(T value)
#define INHERITED(method,...)
void setData(const GrGLSLProgramDataManager &pdman, const GrShaderCaps &shaderCaps, const GrGeometryProcessor &geomProc) override
static GrGeometryProcessor * Make(SkArenaAlloc *arena, const GrShaderCaps &caps, const SkPMColor4f &color, bool wideColor, sk_sp< GrColorSpaceXform > colorSpaceXform, const GrSurfaceProxyView *views, int numActiveViews, GrSamplerState p, skgpu::MaskFormat format, const SkMatrix &localMatrix, bool usesW)
void addToKey(const GrShaderCaps &caps, skgpu::KeyBuilder *b) const override
static constexpr int kMaxTextures
std::unique_ptr< ProgramImpl > makeProgramImpl(const GrShaderCaps &caps) const override
void addNewViews(const GrSurfaceProxyView *, int numActiveViews, GrSamplerState)
virtual void set4fv(UniformHandle, int arrayCount, const float v[]) const =0
virtual void set2f(UniformHandle, float, float) const =0
void codeAppend(const char *str)
void appendColorGamutXform(SkString *out, const char *srcColor, GrGLSLColorSpaceXformHelper *colorXformHelper)
void codeAppendf(const char format[],...) SK_PRINTF_LIKE(2
void emitAttributes(const GrGeometryProcessor &)
void addPassThroughAttribute(const GrShaderVar &vsVar, const char *output, Interpolation=Interpolation::kInterpolated)
const char * fsIn() const
GrShaderVar asShaderVar() const
constexpr const char * name() const
void setupUniformColor(GrGLSLFPFragmentBuilder *fragBuilder, GrGLSLUniformHandler *uniformHandler, const char *outputName, UniformHandle *colorUniform)
GrGLSLProgramDataManager::UniformHandle UniformHandle
static void WriteLocalCoord(GrGLSLVertexBuilder *, GrGLSLUniformHandler *, const GrShaderCaps &, GrGPArgs *, GrShaderVar localVar, const SkMatrix &localMatrix, UniformHandle *localMatrixUniform)
static constexpr int kMatrixKeyBits
static uint32_t ComputeMatrixKey(const GrShaderCaps &caps, const SkMatrix &mat)
static void SetTransform(const GrGLSLProgramDataManager &, const GrShaderCaps &, const UniformHandle &uniform, const SkMatrix &matrix, SkMatrix *state=nullptr)
void reset(GrSamplerState, const GrBackendFormat &, const skgpu::Swizzle &)
int numTextureSamplers() const
void setTextureSamplerCnt(int cnt)
static Attribute MakeColorAttribute(const char *name, bool wideColor)
void setVertexAttributesWithImplicitOffsets(const Attribute *attrs, int attrCount)
skgpu::Swizzle swizzle() const
GrSurfaceProxy * proxy() const
const GrBackendFormat & backendFormat() const
SkISize dimensions() const
static const SkMatrix & InvalidMatrix()
void add32(uint32_t v, std::string_view label="unknown")
const EmbeddedViewParams * params
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint32_t uint32_t * format
static float min(float r, float g, float b)
const float * vec() const
static SkRGBA4f FromBytes_RGBA(uint32_t color)