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