42 return arena->
make([&](
void* ptr) {
43 return new (ptr)
GP(
mode, std::move(colorSpaceXform));
47 const char*
name()
const override {
return "VertexColorXformGP"; }
56 fColorSpaceHelper.setData(pdman, gp.fColorSpaceXform.get());
60 void onEmitCode(EmitArgs&
args, GrGPArgs* gpArgs)
override {
61 const GP& gp =
args.fGeomProc.cast<
GP>();
72 vertBuilder->codeAppendf(
"half4 color = %s;", gp.fInColor.name());
74 if (kShader_Mode == gp.fMode) {
75 fColorSpaceHelper.emitCode(uniformHandler, gp.fColorSpaceXform.get(),
78 vertBuilder->appendColorGamutXform(&xformedColor,
"color", &fColorSpaceHelper);
79 vertBuilder->codeAppendf(
"color = %s;", xformedColor.
c_str());
80 vertBuilder->codeAppend(
"color = half4(color.rgb * color.a, color.a);");
83 vertBuilder->codeAppendf(
"%s = color;", varying.vsOut());
84 fragBuilder->
codeAppendf(
"half4 %s = %s;",
args.fOutputColor, varying.fsIn());
87 WriteOutputPosition(
args.fVertBuilder, gpArgs, gp.fInPosition.name());
90 fragBuilder->
codeAppendf(
"const half4 %s = half4(1);",
args.fOutputCoverage);
96 return std::make_unique<Impl>();
106 :
INHERITED(kVertexColorSpaceBenchGP_ClassID)
108 , fColorSpaceXform(
std::move(colorSpaceXform)) {
122 this->setVertexAttributesWithImplicitOffsets(&fInPosition, 2);
138 const char*
name()
const override {
return "VertColorXformOp"; }
142 ,
fMode(kBaseline_Mode)
150 , fColor4f(color4f) {
157 ,
fMode(kShader_Mode)
159 , fColorSpaceXform(
std::move(colorSpaceXform)) {
172 friend class ::GrMemoryPool;
179 bool usesMSAASurface,
190 std::move(appliedClip),
195 renderPassXferBarriers,
216 if (kFloat_Mode ==
fMode) {
224 v[
i + 0].fPos.set(
dx *
i, 0.0f);
225 v[
i + 0].fColor = fColor4f;
226 v[
i + 1].fPos.set(
dx *
i, 100.0f);
227 v[
i + 1].fColor = fColor4f;
229 }
else if (kHalf_Mode ==
fMode) {
239 v[
i + 0].fPos.set(
dx *
i, 0.0f);
241 v[
i + 1].fPos.set(
dx *
i, 100.0f);
252 v[
i + 0].fPos.set(
dx *
i, 0.0f);
253 v[
i + 0].fColor = fColor;
254 v[
i + 1].fPos.set(
dx *
i, 100.0f);
255 v[
i + 1].fColor = fColor;
259 fMesh =
target->allocMesh();
264 if (!fProgramInfo || !fMesh) {
288 fName =
"vertexcolorspace";
299 if (kHalf_Mode == fMode &&
300 !context->priv().caps()->halfFloatVertexAttributeSupport()) {
310 const int kDrawsPerLoop = 32;
312 for (
int i = 0;
i < loops; ++
i) {
320 "DrawVertexColorSpaceBench");
323 for (
int j = 0; j < kDrawsPerLoop; ++j) {
337 c4f = xform->apply(c4f);
338 op = GrOp::Make<Op>(rContext, c4f, fMode);
341 sdc->addDrawOp(std::move(op));
344 context->flushAndSubmit();
#define DEFINE_OP_CLASS_ID
@ kFloat2_GrVertexAttribType
@ kUByte4_norm_GrVertexAttribType
@ kFloat4_GrVertexAttribType
@ kHalf4_GrVertexAttribType
static const size_t kVertexCount
SkColorSpace * sk_srgb_singleton()
static GrColor SkColorToUnpremulGrColor(SkColor c)
static GrColor SkColorToPremulGrColor(SkColor c)
#define INHERITED(method,...)
DEF_BENCH(return new VertexColorSpaceBench(kBaseline_Mode, "baseline"))
virtual GrDirectContext * asDirectContext()
virtual FixedFunctionFlags fixedFunctionFlags() const
virtual GrProcessorSet::Analysis finalize(const GrCaps &, const GrAppliedClip *, GrClampType)=0
void codeAppendf(const char format[],...) SK_PRINTF_LIKE(2
void emitAttributes(const GrGeometryProcessor &)
void addVarying(const char *name, GrGLSLVarying *varying, Interpolation=Interpolation::kInterpolated)
virtual std::unique_ptr< ProgramImpl > makeProgramImpl(const GrShaderCaps &) const =0
size_t vertexStride() const
virtual GrProgramInfo * programInfo()=0
void createProgramInfo(const GrCaps *caps, SkArenaAlloc *arena, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&appliedClip, const GrDstProxyView &dstProxyView, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
GrMeshDrawOp(uint32_t classID)
virtual void onCreateProgramInfo(const GrCaps *, SkArenaAlloc *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)=0
virtual void onPrepareDraws(GrMeshDrawTarget *)=0
void drawMesh(const GrSimpleMesh &mesh)
void bindPipelineAndScissorClip(const GrProgramInfo &programInfo, const SkRect &drawBounds)
void bindTextures(const GrGeometryProcessor &geomProc, const GrSurfaceProxy &singleGeomProcTexture, const GrPipeline &pipeline)
virtual void onExecute(GrOpFlushState *, const SkRect &chainBounds)=0
std::unique_ptr< GrOp > Owner
virtual const char * name() const =0
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
static constexpr Analysis EmptySetAnalysis()
static GrProcessorSet MakeEmptySet()
virtual const char * name() const =0
const GrPipeline & pipeline() const
const GrGeometryProcessor & geomProc() const
static GrProgramInfo * CreateProgramInfo(const GrCaps *, SkArenaAlloc *, const GrPipeline *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrGeometryProcessor *, GrPrimitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp, const GrUserStencilSettings *=&GrUserStencilSettings::kUnused)
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
virtual GrRecordingContext * recordingContext() const
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
const char * c_str() const
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
VertexColorSpaceBench(Mode mode, const char *name)
const char * onGetName() override
bool isSuitableFor(Backend backend) override
void onDraw(int loops, SkCanvas *canvas) override
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
T __attribute__((ext_vector_type(N))) V
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
static constexpr skcms_Matrix3x3 kDisplayP3
static constexpr skcms_TransferFunction kSRGB
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
DEF_SWITCHES_START aot vmservice shared library name
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
SIN Vec< N, uint16_t > to_half(const Vec< N, float > &x)
void set(sk_sp< const GrBuffer > vertexBuffer, int vertexCount, int baseVertex)
static constexpr SkRect MakeWH(float w, float h)
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)