Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Unified Diff: src/gpu/effects/GrInstanceProcessor.h

Issue 1897203002: Implement instanced rendering for simple shapes (Closed) Base URL: https://skia.googlesource.com/skia.git@upload2_requireHWAA
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/effects/GrInstanceProcessor.h
diff --git a/src/gpu/effects/GrInstanceProcessor.h b/src/gpu/effects/GrInstanceProcessor.h
new file mode 100644
index 0000000000000000000000000000000000000000..9e02821ee0459064f8dff396a3c4b2b379bdc139
--- /dev/null
+++ b/src/gpu/effects/GrInstanceProcessor.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrInstanceProcessor_DEFINED
+#define GrInstanceProcessor_DEFINED
+
+#include "GrBufferAccess.h"
+#include "GrGeometryProcessor.h"
+#include "GrInstancedRenderingTypes.h"
+
+/**
+ * This class provides a GP implementation that uses instanced rendering. Is sends geometry in as
+ * basic, pre-baked canonical shapes, and uses instanced vertex attribs to control how these shapes
+ * are transformed and drawn. MSAA is accomplished with the sample mask rather than finely
+ * tesselated geometry.
+ */
+class GrInstanceProcessor : public GrGeometryProcessor, private GrInstancedRenderingTypes {
+public:
+ static uint32_t GetSupportedAAModes(const GrGLSLCaps&, const GrCaps&);
bsalomon 2016/04/25 13:22:39 Having GLSL caps here is sort of violation of the
Chris Dalton 2016/04/25 17:01:19 Is it really a layering violation when the class h
bsalomon 2016/04/27 14:10:32 It is definitely the case that if we added another
+
+ GrInstanceProcessor(BatchTracker, GrBuffer* paramsBuffer, AntialiasMode);
+
+ const char* name() const override { return "Instance Processor"; }
+ BatchTracker tracker() const { return fTracker; }
+ AntialiasMode antialiasMode() const { return fAntialiasMode; }
+
+ void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
+
+ /**
+ * Returns a buffer of ShapeVertex that defines the canonical instanced geometry.
+ */
+ static const GrBuffer* SK_WARN_UNUSED_RESULT FindOrCreateVertexBuffer(GrGpu*);
+
+ /**
+ * Returns a buffer of 8-bit indices for the canonical instanced geometry. The client can call
+ * GetIndexRangeForXXX to know which indices to use for a specific shape.
+ */
+ static const GrBuffer* SK_WARN_UNUSED_RESULT FindOrCreateIndex8Buffer(GrGpu*);
+
+ static void GetIndexRangeForRect(AntialiasMode, uint32_t* firstIndex, uint32_t* count);
+ static void GetIndexRangeForOval(AntialiasMode, const SkRect& devBounds, uint32_t* firstIndex,
+ uint32_t* count);
+ static void GetIndexRangeForRRect(AntialiasMode, uint32_t* firstIndex, uint32_t* count);
+
+private:
+ const BatchTracker fTracker;
+ const AntialiasMode fAntialiasMode;
+ GrBufferAccess fParamsAccess;
+
+ typedef GrGeometryProcessor INHERITED;
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698