| 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 | 8 |
| 9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
| 10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
| (...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2372 SkFAIL("Unknown draw face."); | 2372 SkFAIL("Unknown draw face."); |
| 2373 } | 2373 } |
| 2374 fHWDrawFace = face; | 2374 fHWDrawFace = face; |
| 2375 } | 2375 } |
| 2376 } | 2376 } |
| 2377 | 2377 |
| 2378 bool GrGLGpu::configToGLFormats(GrPixelConfig config, | 2378 bool GrGLGpu::configToGLFormats(GrPixelConfig config, |
| 2379 bool getSizedInternalFormat, | 2379 bool getSizedInternalFormat, |
| 2380 GrGLenum* internalFormat, | 2380 GrGLenum* internalFormat, |
| 2381 GrGLenum* externalFormat, | 2381 GrGLenum* externalFormat, |
| 2382 GrGLenum* externalType) { | 2382 GrGLenum* externalType) const { |
| 2383 GrGLenum dontCare; | 2383 GrGLenum dontCare; |
| 2384 if (NULL == internalFormat) { | 2384 if (NULL == internalFormat) { |
| 2385 internalFormat = &dontCare; | 2385 internalFormat = &dontCare; |
| 2386 } | 2386 } |
| 2387 if (NULL == externalFormat) { | 2387 if (NULL == externalFormat) { |
| 2388 externalFormat = &dontCare; | 2388 externalFormat = &dontCare; |
| 2389 } | 2389 } |
| 2390 if (NULL == externalType) { | 2390 if (NULL == externalType) { |
| 2391 externalType = &dontCare; | 2391 externalType = &dontCare; |
| 2392 } | 2392 } |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3060 void GrGLGpu::didRemoveGpuTraceMarker() { | 3060 void GrGLGpu::didRemoveGpuTraceMarker() { |
| 3061 if (this->caps()->gpuTracingSupport()) { | 3061 if (this->caps()->gpuTracingSupport()) { |
| 3062 #if GR_FORCE_GPU_TRACE_DEBUGGING | 3062 #if GR_FORCE_GPU_TRACE_DEBUGGING |
| 3063 SkDebugf("Pop trace marker.\n"); | 3063 SkDebugf("Pop trace marker.\n"); |
| 3064 #else | 3064 #else |
| 3065 GL_CALL(PopGroupMarker()); | 3065 GL_CALL(PopGroupMarker()); |
| 3066 #endif | 3066 #endif |
| 3067 } | 3067 } |
| 3068 } | 3068 } |
| 3069 | 3069 |
| 3070 GrBackendObject GrGLGpu::createBackendTexture(void* pixels, int w, int h, |
| 3071 GrPixelConfig config) const { |
| 3072 GrGLuint texID; |
| 3073 GL_CALL(GenTextures(1, &texID)); |
| 3074 GL_CALL(ActiveTexture(GR_GL_TEXTURE0)); |
| 3075 GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, 1)); |
| 3076 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texID)); |
| 3077 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_MAG_FILTER, GR_GL_NEAR
EST)); |
| 3078 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_MIN_FILTER, GR_GL_NEAR
EST)); |
| 3079 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO
_EDGE)); |
| 3080 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO
_EDGE)); |
| 3081 |
| 3082 GrGLenum internalFormat = 0x0; // suppress warning |
| 3083 GrGLenum externalFormat = 0x0; // suppress warning |
| 3084 GrGLenum externalType = 0x0; // suppress warning |
| 3085 |
| 3086 this->configToGLFormats(config, false, &internalFormat, &externalFormat, &ex
ternalType); |
| 3087 |
| 3088 GL_CALL(TexImage2D(GR_GL_TEXTURE_2D, 0, internalFormat, w, h, 0, externalFor
mat, |
| 3089 externalType, pixels)); |
| 3090 |
| 3091 return texID; |
| 3092 } |
| 3093 |
| 3094 bool GrGLGpu::isBackendTexture(GrBackendObject id) const { |
| 3095 GrGLuint texID = (GrGLuint)id; |
| 3096 |
| 3097 GrGLboolean result; |
| 3098 GL_CALL_RET(result, IsTexture(texID)); |
| 3099 |
| 3100 return (GR_GL_TRUE == result); |
| 3101 } |
| 3102 |
| 3103 void GrGLGpu::deleteBackendTexture(GrBackendObject id) const { |
| 3104 GrGLuint texID = (GrGLuint)id; |
| 3105 GL_CALL(DeleteTextures(1, &texID)); |
| 3106 } |
| 3107 |
| 3070 /////////////////////////////////////////////////////////////////////////////// | 3108 /////////////////////////////////////////////////////////////////////////////// |
| 3071 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBuffersToDraw( | 3109 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBuffersToDraw( |
| 3072 GrGLGpu* gpu, | 3110 GrGLGpu* gpu, |
| 3073 const GrGLVertexBuffer* vbuffer, | 3111 const GrGLVertexBuffer* vbuffer, |
| 3074 const GrGLIndexBuffer* ibuffer)
{ | 3112 const GrGLIndexBuffer* ibuffer)
{ |
| 3075 SkASSERT(vbuffer); | 3113 SkASSERT(vbuffer); |
| 3076 GrGLuint vbufferID = vbuffer->bufferID(); | 3114 GrGLuint vbufferID = vbuffer->bufferID(); |
| 3077 GrGLuint* ibufferIDPtr = NULL; | 3115 GrGLuint* ibufferIDPtr = NULL; |
| 3078 GrGLuint ibufferID; | 3116 GrGLuint ibufferID; |
| 3079 if (ibuffer) { | 3117 if (ibuffer) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3118 this->setVertexArrayID(gpu, 0); | 3156 this->setVertexArrayID(gpu, 0); |
| 3119 } | 3157 } |
| 3120 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3158 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3121 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3159 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3122 fDefaultVertexArrayAttribState.resize(attrCount); | 3160 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3123 } | 3161 } |
| 3124 attribState = &fDefaultVertexArrayAttribState; | 3162 attribState = &fDefaultVertexArrayAttribState; |
| 3125 } | 3163 } |
| 3126 return attribState; | 3164 return attribState; |
| 3127 } | 3165 } |
| OLD | NEW |