readpixels GM uses GPU image in GPU configs

This now demonstrates that readPixels does not do color sapce conversion
in Ganesh (and fails completely for unpremul F16). Next: fix those issues.

BUG=skia:5853

Change-Id: If3bd1882249ae85b4738ef72e16cfb87b06b9363
Reviewed-on: https://skia-review.googlesource.com/9904
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
This commit is contained in:
Brian Osman 2017-03-20 16:54:28 -04:00 committed by Skia Commit-Bot
parent 4c55027dbf
commit 8915058264

View File

@ -132,7 +132,9 @@ static void draw_image(SkCanvas* canvas, SkImage* image, SkColorType dstColorTyp
dstColorSpace = fix_for_colortype(dstColorSpace.get(), dstColorType); dstColorSpace = fix_for_colortype(dstColorSpace.get(), dstColorType);
SkImageInfo dstInfo = SkImageInfo::Make(image->width(), image->height(), dstColorType, SkImageInfo dstInfo = SkImageInfo::Make(image->width(), image->height(), dstColorType,
dstAlphaType, dstColorSpace); dstAlphaType, dstColorSpace);
image->readPixels(dstInfo, data->writable_data(), rowBytes, 0, 0, hint); if (!image->readPixels(dstInfo, data->writable_data(), rowBytes, 0, 0, hint)) {
memset(data->writable_data(), 0, rowBytes * image->height());
}
// SkImage must be premul, so manually premul the data if we unpremul'd during readPixels // SkImage must be premul, so manually premul the data if we unpremul'd during readPixels
if (kUnpremul_SkAlphaType == dstAlphaType) { if (kUnpremul_SkAlphaType == dstAlphaType) {
@ -193,11 +195,16 @@ protected:
for (SkColorType srcColorType : colorTypes) { for (SkColorType srcColorType : colorTypes) {
canvas->save(); canvas->save();
sk_sp<SkImage> image = make_raster_image(srcColorType); sk_sp<SkImage> image = make_raster_image(srcColorType);
for (SkColorType dstColorType : colorTypes) { if (GrContext* context = canvas->getGrContext()) {
for (SkAlphaType dstAlphaType : alphaTypes) { image = image->makeTextureImage(context, canvas->imageInfo().colorSpace());
draw_image(canvas, image.get(), dstColorType, dstAlphaType, }
dstColorSpace, SkImage::kAllow_CachingHint); if (image) {
canvas->translate((float) kWidth, 0.0f); for (SkColorType dstColorType : colorTypes) {
for (SkAlphaType dstAlphaType : alphaTypes) {
draw_image(canvas, image.get(), dstColorType, dstAlphaType,
dstColorSpace, SkImage::kAllow_CachingHint);
canvas->translate((float)kWidth, 0.0f);
}
} }
} }
canvas->restore(); canvas->restore();