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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 fCopyProgram.fArrayBuffer = 0; | 263 fCopyProgram.fArrayBuffer = 0; |
264 fCopyProgram.fProgram = 0; | 264 fCopyProgram.fProgram = 0; |
265 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { | 265 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { |
266 this->glPathRendering()->abandonGpuResources(); | 266 this->glPathRendering()->abandonGpuResources(); |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 /////////////////////////////////////////////////////////////////////////////// | 270 /////////////////////////////////////////////////////////////////////////////// |
271 GrPixelConfig GrGLGpu::preferredReadPixelsConfig(GrPixelConfig readConfig, | 271 GrPixelConfig GrGLGpu::preferredReadPixelsConfig(GrPixelConfig readConfig, |
272 GrPixelConfig surfaceConfig) co
nst { | 272 GrPixelConfig surfaceConfig) co
nst { |
273 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig
) { | 273 if (kMesa_GrGLDriver == this->glContext().driver() && |
274 return kBGRA_8888_GrPixelConfig; | 274 GrBytesPerPixel(readConfig) == 4 && GrPixelConfigSwapRAndB(readConfig) =
= surfaceConfig) { |
275 } else if (kMesa_GrGLDriver == this->glContext().driver() && | 275 // Mesa 3D takes a slow path on when reading back BGRA from an RGBA surf
ace and vice-versa. |
276 GrBytesPerPixel(readConfig) == 4 && | 276 // Perhaps this should be guarded by some compile-time or runtime check. |
277 GrPixelConfigSwapRAndB(readConfig) == surfaceConfig) { | |
278 // Mesa 3D takes a slow path on when reading back BGRA from an RGBA sur
face and vice-versa. | |
279 // Perhaps this should be guarded by some compiletime or runtime check. | |
280 return surfaceConfig; | 277 return surfaceConfig; |
281 } else if (readConfig == kBGRA_8888_GrPixelConfig | 278 } else if (readConfig == kBGRA_8888_GrPixelConfig && |
282 && !this->glCaps().readPixelsSupported( | 279 !this->glCaps().readPixelsSupported(this->glInterface(), GR_GL_BG
RA, |
283 this->glInterface(), | 280 GR_GL_UNSIGNED_BYTE, surfaceC
onfig)) { |
284 GR_GL_BGRA, | |
285 GR_GL_UNSIGNED_BYTE, | |
286 surfaceConfig | |
287 )) { | |
288 return kRGBA_8888_GrPixelConfig; | 281 return kRGBA_8888_GrPixelConfig; |
289 } else { | 282 } else { |
290 return readConfig; | 283 return readConfig; |
291 } | 284 } |
292 } | 285 } |
293 | 286 |
294 GrPixelConfig GrGLGpu::preferredWritePixelsConfig(GrPixelConfig writeConfig, | 287 GrPixelConfig GrGLGpu::preferredWritePixelsConfig(GrPixelConfig writeConfig, |
295 GrPixelConfig surfaceConfig) c
onst { | 288 GrPixelConfig surfaceConfig) c
onst { |
296 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == writeConfi
g) { | 289 return writeConfig; |
297 return kBGRA_8888_GrPixelConfig; | |
298 } else { | |
299 return writeConfig; | |
300 } | |
301 } | 290 } |
302 | 291 |
303 bool GrGLGpu::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcC
onfig) const { | 292 bool GrGLGpu::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcC
onfig) const { |
304 if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture
->config()) { | 293 if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture
->config()) { |
305 return false; | 294 return false; |
306 } | 295 } |
307 if (srcConfig != texture->config() && kGLES_GrGLStandard == this->glStandard
()) { | 296 if (srcConfig != texture->config() && kGLES_GrGLStandard == this->glStandard
()) { |
308 // In general ES2 requires the internal format of the texture and the fo
rmat of the src | 297 // In general ES2 requires the internal format of the texture and the fo
rmat of the src |
309 // pixels to match. However, It may or may not be possible to upload BGR
A data to a RGBA | 298 // pixels to match. However, It may or may not be possible to upload BGR
A data to a RGBA |
310 // texture. It depends upon which extension added BGRA. The Apple extens
ion allows it | 299 // texture. It depends upon which extension added BGRA. The Apple extens
ion allows it |
(...skipping 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3106 this->setVertexArrayID(gpu, 0); | 3095 this->setVertexArrayID(gpu, 0); |
3107 } | 3096 } |
3108 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3097 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3109 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3098 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3110 fDefaultVertexArrayAttribState.resize(attrCount); | 3099 fDefaultVertexArrayAttribState.resize(attrCount); |
3111 } | 3100 } |
3112 attribState = &fDefaultVertexArrayAttribState; | 3101 attribState = &fDefaultVertexArrayAttribState; |
3113 } | 3102 } |
3114 return attribState; | 3103 return attribState; |
3115 } | 3104 } |
OLD | NEW |