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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 if (this->glCaps().rgba8RenderbufferSupport()) { | 225 if (this->glCaps().rgba8RenderbufferSupport()) { |
226 fConfigRenderSupport[kRGBA_8888_GrPixelConfig] = true; | 226 fConfigRenderSupport[kRGBA_8888_GrPixelConfig] = true; |
227 } | 227 } |
228 | 228 |
229 if (this->glCaps().bgraFormatSupport()) { | 229 if (this->glCaps().bgraFormatSupport()) { |
230 fConfigRenderSupport[kBGRA_8888_GrPixelConfig] = true; | 230 fConfigRenderSupport[kBGRA_8888_GrPixelConfig] = true; |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 namespace { | |
235 GrPixelConfig preferred_pixel_ops_config(GrPixelConfig cpuConfig, GrPixelConfig
surfaceConfig) { | |
236 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == cpuConfig)
{ | |
237 return kBGRA_8888_GrPixelConfig; | |
238 } else if (GrBytesPerPixel(cpuConfig) == 4 && | |
239 GrPixelConfigSwapRAndB(cpuConfig) == surfaceConfig) { | |
240 // Mesa 3D takes a slow path on when reading back BGRA from an RGBA sur
face and vice-versa. | |
241 // Perhaps this should be guarded by some compiletime or runtime check. | |
242 return surfaceConfig; | |
243 } else { | |
244 return cpuConfig; | |
245 } | |
246 } | |
247 } | |
248 | |
249 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig, | 234 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig, |
250 GrPixelConfig surfaceConfig) co
nst { | 235 GrPixelConfig surfaceConfig) co
nst { |
251 return preferred_pixel_ops_config(readConfig, surfaceConfig); | 236 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig
) { |
| 237 return kBGRA_8888_GrPixelConfig; |
| 238 } else if (fGLContext.info().isMesa() && |
| 239 GrBytesPerPixel(readConfig) == 4 && |
| 240 GrPixelConfigSwapRAndB(readConfig) == surfaceConfig) { |
| 241 // Mesa 3D takes a slow path on when reading back BGRA from an RGBA sur
face and vice-versa. |
| 242 // Perhaps this should be guarded by some compiletime or runtime check. |
| 243 return surfaceConfig; |
| 244 } else if (readConfig == kBGRA_8888_GrPixelConfig && |
| 245 !this->glCaps().readPixelsSupported(this->glInterface(), |
| 246 GR_GL_BGRA, GR_GL_UNSIGNED_BY
TE)) { |
| 247 return kRGBA_8888_GrPixelConfig; |
| 248 } else { |
| 249 return readConfig; |
| 250 } |
252 } | 251 } |
253 | 252 |
254 GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig writeConfig, | 253 GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig writeConfig, |
255 GrPixelConfig surfaceConfig) c
onst { | 254 GrPixelConfig surfaceConfig) c
onst { |
256 return preferred_pixel_ops_config(writeConfig, surfaceConfig); | 255 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == writeConfi
g) { |
| 256 return kBGRA_8888_GrPixelConfig; |
| 257 } else { |
| 258 return writeConfig; |
| 259 } |
257 } | 260 } |
258 | 261 |
259 bool GrGpuGL::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcC
onfig) const { | 262 bool GrGpuGL::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcC
onfig) const { |
260 if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture
->config()) { | 263 if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture
->config()) { |
261 return false; | 264 return false; |
262 } | 265 } |
263 if (srcConfig != texture->config() && kES2_GrGLBinding == this->glBinding())
{ | 266 if (srcConfig != texture->config() && kES2_GrGLBinding == this->glBinding())
{ |
264 // In general ES2 requires the internal format of the texture and the fo
rmat of the src | 267 // In general ES2 requires the internal format of the texture and the fo
rmat of the src |
265 // pixels to match. However, It may or may not be possible to upload BGR
A data to a RGBA | 268 // pixels to match. However, It may or may not be possible to upload BGR
A data to a RGBA |
266 // texture. It depends upon which extension added BGRA. The Apple extens
ion allows it | 269 // texture. It depends upon which extension added BGRA. The Apple extens
ion allows it |
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2549 this->setVertexArrayID(gpu, 0); | 2552 this->setVertexArrayID(gpu, 0); |
2550 } | 2553 } |
2551 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2554 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2552 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2555 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2553 fDefaultVertexArrayAttribState.resize(attrCount); | 2556 fDefaultVertexArrayAttribState.resize(attrCount); |
2554 } | 2557 } |
2555 attribState = &fDefaultVertexArrayAttribState; | 2558 attribState = &fDefaultVertexArrayAttribState; |
2556 } | 2559 } |
2557 return attribState; | 2560 return attribState; |
2558 } | 2561 } |
OLD | NEW |