| Index: src/gpu/GrGpu.cpp
|
| diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
|
| index 4b1c35ad4e9f8143d79a658093557503044a9608..273b1165838fa52a0bfa78c007090e3035062962 100644
|
| --- a/src/gpu/GrGpu.cpp
|
| +++ b/src/gpu/GrGpu.cpp
|
| @@ -275,13 +275,14 @@ 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;
|
| + //GrDrawState::AutoRestoreStencil ars;
|
| if (!fClipMaskManager.setupClipping(this->getClip(),
|
| devBounds,
|
| are,
|
| - &ars,
|
| + ars,
|
| &scissorState)) {
|
| return false;
|
| }
|
| @@ -325,56 +326,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() {
|
|
|