OLD | NEW |
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 #include "GrGLGpu.h" | 8 #include "GrGLGpu.h" |
9 #include "GrGLBuffer.h" | 9 #include "GrGLBuffer.h" |
10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
(...skipping 2851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2862 } | 2862 } |
2863 } | 2863 } |
2864 rt->flagAsResolved(); | 2864 rt->flagAsResolved(); |
2865 } | 2865 } |
2866 } | 2866 } |
2867 | 2867 |
2868 namespace { | 2868 namespace { |
2869 | 2869 |
2870 | 2870 |
2871 GrGLenum gr_to_gl_stencil_op(GrStencilOp op) { | 2871 GrGLenum gr_to_gl_stencil_op(GrStencilOp op) { |
2872 static const GrGLenum gTable[] = { | 2872 static const GrGLenum gTable[kGrStencilOpCount] = { |
2873 GR_GL_KEEP, // kKeep_StencilOp | 2873 GR_GL_KEEP, // kKeep |
2874 GR_GL_REPLACE, // kReplace_StencilOp | 2874 GR_GL_ZERO, // kZero |
2875 GR_GL_INCR_WRAP, // kIncWrap_StencilOp | 2875 GR_GL_REPLACE, // kReplace |
2876 GR_GL_INCR, // kIncClamp_StencilOp | 2876 GR_GL_INVERT, // kInvert |
2877 GR_GL_DECR_WRAP, // kDecWrap_StencilOp | 2877 GR_GL_INCR_WRAP, // kIncWrap |
2878 GR_GL_DECR, // kDecClamp_StencilOp | 2878 GR_GL_DECR_WRAP, // kDecWrap |
2879 GR_GL_ZERO, // kZero_StencilOp | 2879 GR_GL_INCR, // kIncClamp |
2880 GR_GL_INVERT, // kInvert_StencilOp | 2880 GR_GL_DECR, // kDecClamp |
2881 }; | 2881 }; |
2882 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kStencilOpCnt); | 2882 GR_STATIC_ASSERT(0 == (int)GrStencilOp::kKeep); |
2883 GR_STATIC_ASSERT(0 == kKeep_StencilOp); | 2883 GR_STATIC_ASSERT(1 == (int)GrStencilOp::kZero); |
2884 GR_STATIC_ASSERT(1 == kReplace_StencilOp); | 2884 GR_STATIC_ASSERT(2 == (int)GrStencilOp::kReplace); |
2885 GR_STATIC_ASSERT(2 == kIncWrap_StencilOp); | 2885 GR_STATIC_ASSERT(3 == (int)GrStencilOp::kInvert); |
2886 GR_STATIC_ASSERT(3 == kIncClamp_StencilOp); | 2886 GR_STATIC_ASSERT(4 == (int)GrStencilOp::kIncWrap); |
2887 GR_STATIC_ASSERT(4 == kDecWrap_StencilOp); | 2887 GR_STATIC_ASSERT(5 == (int)GrStencilOp::kDecWrap); |
2888 GR_STATIC_ASSERT(5 == kDecClamp_StencilOp); | 2888 GR_STATIC_ASSERT(6 == (int)GrStencilOp::kIncClamp); |
2889 GR_STATIC_ASSERT(6 == kZero_StencilOp); | 2889 GR_STATIC_ASSERT(7 == (int)GrStencilOp::kDecClamp); |
2890 GR_STATIC_ASSERT(7 == kInvert_StencilOp); | 2890 SkASSERT(op < (GrStencilOp)kGrStencilOpCount); |
2891 SkASSERT((unsigned) op < kStencilOpCnt); | 2891 return gTable[(int)op]; |
2892 return gTable[op]; | |
2893 } | 2892 } |
2894 | 2893 |
2895 void set_gl_stencil(const GrGLInterface* gl, | 2894 void set_gl_stencil(const GrGLInterface* gl, |
2896 const GrStencilSettings& settings, | 2895 const GrStencilSettings::Face& face, |
2897 GrGLenum glFace, | 2896 GrGLenum glFace) { |
2898 GrStencilSettings::Face grFace) { | 2897 GrGLenum glFunc = GrToGLStencilFunc(face.fTest); |
2899 GrGLenum glFunc = GrToGLStencilFunc(settings.func(grFace)); | 2898 GrGLenum glFailOp = gr_to_gl_stencil_op(face.fFailOp); |
2900 GrGLenum glFailOp = gr_to_gl_stencil_op(settings.failOp(grFace)); | 2899 GrGLenum glPassOp = gr_to_gl_stencil_op(face.fPassOp); |
2901 GrGLenum glPassOp = gr_to_gl_stencil_op(settings.passOp(grFace)); | |
2902 | 2900 |
2903 GrGLint ref = settings.funcRef(grFace); | 2901 GrGLint ref = face.fRef; |
2904 GrGLint mask = settings.funcMask(grFace); | 2902 GrGLint mask = face.fTestMask; |
2905 GrGLint writeMask = settings.writeMask(grFace); | 2903 GrGLint writeMask = face.fWriteMask; |
2906 | 2904 |
2907 if (GR_GL_FRONT_AND_BACK == glFace) { | 2905 if (GR_GL_FRONT_AND_BACK == glFace) { |
2908 // we call the combined func just in case separate stencil is not | 2906 // we call the combined func just in case separate stencil is not |
2909 // supported. | 2907 // supported. |
2910 GR_GL_CALL(gl, StencilFunc(glFunc, ref, mask)); | 2908 GR_GL_CALL(gl, StencilFunc(glFunc, ref, mask)); |
2911 GR_GL_CALL(gl, StencilMask(writeMask)); | 2909 GR_GL_CALL(gl, StencilMask(writeMask)); |
2912 GR_GL_CALL(gl, StencilOp(glFailOp, GR_GL_KEEP, glPassOp)); | 2910 GR_GL_CALL(gl, StencilOp(glFailOp, GR_GL_KEEP, glPassOp)); |
2913 } else { | 2911 } else { |
2914 GR_GL_CALL(gl, StencilFuncSeparate(glFace, glFunc, ref, mask)); | 2912 GR_GL_CALL(gl, StencilFuncSeparate(glFace, glFunc, ref, mask)); |
2915 GR_GL_CALL(gl, StencilMaskSeparate(glFace, writeMask)); | 2913 GR_GL_CALL(gl, StencilMaskSeparate(glFace, writeMask)); |
2916 GR_GL_CALL(gl, StencilOpSeparate(glFace, glFailOp, GR_GL_KEEP, glPassOp)
); | 2914 GR_GL_CALL(gl, StencilOpSeparate(glFace, glFailOp, GR_GL_KEEP, glPassOp)
); |
2917 } | 2915 } |
2918 } | 2916 } |
2919 } | 2917 } |
2920 | 2918 |
2921 void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) { | 2919 void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) { |
2922 if (fHWStencilSettings != stencilSettings) { | 2920 if (fHWStencilSettings != stencilSettings) { |
2923 if (stencilSettings.isDisabled()) { | 2921 if (stencilSettings.isDisabled()) { |
2924 if (kNo_TriState != fHWStencilTestEnabled) { | 2922 if (kNo_TriState != fHWStencilTestEnabled) { |
2925 GL_CALL(Disable(GR_GL_STENCIL_TEST)); | 2923 GL_CALL(Disable(GR_GL_STENCIL_TEST)); |
2926 fHWStencilTestEnabled = kNo_TriState; | 2924 fHWStencilTestEnabled = kNo_TriState; |
2927 } | 2925 } |
2928 } else { | 2926 } else { |
2929 if (kYes_TriState != fHWStencilTestEnabled) { | 2927 if (kYes_TriState != fHWStencilTestEnabled) { |
2930 GL_CALL(Enable(GR_GL_STENCIL_TEST)); | 2928 GL_CALL(Enable(GR_GL_STENCIL_TEST)); |
2931 fHWStencilTestEnabled = kYes_TriState; | 2929 fHWStencilTestEnabled = kYes_TriState; |
2932 } | 2930 } |
2933 } | 2931 } |
2934 if (!stencilSettings.isDisabled()) { | 2932 if (!stencilSettings.isDisabled()) { |
2935 if (this->caps()->twoSidedStencilSupport()) { | 2933 if (stencilSettings.isTwoSided()) { |
| 2934 SkASSERT(this->caps()->twoSidedStencilSupport()); |
2936 set_gl_stencil(this->glInterface(), | 2935 set_gl_stencil(this->glInterface(), |
2937 stencilSettings, | 2936 stencilSettings.front(), |
2938 GR_GL_FRONT, | 2937 GR_GL_FRONT); |
2939 GrStencilSettings::kFront_Face); | |
2940 set_gl_stencil(this->glInterface(), | 2938 set_gl_stencil(this->glInterface(), |
2941 stencilSettings, | 2939 stencilSettings.back(), |
2942 GR_GL_BACK, | 2940 GR_GL_BACK); |
2943 GrStencilSettings::kBack_Face); | |
2944 } else { | 2941 } else { |
2945 set_gl_stencil(this->glInterface(), | 2942 set_gl_stencil(this->glInterface(), |
2946 stencilSettings, | 2943 stencilSettings.front(), |
2947 GR_GL_FRONT_AND_BACK, | 2944 GR_GL_FRONT_AND_BACK); |
2948 GrStencilSettings::kFront_Face); | |
2949 } | 2945 } |
2950 } | 2946 } |
2951 fHWStencilSettings = stencilSettings; | 2947 fHWStencilSettings = stencilSettings; |
2952 } | 2948 } |
2953 } | 2949 } |
2954 | 2950 |
2955 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl
ed) { | 2951 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl
ed) { |
2956 // rt is only optional if useHWAA is false. | 2952 // rt is only optional if useHWAA is false. |
2957 SkASSERT(rt || !useHWAA); | 2953 SkASSERT(rt || !useHWAA); |
2958 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); | 2954 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4246 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4242 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
4247 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4243 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
4248 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4244 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
4249 copyParams->fWidth = texture->width(); | 4245 copyParams->fWidth = texture->width(); |
4250 copyParams->fHeight = texture->height(); | 4246 copyParams->fHeight = texture->height(); |
4251 return true; | 4247 return true; |
4252 } | 4248 } |
4253 } | 4249 } |
4254 return false; | 4250 return false; |
4255 } | 4251 } |
OLD | NEW |