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

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: Define clear regions in terms of GrFixedClip Created 4 years, 4 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
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 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2186 } 2187 }
2187 2188
2188 void GrGLGpu::disableScissor() { 2189 void GrGLGpu::disableScissor() {
2189 if (kNo_TriState != fHWScissorSettings.fEnabled) { 2190 if (kNo_TriState != fHWScissorSettings.fEnabled) {
2190 GL_CALL(Disable(GR_GL_SCISSOR_TEST)); 2191 GL_CALL(Disable(GR_GL_SCISSOR_TEST));
2191 fHWScissorSettings.fEnabled = kNo_TriState; 2192 fHWScissorSettings.fEnabled = kNo_TriState;
2192 return; 2193 return;
2193 } 2194 }
2194 } 2195 }
2195 2196
2196 void GrGLGpu::clear(const SkIRect& rect, GrColor color, GrRenderTarget* target) { 2197 void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrRenderTarget* targ et) {
2197 this->handleDirtyContext(); 2198 this->handleDirtyContext();
2198 2199
2199 // parent class should never let us get here with no RT 2200 // parent class should never let us get here with no RT
2200 SkASSERT(target); 2201 SkASSERT(target);
2201 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 2202 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
2202 2203
2203 this->flushRenderTarget(glRT, &rect); 2204 this->flushRenderTarget(glRT, clip.scissorEnabled() ? &clip.scissorRect() : nullptr);
2204 GrScissorState scissorState; 2205 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin()) ;
2205 scissorState.set(rect);
2206 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin());
2207 this->disableWindowRectangles(); 2206 this->disableWindowRectangles();
2208 2207
2209 GrGLfloat r, g, b, a; 2208 GrGLfloat r, g, b, a;
2210 static const GrGLfloat scale255 = 1.f / 255.f; 2209 static const GrGLfloat scale255 = 1.f / 255.f;
2211 a = GrColorUnpackA(color) * scale255; 2210 a = GrColorUnpackA(color) * scale255;
2212 GrGLfloat scaleRGB = scale255; 2211 GrGLfloat scaleRGB = scale255;
2213 r = GrColorUnpackR(color) * scaleRGB; 2212 r = GrColorUnpackR(color) * scaleRGB;
2214 g = GrColorUnpackG(color) * scaleRGB; 2213 g = GrColorUnpackG(color) * scaleRGB;
2215 b = GrColorUnpackB(color) * scaleRGB; 2214 b = GrColorUnpackB(color) * scaleRGB;
2216 2215
(...skipping 12 matching lines...) Expand all
2229 2228
2230 this->disableScissor(); 2229 this->disableScissor();
2231 this->disableWindowRectangles(); 2230 this->disableWindowRectangles();
2232 2231
2233 GL_CALL(StencilMask(0xffffffff)); 2232 GL_CALL(StencilMask(0xffffffff));
2234 GL_CALL(ClearStencil(0)); 2233 GL_CALL(ClearStencil(0));
2235 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 2234 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
2236 fHWStencilSettings.invalidate(); 2235 fHWStencilSettings.invalidate();
2237 } 2236 }
2238 2237
2239 void GrGLGpu::clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTar get* target) { 2238 void GrGLGpu::clearStencilClip(const GrFixedClip& clip,
2239 bool insideStencilMask,
2240 GrRenderTarget* target) {
2240 SkASSERT(target); 2241 SkASSERT(target);
2241 this->handleDirtyContext(); 2242 this->handleDirtyContext();
2242 2243
2243 GrStencilAttachment* sb = target->renderTargetPriv().getStencilAttachment(); 2244 GrStencilAttachment* sb = target->renderTargetPriv().getStencilAttachment();
2244 // this should only be called internally when we know we have a 2245 // this should only be called internally when we know we have a
2245 // stencil buffer. 2246 // stencil buffer.
2246 SkASSERT(sb); 2247 SkASSERT(sb);
2247 GrGLint stencilBitCount = sb->bits(); 2248 GrGLint stencilBitCount = sb->bits();
2248 #if 0 2249 #if 0
2249 SkASSERT(stencilBitCount > 0); 2250 SkASSERT(stencilBitCount > 0);
2250 GrGLint clipStencilMask = (1 << (stencilBitCount - 1)); 2251 GrGLint clipStencilMask = (1 << (stencilBitCount - 1));
2251 #else 2252 #else
2252 // we could just clear the clip bit but when we go through 2253 // we could just clear the clip bit but when we go through
2253 // ANGLE a partial stencil mask will cause clears to be 2254 // ANGLE a partial stencil mask will cause clears to be
2254 // turned into draws. Our contract on GrDrawTarget says that 2255 // turned into draws. Our contract on GrDrawTarget says that
2255 // changing the clip between stencil passes may or may not 2256 // changing the clip between stencil passes may or may not
2256 // zero the client's clip bits. So we just clear the whole thing. 2257 // zero the client's clip bits. So we just clear the whole thing.
2257 static const GrGLint clipStencilMask = ~0; 2258 static const GrGLint clipStencilMask = ~0;
2258 #endif 2259 #endif
2259 GrGLint value; 2260 GrGLint value;
2260 if (insideClip) { 2261 if (insideStencilMask) {
2261 value = (1 << (stencilBitCount - 1)); 2262 value = (1 << (stencilBitCount - 1));
2262 } else { 2263 } else {
2263 value = 0; 2264 value = 0;
2264 } 2265 }
2265 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 2266 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
2266 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); 2267 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect());
2267 2268
2268 GrScissorState scissorState; 2269 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin()) ;
2269 scissorState.set(rect);
2270 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin());
2271 this->disableWindowRectangles(); 2270 this->disableWindowRectangles();
2272 2271
2273 GL_CALL(StencilMask((uint32_t) clipStencilMask)); 2272 GL_CALL(StencilMask((uint32_t) clipStencilMask));
2274 GL_CALL(ClearStencil(value)); 2273 GL_CALL(ClearStencil(value));
2275 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 2274 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
2276 fHWStencilSettings.invalidate(); 2275 fHWStencilSettings.invalidate();
2277 } 2276 }
2278 2277
2279 static bool read_pixels_pays_for_y_flip(GrRenderTarget* renderTarget, const GrGL Caps& caps, 2278 static bool read_pixels_pays_for_y_flip(GrRenderTarget* renderTarget, const GrGL Caps& caps,
2280 int width, int height, GrPixelConfig co nfig, 2279 int width, int height, GrPixelConfig co nfig,
(...skipping 2376 matching lines...) Expand 10 before | Expand all | Expand 10 after
4657 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || 4656 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
4658 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { 4657 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
4659 copyParams->fFilter = GrTextureParams::kNone_FilterMode; 4658 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
4660 copyParams->fWidth = texture->width(); 4659 copyParams->fWidth = texture->width();
4661 copyParams->fHeight = texture->height(); 4660 copyParams->fHeight = texture->height();
4662 return true; 4661 return true;
4663 } 4662 }
4664 } 4663 }
4665 return false; 4664 return false;
4666 } 4665 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698