本文整理汇总了C++中android::sp::lock方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::lock方法的具体用法?C++ sp::lock怎么用?C++ sp::lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android::sp
的用法示例。
在下文中一共展示了sp::lock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unlock
static status_t
ConvertOmxYUVFormatToRGB565(android::sp<GraphicBuffer>& aBuffer,
gfx::DataSourceSurface *aSurface,
gfx::DataSourceSurface::MappedSurface *aMappedSurface,
const layers::PlanarYCbCrData& aYcbcrData,
int aOmxFormat)
{
if (!aOmxFormat) {
NS_WARNING("Unknown color format");
return BAD_VALUE;
}
status_t rv;
uint8_t *buffer;
rv = aBuffer->lock(android::GraphicBuffer::USAGE_SW_READ_OFTEN,
reinterpret_cast<void **>(&buffer));
if (rv != OK) {
NS_WARNING("Couldn't lock graphic buffer");
return BAD_VALUE;
}
GraphicBufferAutoUnlock unlock(aBuffer);
uint32_t format = aBuffer->getPixelFormat();
uint32_t width = aSurface->GetSize().width;
uint32_t height = aSurface->GetSize().height;
if (format == GrallocImage::HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO) {
// The Adreno hardware decoder aligns image dimensions to a multiple of 32,
// so we have to account for that here
uint32_t alignedWidth = ALIGN(width, 32);
uint32_t alignedHeight = ALIGN(height, 32);
uint32_t uvOffset = ALIGN(alignedHeight * alignedWidth, 4096);
uint32_t uvStride = 2 * ALIGN(width / 2, 32);
ConvertYVU420SPToRGB565(buffer, alignedWidth,
buffer + uvOffset + 1,
buffer + uvOffset,
uvStride,
aMappedSurface->mData,
width, height);
return OK;
}
if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP) {
uint32_t uvOffset = height * width;
ConvertYVU420SPToRGB565(buffer, width,
buffer + uvOffset + 1,
buffer + uvOffset,
width,
aMappedSurface->mData,
width, height);
return OK;
}
if (format == HAL_PIXEL_FORMAT_YV12) {
// Depend on platforms, it is possible for HW decoder to output YV12 format.
// It means the mData won't be configured during the SetData API because the
// yuv data has already stored in GraphicBuffer. Here we try to confgiure the
// mData if it doesn't contain valid configuration.
layers::PlanarYCbCrData ycbcrData = aYcbcrData;
if (!ycbcrData.mYChannel) {
ycbcrData.mYChannel = buffer;
ycbcrData.mYSkip = 0;
ycbcrData.mYStride = aBuffer->getStride();
ycbcrData.mYSize = aSurface->GetSize();
ycbcrData.mCbSkip = 0;
ycbcrData.mCbCrSize = aSurface->GetSize() / 2;
ycbcrData.mPicSize = aSurface->GetSize();
ycbcrData.mCrChannel = buffer + ycbcrData.mYStride * aBuffer->getHeight();
ycbcrData.mCrSkip = 0;
// Align to 16 bytes boundary
ycbcrData.mCbCrStride = ALIGN(ycbcrData.mYStride / 2, 16);
ycbcrData.mCbChannel = ycbcrData.mCrChannel + (ycbcrData.mCbCrStride * aBuffer->getHeight() / 2);
} else {
// Update channels' address.
// Gralloc buffer could map gralloc buffer only when the buffer is locked.
ycbcrData.mYChannel = buffer;
ycbcrData.mCrChannel = buffer + ycbcrData.mYStride * aBuffer->getHeight();
ycbcrData.mCbChannel = ycbcrData.mCrChannel + (ycbcrData.mCbCrStride * aBuffer->getHeight() / 2);
}
gfx::ConvertYCbCrToRGB(ycbcrData,
aSurface->GetFormat(),
aSurface->GetSize(),
aMappedSurface->mData,
aMappedSurface->mStride);
return OK;
}
android::ColorConverter colorConverter((OMX_COLOR_FORMATTYPE)aOmxFormat,
OMX_COLOR_Format16bitRGB565);
if (!colorConverter.isValid()) {
NS_WARNING("Invalid color conversion");
return BAD_VALUE;
}
uint32_t pixelStride = aMappedSurface->mStride/gfx::BytesPerPixel(gfx::SurfaceFormat::R5G6B5);
rv = colorConverter.convert(buffer, width, height,
0, 0, width - 1, height - 1 /* source crop */,
aMappedSurface->mData, pixelStride, height,
//.........这里部分代码省略.........