34 : fVertexPool(gpu, cpuBufferCache)
35 , fIndexPool(gpu, cpuBufferCache)
36 , fDrawIndirectPool(gpu,
std::move(cpuBufferCache))
38 , fResourceProvider(resourceProvider)
39 , fTokenTracker(tokenTracker) {}
54 while (fCurrDraw != fDraws.
end() && fCurrDraw->fOp == op) {
56 while (fCurrUpload != fInlineUploads.
end() &&
57 fCurrUpload->fUploadBeforeToken == drawToken) {
67 fCurrDraw->fGeometryProcessor,
68 fCurrDraw->fPrimitiveType,
69 this->renderPassBarriers(),
75 for (
int i = 0; i < fCurrDraw->fMeshCnt; ++i) {
76 this->
drawMesh(fCurrDraw->fMeshes[i]);
79 fTokenTracker->issueFlushToken();
87 fDrawIndirectPool.
unmap();
88 for (
auto&
upload : fASAPUploads) {
92 fCurrDraw = fDraws.
begin();
93 fCurrUpload = fInlineUploads.
begin();
102 fDrawIndirectPool.
reset();
104 fASAPUploads.
reset();
105 fInlineUploads.
reset();
111 bool shouldPrepareSurfaceForSampling) {
126 std::unique_ptr<char[]> tmpPixels;
129 tmpPixels.reset(
new char[rect.height()*tightRB]);
147 shouldPrepareSurfaceForSampling);
170 bool firstDraw = fDraws.
begin() == fDraws.
end();
174 SkASSERT(geomProcProxies && geomProcProxies[i]);
175 geomProcProxies[i]->
ref();
177 draw.fGeometryProcessor = geomProc;
178 draw.fGeomProcProxies = geomProcProxies;
179 draw.fMeshes = meshes;
180 draw.fMeshCnt = meshCnt;
182 draw.fPrimitiveType = primitiveType;
184 fBaseDrawToken = token;
190 return fVertexPool.
makeSpace(vertexSize, vertexCount,
buffer, startVertex);
195 return reinterpret_cast<uint16_t*
>(fIndexPool.
makeSpace(indexCount,
buffer, startIndex));
200 int* startVertex,
int* actualVertexCount) {
202 startVertex, actualVertexCount);
207 int* actualIndexCount) {
209 minIndexCount, fallbackIndexCount,
buffer, startIndex, actualIndexCount));
213 fIndexPool.
putBack(indexCount *
sizeof(uint16_t));
217 fVertexPool.
putBack(vertices * vertexStride);
232#if !defined(SK_ENABLE_OPTIMIZE_SIZE)
240 if (!mesh.fIndexBuffer) {
245 if (0 == mesh.fPatternRepeatCount) {
247 mesh.fMaxIndexValue, mesh.fBaseVertex);
250 mesh.fMaxPatternRepetitionsInIndexBuffer, mesh.fVertexCount,
258GrOpFlushState::Draw::~Draw() {
260 SkASSERT(fGeomProcProxies && fGeomProcProxies[i]);
261 fGeomProcProxies[i]->unref();
bool GrConvertPixels(const GrPixmap &dst, const GrCPixmap &src, bool flipY)
std::function< void(GrDeferredTextureUploadWritePixelsFn &)> GrDeferredTextureUploadFn
std::function< bool(GrTextureProxy *, SkIRect, GrColorType srcColorType, const void *, size_t rowBytes)> GrDeferredTextureUploadWritePixelsFn
static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct)
@ kUnknown_SkAlphaType
uninitialized
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
GrGeometryProcessor * fGeometryProcessor
static GrAppliedClip Disabled()
void putBack(size_t bytes)
virtual SupportedWrite supportedWritePixelsColorType(GrColorType surfaceColorType, const GrBackendFormat &surfaceFormat, GrColorType srcColorType) const =0
bool surfaceSupportsWritePixels(const GrSurface *) const
bool writePixelsRowBytesSupport() const
skgpu::ganesh::SmallPathAtlasMgr * getSmallPathAtlasMgr()
GrAtlasManager * getAtlasManager()
sktext::gpu::StrikeCache * getStrikeCache()
GrDirectContextPriv priv()
int numTextureSamplers() const
bool writePixels(GrSurface *surface, SkIRect rect, GrColorType surfaceColorType, GrColorType srcColorType, const GrMipLevel texels[], int mipLevelCount, bool prepForTexSampling=false)
const GrCaps * caps() const
GrDirectContext * getContext()
virtual void willExecute()
void * makeSpace(int indexCount, sk_sp< const GrBuffer > *buffer, int *startIndex)
void * makeSpaceAtLeast(int minIndexCount, int fallbackIndexCount, sk_sp< const GrBuffer > *buffer, int *startIndex, int *actualIndexCount)
sktext::gpu::StrikeCache * strikeCache() const final
skgpu::ganesh::SmallPathAtlasMgr * smallPathAtlasManager() const final
void drawMesh(const GrSimpleMesh &mesh)
uint16_t * makeIndexSpace(int indexCount, sk_sp< const GrBuffer > *, int *startIndex) final
void bindPipelineAndScissorClip(const GrProgramInfo &programInfo, const SkRect &drawBounds)
GrThreadSafeCache * threadSafeCache() const final
void recordDraw(const GrGeometryProcessor *, const GrSimpleMesh[], int meshCnt, const GrSurfaceProxy *const primProcProxies[], GrPrimitiveType) final
void putBackIndices(int indexCount) final
void * makeVertexSpaceAtLeast(size_t vertexSize, int minVertexCount, int fallbackVertexCount, sk_sp< const GrBuffer > *, int *startVertex, int *actualVertexCount) final
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
GrOpFlushState(GrGpu *, GrResourceProvider *, skgpu::TokenTracker *, sk_sp< GrBufferAllocPool::CpuBufferCache >=nullptr)
GrAppliedClip detachAppliedClip() final
GrAtlasManager * atlasManager() const final
const GrCaps & caps() const final
skgpu::AtlasToken addInlineUpload(GrDeferredTextureUploadFn &&) final
void drawIndexed(int indexCount, int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, int baseVertex)
GrOpsRenderPass * opsRenderPass()
void putBackVertices(int vertices, size_t vertexStride) final
void * makeVertexSpace(size_t vertexSize, int vertexCount, sk_sp< const GrBuffer > *, int *startVertex) final
void executeDrawsAndUploadsForMeshDrawOp(const GrOp *op, const SkRect &chainBounds, const GrPipeline *, const GrUserStencilSettings *)
uint16_t * makeIndexSpaceAtLeast(int minIndexCount, int fallbackIndexCount, sk_sp< const GrBuffer > *, int *startIndex, int *actualIndexCount) final
void bindTextures(const GrGeometryProcessor &geomProc, const GrSurfaceProxy &singleGeomProcTexture, const GrPipeline &pipeline)
void doUpload(GrDeferredTextureUploadFn &, bool shouldPrepareSurfaceForSampling=false)
void draw(int vertexCount, int baseVertex)
bool usesMSAASurface() const final
skgpu::AtlasToken addASAPUpload(GrDeferredTextureUploadFn &&) final
void drawIndexPattern(int patternIndexCount, int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer, int patternVertexCount, int baseVertex)
virtual void inlineUpload(GrOpFlushState *, GrDeferredTextureUploadFn &)=0
const GrPipeline & pipeline() const
const GrGeometryProcessor & geomProc() const
GrThreadSafeCache * threadSafeCache()
GrSurface * peekSurface() const
virtual GrBackendFormat backendFormat() const =0
void * makeSpace(size_t vertexSize, int vertexCount, sk_sp< const GrBuffer > *buffer, int *startVertex)
void * makeSpaceAtLeast(size_t vertexSize, int minVertexCount, int fallbackVertexCount, sk_sp< const GrBuffer > *buffer, int *startVertex, int *actualVertexCount)
T & append(SkArenaAlloc *arena, Args... args)
static AtlasToken InvalidToken()
AtlasToken nextFlushToken() const
AtlasToken nextDrawToken() const
static const uint8_t buffer[]
GrAppliedClip * appliedClip()
sk_sp< const GrBuffer > fIndexBuffer
sk_sp< const GrBuffer > fVertexBuffer