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 #include "GrGLGpu.h" | 8 #include "GrGLGpu.h" |
9 #include "GrGLBuffer.h" | 9 #include "GrGLBuffer.h" |
10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 | 1271 |
1272 /* | 1272 /* |
1273 * check whether to allocate a temporary buffer for flipping y or | 1273 * check whether to allocate a temporary buffer for flipping y or |
1274 * because our srcData has extra bytes past each row. If so, we need | 1274 * because our srcData has extra bytes past each row. If so, we need |
1275 * to trim those off here, since GL ES may not let us specify | 1275 * to trim those off here, since GL ES may not let us specify |
1276 * GL_UNPACK_ROW_LENGTH. | 1276 * GL_UNPACK_ROW_LENGTH. |
1277 */ | 1277 */ |
1278 restoreGLRowLength = false; | 1278 restoreGLRowLength = false; |
1279 | 1279 |
1280 const size_t rowBytes = texelsShallowCopy[currentMipLevel].fRowBytes; | 1280 const size_t rowBytes = texelsShallowCopy[currentMipLevel].fRowBytes; |
1281 if (caps.unpackRowLengthSupport() && !swFlipY) { | 1281 |
| 1282 // TODO: This optimization should be enabled with or without mips. |
| 1283 // For use with mips, we must set GR_GL_UNPACK_ROW_LENGTH once per |
| 1284 // mip level, before calling glTexImage2D. |
| 1285 const bool usesMips = texelsShallowCopy.count() > 1; |
| 1286 if (caps.unpackRowLengthSupport() && !swFlipY && !usesMips) { |
1282 // can't use this for flipping, only non-neg values allowed. :( | 1287 // can't use this for flipping, only non-neg values allowed. :( |
1283 if (rowBytes != trimRowBytes) { | 1288 if (rowBytes != trimRowBytes) { |
1284 GrGLint rowLength = static_cast<GrGLint>(rowBytes / bpp); | 1289 GrGLint rowLength = static_cast<GrGLint>(rowBytes / bpp); |
1285 GR_GL_CALL(interface, PixelStorei(GR_GL_UNPACK_ROW_LENGTH, rowLe
ngth)); | 1290 GR_GL_CALL(interface, PixelStorei(GR_GL_UNPACK_ROW_LENGTH, rowLe
ngth)); |
1286 restoreGLRowLength = true; | 1291 restoreGLRowLength = true; |
1287 } | 1292 } |
1288 } else if (kTransfer_UploadType != uploadType) { | 1293 } else if (kTransfer_UploadType != uploadType) { |
1289 if (trimRowBytes != rowBytes || swFlipY) { | 1294 if (trimRowBytes != rowBytes || swFlipY) { |
1290 // copy data into our new storage, skipping the trailing bytes | 1295 // copy data into our new storage, skipping the trailing bytes |
1291 const char* src = (const char*)texelsShallowCopy[currentMipLevel
].fPixels; | 1296 const char* src = (const char*)texelsShallowCopy[currentMipLevel
].fPixels; |
(...skipping 2954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4246 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4251 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
4247 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4252 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
4248 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4253 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
4249 copyParams->fWidth = texture->width(); | 4254 copyParams->fWidth = texture->width(); |
4250 copyParams->fHeight = texture->height(); | 4255 copyParams->fHeight = texture->height(); |
4251 return true; | 4256 return true; |
4252 } | 4257 } |
4253 } | 4258 } |
4254 return false; | 4259 return false; |
4255 } | 4260 } |
OLD | NEW |