[graphite] Fix A->RGBx GPU to CPU transfers

Because GPU->CPU transfers that detect kIgnoreSrc rewrite the
texture format *after* FormatXferOps were queried, the transfer
function was not detecting that the case where we'd normally be
padding a 3-channel RGB texture up to a 4-channel CPU type.

Before this fix, an A->RGBx GPU to CPU transfer would detect it as
kIgnoreSrc, and then switch the texture format to the default format
for the kRGB_888x color type, which is TF::kRGB8 (3 bytes). Since this
switch happened after the extended transfer ops were set, the actual
transfer function assumed the bpp was 12 and would not properly
iterate across each row.

The fix is to lift the dstCT from RGBx to RGBA and add the kForceOpaque
flag. This then means the switched texture format is kRGBA8 and all the
pixels' bits are written to. An alternative fix would have been to keep
the dstCT as RGBx but add in the kPadAlpha. This would produce the
identical output. I chose not to do this because there is already the
kIgnoreSrc + kForceOpaque xfer op combination, but not currently any
use for kIgnoreSrc + kPadAlpha.

This scenario should have been caught by the existing bulk transfer
tests in TextureFormatTest, except that the dst output buffer was
being zero-initialized alongside the expected 1px dst output. This
meant the comparison was unable to differentiate the problematic
case writing `00 00 00, 00 00 00, ...` vs. the correct
`00 00 00 xx, 00 00 00 xx`.

I confirmed that by initializing the dst output with a sentinel
value that the TextureFormatTest detected this bpp problem. Because
the values that were problematic happened to fall into a padding
channel, I adjusted transfer_data to report success in order to
dump the pixel comparison, instead of assuming that compare_pixels
would also report a failure.

Bug: 573263421
Fixed: 573263421
Change-Id: I6f535822c91aaddaa66bbc6d2457ff0c54f471fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1414539
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2 files changed