Update GenerateMipMapsAndUploadtoTextureProxy to respect color space when setting up SurfaceDesc

Bug: skia:
Change-Id: Ie98c9c565ee9e2fd4d405389be9e9487cf71f951
Reviewed-on: https://skia-review.googlesource.com/43743
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2017-09-07 16:17:24 -04:00 committed by Skia Commit-Bot
parent 2e50d0f5f9
commit faa5329b9b

View File

@ -172,15 +172,22 @@ sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext* ctx,
return nullptr;
}
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps());
SkPixmap pixmap;
if (!bitmap.peekPixels(&pixmap)) {
return nullptr;
}
ATRACE_ANDROID_FRAMEWORK("Upload MipMap Texture [%ux%u]", pixmap.width(), pixmap.height());
std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, colorMode, nullptr));
SkBitmap tmpBitmap;
SkPixmap tmpPixmap;
GrSurfaceDesc desc;
const SkPixmap* pmap = compute_desc(*ctx->resourceProvider()->caps(), pixmap, &desc,
&tmpBitmap, &tmpPixmap);
if (!pmap) {
return nullptr;
}
ATRACE_ANDROID_FRAMEWORK("Upload MipMap Texture [%ux%u]", pmap->width(), pmap->height());
std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(*pmap, colorMode, nullptr));
if (!mipmaps) {
return nullptr;
}
@ -192,8 +199,8 @@ sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext* ctx,
std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
texels[0].fPixels = pixmap.addr();
texels[0].fRowBytes = pixmap.rowBytes();
texels[0].fPixels = pmap->addr();
texels[0].fRowBytes = pmap->rowBytes();
for (int i = 1; i < mipLevelCount; ++i) {
SkMipMap::Level generatedMipLevel;