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 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2169 r = GrColorUnpackR(color) * scaleRGB; | 2169 r = GrColorUnpackR(color) * scaleRGB; |
2170 g = GrColorUnpackG(color) * scaleRGB; | 2170 g = GrColorUnpackG(color) * scaleRGB; |
2171 b = GrColorUnpackB(color) * scaleRGB; | 2171 b = GrColorUnpackB(color) * scaleRGB; |
2172 | 2172 |
2173 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); | 2173 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); |
2174 fHWWriteToColor = kYes_TriState; | 2174 fHWWriteToColor = kYes_TriState; |
2175 GL_CALL(ClearColor(r, g, b, a)); | 2175 GL_CALL(ClearColor(r, g, b, a)); |
2176 GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT)); | 2176 GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT)); |
2177 } | 2177 } |
2178 | 2178 |
2179 void GrGLGpu::discard(GrRenderTarget* renderTarget) { | |
2180 SkASSERT(renderTarget); | |
2181 if (!this->caps()->discardRenderTargetSupport()) { | |
2182 return; | |
2183 } | |
2184 | |
2185 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget); | |
2186 if (renderTarget->getUniqueID() != fHWBoundRenderTargetUniqueID) { | |
2187 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | |
2188 fStats.incRenderTargetBinds(); | |
2189 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); | |
2190 } | |
2191 switch (this->glCaps().invalidateFBType()) { | |
2192 case GrGLCaps::kNone_InvalidateFBType: | |
2193 SkFAIL("Should never get here."); | |
2194 break; | |
2195 case GrGLCaps::kInvalidate_InvalidateFBType: | |
2196 if (0 == glRT->renderFBOID()) { | |
2197 // When rendering to the default framebuffer the legal values f
or attachments | |
2198 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari
ous FBO attachment | |
2199 // types. | |
2200 static const GrGLenum attachments[] = { GR_GL_COLOR }; | |
2201 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(
attachments), | |
2202 attachments)); | |
2203 } else { | |
2204 static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0
}; | |
2205 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(
attachments), | |
2206 attachments)); | |
2207 } | |
2208 break; | |
2209 case GrGLCaps::kDiscard_InvalidateFBType: { | |
2210 if (0 == glRT->renderFBOID()) { | |
2211 // When rendering to the default framebuffer the legal values f
or attachments | |
2212 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari
ous FBO attachment | |
2213 // types. See glDiscardFramebuffer() spec. | |
2214 static const GrGLenum attachments[] = { GR_GL_COLOR }; | |
2215 GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(att
achments), | |
2216 attachments)); | |
2217 } else { | |
2218 static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0
}; | |
2219 GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(att
achments), | |
2220 attachments)); | |
2221 } | |
2222 break; | |
2223 } | |
2224 } | |
2225 renderTarget->flagAsResolved(); | |
2226 } | |
2227 | |
2228 void GrGLGpu::clearStencil(GrRenderTarget* target) { | 2179 void GrGLGpu::clearStencil(GrRenderTarget* target) { |
2229 if (nullptr == target) { | 2180 if (nullptr == target) { |
2230 return; | 2181 return; |
2231 } | 2182 } |
2232 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); | 2183 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); |
2233 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); | 2184 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); |
2234 | 2185 |
2235 this->disableScissor(); | 2186 this->disableScissor(); |
2236 | 2187 |
2237 GL_CALL(StencilMask(0xffffffff)); | 2188 GL_CALL(StencilMask(0xffffffff)); |
(...skipping 2413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4651 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4602 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
4652 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4603 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
4653 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4604 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
4654 copyParams->fWidth = texture->width(); | 4605 copyParams->fWidth = texture->width(); |
4655 copyParams->fHeight = texture->height(); | 4606 copyParams->fHeight = texture->height(); |
4656 return true; | 4607 return true; |
4657 } | 4608 } |
4658 } | 4609 } |
4659 return false; | 4610 return false; |
4660 } | 4611 } |
OLD | NEW |