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

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

Issue 23440049: Implement stroking a path with nv_path_rendering (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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/gl/GrGpuGL.cpp
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index b4111950c1ab6276a744c7df69cfa3967efa534d..09c0fdce739ce43abccf65dad085d01353156db6 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -12,6 +12,7 @@
#include "GrGLShaderBuilder.h"
#include "GrTemplates.h"
#include "GrTypes.h"
+#include "SkStrokeRec.h"
#include "SkTemplates.h"
static const GrGLuint GR_MAX_GLUINT = ~0U;
@@ -1273,9 +1274,9 @@ GrIndexBuffer* GrGpuGL::onCreateIndexBuffer(uint32_t size, bool dynamic) {
}
}
-GrPath* GrGpuGL::onCreatePath(const SkPath& inPath) {
+GrPath* GrGpuGL::onCreatePath(const SkPath& inPath, const SkStrokeRec& stroke) {
SkASSERT(this->caps()->pathRenderingSupport());
- return SkNEW_ARGS(GrGLPath, (this, inPath));
+ return SkNEW_ARGS(GrGLPath, (this, inPath, stroke));
}
void GrGpuGL::flushScissor() {
@@ -1728,7 +1729,7 @@ void GrGpuGL::onGpuStencilPath(const GrPath* path, SkPath::FillType fill) {
GL_CALL(StencilFillPath(id, fillMode, writeMask));
}
-void GrGpuGL::onGpuFillPath(const GrPath* path, SkPath::FillType fill) {
+void GrGpuGL::onGpuDrawPath(const GrPath* path, const SkStrokeRec& stroke, SkPath::FillType fill) {
SkASSERT(this->caps()->pathRenderingSupport());
GrGLuint id = static_cast<const GrGLPath*>(path)->pathID();
@@ -1736,25 +1737,38 @@ void GrGpuGL::onGpuFillPath(const GrPath* path, SkPath::FillType fill) {
SkASSERT(NULL != drawState->getRenderTarget());
SkASSERT(NULL != drawState->getRenderTarget()->getStencilBuffer());
- SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill);
SkASSERT(!fPathStencilSettings.isTwoSided());
GrGLenum fillMode =
gr_stencil_op_to_gl_path_rendering_fill_mode(fPathStencilSettings.passOp(GrStencilSettings::kFront_Face));
GrGLint writeMask = fPathStencilSettings.writeMask(GrStencilSettings::kFront_Face);
- GL_CALL(StencilFillPath(id, fillMode, writeMask));
- if (!fCurrentProgram->hasVertexShader() && nonInvertedFill == fill) {
- GL_CALL(CoverFillPath(id, GR_GL_BOUNDING_BOX));
+ if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.getStyle()) {
+ GL_CALL(StencilFillPath(id, fillMode, writeMask));
+ }
+
+ if (stroke.needToApply()) {
+ GL_CALL(StencilStrokePath(id, 0xffff, writeMask));
+ }
+
+ bool isInverseFill = SkPath::ConvertToNonInverseFillType(fill) != fill;
+
+ if (!fCurrentProgram->hasVertexShader() && !isInverseFill) {
+ if (stroke.needToApply()) {
+ GL_CALL(CoverStrokePath(id, GR_GL_BOUNDING_BOX));
+ } else {
+ GL_CALL(CoverFillPath(id, GR_GL_BOUNDING_BOX));
+ }
} else {
GrDrawState::AutoViewMatrixRestore avmr;
+ SkMatrix vmi;
SkRect bounds;
- if (nonInvertedFill == fill) {
+ if (!isInverseFill) {
bounds = path->getBounds();
} else {
bounds = SkRect::MakeLTRB(0, 0,
SkIntToScalar(drawState->getRenderTarget()->width()),
- SkIntToScalar(drawState->getRenderTarget()->height()));
- SkMatrix vmi;
+ SkIntToScalar(drawState->getRenderTarget()->height()));
+
// mapRect through persp matrix may not be correct
if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewInverse(&vmi)) {
vmi.mapRect(&bounds);
@@ -1892,7 +1906,7 @@ void set_gl_stencil(const GrGLInterface* gl,
}
void GrGpuGL::flushStencil(DrawType type) {
- if ((kStencilPath_DrawType == type || kFillPath_DrawType == type) &&
+ if ((kStencilPath_DrawType == type || kDrawPath_DrawType == type) &&
fHWPathStencilSettings != fPathStencilSettings) {
// Just the func, ref, and mask is set here. The op and write mask are params to the call
@@ -2227,7 +2241,6 @@ void GrGpuGL::enableTexGen(int unitIdx, int numComponents, const GrGLfloat* coef
}
void GrGpuGL::enableTexGen(int unitIdx, int numComponents, const SkMatrix& matrix) {
-
GrGLfloat coefficients[9];
SkASSERT(this->glCaps().fixedFunctionSupport());
SkASSERT(numComponents <= 3 && numComponents > 0);
« src/gpu/gl/GrGpuGL.h ('K') | « src/gpu/gl/GrGpuGL.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698