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 "GrGLGLSL.h" | 9 #include "GrGLGLSL.h" |
10 #include "GrGLStencilAttachment.h" | 10 #include "GrGLStencilAttachment.h" |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 } | 405 } |
406 | 406 |
407 /////////////////////////////////////////////////////////////////////////////// | 407 /////////////////////////////////////////////////////////////////////////////// |
408 | 408 |
409 void GrGLGpu::onResetContext(uint32_t resetBits) { | 409 void GrGLGpu::onResetContext(uint32_t resetBits) { |
410 // we don't use the zb at all | 410 // we don't use the zb at all |
411 if (resetBits & kMisc_GrGLBackendState) { | 411 if (resetBits & kMisc_GrGLBackendState) { |
412 GL_CALL(Disable(GR_GL_DEPTH_TEST)); | 412 GL_CALL(Disable(GR_GL_DEPTH_TEST)); |
413 GL_CALL(DepthMask(GR_GL_FALSE)); | 413 GL_CALL(DepthMask(GR_GL_FALSE)); |
414 | 414 |
415 fHWBoundTextureBufferIDIsValid = false; | |
416 fHWBoundDrawIndirectBufferIDIsValid = false; | |
417 | |
415 fHWDrawFace = GrPipelineBuilder::kInvalid_DrawFace; | 418 fHWDrawFace = GrPipelineBuilder::kInvalid_DrawFace; |
416 | 419 |
417 if (kGL_GrGLStandard == this->glStandard()) { | 420 if (kGL_GrGLStandard == this->glStandard()) { |
418 // Desktop-only state that we never change | 421 // Desktop-only state that we never change |
419 if (!this->glCaps().isCoreProfile()) { | 422 if (!this->glCaps().isCoreProfile()) { |
420 GL_CALL(Disable(GR_GL_POINT_SMOOTH)); | 423 GL_CALL(Disable(GR_GL_POINT_SMOOTH)); |
421 GL_CALL(Disable(GR_GL_LINE_SMOOTH)); | 424 GL_CALL(Disable(GR_GL_LINE_SMOOTH)); |
422 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH)); | 425 GL_CALL(Disable(GR_GL_POLYGON_SMOOTH)); |
423 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE)); | 426 GL_CALL(Disable(GR_GL_POLYGON_STIPPLE)); |
424 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP)); | 427 GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP)); |
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2170 void GrGLGpu::buildProgramDesc(GrProgramDesc* desc, | 2173 void GrGLGpu::buildProgramDesc(GrProgramDesc* desc, |
2171 const GrPrimitiveProcessor& primProc, | 2174 const GrPrimitiveProcessor& primProc, |
2172 const GrPipeline& pipeline) const { | 2175 const GrPipeline& pipeline) const { |
2173 if (!GrGLProgramDescBuilder::Build(desc, primProc, pipeline, *this->glCaps() .glslCaps())) { | 2176 if (!GrGLProgramDescBuilder::Build(desc, primProc, pipeline, *this->glCaps() .glslCaps())) { |
2174 SkDEBUGFAIL("Failed to generate GL program descriptor"); | 2177 SkDEBUGFAIL("Failed to generate GL program descriptor"); |
2175 } | 2178 } |
2176 } | 2179 } |
2177 | 2180 |
2178 void GrGLGpu::bindBuffer(GrGLuint id, GrGLenum type) { | 2181 void GrGLGpu::bindBuffer(GrGLuint id, GrGLenum type) { |
2179 this->handleDirtyContext(); | 2182 this->handleDirtyContext(); |
2180 if (GR_GL_ARRAY_BUFFER == type) { | 2183 switch (type) { |
2181 this->bindVertexBuffer(id); | 2184 case GR_GL_ARRAY_BUFFER: |
2182 } else if (GR_GL_ELEMENT_ARRAY_BUFFER == type) { | 2185 this->bindVertexBuffer(id); |
2183 this->bindIndexBufferAndDefaultVertexArray(id); | 2186 break; |
2184 } else { | 2187 case GR_GL_ELEMENT_ARRAY_BUFFER: |
2185 GR_GL_CALL(this->glInterface(), BindBuffer(type, id)); | 2188 this->bindIndexBufferAndDefaultVertexArray(id); |
2189 break; | |
2190 case GR_GL_TEXTURE_BUFFER: | |
2191 if (!fHWBoundTextureBufferIDIsValid || id != fHWBoundTextureBufferID ) { | |
2192 GR_GL_CALL(this->glInterface(), BindBuffer(type, id)); | |
2193 fHWBoundTextureBufferID = id; | |
2194 fHWBoundTextureBufferIDIsValid = true; | |
2195 } | |
2196 break; | |
2197 case GR_GL_DRAW_INDIRECT_BUFFER: | |
2198 if (!fHWBoundDrawIndirectBufferIDIsValid || id != fHWBoundDrawIndire ctBufferID) { | |
2199 GR_GL_CALL(this->glInterface(), BindBuffer(type, id)); | |
2200 fHWBoundDrawIndirectBufferID = id; | |
2201 fHWBoundDrawIndirectBufferIDIsValid = true; | |
2202 } | |
2203 break; | |
2204 default: | |
2205 SkDebugf("WARNING: buffer target 0x%x is not tracked by GrGLGpu.\n", type); | |
2206 GR_GL_CALL(this->glInterface(), BindBuffer(type, id)); | |
2207 break; | |
2186 } | 2208 } |
2187 } | 2209 } |
2188 | 2210 |
2189 void GrGLGpu::releaseBuffer(GrGLuint id, GrGLenum type) { | 2211 void GrGLGpu::releaseBuffer(GrGLuint id, GrGLenum type) { |
2190 this->handleDirtyContext(); | 2212 this->handleDirtyContext(); |
2191 GL_CALL(DeleteBuffers(1, &id)); | 2213 GL_CALL(DeleteBuffers(1, &id)); |
2192 if (GR_GL_ARRAY_BUFFER == type) { | 2214 switch (type) { |
Chris Dalton
2016/03/14 15:46:53
This has technically been a bit dangerous because
bsalomon
2016/03/16 13:42:23
Right now the buffer type is inherent to the Gr-ob
| |
2193 this->notifyVertexBufferDelete(id); | 2215 case GR_GL_ARRAY_BUFFER: |
2194 } else if (GR_GL_ELEMENT_ARRAY_BUFFER == type) { | 2216 this->notifyVertexBufferDelete(id); |
2195 this->notifyIndexBufferDelete(id); | 2217 break; |
2218 case GR_GL_ELEMENT_ARRAY_BUFFER: | |
2219 this->notifyIndexBufferDelete(id); | |
2220 break; | |
2221 case GR_GL_TEXTURE_BUFFER: | |
2222 if (fHWBoundTextureBufferIDIsValid && id == fHWBoundTextureBufferID) { | |
2223 fHWBoundTextureBufferID = 0; | |
2224 } | |
2225 break; | |
2226 case GR_GL_DRAW_INDIRECT_BUFFER: | |
2227 if (fHWBoundDrawIndirectBufferIDIsValid && id == fHWBoundDrawIndirec tBufferID) { | |
2228 fHWBoundDrawIndirectBufferID = 0; | |
2229 } | |
2230 break; | |
2196 } | 2231 } |
2197 } | 2232 } |
2198 | 2233 |
2199 static GrGLenum get_gl_usage(GrGLBufferImpl::Usage usage) { | 2234 static GrGLenum get_gl_usage(GrGLBufferImpl::Usage usage) { |
2200 static const GrGLenum grToGL[] = { | 2235 static const GrGLenum grToGL[] = { |
2201 GR_GL_STATIC_DRAW, // GrGLBufferImpl::kStaticDraw_Usage | 2236 GR_GL_STATIC_DRAW, // GrGLBufferImpl::kStaticDraw_Usage |
2202 DYNAMIC_USAGE_PARAM, // GrGLBufferImpl::kDynamicDraw_Usage | 2237 DYNAMIC_USAGE_PARAM, // GrGLBufferImpl::kDynamicDraw_Usage |
2203 GR_GL_STREAM_DRAW, // GrGLBufferImpl::kStreamDraw_Usage | 2238 GR_GL_STREAM_DRAW, // GrGLBufferImpl::kStreamDraw_Usage |
2204 GR_GL_STREAM_READ, // GrGLBufferImpl::kStreamRead_Usage | 2239 GR_GL_STREAM_READ, // GrGLBufferImpl::kStreamRead_Usage |
2205 }; | 2240 }; |
(...skipping 2146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4352 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4387 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
4353 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4388 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
4354 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4389 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
4355 copyParams->fWidth = texture->width(); | 4390 copyParams->fWidth = texture->width(); |
4356 copyParams->fHeight = texture->height(); | 4391 copyParams->fHeight = texture->height(); |
4357 return true; | 4392 return true; |
4358 } | 4393 } |
4359 } | 4394 } |
4360 return false; | 4395 return false; |
4361 } | 4396 } |
OLD | NEW |