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

Side by Side 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: rebase Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
11 #include "GrGLPath.h" 11 #include "GrGLPath.h"
12 #include "GrGLShaderBuilder.h" 12 #include "GrGLShaderBuilder.h"
13 #include "GrTemplates.h" 13 #include "GrTemplates.h"
14 #include "GrTypes.h" 14 #include "GrTypes.h"
15 #include "SkStrokeRec.h"
15 #include "SkTemplates.h" 16 #include "SkTemplates.h"
16 17
17 static const GrGLuint GR_MAX_GLUINT = ~0U; 18 static const GrGLuint GR_MAX_GLUINT = ~0U;
18 static const GrGLint GR_INVAL_GLINT = ~0; 19 static const GrGLint GR_INVAL_GLINT = ~0;
19 20
20 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) 21 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
21 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) 22 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X)
22 23
23 24
24 #define SKIP_CACHE_CHECK true 25 #define SKIP_CACHE_CHECK true
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 this->notifyIndexBufferDelete(desc.fID); 1270 this->notifyIndexBufferDelete(desc.fID);
1270 return NULL; 1271 return NULL;
1271 } 1272 }
1272 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc )); 1273 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc ));
1273 return indexBuffer; 1274 return indexBuffer;
1274 } 1275 }
1275 return NULL; 1276 return NULL;
1276 } 1277 }
1277 } 1278 }
1278 1279
1279 GrPath* GrGpuGL::onCreatePath(const SkPath& inPath) { 1280 GrPath* GrGpuGL::onCreatePath(const SkPath& inPath, const SkStrokeRec& stroke) {
1280 SkASSERT(this->caps()->pathRenderingSupport()); 1281 SkASSERT(this->caps()->pathRenderingSupport());
1281 return SkNEW_ARGS(GrGLPath, (this, inPath)); 1282 return SkNEW_ARGS(GrGLPath, (this, inPath, stroke));
1282 } 1283 }
1283 1284
1284 void GrGpuGL::flushScissor() { 1285 void GrGpuGL::flushScissor() {
1285 if (fScissorState.fEnabled) { 1286 if (fScissorState.fEnabled) {
1286 // Only access the RT if scissoring is being enabled. We can call this b efore performing 1287 // Only access the RT if scissoring is being enabled. We can call this b efore performing
1287 // a glBitframebuffer for a surface->surface copy, which requires no RT to be bound to the 1288 // a glBitframebuffer for a surface->surface copy, which requires no RT to be bound to the
1288 // GrDrawState. 1289 // GrDrawState.
1289 const GrDrawState& drawState = this->getDrawState(); 1290 const GrDrawState& drawState = this->getDrawState();
1290 const GrGLRenderTarget* rt = 1291 const GrGLRenderTarget* rt =
1291 static_cast<const GrGLRenderTarget*>(drawState.getRenderTarget()); 1292 static_cast<const GrGLRenderTarget*>(drawState.getRenderTarget());
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 1694
1694 // Decide how to manipulate the stencil buffer based on the fill rule. 1695 // Decide how to manipulate the stencil buffer based on the fill rule.
1695 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 1696 SkASSERT(!fHWPathStencilSettings.isTwoSided());
1696 1697
1697 GrGLenum fillMode = 1698 GrGLenum fillMode =
1698 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face)); 1699 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face));
1699 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face); 1700 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face);
1700 GL_CALL(StencilFillPath(id, fillMode, writeMask)); 1701 GL_CALL(StencilFillPath(id, fillMode, writeMask));
1701 } 1702 }
1702 1703
1703 void GrGpuGL::onGpuFillPath(const GrPath* path, SkPath::FillType fill) { 1704 void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) {
1704 SkASSERT(this->caps()->pathRenderingSupport()); 1705 SkASSERT(this->caps()->pathRenderingSupport());
1705 1706
1706 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); 1707 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID();
1707 SkASSERT(NULL != this->drawState()->getRenderTarget()); 1708 SkASSERT(NULL != this->drawState()->getRenderTarget());
1708 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer()); 1709 SkASSERT(NULL != this->drawState()->getRenderTarget()->getStencilBuffer());
1709 SkASSERT(!fCurrentProgram->hasVertexShader()); 1710 SkASSERT(!fCurrentProgram->hasVertexShader());
1710 1711
1711 flushPathStencilSettings(fill); 1712 flushPathStencilSettings(fill);
1713 const SkStrokeRec& stroke = path->getStroke();
1712 1714
1713 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill) ; 1715 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill) ;
1714 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 1716 SkASSERT(!fHWPathStencilSettings.isTwoSided());
1715 GrGLenum fillMode = 1717 GrGLenum fillMode =
1716 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face)); 1718 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face));
1717 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face); 1719 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face);
1718 GL_CALL(StencilFillPath(id, fillMode, writeMask)); 1720
1721 if (stroke.isFillStyle() || SkStrokeRec::kStrokeAndFill_Style == stroke.getS tyle()) {
1722 GL_CALL(StencilFillPath(id, fillMode, writeMask));
1723 }
1724 if (stroke.needToApply()) {
1725 GL_CALL(StencilStrokePath(id, 0xffff, writeMask));
1726 }
1719 1727
1720 if (nonInvertedFill == fill) { 1728 if (nonInvertedFill == fill) {
1721 GL_CALL(CoverFillPath(id, GR_GL_BOUNDING_BOX)); 1729 if (stroke.needToApply()) {
1730 GL_CALL(CoverStrokePath(id, GR_GL_BOUNDING_BOX));
1731 } else {
1732 GL_CALL(CoverFillPath(id, GR_GL_BOUNDING_BOX));
1733 }
1722 } else { 1734 } else {
1723 GrDrawState* drawState = this->drawState(); 1735 GrDrawState* drawState = this->drawState();
1724 GrDrawState::AutoViewMatrixRestore avmr; 1736 GrDrawState::AutoViewMatrixRestore avmr;
1725 SkRect bounds = SkRect::MakeLTRB(0, 0, 1737 SkRect bounds = SkRect::MakeLTRB(0, 0,
1726 SkIntToScalar(drawState->getRenderTarge t()->width()), 1738 SkIntToScalar(drawState->getRenderTarge t()->width()),
1727 SkIntToScalar(drawState->getRenderTarge t()->height())); 1739 SkIntToScalar(drawState->getRenderTarge t()->height()));
1728 SkMatrix vmi; 1740 SkMatrix vmi;
1729 // mapRect through persp matrix may not be correct 1741 // mapRect through persp matrix may not be correct
1730 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn verse(&vmi)) { 1742 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn verse(&vmi)) {
1731 vmi.mapRect(&bounds); 1743 vmi.mapRect(&bounds);
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
2722 this->setVertexArrayID(gpu, 0); 2734 this->setVertexArrayID(gpu, 0);
2723 } 2735 }
2724 int attrCount = gpu->glCaps().maxVertexAttributes(); 2736 int attrCount = gpu->glCaps().maxVertexAttributes();
2725 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2737 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2726 fDefaultVertexArrayAttribState.resize(attrCount); 2738 fDefaultVertexArrayAttribState.resize(attrCount);
2727 } 2739 }
2728 attribState = &fDefaultVertexArrayAttribState; 2740 attribState = &fDefaultVertexArrayAttribState;
2729 } 2741 }
2730 return attribState; 2742 return attribState;
2731 } 2743 }
OLDNEW
« no previous file with comments | « 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