| 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 this->glCaps().texStorageSupport(); | 547 this->glCaps().texStorageSupport(); |
| 548 | 548 |
| 549 if (useTexStorage && kGL_GrGLStandard == this->glStandard()) { | 549 if (useTexStorage && kGL_GrGLStandard == this->glStandard()) { |
| 550 // 565 is not a sized internal format on desktop GL. So on desktop with | 550 // 565 is not a sized internal format on desktop GL. So on desktop with |
| 551 // 565 we always use an unsized internal format to let the system pick | 551 // 565 we always use an unsized internal format to let the system pick |
| 552 // the best sized format to convert the 565 data to. Since TexStorage | 552 // the best sized format to convert the 565 data to. Since TexStorage |
| 553 // only allows sized internal formats we will instead use TexImage2D. | 553 // only allows sized internal formats we will instead use TexImage2D. |
| 554 useTexStorage = desc.fConfig != kRGB_565_GrPixelConfig; | 554 useTexStorage = desc.fConfig != kRGB_565_GrPixelConfig; |
| 555 } | 555 } |
| 556 | 556 |
| 557 GrGLenum internalFormat; | 557 GrGLenum internalFormat = 0x0; // suppress warning |
| 558 GrGLenum externalFormat = 0x0; // suprress warning | 558 GrGLenum externalFormat = 0x0; // suppress warning |
| 559 GrGLenum externalType = 0x0;// suprress warning | 559 GrGLenum externalType = 0x0; // suppress warning |
| 560 | 560 |
| 561 // glTexStorage requires sized internal formats on both desktop and ES. ES2
requires an unsized | 561 // glTexStorage requires sized internal formats on both desktop and ES. |
| 562 // format for glTexImage, unlike ES3 and desktop. However, we allow the driv
er to decide the | 562 // ES2 requires an unsized format for glTexImage. On ES3 and desktop we defa
ult to sized. |
| 563 // size of the internal format whenever possible and so only use a sized int
ernal format when | 563 bool useSizedFormat = useTexStorage || kGL_GrGLStandard == this->glStandard(
) || |
| 564 // using texture storage. | 564 this->glVersion() >= GR_GL_VER(3, 0); |
| 565 bool useSizedFormat = useTexStorage; | |
| 566 // Many versions of the ES3 drivers on various platforms will not accept GL_
RED in | |
| 567 // glTexImage2D for the internal format but will accept GL_R8. | |
| 568 if (kGLES_GrGLStandard == this->glStandard() && this->glVersion() >= GR_GL_V
ER(3, 0) && | |
| 569 kAlpha_8_GrPixelConfig == dataConfig) { | |
| 570 useSizedFormat = true; | |
| 571 } | |
| 572 if (!this->configToGLFormats(dataConfig, useSizedFormat, &internalFormat, | 565 if (!this->configToGLFormats(dataConfig, useSizedFormat, &internalFormat, |
| 573 &externalFormat, &externalType)) { | 566 &externalFormat, &externalType)) { |
| 574 return false; | 567 return false; |
| 575 } | 568 } |
| 576 | 569 |
| 577 /* | 570 /* |
| 578 * check whether to allocate a temporary buffer for flipping y or | 571 * check whether to allocate a temporary buffer for flipping y or |
| 579 * because our srcData has extra bytes past each row. If so, we need | 572 * because our srcData has extra bytes past each row. If so, we need |
| 580 * to trim those off here, since GL ES may not let us specify | 573 * to trim those off here, since GL ES may not let us specify |
| 581 * GL_UNPACK_ROW_LENGTH. | 574 * GL_UNPACK_ROW_LENGTH. |
| (...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2269 *internalFormat = GR_GL_RGBA; | 2262 *internalFormat = GR_GL_RGBA; |
| 2270 } | 2263 } |
| 2271 } | 2264 } |
| 2272 *externalFormat = GR_GL_BGRA; | 2265 *externalFormat = GR_GL_BGRA; |
| 2273 *externalType = GR_GL_UNSIGNED_BYTE; | 2266 *externalType = GR_GL_UNSIGNED_BYTE; |
| 2274 break; | 2267 break; |
| 2275 case kRGB_565_GrPixelConfig: | 2268 case kRGB_565_GrPixelConfig: |
| 2276 *internalFormat = GR_GL_RGB; | 2269 *internalFormat = GR_GL_RGB; |
| 2277 *externalFormat = GR_GL_RGB; | 2270 *externalFormat = GR_GL_RGB; |
| 2278 if (getSizedInternalFormat) { | 2271 if (getSizedInternalFormat) { |
| 2279 if (this->glStandard() == kGL_GrGLStandard) { | 2272 if (!this->glCaps().ES2CompatibilitySupport()) { |
| 2280 return false; | 2273 *internalFormat = GR_GL_RGB5; |
| 2281 } else { | 2274 } else { |
| 2282 *internalFormat = GR_GL_RGB565; | 2275 *internalFormat = GR_GL_RGB565; |
| 2283 } | 2276 } |
| 2284 } else { | 2277 } else { |
| 2285 *internalFormat = GR_GL_RGB; | 2278 *internalFormat = GR_GL_RGB; |
| 2286 } | 2279 } |
| 2287 *externalType = GR_GL_UNSIGNED_SHORT_5_6_5; | 2280 *externalType = GR_GL_UNSIGNED_SHORT_5_6_5; |
| 2288 break; | 2281 break; |
| 2289 case kRGBA_4444_GrPixelConfig: | 2282 case kRGBA_4444_GrPixelConfig: |
| 2290 *internalFormat = GR_GL_RGBA; | 2283 *internalFormat = GR_GL_RGBA; |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2695 this->setVertexArrayID(gpu, 0); | 2688 this->setVertexArrayID(gpu, 0); |
| 2696 } | 2689 } |
| 2697 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2690 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2698 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2691 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2699 fDefaultVertexArrayAttribState.resize(attrCount); | 2692 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2700 } | 2693 } |
| 2701 attribState = &fDefaultVertexArrayAttribState; | 2694 attribState = &fDefaultVertexArrayAttribState; |
| 2702 } | 2695 } |
| 2703 return attribState; | 2696 return attribState; |
| 2704 } | 2697 } |
| OLD | NEW |