OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef gr_instanced_GLInstancedRendering_DEFINED | 8 #ifndef gr_instanced_GLInstancedRendering_DEFINED |
9 #define gr_instanced_GLInstancedRendering_DEFINED | 9 #define gr_instanced_GLInstancedRendering_DEFINED |
10 | 10 |
| 11 #include "GrCaps.h" |
11 #include "gl/GrGLBuffer.h" | 12 #include "gl/GrGLBuffer.h" |
12 #include "instanced/InstancedRendering.h" | 13 #include "instanced/InstancedRendering.h" |
13 | 14 |
| 15 class GrGLCaps; |
14 class GrGLGpu; | 16 class GrGLGpu; |
15 | 17 |
16 #define GR_GL_LOG_INSTANCED_BATCHES 0 | 18 #define GR_GL_LOG_INSTANCED_BATCHES 0 |
17 | 19 |
18 namespace gr_instanced { | 20 namespace gr_instanced { |
19 | 21 |
20 class GLInstancedRendering final : public InstancedRendering { | 22 class GLInstancedRendering final : public InstancedRendering { |
21 public: | 23 public: |
22 static GLInstancedRendering* CreateIfSupported(GrGLGpu*); | 24 GLInstancedRendering(GrGLGpu*); |
23 ~GLInstancedRendering() override; | 25 ~GLInstancedRendering() override; |
24 | 26 |
25 private: | 27 private: |
26 GLInstancedRendering(GrGLGpu*, AntialiasMode lastSupportedAAMode); | 28 /** |
| 29 * Called by GrGLCaps to determine the level of support this class can offer
for instanced |
| 30 * rendering on the current platform. |
| 31 */ |
| 32 static GrCaps::InstancedSupport CheckSupport(const GrGLCaps&); |
27 | 33 |
28 GrGLGpu* glGpu() const; | 34 GrGLGpu* glGpu() const; |
29 | 35 |
30 Batch* createBatch() override; | 36 Batch* createBatch() override; |
31 | 37 |
32 void onBeginFlush(GrResourceProvider*) override; | 38 void onBeginFlush(GrResourceProvider*) override; |
33 void onDraw(const GrPipeline&, const InstanceProcessor&, const Batch*) overr
ide; | 39 void onDraw(const GrPipeline&, const InstanceProcessor&, const Batch*) overr
ide; |
34 void onEndFlush() override; | 40 void onEndFlush() override; |
35 void onResetGpuResources(ResetType) override; | 41 void onResetGpuResources(ResetType) override; |
36 | 42 |
37 void flushInstanceAttribs(int baseInstance); | 43 void flushInstanceAttribs(int baseInstance); |
38 | 44 |
39 struct GLDrawCmdInfo { | 45 struct GLDrawCmdInfo { |
40 int fInstanceCount; | 46 int fInstanceCount; |
41 #if GR_GL_LOG_INSTANCED_BATCHES | 47 #if GR_GL_LOG_INSTANCED_BATCHES |
42 IndexRange fGeometry; | 48 IndexRange fGeometry; |
43 #endif | 49 #endif |
44 }; | 50 }; |
45 | 51 |
46 GrGLuint fVertexArrayID; | 52 GrGLuint fVertexArrayID; |
47 SkAutoTUnref<GrBuffer> fInstanceBuffer; | 53 SkAutoTUnref<GrBuffer> fInstanceBuffer; |
48 SkAutoTUnref<GrBuffer> fDrawIndirectBuffer; | 54 SkAutoTUnref<GrBuffer> fDrawIndirectBuffer; |
49 SkAutoSTMalloc<1024, GLDrawCmdInfo> fGLDrawCmdsInfo; | 55 SkAutoSTMalloc<1024, GLDrawCmdInfo> fGLDrawCmdsInfo; |
50 uint32_t fInstanceAttribsBufferUniqueId; | 56 uint32_t fInstanceAttribsBufferUniqueId; |
51 int fInstanceAttribsBaseInstance; | 57 int fInstanceAttribsBaseInstance; |
52 | 58 |
53 class GLBatch; | 59 class GLBatch; |
54 | 60 |
| 61 friend class ::GrGLCaps; // For CheckSupport. |
| 62 |
55 typedef InstancedRendering INHERITED; | 63 typedef InstancedRendering INHERITED; |
56 }; | 64 }; |
57 | 65 |
58 } | 66 } |
59 | 67 |
60 #endif | 68 #endif |
OLD | NEW |