Minor GM cleanup

This CL:
1) Makes the compressed_textures GM use a red outline to indicate decompression (instead of a color rotation)

2) Disallows GPU resizing of textures w/ alpha in the wacky_yuv_formats GM

3) Guards GrTwoColorBC1Compress with GR_TEST_UTILS to make it clear that it is just a testing utility

4) Fixes the wacky_yuv_formats GM on platforms with RGBA PM color order

Change-Id: I3942c4ab1d2c1fab3c8d39c6c99136b75ba10132
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268119
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2020-01-31 11:03:32 -05:00 committed by Skia Commit-Bot
parent 89b5c8ec8c
commit e0735529fa
4 changed files with 36 additions and 27 deletions

View File

@ -31,17 +31,6 @@
class GrContext;
class GrRenderTargetContext;
static sk_sp<SkColorFilter> make_color_filter() {
// rotate R, G and B
float colorMatrix[20] = {
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
1, 0, 0, 0, 0,
0, 0, 0, 1, 0
};
return SkColorFilters::Matrix(colorMatrix);
}
static SkPoint gen_pt(float angle, const SkVector& scale) {
SkScalar s = SkScalarSin(angle);
SkScalar c = SkScalarCos(angle);
@ -258,8 +247,8 @@ private:
int numMipLevels = SkMipMap::ComputeLevelCount(levelDimensions.width(),
levelDimensions.height()) + 1;
SkPaint paint;
paint.setFilterQuality(kHigh_SkFilterQuality); // to force mipmapping
SkPaint imagePaint;
imagePaint.setFilterQuality(kHigh_SkFilterQuality); // to force mipmapping
bool isCompressed = false;
if (image->isTextureBacked()) {
@ -269,16 +258,19 @@ private:
isCompressed = caps->isFormatCompressed(proxy->backendFormat());
}
if (!isCompressed) {
// Make it obvious which drawImages used decompressed images
paint.setColorFilter(make_color_filter());
}
SkPaint redStrokePaint;
redStrokePaint.setColor(SK_ColorRED);
redStrokePaint.setStyle(SkPaint::kStroke_Style);
for (int i = 0; i < numMipLevels; ++i) {
SkRect r = SkRect::MakeXYWH(offset.fX, offset.fY,
levelDimensions.width(), levelDimensions.height());
canvas->drawImageRect(image, r, &paint);
canvas->drawImageRect(image, r, &imagePaint);
if (!isCompressed) {
// Make it obvious which drawImages used decompressed images
canvas->drawRect(r, redStrokePaint);
}
if (i == 0) {
offset.fX += levelDimensions.width()+1;

View File

@ -425,7 +425,7 @@ static SkPMColor convert_yuva_to_rgba(const float mtx[20],
uint8_t g = SkScalarPin(SkScalarRoundToInt(mtx[ 5]*y + mtx[ 6]*u + mtx[ 7]*v + mtx[ 9]*255), 0, 255);
uint8_t b = SkScalarPin(SkScalarRoundToInt(mtx[10]*y + mtx[11]*u + mtx[12]*v + mtx[14]*255), 0, 255);
return SkPremultiplyARGBInline(a, b, g, r);
return SkPremultiplyARGBInline(a, r, g, b);
}
static void extract_planes(const SkBitmap& bm, SkYUVColorSpace yuvColorSpace, PlaneData* planes) {
@ -821,6 +821,7 @@ protected:
if (kUnknown_SkColorType == fFlattened.colorType()) {
fFlattened.allocPixels(info);
SkASSERT(kN32_SkColorType == info.colorType());
SkASSERT(kPremul_SkAlphaType == info.alphaType());
float mtx[20];
@ -1155,6 +1156,13 @@ protected:
return nullptr;
}
if (ct == kRGBA_8888_SkColorType || ct == kRGBA_1010102_SkColorType) {
// We disallow resizing AYUV and Y410 formats on the GPU bc resizing them w/ a
// premul draw combines the YUV channels w/ the A channel in an inappropriate
// manner.
return nullptr;
}
SkISize shrunkPlaneSize = { yuvaTextures[i].width() / 2, yuvaTextures[i].height() / 2 };
sk_sp<SkImage> wrappedOrig = SkImage::MakeFromTexture(context, yuvaTextures[i],
@ -1294,11 +1302,14 @@ protected:
++counter;
}
} else {
fImages[opaque][cs][format] = make_yuv_gen_image(
fOriginalBMs[opaque].info(),
(SkYUVColorSpace) cs,
yuvaIndices,
resultBMs);
SkImageInfo ii = SkImageInfo::MakeN32(fOriginalBMs[opaque].width(),
fOriginalBMs[opaque].height(),
kPremul_SkAlphaType);
fImages[opaque][cs][format] = make_yuv_gen_image(ii,
(SkYUVColorSpace) cs,
yuvaIndices,
resultBMs);
}
}
}
@ -1640,9 +1651,9 @@ protected:
void onDraw(SkCanvas* canvas) override {
SkYUVAIndex indices[4];
indices[SkYUVAIndex::kY_Index] = {0, SkColorChannel::kR};
indices[SkYUVAIndex::kU_Index] = {1, SkColorChannel::kR};
indices[SkYUVAIndex::kV_Index] = {2, SkColorChannel::kR};
indices[SkYUVAIndex::kY_Index] = {0, SkColorChannel::kR};
indices[SkYUVAIndex::kU_Index] = {1, SkColorChannel::kR};
indices[SkYUVAIndex::kV_Index] = {2, SkColorChannel::kR};
indices[SkYUVAIndex::kA_Index] = {-1, SkColorChannel::kR};
canvas->translate(fOrig->width(), 0);

View File

@ -209,6 +209,8 @@ static void fillin_BC1_with_color(SkISize dimensions, const SkColor4f& colorf, c
}
}
#if GR_TEST_UTILS
// Fill in 'dstPixels' with BC1 blocks derived from the 'pixmap'.
void GrTwoColorBC1Compress(const SkPixmap& pixmap, SkColor otherColor, char* dstPixels) {
BC1Block* dstBlocks = reinterpret_cast<BC1Block*>(dstPixels);
@ -250,6 +252,8 @@ void GrTwoColorBC1Compress(const SkPixmap& pixmap, SkColor otherColor, char* dst
}
}
#endif
size_t GrComputeTightCombinedBufferSize(size_t bytesPerPixel, SkISize baseDimensions,
SkTArray<size_t>* individualMipOffsets, int mipLevelCount) {
SkASSERT(individualMipOffsets && !individualMipOffsets->count());

View File

@ -40,6 +40,7 @@ bool GrConvertPixels(const GrImageInfo& dstInfo, void* dst, size_t dstRB,
/** Clears the dst image to a constant color. */
bool GrClearImage(const GrImageInfo& dstInfo, void* dst, size_t dstRB, SkColor4f color);
#if GR_TEST_UTILS
/**
* BC1 compress an image that contains only either opaque black or transparent black and one
* other color.
@ -47,5 +48,6 @@ bool GrClearImage(const GrImageInfo& dstInfo, void* dst, size_t dstRB, SkColor4f
* transparent pixmaps -> kBC1_RGBA8_UNORM
*/
void GrTwoColorBC1Compress(const SkPixmap& pixmap, SkColor otherColor, char* dstPixels);
#endif
#endif