blob: 3b87b0485ac46d1ab99a3d2bdec7e9e8b06f6dc3 [file] [log] [blame]
csmartdaltona7f29642016-07-07 08:49:11 -07001/*
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 gr_instanced_GLInstancedRendering_DEFINED
9#define gr_instanced_GLInstancedRendering_DEFINED
10
11#include "gl/GrGLBuffer.h"
12#include "instanced/InstancedRendering.h"
13
14class GrGLGpu;
15
16#define GR_GL_LOG_INSTANCED_BATCHES 0
17
18namespace gr_instanced {
19
20class GLInstancedRendering final : public InstancedRendering {
21public:
22 static GLInstancedRendering* CreateIfSupported(GrGLGpu*);
23 ~GLInstancedRendering() override;
24
25private:
26 GLInstancedRendering(GrGLGpu*, AntialiasMode lastSupportedAAMode);
27
28 GrGLGpu* glGpu() const;
29
30 Batch* createBatch() override;
31
32 void onBeginFlush(GrResourceProvider*) override;
33 void onDraw(const GrPipeline&, const InstanceProcessor&, const Batch*) override;
34 void onEndFlush() override;
35 void onResetGpuResources(ResetType) override;
36
37 void flushInstanceAttribs(int baseInstance);
38
39 struct GLDrawCmdInfo {
40 int fInstanceCount;
41#if GR_GL_LOG_INSTANCED_BATCHES
42 IndexRange fGeometry;
43#endif
44 };
45
46 GrGLuint fVertexArrayID;
csmartdalton485a1202016-07-13 10:16:32 -070047 SkAutoTUnref<GrBuffer> fInstanceBuffer;
48 SkAutoTUnref<GrBuffer> fDrawIndirectBuffer;
csmartdaltona7f29642016-07-07 08:49:11 -070049 SkAutoSTMalloc<1024, GLDrawCmdInfo> fGLDrawCmdsInfo;
50 uint32_t fInstanceAttribsBufferUniqueId;
51 int fInstanceAttribsBaseInstance;
52
53 class GLBatch;
54
55 typedef InstancedRendering INHERITED;
56};
57
58}
59
60#endif