Chromium Code Reviews| 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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; |
| 558 GrGLenum externalFormat = 0x0; // suprress warning | 558 GrGLenum externalFormat = 0x0; // suprress warning |
| 559 GrGLenum externalType = 0x0;// suprress warning | 559 GrGLenum externalType = 0x0;// suprress 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 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2163 *internalFormat = GR_GL_RGBA; | 2156 *internalFormat = GR_GL_RGBA; |
| 2164 } | 2157 } |
| 2165 } | 2158 } |
| 2166 *externalFormat = GR_GL_BGRA; | 2159 *externalFormat = GR_GL_BGRA; |
| 2167 *externalType = GR_GL_UNSIGNED_BYTE; | 2160 *externalType = GR_GL_UNSIGNED_BYTE; |
| 2168 break; | 2161 break; |
| 2169 case kRGB_565_GrPixelConfig: | 2162 case kRGB_565_GrPixelConfig: |
| 2170 *internalFormat = GR_GL_RGB; | 2163 *internalFormat = GR_GL_RGB; |
| 2171 *externalFormat = GR_GL_RGB; | 2164 *externalFormat = GR_GL_RGB; |
| 2172 if (getSizedInternalFormat) { | 2165 if (getSizedInternalFormat) { |
| 2173 if (this->glStandard() == kGL_GrGLStandard) { | 2166 if (this->glStandard() == kGL_GrGLStandard && |
|
bsalomon
2014/12/16 15:28:18
won't this check happen in line 2130?
| |
| 2167 !this->glCaps().ES2CompatibilitySupport()) { | |
| 2174 return false; | 2168 return false; |
| 2175 } else { | 2169 } else { |
| 2176 *internalFormat = GR_GL_RGB565; | 2170 *internalFormat = GR_GL_RGB565; |
| 2177 } | 2171 } |
| 2178 } else { | 2172 } else { |
| 2179 *internalFormat = GR_GL_RGB; | 2173 *internalFormat = GR_GL_RGB; |
| 2180 } | 2174 } |
| 2181 *externalType = GR_GL_UNSIGNED_SHORT_5_6_5; | 2175 *externalType = GR_GL_UNSIGNED_SHORT_5_6_5; |
| 2182 break; | 2176 break; |
| 2183 case kRGBA_4444_GrPixelConfig: | 2177 case kRGBA_4444_GrPixelConfig: |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2589 this->setVertexArrayID(gpu, 0); | 2583 this->setVertexArrayID(gpu, 0); |
| 2590 } | 2584 } |
| 2591 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2585 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2592 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2586 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2593 fDefaultVertexArrayAttribState.resize(attrCount); | 2587 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2594 } | 2588 } |
| 2595 attribState = &fDefaultVertexArrayAttribState; | 2589 attribState = &fDefaultVertexArrayAttribState; |
| 2596 } | 2590 } |
| 2597 return attribState; | 2591 return attribState; |
| 2598 } | 2592 } |
| OLD | NEW |