aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLGpu.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-09-28 20:46:45 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-28 20:46:53 +0000
commit8b059bd946d9f14607f6d2e8b966267dd8e5a54d (patch)
tree0e88e6107bf964705c85cdead1a95f082a1d7e61 /src/gpu/gl/GrGLGpu.cpp
parent4b050009067044ad9352d26013c10991bda38f91 (diff)
Revert "Update GrBitmapTextureMaker for handling mipped requests"
This reverts commit d1935c16e889b6707a522f711e79c75353caa343. Reason for revert: breaking lots of GMs, especially on gles Original change's description: > Update GrBitmapTextureMaker for handling mipped requests > > Specifically this updates the case when we are requesting to use mip > maps but there is already an unmipped version in the cache. Previously > we just grabbed the unmipped. > > Now we will create a new mipped resource. Upload the cpu data to all > the levels besides the base, copy the base level on GPU from the > original resource to the mipped one. Then the mipped resource will > take over the originals unique key. > > Bug: skia: > Change-Id: I38e9725c93280dc2460a0be8a7a229e7f20e1614 > Reviewed-on: https://skia-review.googlesource.com/43840 > Commit-Queue: Greg Daniel <egdaniel@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> TBR=egdaniel@google.com,robertphillips@google.com,brianosman@google.com Change-Id: Id82e8b6e8ab69e46ff018bb07ae5d1f6ea8d7e76 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/52901 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/gl/GrGLGpu.cpp')
-rw-r--r--src/gpu/gl/GrGLGpu.cpp48
1 files changed, 19 insertions, 29 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 930e2e447a..ff19bb6fc3 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -952,13 +952,10 @@ static bool allocate_and_populate_texture(GrPixelConfig config,
}
} else {
for (int currentMipLevel = 0; currentMipLevel < mipLevelCount; currentMipLevel++) {
- const void* currentMipData = texels[currentMipLevel].fPixels;
- if (!currentMipData) {
- continue;
- }
int twoToTheMipLevel = 1 << currentMipLevel;
int currentWidth = SkTMax(1, baseWidth / twoToTheMipLevel);
int currentHeight = SkTMax(1, baseHeight / twoToTheMipLevel);
+ const void* currentMipData = texels[currentMipLevel].fPixels;
// Even if curremtMipData is nullptr, continue to call TexImage2D.
// This will allocate texture memory which we can later populate.
GL_ALLOC_CALL(&interface,
@@ -1036,6 +1033,10 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
memcpy(texelsShallowCopy.get(), texels, mipLevelCount*sizeof(GrMipLevel));
}
+ for (int currentMipLevel = 0; currentMipLevel < mipLevelCount; ++currentMipLevel) {
+ SkASSERT(texelsShallowCopy[currentMipLevel].fPixels);
+ }
+
const GrGLInterface* interface = this->glInterface();
const GrGLCaps& caps = this->glCaps();
@@ -1080,27 +1081,19 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
// find the combined size of all the mip levels and the relative offset of
// each into the collective buffer
- size_t combinedBufferSize = 0;
- SkTArray<size_t> individualMipOffsets(mipLevelCount);
+ size_t combined_buffer_size = 0;
+ SkTArray<size_t> individual_mip_offsets(mipLevelCount);
for (int currentMipLevel = 0; currentMipLevel < mipLevelCount; currentMipLevel++) {
- if (texelsShallowCopy[currentMipLevel].fPixels) {
- int twoToTheMipLevel = 1 << currentMipLevel;
- int currentWidth = SkTMax(1, width / twoToTheMipLevel);
- int currentHeight = SkTMax(1, height / twoToTheMipLevel);
- const size_t trimmedSize = currentWidth * bpp * currentHeight;
- individualMipOffsets.push_back(combinedBufferSize);
- combinedBufferSize += trimmedSize;
- } else {
- individualMipOffsets.push_back(0);
- }
-
+ int twoToTheMipLevel = 1 << currentMipLevel;
+ int currentWidth = SkTMax(1, width / twoToTheMipLevel);
+ int currentHeight = SkTMax(1, height / twoToTheMipLevel);
+ const size_t trimmedSize = currentWidth * bpp * currentHeight;
+ individual_mip_offsets.push_back(combined_buffer_size);
+ combined_buffer_size += trimmedSize;
}
- char* buffer = (char*)tempStorage.reset(combinedBufferSize);
+ char* buffer = (char*)tempStorage.reset(combined_buffer_size);
for (int currentMipLevel = 0; currentMipLevel < mipLevelCount; currentMipLevel++) {
- if (!texelsShallowCopy[currentMipLevel].fPixels) {
- continue;
- }
int twoToTheMipLevel = 1 << currentMipLevel;
int currentWidth = SkTMax(1, width / twoToTheMipLevel);
int currentHeight = SkTMax(1, height / twoToTheMipLevel);
@@ -1114,9 +1107,9 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
*/
restoreGLRowLength = false;
- const size_t rowBytes = texelsShallowCopy[currentMipLevel].fRowBytes
- ? texelsShallowCopy[currentMipLevel].fRowBytes
- : trimRowBytes;
+ const size_t rowBytes = texelsShallowCopy[currentMipLevel].fRowBytes ?
+ texelsShallowCopy[currentMipLevel].fRowBytes :
+ trimRowBytes;
// TODO: This optimization should be enabled with or without mips.
// For use with mips, we must set GR_GL_UNPACK_ROW_LENGTH once per
@@ -1135,7 +1128,7 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
if (swFlipY && currentHeight >= 1) {
src += (currentHeight - 1) * rowBytes;
}
- char* dst = buffer + individualMipOffsets[currentMipLevel];
+ char* dst = buffer + individual_mip_offsets[currentMipLevel];
for (int y = 0; y < currentHeight; y++) {
memcpy(dst, src, trimRowBytes);
if (swFlipY) {
@@ -1147,7 +1140,7 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
}
// now point data to our copied version
texelsShallowCopy[currentMipLevel].fPixels = buffer +
- individualMipOffsets[currentMipLevel];
+ individual_mip_offsets[currentMipLevel];
texelsShallowCopy[currentMipLevel].fRowBytes = trimRowBytes;
}
}
@@ -1174,9 +1167,6 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
top = texHeight - (top + height);
}
for (int currentMipLevel = 0; currentMipLevel < mipLevelCount; currentMipLevel++) {
- if (!texelsShallowCopy[currentMipLevel].fPixels) {
- continue;
- }
int twoToTheMipLevel = 1 << currentMipLevel;
int currentWidth = SkTMax(1, width / twoToTheMipLevel);
int currentHeight = SkTMax(1, height / twoToTheMipLevel);