Flutter Engine
The Flutter Engine
GrGLOpsRenderPass.h
Go to the documentation of this file.
1/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrGLOpsRenderPass_DEFINED
9#define GrGLOpsRenderPass_DEFINED
10
12
16
17class GrGLGpu;
19
21/**
22 * We do not actually buffer up draws or do any work in the this class for GL. Instead commands
23 * are immediately sent to the gpu to execute. Thus all the commands in this class are simply
24 * pass through functions to corresponding calls in the GrGLGpu class.
25 */
26public:
27 GrGLOpsRenderPass(GrGLGpu* gpu) : fGpu(gpu) {}
28
30 state->doUpload(upload);
31 }
32
33 void set(GrRenderTarget*, bool useMSAASurface, const SkIRect& contentBounds, GrSurfaceOrigin,
34 const LoadAndStoreInfo&, const StencilLoadAndStoreInfo&);
35
36 void reset() {
37 fRenderTarget = nullptr;
38 }
39
40private:
41 GrGpu* gpu() override { return fGpu; }
42
43 void bindInstanceBuffer(const GrBuffer*, int baseInstance);
44 void bindVertexBuffer(const GrBuffer*, int baseVertex);
45
46 const void* offsetForBaseIndex(int baseIndex) const {
47 if (!fIndexPointer) {
48 // nullptr != 0. Adding an offset to a nullptr is undefined.
49 return (void*)(baseIndex * sizeof(uint16_t));
50 }
51 return fIndexPointer + baseIndex;
52 }
53
54 // Ideally we load and store DMSAA only within the content bounds of our render pass, but if
55 // the caps don't allow for partial framebuffer blits, we resolve the full target.
56 // We resolve the same bounds during load and store both because if we have to do a full size
57 // resolve at the end, the full DMSAA attachment needs to have valid content.
58 GrNativeRect dmsaaLoadStoreBounds() const;
59
60 void onBegin() override;
61 void onEnd() override;
62 bool onBindPipeline(const GrProgramInfo& programInfo, const SkRect& drawBounds) override;
63 void onSetScissorRect(const SkIRect& scissor) override;
64 bool onBindTextures(const GrGeometryProcessor&,
65 const GrSurfaceProxy* const geomProcTextures[],
66 const GrPipeline&) override;
67 void onBindBuffers(sk_sp<const GrBuffer> indexBuffer, sk_sp<const GrBuffer> instanceBuffer,
68 sk_sp<const GrBuffer> vertexBuffer, GrPrimitiveRestart) override;
69 void onDraw(int vertexCount, int baseVertex) override;
70 void onDrawIndexed(int indexCount, int baseIndex, uint16_t minIndexValue,
71 uint16_t maxIndexValue, int baseVertex) override;
72 void onDrawInstanced(int instanceCount, int baseInstance, int vertexCount,
73 int baseVertex) override;
74 void onDrawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance,
75 int baseVertex) override;
76 void onDrawIndirect(const GrBuffer* drawIndirectBuffer, size_t offset, int drawCount) override;
77 void multiDrawArraysANGLEOrWebGL(const GrBuffer* drawIndirectBuffer, size_t offset,
78 int drawCount);
79 void onDrawIndexedIndirect(const GrBuffer* drawIndirectBuffer, size_t offset,
80 int drawCount) override;
81 void multiDrawElementsANGLEOrWebGL(const GrBuffer* drawIndirectBuffer, size_t offset,
82 int drawCount);
83 void onClear(const GrScissorState& scissor, std::array<float, 4> color) override;
84 void onClearStencilClip(const GrScissorState& scissor, bool insideStencilMask) override;
85
86 GrGLGpu* const fGpu;
87
88 bool fUseMultisampleFBO;
89 SkIRect fContentBounds;
90 LoadAndStoreInfo fColorLoadAndStoreInfo;
91 StencilLoadAndStoreInfo fStencilLoadAndStoreInfo;
92
93 // Per-pipeline state.
94 GrPrimitiveType fPrimitiveType;
95 GrGLAttribArrayState* fAttribArrayState = nullptr;
96
97 // If using an index buffer, this gets set during onBindBuffers. It is either the CPU address of
98 // the indices, or nullptr if they reside physically in GPU memory.
99 const uint16_t* fIndexPointer;
100
101 // This tracks whether or not we bound the respective buffers during the bindBuffers call.
102 SkDEBUGCODE(bool fDidBindVertexBuffer = false;)
103 SkDEBUGCODE(bool fDidBindInstanceBuffer = false;)
104
105 using INHERITED = GrOpsRenderPass;
106};
107
108#endif
std::function< void(GrDeferredTextureUploadWritePixelsFn &)> GrDeferredTextureUploadFn
GrPrimitiveRestart
Definition: GrTypesPriv.h:56
GrPrimitiveType
Definition: GrTypesPriv.h:43
GrSurfaceOrigin
Definition: GrTypes.h:147
GrGLOpsRenderPass(GrGLGpu *gpu)
void set(GrRenderTarget *, bool useMSAASurface, const SkIRect &contentBounds, GrSurfaceOrigin, const LoadAndStoreInfo &, const StencilLoadAndStoreInfo &)
void inlineUpload(GrOpFlushState *state, GrDeferredTextureUploadFn &upload) override
Definition: GrGpu.h:62
GrRenderTarget * fRenderTarget
DlColor color
AtkStateType state
Definition: upload.py:1
SeparatedVector2 offset
Definition: SkRect.h:32