32 UniformMatrixEffect(std::unique_ptr<GrFragmentProcessor> child)
38 const char*
name()
const override {
return "UniformMatrixEffect"; }
41 std::unique_ptr<GrFragmentProcessor>
clone()
const override {
return nullptr; }
46 void emitCode(EmitArgs&
args)
override {
48 args.fUniformHandler->addUniform(&
args.fFp,
53 args.fFragBuilder->codeAppendf(
"return %s;\n", sample.
c_str());
61 UniformHandle fMatrixVar;
63 return std::make_unique<Impl>();
73 ExplicitCoordEffect(std::unique_ptr<GrFragmentProcessor> child)
79 const char*
name()
const override {
return "ExplicitCoordEffect"; }
82 std::unique_ptr<GrFragmentProcessor>
clone()
const override {
return nullptr; }
87 void emitCode(EmitArgs&
args)
override {
88 args.fFragBuilder->codeAppendf(
"float2 coord = %s + float2(0, 8);",
91 args.fFragBuilder->codeAppendf(
"return %s;\n", sample.
c_str());
95 return std::make_unique<Impl>();
108 const char*
name()
const override {
return "TestPatternEffect"; }
111 std::unique_ptr<GrFragmentProcessor>
clone()
const override {
return nullptr; }
116 void emitCode(EmitArgs&
args)
override {
117 auto fb =
args.fFragBuilder;
118 fb->codeAppendf(
"float2 coord = %s / 64.0;",
args.fSampleCoord);
119 fb->codeAppendf(
"coord = floor(coord * 4) / 3;");
120 fb->codeAppendf(
"return half2(coord).rg01;\n");
124 return std::make_unique<Impl>();
130 bitmap.allocN32Pixels(64, 64);
134 const char* alpha =
"ABCDEFGHIJKLMNOP";
136 for (
int i = 0;
i < 16; ++
i) {
142 paint.setColor4f({ tx / 3.0f, ty / 3.0f, 0.0f, 1.0f });
144 paint.setColor4f({ (3-tx) / 3.0f, (3-ty)/3.0f, 1.0f, 1.0f });
157static std::unique_ptr<GrFragmentProcessor> wrap(std::unique_ptr<GrFragmentProcessor>
fp,
158 EffectType effectType,
159 int drawX,
int drawY) {
160 switch (effectType) {
162 return std::make_unique<UniformMatrixEffect>(std::move(
fp));
164 return std::make_unique<ExplicitCoordEffect>(std::move(
fp));
188 auto nextCol = [&] {
x += (64 + 10); };
189 auto nextRow = [&] {
x = 10;
y += (64 + 10); };
191 auto draw = [&](std::initializer_list<EffectType> effects) {
196 auto fp = std::unique_ptr<GrFragmentProcessor>(
new TestPatternEffect());
202 for (EffectType effectType : effects) {
203 fp = wrap(std::move(
fp), effectType,
x,
y);
206 paint.setColorFragmentProcessor(std::move(
fp));
224 draw({ kExplicit, kExplicit });
@ kUTF8
uses bytes to represent UTF-8 or ASCII
std::tuple< GrSurfaceProxyView, GrColorType > GrMakeCachedBitmapProxyView(GrRecordingContext *rContext, const SkBitmap &bitmap, std::string_view label, skgpu::Mipmapped mipmapped)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
virtual std::unique_ptr< GrFragmentProcessor > clone() const =0
static std::unique_ptr< GrFragmentProcessor > DeviceSpace(std::unique_ptr< GrFragmentProcessor >)
void registerChild(std::unique_ptr< GrFragmentProcessor > child, SkSL::SampleUsage sampleUsage=SkSL::SampleUsage::PassThrough())
virtual void onAddToKey(const GrShaderCaps &, skgpu::KeyBuilder *) const =0
void setUsesSampleCoordsDirectly()
virtual bool onIsEqual(const GrFragmentProcessor &) const =0
virtual std::unique_ptr< ProgramImpl > onMakeProgramImpl() const =0
void setSkMatrix(UniformHandle, const SkMatrix &) const
static std::unique_ptr< GrFragmentProcessor > Make(const SkMatrix &matrix, std::unique_ptr< GrFragmentProcessor > child)
virtual const char * name() const =0
static std::unique_ptr< GrFragmentProcessor > Make(GrSurfaceProxyView, SkAlphaType, const SkMatrix &=SkMatrix::I(), GrSamplerState::Filter=GrSamplerState::Filter::kNearest, GrSamplerState::MipmapMode mipmapMode=GrSamplerState::MipmapMode::kNone)
SkAlphaType alphaType() const
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
static SampleUsage Explicit()
static SampleUsage UniformMatrix(bool hasPerspective)
static const char * MatrixUniformName()
const char * c_str() const
static constexpr char kErrorMsg_DrawSkippedGpuOnly[]
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
font
Font Metadata and Metrics.
const myers::Point & get< 0 >(const myers::Segment &s)
SurfaceDrawContext * TopDeviceSurfaceDrawContext(const SkCanvas *canvas)
DEF_SIMPLE_GPU_GM_CAN_FAIL(clear_swizzle, rContext, canvas, errorMsg, 6 *kSize, 2 *kSize)
static SkRect MakeIWH(int w, int h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)