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

Side by Side Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1969693003: Revert of Separate user and raw stencil settings (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « src/gpu/batches/GrStencilPathBatch.h ('k') | src/gpu/gl/GrGLPathRendering.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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[kGrStencilOpCount] = { 2872 static const GrGLenum gTable[] = {
2873 GR_GL_KEEP, // kKeep 2873 GR_GL_KEEP, // kKeep_StencilOp
2874 GR_GL_ZERO, // kZero 2874 GR_GL_REPLACE, // kReplace_StencilOp
2875 GR_GL_REPLACE, // kReplace 2875 GR_GL_INCR_WRAP, // kIncWrap_StencilOp
2876 GR_GL_INVERT, // kInvert 2876 GR_GL_INCR, // kIncClamp_StencilOp
2877 GR_GL_INCR_WRAP, // kIncWrap 2877 GR_GL_DECR_WRAP, // kDecWrap_StencilOp
2878 GR_GL_DECR_WRAP, // kDecWrap 2878 GR_GL_DECR, // kDecClamp_StencilOp
2879 GR_GL_INCR, // kIncClamp 2879 GR_GL_ZERO, // kZero_StencilOp
2880 GR_GL_DECR, // kDecClamp 2880 GR_GL_INVERT, // kInvert_StencilOp
2881 }; 2881 };
2882 GR_STATIC_ASSERT(0 == (int)GrStencilOp::kKeep); 2882 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kStencilOpCnt);
2883 GR_STATIC_ASSERT(1 == (int)GrStencilOp::kZero); 2883 GR_STATIC_ASSERT(0 == kKeep_StencilOp);
2884 GR_STATIC_ASSERT(2 == (int)GrStencilOp::kReplace); 2884 GR_STATIC_ASSERT(1 == kReplace_StencilOp);
2885 GR_STATIC_ASSERT(3 == (int)GrStencilOp::kInvert); 2885 GR_STATIC_ASSERT(2 == kIncWrap_StencilOp);
2886 GR_STATIC_ASSERT(4 == (int)GrStencilOp::kIncWrap); 2886 GR_STATIC_ASSERT(3 == kIncClamp_StencilOp);
2887 GR_STATIC_ASSERT(5 == (int)GrStencilOp::kDecWrap); 2887 GR_STATIC_ASSERT(4 == kDecWrap_StencilOp);
2888 GR_STATIC_ASSERT(6 == (int)GrStencilOp::kIncClamp); 2888 GR_STATIC_ASSERT(5 == kDecClamp_StencilOp);
2889 GR_STATIC_ASSERT(7 == (int)GrStencilOp::kDecClamp); 2889 GR_STATIC_ASSERT(6 == kZero_StencilOp);
2890 SkASSERT(op < (GrStencilOp)kGrStencilOpCount); 2890 GR_STATIC_ASSERT(7 == kInvert_StencilOp);
2891 return gTable[(int)op]; 2891 SkASSERT((unsigned) op < kStencilOpCnt);
2892 return gTable[op];
2892 } 2893 }
2893 2894
2894 void set_gl_stencil(const GrGLInterface* gl, 2895 void set_gl_stencil(const GrGLInterface* gl,
2895 const GrStencilSettings::Face& face, 2896 const GrStencilSettings& settings,
2896 GrGLenum glFace) { 2897 GrGLenum glFace,
2897 GrGLenum glFunc = GrToGLStencilFunc(face.fTest); 2898 GrStencilSettings::Face grFace) {
2898 GrGLenum glFailOp = gr_to_gl_stencil_op(face.fFailOp); 2899 GrGLenum glFunc = GrToGLStencilFunc(settings.func(grFace));
2899 GrGLenum glPassOp = gr_to_gl_stencil_op(face.fPassOp); 2900 GrGLenum glFailOp = gr_to_gl_stencil_op(settings.failOp(grFace));
2901 GrGLenum glPassOp = gr_to_gl_stencil_op(settings.passOp(grFace));
2900 2902
2901 GrGLint ref = face.fRef; 2903 GrGLint ref = settings.funcRef(grFace);
2902 GrGLint mask = face.fTestMask; 2904 GrGLint mask = settings.funcMask(grFace);
2903 GrGLint writeMask = face.fWriteMask; 2905 GrGLint writeMask = settings.writeMask(grFace);
2904 2906
2905 if (GR_GL_FRONT_AND_BACK == glFace) { 2907 if (GR_GL_FRONT_AND_BACK == glFace) {
2906 // we call the combined func just in case separate stencil is not 2908 // we call the combined func just in case separate stencil is not
2907 // supported. 2909 // supported.
2908 GR_GL_CALL(gl, StencilFunc(glFunc, ref, mask)); 2910 GR_GL_CALL(gl, StencilFunc(glFunc, ref, mask));
2909 GR_GL_CALL(gl, StencilMask(writeMask)); 2911 GR_GL_CALL(gl, StencilMask(writeMask));
2910 GR_GL_CALL(gl, StencilOp(glFailOp, GR_GL_KEEP, glPassOp)); 2912 GR_GL_CALL(gl, StencilOp(glFailOp, GR_GL_KEEP, glPassOp));
2911 } else { 2913 } else {
2912 GR_GL_CALL(gl, StencilFuncSeparate(glFace, glFunc, ref, mask)); 2914 GR_GL_CALL(gl, StencilFuncSeparate(glFace, glFunc, ref, mask));
2913 GR_GL_CALL(gl, StencilMaskSeparate(glFace, writeMask)); 2915 GR_GL_CALL(gl, StencilMaskSeparate(glFace, writeMask));
2914 GR_GL_CALL(gl, StencilOpSeparate(glFace, glFailOp, GR_GL_KEEP, glPassOp) ); 2916 GR_GL_CALL(gl, StencilOpSeparate(glFace, glFailOp, GR_GL_KEEP, glPassOp) );
2915 } 2917 }
2916 } 2918 }
2917 } 2919 }
2918 2920
2919 void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) { 2921 void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) {
2920 if (fHWStencilSettings != stencilSettings) { 2922 if (fHWStencilSettings != stencilSettings) {
2921 if (stencilSettings.isDisabled()) { 2923 if (stencilSettings.isDisabled()) {
2922 if (kNo_TriState != fHWStencilTestEnabled) { 2924 if (kNo_TriState != fHWStencilTestEnabled) {
2923 GL_CALL(Disable(GR_GL_STENCIL_TEST)); 2925 GL_CALL(Disable(GR_GL_STENCIL_TEST));
2924 fHWStencilTestEnabled = kNo_TriState; 2926 fHWStencilTestEnabled = kNo_TriState;
2925 } 2927 }
2926 } else { 2928 } else {
2927 if (kYes_TriState != fHWStencilTestEnabled) { 2929 if (kYes_TriState != fHWStencilTestEnabled) {
2928 GL_CALL(Enable(GR_GL_STENCIL_TEST)); 2930 GL_CALL(Enable(GR_GL_STENCIL_TEST));
2929 fHWStencilTestEnabled = kYes_TriState; 2931 fHWStencilTestEnabled = kYes_TriState;
2930 } 2932 }
2931 } 2933 }
2932 if (!stencilSettings.isDisabled()) { 2934 if (!stencilSettings.isDisabled()) {
2933 if (stencilSettings.isTwoSided()) { 2935 if (this->caps()->twoSidedStencilSupport()) {
2934 SkASSERT(this->caps()->twoSidedStencilSupport());
2935 set_gl_stencil(this->glInterface(), 2936 set_gl_stencil(this->glInterface(),
2936 stencilSettings.front(), 2937 stencilSettings,
2937 GR_GL_FRONT); 2938 GR_GL_FRONT,
2939 GrStencilSettings::kFront_Face);
2938 set_gl_stencil(this->glInterface(), 2940 set_gl_stencil(this->glInterface(),
2939 stencilSettings.back(), 2941 stencilSettings,
2940 GR_GL_BACK); 2942 GR_GL_BACK,
2943 GrStencilSettings::kBack_Face);
2941 } else { 2944 } else {
2942 set_gl_stencil(this->glInterface(), 2945 set_gl_stencil(this->glInterface(),
2943 stencilSettings.front(), 2946 stencilSettings,
2944 GR_GL_FRONT_AND_BACK); 2947 GR_GL_FRONT_AND_BACK,
2948 GrStencilSettings::kFront_Face);
2945 } 2949 }
2946 } 2950 }
2947 fHWStencilSettings = stencilSettings; 2951 fHWStencilSettings = stencilSettings;
2948 } 2952 }
2949 } 2953 }
2950 2954
2951 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl ed) { 2955 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl ed) {
2952 // rt is only optional if useHWAA is false. 2956 // rt is only optional if useHWAA is false.
2953 SkASSERT(rt || !useHWAA); 2957 SkASSERT(rt || !useHWAA);
2954 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); 2958 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled());
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
4242 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || 4246 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
4243 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { 4247 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
4244 copyParams->fFilter = GrTextureParams::kNone_FilterMode; 4248 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
4245 copyParams->fWidth = texture->width(); 4249 copyParams->fWidth = texture->width();
4246 copyParams->fHeight = texture->height(); 4250 copyParams->fHeight = texture->height();
4247 return true; 4251 return true;
4248 } 4252 }
4249 } 4253 }
4250 return false; 4254 return false;
4251 } 4255 }
OLDNEW
« no previous file with comments | « src/gpu/batches/GrStencilPathBatch.h ('k') | src/gpu/gl/GrGLPathRendering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698