OLD | NEW |
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 Loading... |
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 fHWWindowRects.invalidate(); | 567 fHWWindowRectsState.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 Loading... |
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 GrWindowRectangles& windows, const GrG
LRenderTarget* rt) { | 2000 void GrGLGpu::flushWindowRectangles(const GrWindowRectsState& windowState, |
2001 typedef GrWindowRectangles::Mode Mode; | 2001 const GrGLRenderTarget* rt) { |
2002 SkASSERT(windows.count() <= this->caps()->maxWindowRectangles()); | 2002 typedef GrWindowRectsState::Mode Mode; |
2003 SkASSERT(windows.disabled() || rt->renderFBOID()); // Window rectangles can'
t be used on-screen. | 2003 SkASSERT(windowState.disabled() || rt->renderFBOID()); // Window rects can't
be used on-screen. |
| 2004 SkASSERT(windowState.numWindows() <= this->caps()->maxWindowRectangles()); |
2004 | 2005 |
2005 if (!this->caps()->maxWindowRectangles() || | 2006 if (!this->caps()->maxWindowRectangles() || |
2006 fHWWindowRects.equal(rt->origin(), rt->getViewport(), windows)) { | 2007 fHWWindowRectsState.cheapEqualTo(rt->origin(), rt->getViewport(), window
State)) { |
2007 return; | 2008 return; |
2008 } | 2009 } |
2009 | 2010 |
2010 // This is purely a workaround for a spurious warning generated by gcc. Othe
rwise the above | 2011 // This is purely a workaround for a spurious warning generated by gcc. Othe
rwise the above |
2011 // assert would be sufficient. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=
5912 | 2012 // assert would be sufficient. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=
5912 |
2012 int numWindows = SkTMin(windows.count(), int(GrWindowRectangles::kMaxWindows
)); | 2013 int numWindows = SkTMin(windowState.numWindows(), int(GrWindowRectangles::kM
axWindows)); |
2013 SkASSERT(windows.count() == numWindows); | 2014 SkASSERT(windowState.numWindows() == numWindows); |
2014 | 2015 |
2015 GrGLIRect glwindows[GrWindowRectangles::kMaxWindows]; | 2016 GrGLIRect glwindows[GrWindowRectangles::kMaxWindows]; |
2016 const SkIRect* skwindows = windows.data(); | 2017 const SkIRect* skwindows = windowState.windows().data(); |
| 2018 int dx = -windowState.origin().x(), dy = -windowState.origin().y(); |
2017 for (int i = 0; i < numWindows; ++i) { | 2019 for (int i = 0; i < numWindows; ++i) { |
2018 glwindows[i].setRelativeTo(rt->getViewport(), skwindows[i], rt->origin()
); | 2020 const SkIRect& skwindow = skwindows[i].makeOffset(dx, dy); |
| 2021 glwindows[i].setRelativeTo(rt->getViewport(), skwindow, rt->origin()); |
2019 } | 2022 } |
2020 | 2023 |
2021 GrGLenum glmode = (Mode::kExclusive == windows.mode()) ? GR_GL_EXCLUSIVE : G
R_GL_INCLUSIVE; | 2024 GrGLenum glmode = (Mode::kExclusive == windowState.mode()) ? GR_GL_EXCLUSIVE
: GR_GL_INCLUSIVE; |
2022 GL_CALL(WindowRectangles(glmode, numWindows, glwindows->asInts())); | 2025 GL_CALL(WindowRectangles(glmode, numWindows, glwindows->asInts())); |
2023 | 2026 |
2024 fHWWindowRects.set(rt->origin(), rt->getViewport(), windows); | 2027 fHWWindowRectsState.set(rt->origin(), rt->getViewport(), windowState); |
2025 } | 2028 } |
2026 | 2029 |
2027 void GrGLGpu::disableWindowRectangles() { | 2030 void GrGLGpu::disableWindowRectangles() { |
2028 if (!this->caps()->maxWindowRectangles() || fHWWindowRects.disabled()) { | 2031 if (!this->caps()->maxWindowRectangles() || fHWWindowRectsState.disabled())
{ |
2029 return; | 2032 return; |
2030 } | 2033 } |
2031 GL_CALL(WindowRectangles(GR_GL_EXCLUSIVE, 0, nullptr)); | 2034 GL_CALL(WindowRectangles(GR_GL_EXCLUSIVE, 0, nullptr)); |
2032 fHWWindowRects.setDisabled(); | 2035 fHWWindowRectsState.setDisabled(); |
2033 } | 2036 } |
2034 | 2037 |
2035 void GrGLGpu::flushMinSampleShading(float minSampleShading) { | 2038 void GrGLGpu::flushMinSampleShading(float minSampleShading) { |
2036 if (fHWMinSampleShading != minSampleShading) { | 2039 if (fHWMinSampleShading != minSampleShading) { |
2037 if (minSampleShading > 0.0) { | 2040 if (minSampleShading > 0.0) { |
2038 GL_CALL(Enable(GR_GL_SAMPLE_SHADING)); | 2041 GL_CALL(Enable(GR_GL_SAMPLE_SHADING)); |
2039 GL_CALL(MinSampleShading(minSampleShading)); | 2042 GL_CALL(MinSampleShading(minSampleShading)); |
2040 } | 2043 } |
2041 else { | 2044 else { |
2042 GL_CALL(Disable(GR_GL_SAMPLE_SHADING)); | 2045 GL_CALL(Disable(GR_GL_SAMPLE_SHADING)); |
(...skipping 29 matching lines...) Expand all Loading... |
2072 const GrSwizzle& swizzle = this->glCaps().glslCaps()->configOutputSwizzl
e( | 2075 const GrSwizzle& swizzle = this->glCaps().glslCaps()->configOutputSwizzl
e( |
2073 pipeline.getRenderTarget()->config()); | 2076 pipeline.getRenderTarget()->config()); |
2074 this->flushBlend(blendInfo, swizzle); | 2077 this->flushBlend(blendInfo, swizzle); |
2075 } | 2078 } |
2076 | 2079 |
2077 program->setData(primProc, pipeline); | 2080 program->setData(primProc, pipeline); |
2078 | 2081 |
2079 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa
rget()); | 2082 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa
rget()); |
2080 this->flushStencil(pipeline.getStencil()); | 2083 this->flushStencil(pipeline.getStencil()); |
2081 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or
igin()); | 2084 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or
igin()); |
2082 this->flushWindowRectangles(pipeline.getWindowRectangles(), glRT); | 2085 this->flushWindowRectangles(pipeline.getWindowRectsState(), glRT); |
2083 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStenc
il().isDisabled()); | 2086 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStenc
il().isDisabled()); |
2084 | 2087 |
2085 // This must come after textures are flushed because a texture may need | 2088 // This must come after textures are flushed because a texture may need |
2086 // to be msaa-resolved (which will modify bound FBO state). | 2089 // to be msaa-resolved (which will modify bound FBO state). |
2087 this->flushRenderTarget(glRT, nullptr, pipeline.getDisableOutputConversionTo
SRGB()); | 2090 this->flushRenderTarget(glRT, nullptr, pipeline.getDisableOutputConversionTo
SRGB()); |
2088 | 2091 |
2089 return true; | 2092 return true; |
2090 } | 2093 } |
2091 | 2094 |
2092 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, | 2095 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2200 | 2203 |
2201 void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrRenderTarget* targ
et) { | 2204 void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrRenderTarget* targ
et) { |
2202 this->handleDirtyContext(); | 2205 this->handleDirtyContext(); |
2203 | 2206 |
2204 // parent class should never let us get here with no RT | 2207 // parent class should never let us get here with no RT |
2205 SkASSERT(target); | 2208 SkASSERT(target); |
2206 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); | 2209 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); |
2207 | 2210 |
2208 this->flushRenderTarget(glRT, clip.scissorEnabled() ? &clip.scissorRect() :
nullptr); | 2211 this->flushRenderTarget(glRT, clip.scissorEnabled() ? &clip.scissorRect() :
nullptr); |
2209 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin())
; | 2212 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin())
; |
2210 this->disableWindowRectangles(); | 2213 this->flushWindowRectangles(clip.windowRectsState(), glRT); |
2211 | 2214 |
2212 GrGLfloat r, g, b, a; | 2215 GrGLfloat r, g, b, a; |
2213 static const GrGLfloat scale255 = 1.f / 255.f; | 2216 static const GrGLfloat scale255 = 1.f / 255.f; |
2214 a = GrColorUnpackA(color) * scale255; | 2217 a = GrColorUnpackA(color) * scale255; |
2215 GrGLfloat scaleRGB = scale255; | 2218 GrGLfloat scaleRGB = scale255; |
2216 r = GrColorUnpackR(color) * scaleRGB; | 2219 r = GrColorUnpackR(color) * scaleRGB; |
2217 g = GrColorUnpackG(color) * scaleRGB; | 2220 g = GrColorUnpackG(color) * scaleRGB; |
2218 b = GrColorUnpackB(color) * scaleRGB; | 2221 b = GrColorUnpackB(color) * scaleRGB; |
2219 | 2222 |
2220 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); | 2223 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 Loading... |
2264 GrGLint value; | 2267 GrGLint value; |
2265 if (insideStencilMask) { | 2268 if (insideStencilMask) { |
2266 value = (1 << (stencilBitCount - 1)); | 2269 value = (1 << (stencilBitCount - 1)); |
2267 } else { | 2270 } else { |
2268 value = 0; | 2271 value = 0; |
2269 } | 2272 } |
2270 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); | 2273 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); |
2271 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); | 2274 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); |
2272 | 2275 |
2273 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin())
; | 2276 this->flushScissor(clip.scissorState(), glRT->getViewport(), glRT->origin())
; |
2274 this->disableWindowRectangles(); | 2277 this->flushWindowRectangles(clip.windowRectsState(), glRT); |
2275 | 2278 |
2276 GL_CALL(StencilMask((uint32_t) clipStencilMask)); | 2279 GL_CALL(StencilMask((uint32_t) clipStencilMask)); |
2277 GL_CALL(ClearStencil(value)); | 2280 GL_CALL(ClearStencil(value)); |
2278 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); | 2281 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); |
2279 fHWStencilSettings.invalidate(); | 2282 fHWStencilSettings.invalidate(); |
2280 } | 2283 } |
2281 | 2284 |
2282 static bool read_pixels_pays_for_y_flip(GrRenderTarget* renderTarget, const GrGL
Caps& caps, | 2285 static bool read_pixels_pays_for_y_flip(GrRenderTarget* renderTarget, const GrGL
Caps& caps, |
2283 int width, int height, GrPixelConfig co
nfig, | 2286 int width, int height, GrPixelConfig co
nfig, |
2284 size_t rowBytes) { | 2287 size_t rowBytes) { |
(...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4672 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4675 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
4673 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4676 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
4674 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4677 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
4675 copyParams->fWidth = texture->width(); | 4678 copyParams->fWidth = texture->width(); |
4676 copyParams->fHeight = texture->height(); | 4679 copyParams->fHeight = texture->height(); |
4677 return true; | 4680 return true; |
4678 } | 4681 } |
4679 } | 4682 } |
4680 return false; | 4683 return false; |
4681 } | 4684 } |
OLD | NEW |