OLD | NEW |
(Empty) | |
| 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 GrInstanceProcessor_DEFINED |
| 9 #define GrInstanceProcessor_DEFINED |
| 10 |
| 11 #include "GrBufferAccess.h" |
| 12 #include "GrGeometryProcessor.h" |
| 13 #include "GrInstancedRenderingTypes.h" |
| 14 |
| 15 /** |
| 16 * This class provides a GP implementation that uses instanced rendering. Is sen
ds geometry in as |
| 17 * basic, pre-baked canonical shapes, and uses instanced vertex attribs to contr
ol how these shapes |
| 18 * are transformed and drawn. MSAA is accomplished with the sample mask rather t
han finely |
| 19 * tesselated geometry. |
| 20 */ |
| 21 class GrInstanceProcessor : public GrGeometryProcessor, private GrInstancedRende
ringTypes { |
| 22 public: |
| 23 static uint32_t GetSupportedAAModes(const GrGLSLCaps&, const GrCaps&); |
| 24 |
| 25 GrInstanceProcessor(BatchInfo, GrBuffer* paramsBuffer); |
| 26 |
| 27 const char* name() const override { return "Instance Processor"; } |
| 28 BatchInfo batchInfo() const { return fBatchInfo; } |
| 29 |
| 30 void getGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder* b) const
override { |
| 31 b->add32(fBatchInfo.fData); |
| 32 } |
| 33 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const overri
de; |
| 34 |
| 35 /** |
| 36 * Returns a buffer of ShapeVertex that defines the canonical instanced geom
etry. |
| 37 */ |
| 38 static const GrBuffer* SK_WARN_UNUSED_RESULT FindOrCreateVertexBuffer(GrGpu*
); |
| 39 |
| 40 /** |
| 41 * Returns a buffer of 8-bit indices for the canonical instanced geometry. T
he client can call |
| 42 * GetIndexRangeForXXX to know which indices to use for a specific shape. |
| 43 */ |
| 44 static const GrBuffer* SK_WARN_UNUSED_RESULT FindOrCreateIndex8Buffer(GrGpu*
); |
| 45 |
| 46 static void GetIndexRangeForRect(AntialiasMode, uint32_t* firstIndex, uint32
_t* count); |
| 47 static void GetIndexRangeForOval(AntialiasMode, const SkRect& devBounds, uin
t32_t* firstIndex, |
| 48 uint32_t* count); |
| 49 static void GetIndexRangeForRRect(AntialiasMode, uint32_t* firstIndex, uint3
2_t* count); |
| 50 |
| 51 private: |
| 52 const BatchInfo fBatchInfo; |
| 53 GrBufferAccess fParamsAccess; |
| 54 |
| 55 typedef GrGeometryProcessor INHERITED; |
| 56 }; |
| 57 |
| 58 #endif |
OLD | NEW |