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_InstanceProcessor_DEFINED | 8 #ifndef gr_instanced_InstanceProcessor_DEFINED |
9 #define gr_instanced_InstanceProcessor_DEFINED | 9 #define gr_instanced_InstanceProcessor_DEFINED |
10 | 10 |
| 11 #include "GrCaps.h" |
11 #include "GrBufferAccess.h" | 12 #include "GrBufferAccess.h" |
12 #include "GrGeometryProcessor.h" | 13 #include "GrGeometryProcessor.h" |
13 #include "instanced/InstancedRenderingTypes.h" | 14 #include "instanced/InstancedRenderingTypes.h" |
14 | 15 |
15 namespace gr_instanced { | 16 namespace gr_instanced { |
16 | 17 |
17 /** | 18 /** |
18 * This class provides a GP implementation that uses instanced rendering. Is sen
ds geometry in as | 19 * This class provides a GP implementation that uses instanced rendering. Is sen
ds geometry in as |
19 * basic, pre-baked canonical shapes, and uses instanced vertex attribs to contr
ol how these shapes | 20 * basic, pre-baked canonical shapes, and uses instanced vertex attribs to contr
ol how these shapes |
20 * are transformed and drawn. MSAA is accomplished with the sample mask rather t
han finely | 21 * are transformed and drawn. MSAA is accomplished with the sample mask rather t
han finely |
21 * tesselated geometry. | 22 * tesselated geometry. |
22 */ | 23 */ |
23 class InstanceProcessor : public GrGeometryProcessor { | 24 class InstanceProcessor : public GrGeometryProcessor { |
24 public: | 25 public: |
25 static bool IsSupported(const GrGLSLCaps&, const GrCaps&, AntialiasMode* las
tSupportedAAMode); | |
26 | |
27 InstanceProcessor(BatchInfo, GrBuffer* paramsBuffer); | 26 InstanceProcessor(BatchInfo, GrBuffer* paramsBuffer); |
28 | 27 |
29 const char* name() const override { return "Instance Processor"; } | 28 const char* name() const override { return "Instance Processor"; } |
30 BatchInfo batchInfo() const { return fBatchInfo; } | 29 BatchInfo batchInfo() const { return fBatchInfo; } |
31 | 30 |
32 void getGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder* b) const
override { | 31 void getGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder* b) const
override { |
33 b->add32(fBatchInfo.fData); | 32 b->add32(fBatchInfo.fData); |
34 } | 33 } |
35 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const overri
de; | 34 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const overri
de; |
36 | 35 |
37 /** | 36 /** |
38 * Returns a buffer of ShapeVertex that defines the canonical instanced geom
etry. | 37 * Returns a buffer of ShapeVertex that defines the canonical instanced geom
etry. |
39 */ | 38 */ |
40 static const GrBuffer* SK_WARN_UNUSED_RESULT FindOrCreateVertexBuffer(GrGpu*
); | 39 static const GrBuffer* SK_WARN_UNUSED_RESULT FindOrCreateVertexBuffer(GrGpu*
); |
41 | 40 |
42 /** | 41 /** |
43 * Returns a buffer of 8-bit indices for the canonical instanced geometry. T
he client can call | 42 * Returns a buffer of 8-bit indices for the canonical instanced geometry. T
he client can call |
44 * GetIndexRangeForXXX to know which indices to use for a specific shape. | 43 * GetIndexRangeForXXX to know which indices to use for a specific shape. |
45 */ | 44 */ |
46 static const GrBuffer* SK_WARN_UNUSED_RESULT FindOrCreateIndex8Buffer(GrGpu*
); | 45 static const GrBuffer* SK_WARN_UNUSED_RESULT FindOrCreateIndex8Buffer(GrGpu*
); |
47 | 46 |
48 static IndexRange GetIndexRangeForRect(AntialiasMode); | 47 static IndexRange GetIndexRangeForRect(AntialiasMode); |
49 static IndexRange GetIndexRangeForOval(AntialiasMode, const SkRect& devBound
s); | 48 static IndexRange GetIndexRangeForOval(AntialiasMode, const SkRect& devBound
s); |
50 static IndexRange GetIndexRangeForRRect(AntialiasMode); | 49 static IndexRange GetIndexRangeForRRect(AntialiasMode); |
51 | 50 |
52 static const char* GetNameOfIndexRange(IndexRange); | 51 static const char* GetNameOfIndexRange(IndexRange); |
53 | 52 |
54 private: | 53 private: |
| 54 /** |
| 55 * Called by the platform-specific instanced rendering implementation to det
ermine the level of |
| 56 * support this class can offer on the given GLSL platform. |
| 57 */ |
| 58 static GrCaps::InstancedSupport CheckSupport(const GrGLSLCaps&, const GrCaps
&); |
| 59 |
55 const BatchInfo fBatchInfo; | 60 const BatchInfo fBatchInfo; |
56 GrBufferAccess fParamsAccess; | 61 GrBufferAccess fParamsAccess; |
57 | 62 |
| 63 friend class GLInstancedRendering; // For CheckSupport. |
| 64 |
58 typedef GrGeometryProcessor INHERITED; | 65 typedef GrGeometryProcessor INHERITED; |
59 }; | 66 }; |
60 | 67 |
61 } | 68 } |
62 | 69 |
63 #endif | 70 #endif |
OLD | NEW |