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

Unified Diff: src/gpu/GrGpu.cpp

Issue 687563008: Beginning to refactor nvpr code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 6 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 4b1c35ad4e9f8143d79a658093557503044a9608..2f4f0a68c873c3546d3b0db68861c20d14de016e 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -275,13 +275,13 @@ const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
bool GrGpu::setupClipAndFlushState(DrawType type,
const GrDeviceCoordTexture* dstCopy,
const SkRect* devBounds,
- GrDrawState::AutoRestoreEffects* are) {
+ GrDrawState::AutoRestoreEffects* are,
+ GrDrawState::AutoRestoreStencil* ars) {
GrClipMaskManager::ScissorState scissorState;
- GrDrawState::AutoRestoreStencil ars;
if (!fClipMaskManager.setupClipping(this->getClip(),
devBounds,
are,
- &ars,
+ ars,
&scissorState)) {
return false;
}
@@ -325,56 +325,109 @@ void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) {
void GrGpu::onDraw(const DrawInfo& info) {
this->handleDirtyContext();
GrDrawState::AutoRestoreEffects are;
+ GrDrawState::AutoRestoreStencil ars;
if (!this->setupClipAndFlushState(PrimTypeToDrawType(info.primitiveType()),
info.getDstCopy(),
info.getDevBounds(),
- &are)) {
+ &are,
+ &ars)) {
return;
}
this->onGpuDraw(info);
}
-void GrGpu::onStencilPath(const GrPath* path, SkPath::FillType fill) {
+
+// TODO hack
+static 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);
+}
+
+static 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);
+}
+
+static void get_path_stencil_settings_for_filltype(GrPathRendering::FillType fill,
+ GrStencilSettings* outStencilSettings) {
+
+ switch (fill) {
+ default:
+ SkFAIL("Unexpected path fill.");
+ case GrPathRendering::kWinding_FillType:
+ *outStencilSettings = winding_path_stencil_settings();
+ break;
+ case GrPathRendering::kEvenOdd_FillType:
+ *outStencilSettings = even_odd_path_stencil_settings();
+ break;
+ }
+}
+
+void GrGpu::onStencilPath(const GrPath* path, GrPathRendering::FillType fill) {
this->handleDirtyContext();
GrDrawState::AutoRestoreEffects are;
- if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, NULL, &are)) {
+ GrDrawState::AutoRestoreStencil ars;
+ if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, NULL, &are, &ars)) {
return;
}
- this->pathRendering()->stencilPath(path, fill);
+ GrStencilSettings stencilSettings;
+ get_path_stencil_settings_for_filltype(fill, &stencilSettings);
+ fClipMaskManager.adjustPathStencilParams(&stencilSettings);
+
+ this->pathRendering()->stencilPath(path, stencilSettings);
}
-void GrGpu::onDrawPath(const GrPath* path, SkPath::FillType fill,
+void GrGpu::onDrawPath(const GrPath* path, GrPathRendering::FillType fill,
const GrDeviceCoordTexture* dstCopy) {
this->handleDirtyContext();
drawState()->setDefaultVertexAttribs();
GrDrawState::AutoRestoreEffects are;
- if (!this->setupClipAndFlushState(kDrawPath_DrawType, dstCopy, NULL, &are)) {
+ GrDrawState::AutoRestoreStencil ars;
+ if (!this->setupClipAndFlushState(kDrawPath_DrawType, dstCopy, NULL, &are, &ars)) {
return;
}
- this->pathRendering()->drawPath(path, fill);
+ GrStencilSettings stencilSettings;
+ get_path_stencil_settings_for_filltype(fill, &stencilSettings);
+ fClipMaskManager.adjustPathStencilParams(&stencilSettings);
+
+ this->pathRendering()->drawPath(path, stencilSettings);
}
void GrGpu::onDrawPaths(const GrPathRange* pathRange,
const uint32_t indices[], int count,
const float transforms[], PathTransformType transformsType,
- SkPath::FillType fill, const GrDeviceCoordTexture* dstCopy) {
+ GrPathRendering::FillType fill, const GrDeviceCoordTexture* dstCopy) {
this->handleDirtyContext();
drawState()->setDefaultVertexAttribs();
GrDrawState::AutoRestoreEffects are;
- if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, NULL, &are)) {
+ GrDrawState::AutoRestoreStencil ars;
+ if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, NULL, &are, &ars)) {
return;
}
+ GrStencilSettings stencilSettings;
+ get_path_stencil_settings_for_filltype(fill, &stencilSettings);
+ fClipMaskManager.adjustPathStencilParams(&stencilSettings);
+
pathRange->willDrawPaths(indices, count);
- this->pathRendering()->drawPaths(pathRange, indices, count, transforms, transformsType, fill);
+ this->pathRendering()->drawPaths(pathRange, indices, count, transforms, transformsType,
+ stencilSettings);
}
void GrGpu::finalizeReservedVertices() {

Powered by Google App Engine
This is Rietveld 408576698