本文整理汇总了C++中SkAutoTUnref::readPixels方法的典型用法代码示例。如果您正苦于以下问题:C++ SkAutoTUnref::readPixels方法的具体用法?C++ SkAutoTUnref::readPixels怎么用?C++ SkAutoTUnref::readPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkAutoTUnref
的用法示例。
在下文中一共展示了SkAutoTUnref::readPixels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GrTextureToYUVPlanes
//.........这里部分代码省略.........
if (!dc) {
return false;
}
if (!convert_texture(texture, dc, sizes[1].fWidth, sizes[1].fHeight,
colorSpace, GrYUVEffect::CreateRGBToUV)) {
return false;
}
} else {
SkASSERT(uTex && vTex);
dc.reset(context->drawContext(uTex->asRenderTarget()));
if (!dc) {
return false;
}
if (!convert_texture(texture, dc, sizes[1].fWidth, sizes[1].fHeight,
colorSpace, GrYUVEffect::CreateRGBToU)) {
return false;
}
dc.reset(context->drawContext(vTex->asRenderTarget()));
if (!dc) {
return false;
}
if (!convert_texture(texture, dc, sizes[2].fWidth, sizes[2].fHeight,
colorSpace, GrYUVEffect::CreateRGBToV)) {
return false;
}
}
}
if (yuvTex) {
SkASSERT(sizes[0] == sizes[1] && sizes[1] == sizes[2]);
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)) {
return false;
}
size_t yRowBytes = rowBytes[0] ? rowBytes[0] : yuvSize.fWidth;
size_t uRowBytes = rowBytes[1] ? rowBytes[1] : yuvSize.fWidth;
size_t vRowBytes = rowBytes[2] ? rowBytes[2] : yuvSize.fWidth;
if (yRowBytes < (size_t)yuvSize.fWidth || uRowBytes < (size_t)yuvSize.fWidth ||
vRowBytes < (size_t)yuvSize.fWidth) {
return false;
}
for (int j = 0; j < yuvSize.fHeight; ++j) {
for (int i = 0; i < yuvSize.fWidth; ++i) {
// These writes could surely be made more efficient.
uint32_t y = GrColorUnpackR(tempYUV.get()[j * yuvSize.fWidth + i]);
uint32_t u = GrColorUnpackG(tempYUV.get()[j * yuvSize.fWidth + i]);
uint32_t v = GrColorUnpackB(tempYUV.get()[j * yuvSize.fWidth + i]);
uint8_t* yLoc = ((uint8_t*)planes[0]) + j * yRowBytes + i;
uint8_t* uLoc = ((uint8_t*)planes[1]) + j * uRowBytes + i;
uint8_t* vLoc = ((uint8_t*)planes[2]) + j * vRowBytes + i;
*yLoc = y;
*uLoc = u;
*vLoc = v;
}
}
return true;
} else {
SkASSERT(yTex);
if (!yTex->readPixels(0, 0, sizes[0].fWidth, sizes[0].fHeight,
kAlpha_8_GrPixelConfig, planes[0], rowBytes[0])) {
return false;
}
if (uvTex) {