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 gr_instanced_InstanceProcessor_DEFINED | |
9 #define gr_instanced_InstanceProcessor_DEFINED | |
10 | |
11 #include "GrBufferAccess.h" | |
12 #include "GrGeometryProcessor.h" | |
13 #include "instanced/InstancedRenderingTypes.h" | |
14 | |
15 namespace gr_instanced { | |
16 | |
17 /** | |
18 * 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 * are transformed and drawn. MSAA is accomplished with the sample mask rather t
han finely | |
21 * tesselated geometry. | |
22 */ | |
23 class InstanceProcessor : public GrGeometryProcessor { | |
24 public: | |
25 static bool IsSupported(const GrGLSLCaps&, const GrCaps&, AntialiasMode* las
tSupportedAAMode); | |
26 | |
27 InstanceProcessor(BatchInfo, GrBuffer* paramsBuffer); | |
28 | |
29 const char* name() const override { return "Instance Processor"; } | |
30 BatchInfo batchInfo() const { return fBatchInfo; } | |
31 | |
32 void getGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder* b) const
override { | |
33 b->add32(fBatchInfo.fData); | |
34 } | |
35 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const overri
de; | |
36 | |
37 /** | |
38 * Returns a buffer of ShapeVertex that defines the canonical instanced geom
etry. | |
39 */ | |
40 static const GrBuffer* SK_WARN_UNUSED_RESULT FindOrCreateVertexBuffer(GrGpu*
); | |
41 | |
42 /** | |
43 * 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. | |
45 */ | |
46 static const GrBuffer* SK_WARN_UNUSED_RESULT FindOrCreateIndex8Buffer(GrGpu*
); | |
47 | |
48 static IndexRange GetIndexRangeForRect(AntialiasMode); | |
49 static IndexRange GetIndexRangeForOval(AntialiasMode, const SkRect& devBound
s); | |
50 static IndexRange GetIndexRangeForRRect(AntialiasMode); | |
51 | |
52 static const char* GetNameOfIndexRange(IndexRange); | |
53 | |
54 private: | |
55 const BatchInfo fBatchInfo; | |
56 GrBufferAccess fParamsAccess; | |
57 | |
58 typedef GrGeometryProcessor INHERITED; | |
59 }; | |
60 | |
61 } | |
62 | |
63 #endif | |
OLD | NEW |