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

Unified Diff: src/gpu/gl/GrGLPathRendering.cpp

Issue 1908433002: Batch multiple single NVPR draw paths to instanced draws Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address review comments 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
« no previous file with comments | « src/gpu/gl/GrGLPathRendering.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLPathRendering.cpp
diff --git a/src/gpu/gl/GrGLPathRendering.cpp b/src/gpu/gl/GrGLPathRendering.cpp
index 0ecf58a8e1f47c58cd60351e6f05d1a344d7c58f..1c6d9b7ab71ebc1ba11e759972d2e1ab8a7d74fe 100644
--- a/src/gpu/gl/GrGLPathRendering.cpp
+++ b/src/gpu/gl/GrGLPathRendering.cpp
@@ -145,37 +145,10 @@ void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath*
}
}
-void GrGLPathRendering::onDrawPath(const GrPipeline& pipeline,
- const GrPrimitiveProcessor& primProc,
- const GrStencilSettings& stencil,
- const GrPath* path) {
- if (!this->gpu()->flushGLState(pipeline, primProc)) {
- return;
- }
- const GrGLPath* glPath = static_cast<const GrGLPath*>(path);
-
- this->flushPathStencilSettings(stencil);
- SkASSERT(!fHWPathStencilSettings.isTwoSided());
-
- GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode(
- fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
- GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face);
-
- if (glPath->shouldStroke()) {
- if (glPath->shouldFill()) {
- GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask));
- }
- GL_CALL(StencilThenCoverStrokePath(glPath->pathID(), 0xffff, writeMask,
- GR_GL_BOUNDING_BOX));
- } else {
- GL_CALL(StencilThenCoverFillPath(glPath->pathID(), fillMode, writeMask,
- GR_GL_BOUNDING_BOX));
- }
-}
-
void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
- const GrStencilSettings& stencil, const GrPathRange* pathRange,
+ const GrStencilSettings& stencil,
+ const GrPathRange* pathRange,
const void* indices, PathIndexType indexType,
const float transformValues[], PathTransformType transformType,
int count) {
@@ -215,6 +188,60 @@ void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline,
}
}
+void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline,
+ const GrPrimitiveProcessor& primProc,
+ const GrStencilSettings& stencil,
+ const GrPath* const* paths,
+ int count) {
+ if (!count) {
+ return;
+ }
+ if (!this->gpu()->flushGLState(pipeline, primProc)) {
+ return;
+ }
+ this->flushPathStencilSettings(stencil);
+ SkASSERT(!fHWPathStencilSettings.isTwoSided());
+
+ GrGLenum fillMode =
+ gr_stencil_op_to_gl_path_rendering_fill_mode(
+ fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
+ GrGLint writeMask =
+ fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face);
+ const GrGLPath* path = static_cast<const GrGLPath*>(paths[0]);
+ if (count > 1) {
+ SkAutoSTMalloc<32, GrGLuint> indexStorage(count);
+ for (int i = 0; i < count; ++i) {
+ indexStorage[i] = static_cast<const GrGLPath*>(paths[i])->pathID();
+ }
+ if (path->shouldStroke()) {
+ if (path->shouldFill()) {
+ GL_CALL(StencilFillPathInstanced(
+ count, GR_GL_UNSIGNED_INT, indexStorage, 0,
+ fillMode, writeMask, GR_GL_NONE, nullptr));
+ }
+ GL_CALL(StencilThenCoverStrokePathInstanced(
+ count, GR_GL_UNSIGNED_INT, indexStorage, 0, 0xffff, writeMask,
+ GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, GR_GL_NONE, nullptr));
+ } else {
+ GL_CALL(StencilThenCoverFillPathInstanced(
+ count, GR_GL_UNSIGNED_INT, indexStorage, 0,
+ fillMode, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES,
+ GR_GL_NONE, nullptr));
+ }
+ } else {
+ if (path->shouldStroke()) {
+ if (path->shouldFill()) {
+ GL_CALL(StencilFillPath(path->pathID(), fillMode, writeMask));
+ }
+ GL_CALL(StencilThenCoverStrokePath(path->pathID(), 0xffff, writeMask,
+ GR_GL_BOUNDING_BOX));
+ } else {
+ GL_CALL(StencilThenCoverFillPath(path->pathID(), fillMode, writeMask,
+ GR_GL_BOUNDING_BOX));
+ }
+ }
+}
+
void GrGLPathRendering::setProgramPathFragmentInputTransform(GrGLuint program, GrGLint location,
GrGLenum genMode, GrGLint components,
const SkMatrix& matrix) {
« no previous file with comments | « src/gpu/gl/GrGLPathRendering.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698