Fix images used in orientation GMs

Previous approach using magick's -orient tool didn't actually change the
stored JPEG's orientation (they were all tagged Undefined and the data
was top-left).

Regenerate the images using new method where the PNGs are generated with
transformations that the EXIF tag will undo. The script converts to JPEG
using magick and then modifies the TAG using exiftool.

Change-Id: Ic2276711c0f4faa26620c93b24f4f0e58d658ae3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345127
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Brian Salomon 2020-12-17 09:38:59 -05:00 committed by Skia Commit-Bot
parent a1b5d7e1eb
commit 72068174f2
52 changed files with 33 additions and 42 deletions

View File

@ -6,6 +6,7 @@
*/
#include "gm/gm.h"
#include "include/codec/SkEncodedOrigin.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkFont.h"
#include "include/core/SkImage.h"
@ -23,54 +24,37 @@ static constexpr int kImgH = 80;
/**
This function was used to create the images used by these test. It saves them as PNGs (so they
are lossless). Then the following bash script was used to create the oriented JPGs with
imagemagick:
imagemagick and exiftool:
#!/bin/bash
function originname() {
case $1 in
1)
echo -n "top-left"
;;
2)
echo -n "top-right"
;;
3)
echo -n "bottom-right"
;;
4)
echo -n "bottom-left"
;;
5)
echo -n "left-top"
;;
6)
echo -n "right-top"
;;
7)
echo -n "right-bottom"
;;
8)
echo -n "left-bottom"
;;
*)
echo -n "unknown"
;;
esac
}
for s in 444 422 420 440 411 410; do
for i in {1..8}; do
magick convert $i.png -sampling-factor ${s:0:1}:${s:1:1}:${s:2:1} \
-orient $(originname $i) $i\_$s.jpg;
magick convert $i.png -sampling-factor ${s:0:1}:${s:1:1}:${s:2:1} $i\_$s.jpg;
exiftool -orientation=$i -n -m -overwrite_original $i\_$s.jpg;
done
done
*/
static void make_images() {
auto surf = SkSurface::MakeRaster(SkImageInfo::Make({kImgW, kImgH},
kRGBA_8888_SkColorType,
kPremul_SkAlphaType));
for (int i = 1; i <= 8; ++i) {
SkISize size{kImgW, kImgH};
SkEncodedOrigin origin = static_cast<SkEncodedOrigin>(i);
// We apply the inverse transformation to the PNG we generate, convert the PNG to a
// a JPEG using magick, then modify the JPEG's tag using exiftool (without modifying the
// stored JPEG data).
if (origin >= kLeftTop_SkEncodedOrigin) {
// The last four SkEncodedOrigin values involve 90 degree rotations
using std::swap;
swap(size.fWidth, size.fHeight);
}
using std::swap;
auto surf = SkSurface::MakeRaster(SkImageInfo::Make(size,
kRGBA_8888_SkColorType,
kPremul_SkAlphaType));
auto* canvas = surf->getCanvas();
SkMatrix m = SkEncodedOriginToMatrix(origin, kImgW, kImgH);
SkAssertResult(m.invert(&m));
canvas->concat(m);
canvas->clear(SK_ColorBLACK);
SkPaint paint;
paint.setColor(SK_ColorRED);
@ -122,7 +106,7 @@ static void make_images() {
drawLabel("left", kPad - bounds.left(), baseY);
bounds = measure("right");
drawLabel("right", midX - kPad - bounds.right(), baseY);
drawLabel("right", kImgW - kPad - bounds.right(), baseY);
SkString num = SkStringPrintf("%d", i);
bounds = measure(num.c_str());

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -456,7 +456,7 @@ sk_sp<SkImage> SkImage_GpuYUVA::MakePromiseYUVATexture(
if (yuvaBackendTextureInfo.yuvaInfo().origin() != SkEncodedOrigin::kDefault_SkEncodedOrigin) {
// SkImage_GpuYUVA does not support this yet. This will get removed
// when the old APIs are gone and we only have to support YUVA configs described by
// SkYUVAInfo.
// SkYUVAInfo. Fix with skbug.com/10632.
return nullptr;
}

View File

@ -71,7 +71,8 @@ void DDLPromiseImageHelper::PromiseImageInfo::setMipLevels(const SkBitmap& baseL
///////////////////////////////////////////////////////////////////////////////////////////////////
PromiseImageCallbackContext::~PromiseImageCallbackContext() {
SkASSERT(fDoneCnt == fNumImages);
// See comment in release() about YUVA image creation failures.
// SkASSERT(fDoneCnt == fNumImages);1
SkASSERT(!fTotalFulfills || fDoneCnt);
if (fPromiseImageTexture) {
@ -340,6 +341,9 @@ sk_sp<SkImage> DDLPromiseImageHelper::CreatePromiseImages(const void* rawData,
PromiseImageCallbackContext::PromiseImageFulfillProc,
PromiseImageCallbackContext::PromiseImageReleaseProc,
contexts);
if (!image) {
return nullptr;
}
for (int i = 0; i < textureCount; ++i) {
curImage.callbackContext(i)->wasAddedToImage();
}

View File

@ -54,7 +54,10 @@ public:
void release() {
++fDoneCnt;
SkASSERT(fDoneCnt <= fNumImages);
// YUVA Images can fail to create if they have a non-default encoded origin. This will be
// fixed when skbug.com/10632 is finished. This assert fires because done is called on
// failure and we never bumped fNumImages.
// SkASSERT(fDoneCnt <= fNumImages);
}
void wasAddedToImage() { fNumImages++; }