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

Unified Diff: src/gpu/GrGpu.cpp

Issue 22686002: Implement path cover 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrGpu.cpp
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 910c57146bd2200727cc1b8455a38bdfe71da366..d74e798a138d289e83b28b912dbd49351e8a557c 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -198,7 +198,7 @@ GrIndexBuffer* GrGpu::createIndexBuffer(uint32_t size, bool dynamic) {
}
GrPath* GrGpu::createPath(const SkPath& path) {
- SkASSERT(this->caps()->pathStencilingSupport());
+ SkASSERT(this->caps()->pathRenderingSupport());
this->handleDirtyContext();
return this->onCreatePath(path);
}
@@ -247,6 +247,45 @@ void GrGpu::resolveRenderTarget(GrRenderTarget* target) {
this->onResolveRenderTarget(target);
}
+namespace {
+
+const GrStencilSettings& winding_path_stencil_settings() {
+ GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
+ kIncClamp_StencilOp,
+ kIncClamp_StencilOp,
+ kAlwaysIfInClip_StencilFunc,
+ 0xFFFF, 0xFFFF, 0xFFFF);
+ return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
+}
+const GrStencilSettings& even_odd_path_stencil_settings() {
+ GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
+ kInvert_StencilOp,
+ kInvert_StencilOp,
+ kAlwaysIfInClip_StencilFunc,
+ 0xFFFF, 0xFFFF, 0xFFFF);
+ return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
+}
+
+}
+
+void GrGpu::getPathStencilSettingsForFillType(SkPath::FillType fill, GrStencilSettings* outStencilSettings) {
+
+ switch (fill) {
+ default:
+ GrCrash("Unexpected path fill.");
+ /* fallthrough */;
+ case SkPath::kWinding_FillType:
+ case SkPath::kInverseWinding_FillType:
+ *outStencilSettings = winding_path_stencil_settings();
+ break;
+ case SkPath::kEvenOdd_FillType:
+ case SkPath::kInverseEvenOdd_FillType:
+ *outStencilSettings = even_odd_path_stencil_settings();
+ break;
+ }
+ fClipMaskManager.adjustPathStencilParams(outStencilSettings);
+}
+
////////////////////////////////////////////////////////////////////////////////
@@ -349,10 +388,6 @@ void GrGpu::onDraw(const DrawInfo& info) {
void GrGpu::onStencilPath(const GrPath* path, const SkStrokeRec&, SkPath::FillType fill) {
this->handleDirtyContext();
- // TODO: make this more efficient (don't copy and copy back)
- GrAutoTRestore<GrStencilSettings> asr(this->drawState()->stencil());
-
- this->setStencilPathSettings(*path, fill, this->drawState()->stencil());
GrDrawState::AutoRestoreEffects are;
if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, &are)) {
return;
@@ -361,6 +396,20 @@ void GrGpu::onStencilPath(const GrPath* path, const SkStrokeRec&, SkPath::FillTy
this->onGpuStencilPath(path, fill);
}
+void GrGpu::onFillPath(const GrPath* path, const SkStrokeRec& stroke, SkPath::FillType fill) {
+ this->handleDirtyContext();
+
+ drawState()->setDefaultVertexAttribs();
+
+ GrDrawState::AutoRestoreEffects are;
+ // TODO: Some blending effects require destination texture, see onDraw
+ if (!this->setupClipAndFlushState(kFillPath_DrawType, NULL, &are)) {
+ return;
+ }
+
+ this->onGpuFillPath(path, fill);
+}
+
void GrGpu::finalizeReservedVertices() {
SkASSERT(NULL != fVertexPool);
fVertexPool->unlock();

Powered by Google App Engine
This is Rietveld 408576698