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

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

Issue 2312173002: Revert of Improve usage of window rectangles (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_drawsinreducedclip
Patch Set: 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/vk/GrVkGpuCommandBuffer.cpp » ('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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 fHWBufferTextures[b].fKnownBound = false; 557 fHWBufferTextures[b].fKnownBound = false;
558 } 558 }
559 } 559 }
560 560
561 if (resetBits & kBlend_GrGLBackendState) { 561 if (resetBits & kBlend_GrGLBackendState) {
562 fHWBlendState.invalidate(); 562 fHWBlendState.invalidate();
563 } 563 }
564 564
565 if (resetBits & kView_GrGLBackendState) { 565 if (resetBits & kView_GrGLBackendState) {
566 fHWScissorSettings.invalidate(); 566 fHWScissorSettings.invalidate();
567 fHWWindowRectsState.invalidate(); 567 fHWWindowRects.invalidate();
568 fHWViewport.invalidate(); 568 fHWViewport.invalidate();
569 } 569 }
570 570
571 if (resetBits & kStencil_GrGLBackendState) { 571 if (resetBits & kStencil_GrGLBackendState) {
572 fHWStencilSettings.invalidate(); 572 fHWStencilSettings.invalidate();
573 fHWStencilTestEnabled = kUnknown_TriState; 573 fHWStencilTestEnabled = kUnknown_TriState;
574 } 574 }
575 575
576 // Vertex 576 // Vertex
577 if (resetBits & kVertex_GrGLBackendState) { 577 if (resetBits & kVertex_GrGLBackendState) {
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 fHWScissorSettings.fEnabled = kYes_TriState; 1990 fHWScissorSettings.fEnabled = kYes_TriState;
1991 } 1991 }
1992 return; 1992 return;
1993 } 1993 }
1994 } 1994 }
1995 1995
1996 // See fall through note above 1996 // See fall through note above
1997 this->disableScissor(); 1997 this->disableScissor();
1998 } 1998 }
1999 1999
2000 void GrGLGpu::flushWindowRectangles(const GrWindowRectsState& windowState, 2000 void GrGLGpu::flushWindowRectangles(const GrWindowRectangles& windows, const GrG LRenderTarget* rt) {
2001 const GrGLRenderTarget* rt) { 2001 typedef GrWindowRectangles::Mode Mode;
2002 typedef GrWindowRectsState::Mode Mode; 2002 SkASSERT(windows.count() <= this->caps()->maxWindowRectangles());
2003 SkASSERT(!windowState.enabled() || rt->renderFBOID()); // Window rects can't be used on-screen. 2003 SkASSERT(windows.disabled() || rt->renderFBOID()); // Window rectangles can' t be used on-screen.
2004 SkASSERT(windowState.numWindows() <= this->caps()->maxWindowRectangles());
2005 2004
2006 if (!this->caps()->maxWindowRectangles() || 2005 if (!this->caps()->maxWindowRectangles() ||
2007 fHWWindowRectsState.knownEqualTo(rt->origin(), rt->getViewport(), window State)) { 2006 fHWWindowRects.equal(rt->origin(), rt->getViewport(), windows)) {
2008 return; 2007 return;
2009 } 2008 }
2010 2009
2011 // This is purely a workaround for a spurious warning generated by gcc. Othe rwise the above 2010 // This is purely a workaround for a spurious warning generated by gcc. Othe rwise the above
2012 // assert would be sufficient. https://gcc.gnu.org/bugzilla/show_bug.cgi?id= 5912 2011 // assert would be sufficient. https://gcc.gnu.org/bugzilla/show_bug.cgi?id= 5912
2013 int numWindows = SkTMin(windowState.numWindows(), int(GrWindowRectangles::kM axWindows)); 2012 int numWindows = SkTMin(windows.count(), int(GrWindowRectangles::kMaxWindows ));
2014 SkASSERT(windowState.numWindows() == numWindows); 2013 SkASSERT(windows.count() == numWindows);
2015 2014
2016 GrGLIRect glwindows[GrWindowRectangles::kMaxWindows]; 2015 GrGLIRect glwindows[GrWindowRectangles::kMaxWindows];
2017 const SkIRect* skwindows = windowState.windows().data(); 2016 const SkIRect* skwindows = windows.data();
2018 int dx = -windowState.origin().x(), dy = -windowState.origin().y();
2019 for (int i = 0; i < numWindows; ++i) { 2017 for (int i = 0; i < numWindows; ++i) {
2020 const SkIRect& skwindow = skwindows[i].makeOffset(dx, dy); 2018 glwindows[i].setRelativeTo(rt->getViewport(), skwindows[i], rt->origin() );
2021 glwindows[i].setRelativeTo(rt->getViewport(), skwindow, rt->origin());
2022 } 2019 }
2023 2020
2024 GrGLenum glmode = (Mode::kExclusive == windowState.mode()) ? GR_GL_EXCLUSIVE : GR_GL_INCLUSIVE; 2021 GrGLenum glmode = (Mode::kExclusive == windows.mode()) ? GR_GL_EXCLUSIVE : G R_GL_INCLUSIVE;
2025 GL_CALL(WindowRectangles(glmode, numWindows, glwindows->asInts())); 2022 GL_CALL(WindowRectangles(glmode, numWindows, glwindows->asInts()));
2026 2023
2027 fHWWindowRectsState.set(rt->origin(), rt->getViewport(), windowState); 2024 fHWWindowRects.set(rt->origin(), rt->getViewport(), windows);
2028 } 2025 }
2029 2026
2030 void GrGLGpu::disableWindowRectangles() { 2027 void GrGLGpu::disableWindowRectangles() {
2031 if (!this->caps()->maxWindowRectangles() || fHWWindowRectsState.knownDisable d()) { 2028 if (!this->caps()->maxWindowRectangles() || fHWWindowRects.disabled()) {
2032 return; 2029 return;
2033 } 2030 }
2034 GL_CALL(WindowRectangles(GR_GL_EXCLUSIVE, 0, nullptr)); 2031 GL_CALL(WindowRectangles(GR_GL_EXCLUSIVE, 0, nullptr));
2035 fHWWindowRectsState.setDisabled(); 2032 fHWWindowRects.setDisabled();
2036 } 2033 }
2037 2034
2038 void GrGLGpu::flushMinSampleShading(float minSampleShading) { 2035 void GrGLGpu::flushMinSampleShading(float minSampleShading) {
2039 if (fHWMinSampleShading != minSampleShading) { 2036 if (fHWMinSampleShading != minSampleShading) {
2040 if (minSampleShading > 0.0) { 2037 if (minSampleShading > 0.0) {
2041 GL_CALL(Enable(GR_GL_SAMPLE_SHADING)); 2038 GL_CALL(Enable(GR_GL_SAMPLE_SHADING));
2042 GL_CALL(MinSampleShading(minSampleShading)); 2039 GL_CALL(MinSampleShading(minSampleShading));
2043 } 2040 }
2044 else { 2041 else {
2045 GL_CALL(Disable(GR_GL_SAMPLE_SHADING)); 2042 GL_CALL(Disable(GR_GL_SAMPLE_SHADING));
(...skipping 29 matching lines...) Expand all
2075 const GrSwizzle& swizzle = this->glCaps().glslCaps()->configOutputSwizzl e( 2072 const GrSwizzle& swizzle = this->glCaps().glslCaps()->configOutputSwizzl e(
2076 pipeline.getRenderTarget()->config()); 2073 pipeline.getRenderTarget()->config());
2077 this->flushBlend(blendInfo, swizzle); 2074 this->flushBlend(blendInfo, swizzle);
2078 } 2075 }
2079 2076
2080 program->setData(primProc, pipeline); 2077 program->setData(primProc, pipeline);
2081 2078
2082 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget()); 2079 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget());
2083 this->flushStencil(pipeline.getStencil()); 2080 this->flushStencil(pipeline.getStencil());
2084 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin()); 2081 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin());
2085 this->flushWindowRectangles(pipeline.getWindowRectsState(), glRT); 2082 this->flushWindowRectangles(pipeline.getWindowRectangles(), glRT);
2086 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStenc il().isDisabled()); 2083 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStenc il().isDisabled());
2087 2084
2088 // This must come after textures are flushed because a texture may need 2085 // This must come after textures are flushed because a texture may need
2089 // to be msaa-resolved (which will modify bound FBO state). 2086 // to be msaa-resolved (which will modify bound FBO state).
2090 this->flushRenderTarget(glRT, nullptr, pipeline.getDisableOutputConversionTo SRGB()); 2087 this->flushRenderTarget(glRT, nullptr, pipeline.getDisableOutputConversionTo SRGB());
2091 2088
2092 return true; 2089 return true;
2093 } 2090 }
2094 2091
2095 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, 2092 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 2200
2204 void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrRenderTarget* targ et) { 2201 void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrRenderTarget* targ et) {
2205 this->handleDirtyContext(); 2202 this->handleDirtyContext();
2206 2203
2207 // parent class should never let us get here with no RT 2204 // parent class should never let us get here with no RT
2208 SkASSERT(target); 2205 SkASSERT(target);
2209 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 2206 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
2210 2207
2211 this->flushRenderTarget(glRT, clip.scissorEnabled() ? &clip.scissorRect() : nullptr); 2208 this->flushRenderTarget(glRT, clip.scissorEnabled() ? &clip.scissorRect() : nullptr);
2212 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin()) ; 2209 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin()) ;
2213 this->flushWindowRectangles(clip.windowRectsState(), glRT); 2210 this->disableWindowRectangles();
2214 2211
2215 GrGLfloat r, g, b, a; 2212 GrGLfloat r, g, b, a;
2216 static const GrGLfloat scale255 = 1.f / 255.f; 2213 static const GrGLfloat scale255 = 1.f / 255.f;
2217 a = GrColorUnpackA(color) * scale255; 2214 a = GrColorUnpackA(color) * scale255;
2218 GrGLfloat scaleRGB = scale255; 2215 GrGLfloat scaleRGB = scale255;
2219 r = GrColorUnpackR(color) * scaleRGB; 2216 r = GrColorUnpackR(color) * scaleRGB;
2220 g = GrColorUnpackG(color) * scaleRGB; 2217 g = GrColorUnpackG(color) * scaleRGB;
2221 b = GrColorUnpackB(color) * scaleRGB; 2218 b = GrColorUnpackB(color) * scaleRGB;
2222 2219
2223 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); 2220 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 GrGLint value; 2264 GrGLint value;
2268 if (insideStencilMask) { 2265 if (insideStencilMask) {
2269 value = (1 << (stencilBitCount - 1)); 2266 value = (1 << (stencilBitCount - 1));
2270 } else { 2267 } else {
2271 value = 0; 2268 value = 0;
2272 } 2269 }
2273 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 2270 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
2274 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); 2271 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect());
2275 2272
2276 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin()) ; 2273 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin()) ;
2277 this->flushWindowRectangles(clip.windowRectsState(), glRT); 2274 this->disableWindowRectangles();
2278 2275
2279 GL_CALL(StencilMask((uint32_t) clipStencilMask)); 2276 GL_CALL(StencilMask((uint32_t) clipStencilMask));
2280 GL_CALL(ClearStencil(value)); 2277 GL_CALL(ClearStencil(value));
2281 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 2278 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
2282 fHWStencilSettings.invalidate(); 2279 fHWStencilSettings.invalidate();
2283 } 2280 }
2284 2281
2285 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,
2286 int width, int height, GrPixelConfig co nfig, 2283 int width, int height, GrPixelConfig co nfig,
2287 size_t rowBytes) { 2284 size_t rowBytes) {
(...skipping 2384 matching lines...) Expand 10 before | Expand all | Expand 10 after
4672 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || 4669 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
4673 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { 4670 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
4674 copyParams->fFilter = GrTextureParams::kNone_FilterMode; 4671 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
4675 copyParams->fWidth = texture->width(); 4672 copyParams->fWidth = texture->width();
4676 copyParams->fHeight = texture->height(); 4673 copyParams->fHeight = texture->height();
4677 return true; 4674 return true;
4678 } 4675 }
4679 } 4676 }
4680 return false; 4677 return false;
4681 } 4678 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/vk/GrVkGpuCommandBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698