Some improvements to backend texture creation.
This initializes more formats correctly with solid colors and relies
less on GrPixelConfig.
It also includes the changes to get gray8 read pixels working
and almost everything to initialize GL_RGB8 textures with data. Minor
stuff to follow to get RGB8 fully working and update test expectations.
Bug: skia:8962
Bug: skia:6718
Bug: skia:9358
Change-Id: Ic044b4c4badc37f14fb46c898cd3b3c21a6fc7fd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/251199
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f099361..7906984 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -12,6 +12,7 @@
#include "include/private/SkDeferredDisplayList.h"
#include "include/private/SkImageInfoPriv.h"
#include "src/core/SkMakeUnique.h"
+#include "src/core/SkMipMap.h"
#include "src/core/SkTaskGroup.h"
#include "src/gpu/GrClientMappedBufferManager.h"
#include "src/gpu/GrContextPriv.h"
@@ -380,9 +381,13 @@
return GrBackendTexture();
}
- return fGpu->createBackendTexture(width, height, backendFormat,
- mipMapped, renderable,
- nullptr, 0, nullptr, isProtected);
+ int numMipLevels = 1;
+ if (mipMapped == GrMipMapped::kYes) {
+ numMipLevels = SkMipMap::ComputeLevelCount(width, height) + 1;
+ }
+
+ return fGpu->createBackendTexture({width, height}, backendFormat, renderable, nullptr,
+ numMipLevels, isProtected);
}
GrBackendTexture GrContext::createBackendTexture(int width, int height,
@@ -481,9 +486,13 @@
return GrBackendTexture();
}
- return fGpu->createBackendTexture(width, height, backendFormat,
- mipMapped, renderable,
- nullptr, 0, &color, isProtected);
+ int numMipLevels = 1;
+ if (mipMapped == GrMipMapped::kYes) {
+ numMipLevels = SkMipMap::ComputeLevelCount(width, height) + 1;
+ }
+ GrGpu::BackendTextureData data(color);
+ return fGpu->createBackendTexture({width, height}, backendFormat, renderable, &data,
+ numMipLevels, isProtected);
}
GrBackendTexture GrContext::createBackendTexture(int width, int height,
@@ -534,9 +543,9 @@
GrBackendFormat backendFormat = this->defaultBackendFormat(colorType, renderable);
- return fGpu->createBackendTexture(baseWidth, baseHeight, backendFormat,
- numLevels > 1 ? GrMipMapped::kYes : GrMipMapped::kNo,
- renderable, srcData, numLevels, nullptr, isProtected);
+ GrGpu::BackendTextureData data(srcData);
+ return fGpu->createBackendTexture({baseWidth, baseHeight}, backendFormat, renderable, &data,
+ numLevels, isProtected);
}
void GrContext::deleteBackendTexture(GrBackendTexture backendTex) {