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

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

Issue 2262473003: Define clear regions in terms of GrFixedClip (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_fixedcliptosrc
Patch Set: rebase Created 4 years, 3 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/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLGpuCommandBuffer.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"
11 #include "GrGLGpuCommandBuffer.h" 11 #include "GrGLGpuCommandBuffer.h"
12 #include "GrGLStencilAttachment.h" 12 #include "GrGLStencilAttachment.h"
13 #include "GrGLTextureRenderTarget.h" 13 #include "GrGLTextureRenderTarget.h"
14 #include "GrFixedClip.h"
14 #include "GrGpuResourcePriv.h" 15 #include "GrGpuResourcePriv.h"
15 #include "GrMesh.h" 16 #include "GrMesh.h"
16 #include "GrPipeline.h" 17 #include "GrPipeline.h"
17 #include "GrPLSGeometryProcessor.h" 18 #include "GrPLSGeometryProcessor.h"
18 #include "GrRenderTargetPriv.h" 19 #include "GrRenderTargetPriv.h"
19 #include "GrSurfacePriv.h" 20 #include "GrSurfacePriv.h"
20 #include "GrTexturePriv.h" 21 #include "GrTexturePriv.h"
21 #include "GrTypes.h" 22 #include "GrTypes.h"
22 #include "builders/GrGLShaderStringBuilder.h" 23 #include "builders/GrGLShaderStringBuilder.h"
23 #include "glsl/GrGLSL.h" 24 #include "glsl/GrGLSL.h"
(...skipping 2166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 } 2191 }
2191 2192
2192 void GrGLGpu::disableScissor() { 2193 void GrGLGpu::disableScissor() {
2193 if (kNo_TriState != fHWScissorSettings.fEnabled) { 2194 if (kNo_TriState != fHWScissorSettings.fEnabled) {
2194 GL_CALL(Disable(GR_GL_SCISSOR_TEST)); 2195 GL_CALL(Disable(GR_GL_SCISSOR_TEST));
2195 fHWScissorSettings.fEnabled = kNo_TriState; 2196 fHWScissorSettings.fEnabled = kNo_TriState;
2196 return; 2197 return;
2197 } 2198 }
2198 } 2199 }
2199 2200
2200 void GrGLGpu::clear(const SkIRect& rect, GrColor color, GrRenderTarget* target) { 2201 void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrRenderTarget* targ et) {
2201 this->handleDirtyContext(); 2202 this->handleDirtyContext();
2202 2203
2203 // parent class should never let us get here with no RT 2204 // parent class should never let us get here with no RT
2204 SkASSERT(target); 2205 SkASSERT(target);
2205 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 2206 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
2206 2207
2207 this->flushRenderTarget(glRT, &rect); 2208 this->flushRenderTarget(glRT, clip.scissorEnabled() ? &clip.scissorRect() : nullptr);
2208 GrScissorState scissorState; 2209 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin()) ;
2209 scissorState.set(rect);
2210 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin());
2211 this->disableWindowRectangles(); 2210 this->disableWindowRectangles();
2212 2211
2213 GrGLfloat r, g, b, a; 2212 GrGLfloat r, g, b, a;
2214 static const GrGLfloat scale255 = 1.f / 255.f; 2213 static const GrGLfloat scale255 = 1.f / 255.f;
2215 a = GrColorUnpackA(color) * scale255; 2214 a = GrColorUnpackA(color) * scale255;
2216 GrGLfloat scaleRGB = scale255; 2215 GrGLfloat scaleRGB = scale255;
2217 r = GrColorUnpackR(color) * scaleRGB; 2216 r = GrColorUnpackR(color) * scaleRGB;
2218 g = GrColorUnpackG(color) * scaleRGB; 2217 g = GrColorUnpackG(color) * scaleRGB;
2219 b = GrColorUnpackB(color) * scaleRGB; 2218 b = GrColorUnpackB(color) * scaleRGB;
2220 2219
(...skipping 12 matching lines...) Expand all
2233 2232
2234 this->disableScissor(); 2233 this->disableScissor();
2235 this->disableWindowRectangles(); 2234 this->disableWindowRectangles();
2236 2235
2237 GL_CALL(StencilMask(0xffffffff)); 2236 GL_CALL(StencilMask(0xffffffff));
2238 GL_CALL(ClearStencil(0)); 2237 GL_CALL(ClearStencil(0));
2239 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 2238 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
2240 fHWStencilSettings.invalidate(); 2239 fHWStencilSettings.invalidate();
2241 } 2240 }
2242 2241
2243 void GrGLGpu::clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTar get* target) { 2242 void GrGLGpu::clearStencilClip(const GrFixedClip& clip,
2243 bool insideStencilMask,
2244 GrRenderTarget* target) {
2244 SkASSERT(target); 2245 SkASSERT(target);
2245 this->handleDirtyContext(); 2246 this->handleDirtyContext();
2246 2247
2247 GrStencilAttachment* sb = target->renderTargetPriv().getStencilAttachment(); 2248 GrStencilAttachment* sb = target->renderTargetPriv().getStencilAttachment();
2248 // this should only be called internally when we know we have a 2249 // this should only be called internally when we know we have a
2249 // stencil buffer. 2250 // stencil buffer.
2250 SkASSERT(sb); 2251 SkASSERT(sb);
2251 GrGLint stencilBitCount = sb->bits(); 2252 GrGLint stencilBitCount = sb->bits();
2252 #if 0 2253 #if 0
2253 SkASSERT(stencilBitCount > 0); 2254 SkASSERT(stencilBitCount > 0);
2254 GrGLint clipStencilMask = (1 << (stencilBitCount - 1)); 2255 GrGLint clipStencilMask = (1 << (stencilBitCount - 1));
2255 #else 2256 #else
2256 // we could just clear the clip bit but when we go through 2257 // we could just clear the clip bit but when we go through
2257 // ANGLE a partial stencil mask will cause clears to be 2258 // ANGLE a partial stencil mask will cause clears to be
2258 // turned into draws. Our contract on GrDrawTarget says that 2259 // turned into draws. Our contract on GrDrawTarget says that
2259 // changing the clip between stencil passes may or may not 2260 // changing the clip between stencil passes may or may not
2260 // zero the client's clip bits. So we just clear the whole thing. 2261 // zero the client's clip bits. So we just clear the whole thing.
2261 static const GrGLint clipStencilMask = ~0; 2262 static const GrGLint clipStencilMask = ~0;
2262 #endif 2263 #endif
2263 GrGLint value; 2264 GrGLint value;
2264 if (insideClip) { 2265 if (insideStencilMask) {
2265 value = (1 << (stencilBitCount - 1)); 2266 value = (1 << (stencilBitCount - 1));
2266 } else { 2267 } else {
2267 value = 0; 2268 value = 0;
2268 } 2269 }
2269 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 2270 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
2270 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); 2271 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect());
2271 2272
2272 GrScissorState scissorState; 2273 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin()) ;
2273 scissorState.set(rect);
2274 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin());
2275 this->disableWindowRectangles(); 2274 this->disableWindowRectangles();
2276 2275
2277 GL_CALL(StencilMask((uint32_t) clipStencilMask)); 2276 GL_CALL(StencilMask((uint32_t) clipStencilMask));
2278 GL_CALL(ClearStencil(value)); 2277 GL_CALL(ClearStencil(value));
2279 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 2278 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
2280 fHWStencilSettings.invalidate(); 2279 fHWStencilSettings.invalidate();
2281 } 2280 }
2282 2281
2283 static bool read_pixels_pays_for_y_flip(GrRenderTarget* renderTarget, const GrGL Caps& caps, 2282 static bool read_pixels_pays_for_y_flip(GrRenderTarget* renderTarget, const GrGL Caps& caps,
2284 int width, int height, GrPixelConfig co nfig, 2283 int width, int height, GrPixelConfig co nfig,
(...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after
4673 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || 4672 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
4674 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { 4673 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
4675 copyParams->fFilter = GrTextureParams::kNone_FilterMode; 4674 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
4676 copyParams->fWidth = texture->width(); 4675 copyParams->fWidth = texture->width();
4677 copyParams->fHeight = texture->height(); 4676 copyParams->fHeight = texture->height();
4678 return true; 4677 return true;
4679 } 4678 }
4680 } 4679 }
4681 return false; 4680 return false;
4682 } 4681 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLGpuCommandBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698