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 config, GrPixelConfig tar
getConfig) { |
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 == config) { |
271 return kBGRA_8888_GrPixelConfig; | 271 return kBGRA_8888_GrPixelConfig; |
| 272 } else if (config == targetConfig |
| 273 || (GrBytesPerPixel(config) == 4 && GrPixelConfigSwapRAndB(config
) == targetConfig)) { |
| 274 return targetConfig; |
272 } else { | 275 } else { |
273 return config; | 276 return config; |
274 } | 277 } |
275 } | 278 } |
276 } | 279 } |
277 | 280 |
278 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig config) const { | 281 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig, GrPix
elConfig targetConfig) const { |
279 return preferred_pixel_ops_config(config); | 282 return preferred_pixel_ops_config(readConfig, targetConfig); |
280 } | 283 } |
281 | 284 |
282 GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig config) const { | 285 GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig writeConfig, GrP
ixelConfig targetConfig) const { |
283 return preferred_pixel_ops_config(config); | 286 return preferred_pixel_ops_config(writeConfig, targetConfig); |
284 } | 287 } |
285 | 288 |
286 bool GrGpuGL::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcC
onfig) const { | 289 bool GrGpuGL::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcC
onfig) const { |
287 if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture
->config()) { | 290 if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture
->config()) { |
288 return false; | 291 return false; |
289 } | 292 } |
290 if (srcConfig != texture->config() && kES2_GrGLBinding == this->glBinding())
{ | 293 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 | 294 // 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 | 295 // 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 | 296 // 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); | 2506 this->setVertexArrayID(gpu, 0); |
2504 } | 2507 } |
2505 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2508 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2506 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2509 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2507 fDefaultVertexArrayAttribState.resize(attrCount); | 2510 fDefaultVertexArrayAttribState.resize(attrCount); |
2508 } | 2511 } |
2509 attribState = &fDefaultVertexArrayAttribState; | 2512 attribState = &fDefaultVertexArrayAttribState; |
2510 } | 2513 } |
2511 return attribState; | 2514 return attribState; |
2512 } | 2515 } |
OLD | NEW |