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

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

Issue 2453793002: Add disableStencil method to GrGLGpu (Closed)
Patch Set: Created 4 years, 1 month 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/gl/GrGLGpu.h ('k') | no next file » | 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 2720 matching lines...) Expand 10 before | Expand all | Expand 10 after
2731 return; 2731 return;
2732 } 2732 }
2733 GrPixelLocalStorageState plsState = primProc.getPixelLocalStorageState(); 2733 GrPixelLocalStorageState plsState = primProc.getPixelLocalStorageState();
2734 if (!fHWPLSEnabled && plsState != 2734 if (!fHWPLSEnabled && plsState !=
2735 GrPixelLocalStorageState::kDisabled_GrPixelLocalStorageState) { 2735 GrPixelLocalStorageState::kDisabled_GrPixelLocalStorageState) {
2736 GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); 2736 GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE));
2737 this->setupPixelLocalStorage(pipeline, primProc); 2737 this->setupPixelLocalStorage(pipeline, primProc);
2738 fHWPLSEnabled = true; 2738 fHWPLSEnabled = true;
2739 } 2739 }
2740 if (plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState) { 2740 if (plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState) {
2741 GrStencilSettings stencil; 2741 this->disableStencil();
2742 stencil.setDisabled();
2743 this->flushStencil(stencil);
2744 } 2742 }
2745 2743
2746 for (int i = 0; i < meshCount; ++i) { 2744 for (int i = 0; i < meshCount; ++i) {
2747 if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*this->caps ())) { 2745 if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*this->caps ())) {
2748 this->xferBarrier(pipeline.getRenderTarget(), barrierType); 2746 this->xferBarrier(pipeline.getRenderTarget(), barrierType);
2749 } 2747 }
2750 2748
2751 const GrMesh& mesh = meshes[i]; 2749 const GrMesh& mesh = meshes[i];
2752 GrMesh::Iterator iter; 2750 GrMesh::Iterator iter;
2753 const GrNonInstancedMesh* nonInstMesh = iter.init(mesh); 2751 const GrNonInstancedMesh* nonInstMesh = iter.init(mesh);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 GR_GL_CALL(gl, StencilOp(glFailOp, GR_GL_KEEP, glPassOp)); 2964 GR_GL_CALL(gl, StencilOp(glFailOp, GR_GL_KEEP, glPassOp));
2967 } else { 2965 } else {
2968 GR_GL_CALL(gl, StencilFuncSeparate(glFace, glFunc, ref, mask)); 2966 GR_GL_CALL(gl, StencilFuncSeparate(glFace, glFunc, ref, mask));
2969 GR_GL_CALL(gl, StencilMaskSeparate(glFace, writeMask)); 2967 GR_GL_CALL(gl, StencilMaskSeparate(glFace, writeMask));
2970 GR_GL_CALL(gl, StencilOpSeparate(glFace, glFailOp, GR_GL_KEEP, glPassOp) ); 2968 GR_GL_CALL(gl, StencilOpSeparate(glFace, glFailOp, GR_GL_KEEP, glPassOp) );
2971 } 2969 }
2972 } 2970 }
2973 } 2971 }
2974 2972
2975 void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) { 2973 void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) {
2976 if (fHWStencilSettings != stencilSettings) { 2974 if (stencilSettings.isDisabled()) {
2977 if (stencilSettings.isDisabled()) { 2975 this->disableStencil();
2978 if (kNo_TriState != fHWStencilTestEnabled) { 2976 } else if (fHWStencilSettings != stencilSettings) {
2979 GL_CALL(Disable(GR_GL_STENCIL_TEST)); 2977 if (kYes_TriState != fHWStencilTestEnabled) {
2980 fHWStencilTestEnabled = kNo_TriState; 2978 GL_CALL(Enable(GR_GL_STENCIL_TEST));
2981 } 2979 fHWStencilTestEnabled = kYes_TriState;
2980 }
2981 if (stencilSettings.isTwoSided()) {
2982 SkASSERT(this->caps()->twoSidedStencilSupport());
2983 set_gl_stencil(this->glInterface(),
2984 stencilSettings.front(),
2985 GR_GL_FRONT);
2986 set_gl_stencil(this->glInterface(),
2987 stencilSettings.back(),
2988 GR_GL_BACK);
2982 } else { 2989 } else {
2983 if (kYes_TriState != fHWStencilTestEnabled) { 2990 set_gl_stencil(this->glInterface(),
2984 GL_CALL(Enable(GR_GL_STENCIL_TEST)); 2991 stencilSettings.front(),
2985 fHWStencilTestEnabled = kYes_TriState; 2992 GR_GL_FRONT_AND_BACK);
2986 }
2987 }
2988 if (!stencilSettings.isDisabled()) {
2989 if (stencilSettings.isTwoSided()) {
2990 SkASSERT(this->caps()->twoSidedStencilSupport());
2991 set_gl_stencil(this->glInterface(),
2992 stencilSettings.front(),
2993 GR_GL_FRONT);
2994 set_gl_stencil(this->glInterface(),
2995 stencilSettings.back(),
2996 GR_GL_BACK);
2997 } else {
2998 set_gl_stencil(this->glInterface(),
2999 stencilSettings.front(),
3000 GR_GL_FRONT_AND_BACK);
3001 }
3002 } 2993 }
3003 fHWStencilSettings = stencilSettings; 2994 fHWStencilSettings = stencilSettings;
3004 } 2995 }
3005 } 2996 }
3006 2997
2998 void GrGLGpu::disableStencil() {
2999 if (kNo_TriState != fHWStencilTestEnabled) {
3000 GL_CALL(Disable(GR_GL_STENCIL_TEST));
3001 fHWStencilTestEnabled = kNo_TriState;
3002 fHWStencilSettings.invalidate();
3003 }
3004 }
3005
3007 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl ed) { 3006 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl ed) {
3008 // rt is only optional if useHWAA is false. 3007 // rt is only optional if useHWAA is false.
3009 SkASSERT(rt || !useHWAA); 3008 SkASSERT(rt || !useHWAA);
3010 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); 3009 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled());
3011 3010
3012 if (this->caps()->multisampleDisableSupport()) { 3011 if (this->caps()->multisampleDisableSupport()) {
3013 if (useHWAA) { 3012 if (useHWAA) {
3014 if (kYes_TriState != fMSAAEnabled) { 3013 if (kYes_TriState != fMSAAEnabled) {
3015 GL_CALL(Enable(GR_GL_MULTISAMPLE)); 3014 GL_CALL(Enable(GR_GL_MULTISAMPLE));
3016 fMSAAEnabled = kYes_TriState; 3015 fMSAAEnabled = kYes_TriState;
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
4131 GL_CALL(Uniform4fv(fWireRectProgram.fColorUniform, 1, channels)); 4130 GL_CALL(Uniform4fv(fWireRectProgram.fColorUniform, 1, channels));
4132 4131
4133 GrXferProcessor::BlendInfo blendInfo; 4132 GrXferProcessor::BlendInfo blendInfo;
4134 blendInfo.reset(); 4133 blendInfo.reset();
4135 this->flushBlend(blendInfo, GrSwizzle::RGBA()); 4134 this->flushBlend(blendInfo, GrSwizzle::RGBA());
4136 this->flushColorWrite(true); 4135 this->flushColorWrite(true);
4137 this->flushDrawFace(GrDrawFace::kBoth); 4136 this->flushDrawFace(GrDrawFace::kBoth);
4138 this->flushHWAAState(glRT, false, false); 4137 this->flushHWAAState(glRT, false, false);
4139 this->disableScissor(); 4138 this->disableScissor();
4140 this->disableWindowRectangles(); 4139 this->disableWindowRectangles();
4141 GrStencilSettings stencil; 4140 this->disableStencil();
4142 stencil.setDisabled();
4143 this->flushStencil(stencil);
4144 4141
4145 GL_CALL(DrawArrays(GR_GL_LINE_LOOP, 0, 4)); 4142 GL_CALL(DrawArrays(GR_GL_LINE_LOOP, 0, 4));
4146 } 4143 }
4147 4144
4148 4145
4149 bool GrGLGpu::copySurfaceAsDraw(GrSurface* dst, 4146 bool GrGLGpu::copySurfaceAsDraw(GrSurface* dst,
4150 GrSurface* src, 4147 GrSurface* src,
4151 const SkIRect& srcRect, 4148 const SkIRect& srcRect,
4152 const SkIPoint& dstPoint) { 4149 const SkIPoint& dstPoint) {
4153 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); 4150 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
4220 GL_CALL(Uniform1i(fCopyPrograms[progIdx].fTextureUniform, 0)); 4217 GL_CALL(Uniform1i(fCopyPrograms[progIdx].fTextureUniform, 0));
4221 4218
4222 GrXferProcessor::BlendInfo blendInfo; 4219 GrXferProcessor::BlendInfo blendInfo;
4223 blendInfo.reset(); 4220 blendInfo.reset();
4224 this->flushBlend(blendInfo, GrSwizzle::RGBA()); 4221 this->flushBlend(blendInfo, GrSwizzle::RGBA());
4225 this->flushColorWrite(true); 4222 this->flushColorWrite(true);
4226 this->flushDrawFace(GrDrawFace::kBoth); 4223 this->flushDrawFace(GrDrawFace::kBoth);
4227 this->flushHWAAState(nullptr, false, false); 4224 this->flushHWAAState(nullptr, false, false);
4228 this->disableScissor(); 4225 this->disableScissor();
4229 this->disableWindowRectangles(); 4226 this->disableWindowRectangles();
4230 GrStencilSettings stencil; 4227 this->disableStencil();
4231 stencil.setDisabled();
4232 this->flushStencil(stencil);
4233 4228
4234 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); 4229 GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4));
4235 this->unbindTextureFBOForCopy(GR_GL_FRAMEBUFFER, dst); 4230 this->unbindTextureFBOForCopy(GR_GL_FRAMEBUFFER, dst);
4236 this->didWriteToSurface(dst, &dstRect); 4231 this->didWriteToSurface(dst, &dstRect);
4237 4232
4238 return true; 4233 return true;
4239 } 4234 }
4240 4235
4241 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst, 4236 void GrGLGpu::copySurfaceAsCopyTexSubImage(GrSurface* dst,
4242 GrSurface* src, 4237 GrSurface* src,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
4430 4425
4431 // Set "simple" state once: 4426 // Set "simple" state once:
4432 GrXferProcessor::BlendInfo blendInfo; 4427 GrXferProcessor::BlendInfo blendInfo;
4433 blendInfo.reset(); 4428 blendInfo.reset();
4434 this->flushBlend(blendInfo, GrSwizzle::RGBA()); 4429 this->flushBlend(blendInfo, GrSwizzle::RGBA());
4435 this->flushColorWrite(true); 4430 this->flushColorWrite(true);
4436 this->flushDrawFace(GrDrawFace::kBoth); 4431 this->flushDrawFace(GrDrawFace::kBoth);
4437 this->flushHWAAState(nullptr, false, false); 4432 this->flushHWAAState(nullptr, false, false);
4438 this->disableScissor(); 4433 this->disableScissor();
4439 this->disableWindowRectangles(); 4434 this->disableWindowRectangles();
4440 GrStencilSettings stencil; 4435 this->disableStencil();
4441 stencil.setDisabled();
4442 this->flushStencil(stencil);
4443 4436
4444 // Do all the blits: 4437 // Do all the blits:
4445 width = texture->width(); 4438 width = texture->width();
4446 height = texture->height(); 4439 height = texture->height();
4447 GrGLIRect viewport; 4440 GrGLIRect viewport;
4448 viewport.fLeft = 0; 4441 viewport.fLeft = 0;
4449 viewport.fBottom = 0; 4442 viewport.fBottom = 0;
4450 for (GrGLint level = 1; level < levelCount; ++level) { 4443 for (GrGLint level = 1; level < levelCount; ++level) {
4451 // Get and bind the program for this particular downsample (filter shape can vary): 4444 // Get and bind the program for this particular downsample (filter shape can vary):
4452 int progIdx = TextureSizeToMipmapProgramIdx(width, height); 4445 int progIdx = TextureSizeToMipmapProgramIdx(width, height);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
4656 4649
4657 bool GrGLGpu::waitFence(GrFence fence, uint64_t timeout) const { 4650 bool GrGLGpu::waitFence(GrFence fence, uint64_t timeout) const {
4658 GrGLenum result; 4651 GrGLenum result;
4659 GL_CALL_RET(result, ClientWaitSync((GrGLsync)fence, GR_GL_SYNC_FLUSH_COMMAND S_BIT, timeout)); 4652 GL_CALL_RET(result, ClientWaitSync((GrGLsync)fence, GR_GL_SYNC_FLUSH_COMMAND S_BIT, timeout));
4660 return (GR_GL_CONDITION_SATISFIED == result); 4653 return (GR_GL_CONDITION_SATISFIED == result);
4661 } 4654 }
4662 4655
4663 void GrGLGpu::deleteFence(GrFence fence) const { 4656 void GrGLGpu::deleteFence(GrFence fence) const {
4664 GL_CALL(DeleteSync((GrGLsync)fence)); 4657 GL_CALL(DeleteSync((GrGLsync)fence));
4665 } 4658 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698