From 411dad0630913fc07f2412b4be17acfbfd914fbc Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Tue, 5 Jun 2012 20:24:20 +0000 Subject: Move stencil param adjustment to GrClipMaskManager, attempt to make GrGpuGL::flushStencil readable Review URL: http://codereview.appspot.com/6295046/ git-svn-id: http://skia.googlecode.com/svn/trunk@4173 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/GrGpu.cpp | 81 ------------------------------------------------------- 1 file changed, 81 deletions(-) (limited to 'src/gpu/GrGpu.cpp') diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 4839e4f045..a873fe7ef5 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -357,87 +357,6 @@ const GrStencilSettings* GrGpu::GetClipStencilSettings(void) { return GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&sClipStencilSettings); } -// mapping of clip-respecting stencil funcs to normal stencil funcs -// mapping depends on whether stencil-clipping is in effect. -static const GrStencilFunc gGrClipToNormalStencilFunc[2][kClipStencilFuncCount] = { - {// Stencil-Clipping is DISABLED, effectively always inside the clip - // In the Clip Funcs - kAlways_StencilFunc, // kAlwaysIfInClip_StencilFunc - kEqual_StencilFunc, // kEqualIfInClip_StencilFunc - kLess_StencilFunc, // kLessIfInClip_StencilFunc - kLEqual_StencilFunc, // kLEqualIfInClip_StencilFunc - // Special in the clip func that forces user's ref to be 0. - kNotEqual_StencilFunc, // kNonZeroIfInClip_StencilFunc - // make ref 0 and do normal nequal. - }, - {// Stencil-Clipping is ENABLED - // In the Clip Funcs - kEqual_StencilFunc, // kAlwaysIfInClip_StencilFunc - // eq stencil clip bit, mask - // out user bits. - - kEqual_StencilFunc, // kEqualIfInClip_StencilFunc - // add stencil bit to mask and ref - - kLess_StencilFunc, // kLessIfInClip_StencilFunc - kLEqual_StencilFunc, // kLEqualIfInClip_StencilFunc - // for both of these we can add - // the clip bit to the mask and - // ref and compare as normal - // Special in the clip func that forces user's ref to be 0. - kLess_StencilFunc, // kNonZeroIfInClip_StencilFunc - // make ref have only the clip bit set - // and make comparison be less - // 10..0 < 1..user_bits.. - } -}; - -GrStencilFunc GrGpu::ConvertStencilFunc(bool stencilInClip, GrStencilFunc func) { - GrAssert(func >= 0); - if (func >= kBasicStencilFuncCount) { - GrAssert(func < kStencilFuncCount); - func = gGrClipToNormalStencilFunc[stencilInClip ? 1 : 0][func - kBasicStencilFuncCount]; - GrAssert(func >= 0 && func < kBasicStencilFuncCount); - } - return func; -} - -void GrGpu::ConvertStencilFuncAndMask(GrStencilFunc func, - bool clipInStencil, - unsigned int clipBit, - unsigned int userBits, - unsigned int* ref, - unsigned int* mask) { - if (func < kBasicStencilFuncCount) { - *mask &= userBits; - *ref &= userBits; - } else { - if (clipInStencil) { - switch (func) { - case kAlwaysIfInClip_StencilFunc: - *mask = clipBit; - *ref = clipBit; - break; - case kEqualIfInClip_StencilFunc: - case kLessIfInClip_StencilFunc: - case kLEqualIfInClip_StencilFunc: - *mask = (*mask & userBits) | clipBit; - *ref = (*ref & userBits) | clipBit; - break; - case kNonZeroIfInClip_StencilFunc: - *mask = (*mask & userBits) | clipBit; - *ref = clipBit; - break; - default: - GrCrash("Unknown stencil func"); - } - } else { - *mask &= userBits; - *ref &= userBits; - } - } -} - //////////////////////////////////////////////////////////////////////////////// bool GrGpu::setupClipAndFlushState(GrPrimitiveType type) { -- cgit v1.2.3