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 "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 if (this->glCaps().rgba8RenderbufferSupport()) { | 259 if (this->glCaps().rgba8RenderbufferSupport()) { |
260 fConfigRenderSupport[kRGBA_8888_GrPixelConfig] = true; | 260 fConfigRenderSupport[kRGBA_8888_GrPixelConfig] = true; |
261 } | 261 } |
262 | 262 |
263 if (this->glCaps().bgraFormatSupport()) { | 263 if (this->glCaps().bgraFormatSupport()) { |
264 fConfigRenderSupport[kBGRA_8888_GrPixelConfig] = true; | 264 fConfigRenderSupport[kBGRA_8888_GrPixelConfig] = true; |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 namespace { | 268 namespace { |
269 GrPixelConfig preferred_pixel_ops_config(GrPixelConfig config) { | 269 GrPixelConfig preferred_pixel_ops_config(GrPixelConfig cpuConfig, GrPixelConfig
surfaceConfig) { |
270 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == config) { | 270 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == cpuConfig)
{ |
271 return kBGRA_8888_GrPixelConfig; | 271 return kBGRA_8888_GrPixelConfig; |
| 272 } else if (GrBytesPerPixel(cpuConfig) == 4 && |
| 273 GrPixelConfigSwapRAndB(cpuConfig) == surfaceConfig) { |
| 274 // Mesa 3D takes a slow path on when reading back BGRA from an RGBA sur
face and vice-versa. |
| 275 // Perhaps this should be guarded by some compiletime or runtime check. |
| 276 return surfaceConfig; |
272 } else { | 277 } else { |
273 return config; | 278 return cpuConfig; |
274 } | 279 } |
275 } | 280 } |
276 } | 281 } |
277 | 282 |
278 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig config) const { | 283 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig, |
279 return preferred_pixel_ops_config(config); | 284 GrPixelConfig surfaceConfig) co
nst { |
| 285 return preferred_pixel_ops_config(readConfig, surfaceConfig); |
280 } | 286 } |
281 | 287 |
282 GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig config) const { | 288 GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig writeConfig, |
283 return preferred_pixel_ops_config(config); | 289 GrPixelConfig surfaceConfig) c
onst { |
| 290 return preferred_pixel_ops_config(writeConfig, surfaceConfig); |
284 } | 291 } |
285 | 292 |
286 bool GrGpuGL::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcC
onfig) const { | 293 bool GrGpuGL::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcC
onfig) const { |
287 if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture
->config()) { | 294 if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture
->config()) { |
288 return false; | 295 return false; |
289 } | 296 } |
290 if (srcConfig != texture->config() && kES2_GrGLBinding == this->glBinding())
{ | 297 if (srcConfig != texture->config() && kES2_GrGLBinding == this->glBinding())
{ |
291 // In general ES2 requires the internal format of the texture and the fo
rmat of the src | 298 // In general ES2 requires the internal format of the texture and the fo
rmat of the src |
292 // pixels to match. However, It may or may not be possible to upload BGR
A data to a RGBA | 299 // pixels to match. However, It may or may not be possible to upload BGR
A data to a RGBA |
293 // texture. It depends upon which extension added BGRA. The Apple extens
ion allows it | 300 // texture. It depends upon which extension added BGRA. The Apple extens
ion allows it |
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2503 this->setVertexArrayID(gpu, 0); | 2510 this->setVertexArrayID(gpu, 0); |
2504 } | 2511 } |
2505 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2512 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2506 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2513 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2507 fDefaultVertexArrayAttribState.resize(attrCount); | 2514 fDefaultVertexArrayAttribState.resize(attrCount); |
2508 } | 2515 } |
2509 attribState = &fDefaultVertexArrayAttribState; | 2516 attribState = &fDefaultVertexArrayAttribState; |
2510 } | 2517 } |
2511 return attribState; | 2518 return attribState; |
2512 } | 2519 } |
OLD | NEW |