70 return arena->
make([&](
void* ptr) {
71 return new (ptr) ClockwiseTestProcessor(readSkFragCoord);
75 const char*
name() const final {
return "ClockwiseTestProcessor"; }
78 b->add32(fReadSkFragCoord);
81 std::unique_ptr<ProgramImpl> makeProgramImpl(
const GrShaderCaps&)
const final;
83 bool readSkFragCoord()
const {
return fReadSkFragCoord; }
86 ClockwiseTestProcessor(
bool readSkFragCoord)
88 , fReadSkFragCoord(readSkFragCoord) {
89 this->setVertexAttributesWithImplicitOffsets(&gVertex, 1);
92 const bool fReadSkFragCoord;
97std::unique_ptr<GrGeometryProcessor::ProgramImpl> ClockwiseTestProcessor::makeProgramImpl(
106 void onEmitCode(EmitArgs&
args, GrGPArgs* gpArgs)
override {
107 const ClockwiseTestProcessor& proc =
args.fGeomProc.cast<ClockwiseTestProcessor>();
108 args.fVaryingHandler->emitAttributes(proc);
110 args.fFragBuilder->codeAppendf(
111 "half4 %s = sk_Clockwise ? half4(0,1,0,1) : half4(1,0,0,1);",
113 if (!proc.readSkFragCoord()) {
114 args.fFragBuilder->codeAppendf(
"const half4 %s = half4(1);",
args.fOutputCoverage);
117 args.fFragBuilder->codeAppendf(
"half4 %s = half4(min(half(sk_FragCoord.y), 1));",
118 args.fOutputCoverage);
123 return std::make_unique<Impl>();
129class ClockwiseTestOp :
public GrDrawOp {
134 bool readSkFragCoord,
int y = 0) {
135 return GrOp::Make<ClockwiseTestOp>(context, readSkFragCoord,
y);
139 ClockwiseTestOp(
bool readSkFragCoord,
float y)
141 , fReadSkFragCoord(readSkFragCoord)
143 this->setBounds(
SkRect::MakeXYWH(0, fY, 100, 100), HasAABloat::kNo, IsHairline::kNo);
146 const char*
name()
const override {
return "ClockwiseTestOp"; }
155 bool usesMSAASurface,
162 return sk_gpu_test::CreateProgramInfo(caps, arena, writeView, usesMSAASurface,
163 std::move(appliedClip), dstProxyView,
166 renderPassXferBarriers, colorLoadOp);
170 return this->createProgramInfo(&flushState->
caps(),
186 SkArenaAlloc* arena = context->priv().recordTimeAllocator();
194 fProgramInfo = this->createProgramInfo(context->priv().caps(), arena, writeView,
195 usesMSAASurface, std::move(appliedClip),
196 dstProxyView, renderPassXferBarriers, colorLoadOp);
198 context->priv().recordProgramInfo(fProgramInfo);
220 fProgramInfo = this->createProgramInfo(flushState);
225 flushState->
draw(4, 0);
229 const bool fReadSkFragCoord;
258 SkISize getISize()
override {
return {300, 200}; }
265 *errorMsg = kErrorMsg_DrawSkippedGpuOnly;
276 GrColorType sdcColorType = sdc->colorInfo().colorType();
292 sdc->drawTexture(
nullptr,
293 topLeftSDC->readSurfaceView(),
294 sdc->colorInfo().alphaType(),
302 SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint,
318 sdc->drawTexture(
nullptr,
319 topLeftSDC->readSurfaceView(),
320 sdc->colorInfo().alphaType(),
328 SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint,
338DEF_GM(
return new ClockwiseGM(); )
#define DEFINE_OP_CLASS_ID
@ kStatic_GrAccessPattern
@ kFloat2_GrVertexAttribType
@ kTopLeft_GrSurfaceOrigin
@ kSrcOver
r = s + (1-sa)*d
constexpr SkPMColor4f SK_PMColor4fWHITE
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
constexpr SkPMColor4f SK_PMColor4fBLACK
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
#define INHERITED(method,...)
sk_sp< const GrBuffer > fVertexBuffer
GrLoadOp colorLoadOp() const final
const GrDstProxyView & dstProxyView() const final
GrXferBarrierFlags renderPassBarriers() const final
SkArenaAlloc * allocator() override
void bindBuffers(sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart primitiveRestart=GrPrimitiveRestart::kNo)
const GrSurfaceProxyView & writeView() const final
GrResourceProvider * resourceProvider() const final
GrAppliedClip detachAppliedClip() final
const GrCaps & caps() const final
void bindPipeline(const GrProgramInfo &programInfo, const SkRect &drawBounds)
void draw(int vertexCount, int baseVertex)
bool usesMSAASurface() const final
std::unique_ptr< GrOp > Owner
static constexpr Analysis EmptySetAnalysis()
sk_sp< GrGpuBuffer > createBuffer(size_t size, GrGpuBufferType, GrAccessPattern, ZeroInit)
GrRenderTargetProxy * asRenderTargetProxy() const
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
static const SkMatrix & I()
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
DEF_SWITCHES_START aot vmservice shared library name
SurfaceDrawContext * TopDeviceSurfaceDrawContext(const SkCanvas *canvas)
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)