Use GrRenderTargetContext::readPixels in GrTextureToYUVPlanes
This is salvaged from an ancient CL or mine. Thoughts? Change-Id: I3712ca911d1ab5def3f4dcb080a3f9e226cdd44b Reviewed-on: https://skia-review.googlesource.com/7031 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
d9b6abb1a1
commit
276be05106
@ -149,13 +149,13 @@ bool GrTextureToYUVPlanes(GrTexture* texture, const SkISize sizes[3], void* cons
|
||||
|
||||
if (yuvRenderTargetContext) {
|
||||
SkASSERT(sizes[0] == sizes[1] && sizes[1] == sizes[2]);
|
||||
sk_sp<GrTexture> yuvTex(yuvRenderTargetContext->asTexture());
|
||||
SkASSERT(yuvTex);
|
||||
SkISize yuvSize = sizes[0];
|
||||
// We have no kRGB_888 pixel format, so readback rgba and then copy three channels.
|
||||
SkAutoSTMalloc<128 * 128, uint32_t> tempYUV(yuvSize.fWidth * yuvSize.fHeight);
|
||||
if (!yuvTex->readPixels(0, 0, yuvSize.fWidth, yuvSize.fHeight,
|
||||
kRGBA_8888_GrPixelConfig, tempYUV.get(), 0)) {
|
||||
|
||||
const SkImageInfo ii = SkImageInfo::Make(yuvSize.fWidth, yuvSize.fHeight,
|
||||
kRGBA_8888_SkColorType, kOpaque_SkAlphaType);
|
||||
if (!yuvRenderTargetContext->readPixels(ii, tempYUV.get(), 0, 0, 0)) {
|
||||
return false;
|
||||
}
|
||||
size_t yRowBytes = rowBytes[0] ? rowBytes[0] : yuvSize.fWidth;
|
||||
@ -182,21 +182,22 @@ bool GrTextureToYUVPlanes(GrTexture* texture, const SkISize sizes[3], void* cons
|
||||
return true;
|
||||
} else {
|
||||
SkASSERT(yRenderTargetContext);
|
||||
sk_sp<GrTexture> yTex(yRenderTargetContext->asTexture());
|
||||
SkASSERT(yTex);
|
||||
if (!yTex->readPixels(0, 0, sizes[0].fWidth, sizes[0].fHeight,
|
||||
kAlpha_8_GrPixelConfig, planes[0], rowBytes[0])) {
|
||||
|
||||
SkImageInfo ii = SkImageInfo::MakeA8(sizes[0].fWidth, sizes[0].fHeight);
|
||||
if (!yRenderTargetContext->readPixels(ii, planes[0], rowBytes[0], 0, 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uvRenderTargetContext) {
|
||||
SkASSERT(sizes[1].fWidth == sizes[2].fWidth);
|
||||
sk_sp<GrTexture> uvTex(uvRenderTargetContext->asTexture());
|
||||
SkASSERT(uvTex);
|
||||
SkISize uvSize = sizes[1];
|
||||
// We have no kRG_88 pixel format, so readback rgba and then copy two channels.
|
||||
SkAutoSTMalloc<128 * 128, uint32_t> tempUV(uvSize.fWidth * uvSize.fHeight);
|
||||
if (!uvTex->readPixels(0, 0, uvSize.fWidth, uvSize.fHeight,
|
||||
kRGBA_8888_GrPixelConfig, tempUV.get(), 0)) {
|
||||
|
||||
ii = SkImageInfo::Make(uvSize.fWidth, uvSize.fHeight,
|
||||
kRGBA_8888_SkColorType, kOpaque_SkAlphaType);
|
||||
|
||||
if (!uvRenderTargetContext->readPixels(ii, tempUV.get(), 0, 0, 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -219,18 +220,17 @@ bool GrTextureToYUVPlanes(GrTexture* texture, const SkISize sizes[3], void* cons
|
||||
return true;
|
||||
} else {
|
||||
SkASSERT(uRenderTargetContext && vRenderTargetContext);
|
||||
sk_sp<GrTexture> tex(uRenderTargetContext->asTexture());
|
||||
SkASSERT(tex);
|
||||
if (!tex->readPixels(0, 0, sizes[1].fWidth, sizes[1].fHeight,
|
||||
kAlpha_8_GrPixelConfig, planes[1], rowBytes[1])) {
|
||||
|
||||
ii = SkImageInfo::MakeA8(sizes[1].fWidth, sizes[1].fHeight);
|
||||
if (!uRenderTargetContext->readPixels(ii, planes[1], rowBytes[1], 0, 0)) {
|
||||
return false;
|
||||
}
|
||||
tex = vRenderTargetContext->asTexture();
|
||||
SkASSERT(tex);
|
||||
if (!tex->readPixels(0, 0, sizes[2].fWidth, sizes[2].fHeight,
|
||||
kAlpha_8_GrPixelConfig, planes[2], rowBytes[2])) {
|
||||
|
||||
ii = SkImageInfo::MakeA8(sizes[2].fWidth, sizes[2].fHeight);
|
||||
if (!vRenderTargetContext->readPixels(ii, planes[2], rowBytes[2], 0, 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user