Reland "Reland "Separate compressed and uncompressed texture functions""
This is a reland of c0519233cdd2545a938848336c7d470bfe27fa96
Original change's description:
> Reland "Separate compressed and uncompressed texture functions"
>
> This is a reland of 9acfb33ad8c6f5fc6097dff57c0de5e51ea590fd
>
> Original change's description:
> > Separate compressed and uncompressed texture functions
> >
> > Change-Id: Iccf31e1e4dbebde8aab4bb9b57cfb0341bb05912
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223802
> > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > Commit-Queue: Brian Salomon <bsalomon@google.com>
>
> Change-Id: I9f212b7d34cf43216f7d2ec63b959b75fd6a71b3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223992
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Change-Id: I0654a49dadfb56ad276051c8632b91da05bf24cd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/224181
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrDataUtils.cpp b/src/gpu/GrDataUtils.cpp
index c83a3cf..9dcc25b 100644
--- a/src/gpu/GrDataUtils.cpp
+++ b/src/gpu/GrDataUtils.cpp
@@ -113,10 +113,14 @@
return w * h;
}
-size_t GrETC1CompressedDataSize(int width, int height) {
- int numBlocks = num_ETC1_blocks(width, height);
-
- return numBlocks * sizeof(ETC1Block);
+size_t GrCompressedDataSize(SkImage::CompressionType type, int width, int height) {
+ switch (type) {
+ case SkImage::kETC1_CompressionType:
+ int numBlocks = num_ETC1_blocks(width, height);
+ return numBlocks * sizeof(ETC1Block);
+ }
+ SK_ABORT("Unexpected compression type");
+ return 0;
}
// Fill in 'dest' with ETC1 blocks derived from 'colorf'
@@ -300,22 +304,14 @@
return true;
}
-size_t GrComputeTightCombinedBufferSize(GrCompression compression, size_t bytesPerPixel,
- int baseWidth, int baseHeight,
- SkTArray<size_t>* individualMipOffsets,
- int mipLevelCount) {
+size_t GrComputeTightCombinedBufferSize(size_t bytesPerPixel, int baseWidth, int baseHeight,
+ SkTArray<size_t>* individualMipOffsets, int mipLevelCount) {
SkASSERT(individualMipOffsets && !individualMipOffsets->count());
SkASSERT(mipLevelCount >= 1);
individualMipOffsets->push_back(0);
size_t combinedBufferSize = baseWidth * bytesPerPixel * baseHeight;
- if (GrCompression::kETC1 == compression) {
- SkASSERT(0 == bytesPerPixel);
- bytesPerPixel = 4; // munge Bpp to make the following code work (and not assert)
- combinedBufferSize = GrETC1CompressedDataSize(baseWidth, baseHeight);
- }
-
int currentWidth = baseWidth;
int currentHeight = baseHeight;
@@ -329,12 +325,7 @@
currentWidth = SkTMax(1, currentWidth / 2);
currentHeight = SkTMax(1, currentHeight / 2);
- size_t trimmedSize;
- if (GrCompression::kETC1 == compression) {
- trimmedSize = GrETC1CompressedDataSize(currentWidth, currentHeight);
- } else {
- trimmedSize = currentWidth * bytesPerPixel * currentHeight;
- }
+ size_t trimmedSize = currentWidth * bytesPerPixel * currentHeight;
const size_t alignmentDiff = combinedBufferSize % desiredAlignment;
if (alignmentDiff != 0) {
combinedBufferSize += desiredAlignment - alignmentDiff;
@@ -349,12 +340,11 @@
return combinedBufferSize;
}
-void GrFillInData(GrCompression compression, GrPixelConfig config,
- int baseWidth, int baseHeight,
+void GrFillInData(GrPixelConfig config, int baseWidth, int baseHeight,
const SkTArray<size_t>& individualMipOffsets, char* dstPixels,
const SkColor4f& colorf) {
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
-
+ SkASSERT(!GrPixelConfigIsCompressed(config));
int mipLevels = individualMipOffsets.count();
int currentWidth = baseWidth;
@@ -362,19 +352,22 @@
for (int currentMipLevel = 0; currentMipLevel < mipLevels; ++currentMipLevel) {
size_t offset = individualMipOffsets[currentMipLevel];
- if (GrCompression::kETC1 == compression) {
- // TODO: compute the ETC1 block for 'colorf' just once
- fillin_ETC1_with_color(currentWidth, currentHeight, colorf, &(dstPixels[offset]));
- } else {
- fill_buffer_with_color(config, currentWidth, currentHeight, colorf,
- &(dstPixels[offset]));
- }
-
+ fill_buffer_with_color(config, currentWidth, currentHeight, colorf, &(dstPixels[offset]));
currentWidth = SkTMax(1, currentWidth / 2);
currentHeight = SkTMax(1, currentHeight / 2);
}
}
+void GrFillInCompressedData(SkImage::CompressionType type, int baseWidth, int baseHeight,
+ char* dstPixels, const SkColor4f& colorf) {
+ TRACE_EVENT0("skia.gpu", TRACE_FUNC);
+ int currentWidth = baseWidth;
+ int currentHeight = baseHeight;
+ if (SkImage::kETC1_CompressionType == type) {
+ fillin_ETC1_with_color(currentWidth, currentHeight, colorf, dstPixels);
+ }
+}
+
static GrSwizzle get_load_and_get_swizzle(GrColorType ct, SkRasterPipeline::StockStage* load,
bool* isNormalized) {
GrSwizzle swizzle("rgba");
@@ -417,7 +410,6 @@
break;
case GrColorType::kUnknown:
- case GrColorType::kRGB_ETC1:
SK_ABORT("unexpected CT");
}
return swizzle;
@@ -465,7 +457,6 @@
case GrColorType::kGray_8: // not currently supported as output
case GrColorType::kUnknown:
- case GrColorType::kRGB_ETC1:
SK_ABORT("unexpected CT");
}
return swizzle;