本文整理汇总了C++中PlanarYCbCrImage::AsSharedPlanarYCbCrImage方法的典型用法代码示例。如果您正苦于以下问题:C++ PlanarYCbCrImage::AsSharedPlanarYCbCrImage方法的具体用法?C++ PlanarYCbCrImage::AsSharedPlanarYCbCrImage怎么用?C++ PlanarYCbCrImage::AsSharedPlanarYCbCrImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlanarYCbCrImage
的用法示例。
在下文中一共展示了PlanarYCbCrImage::AsSharedPlanarYCbCrImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: autoLock
bool
ImageClientSingle::UpdateImage(ImageContainer* aContainer,
uint32_t aContentFlags)
{
AutoLockImage autoLock(aContainer);
Image *image = autoLock.GetImage();
if (!image) {
return false;
}
if (mLastPaintedImageSerial == image->GetSerial()) {
return true;
}
if (image->GetFormat() == PLANAR_YCBCR) {
EnsureTextureClient(TEXTURE_YCBCR);
PlanarYCbCrImage* ycbcr = static_cast<PlanarYCbCrImage*>(image);
if (ycbcr->AsSharedPlanarYCbCrImage()) {
AutoLockTextureClient lock(mTextureClient);
SurfaceDescriptor sd;
if (!ycbcr->AsSharedPlanarYCbCrImage()->ToSurfaceDescriptor(sd)) {
return false;
}
if (IsSurfaceDescriptorValid(*lock.GetSurfaceDescriptor())) {
GetForwarder()->DestroySharedSurface(lock.GetSurfaceDescriptor());
}
*lock.GetSurfaceDescriptor() = sd;
} else {
AutoLockYCbCrClient clientLock(mTextureClient);
if (!clientLock.Update(ycbcr)) {
NS_WARNING("failed to update TextureClient (YCbCr)");
return false;
}
}
} else if (image->GetFormat() == SHARED_TEXTURE) {
EnsureTextureClient(TEXTURE_SHARED_GL_EXTERNAL);
SharedTextureImage* sharedImage = static_cast<SharedTextureImage*>(image);
const SharedTextureImage::Data *data = sharedImage->GetData();
SharedTextureDescriptor texture(data->mShareType,
data->mHandle,
data->mSize,
data->mInverted);
mTextureClient->SetDescriptor(SurfaceDescriptor(texture));
} else if (image->GetFormat() == SHARED_RGB) {
EnsureTextureClient(TEXTURE_SHMEM);
nsIntRect rect(0, 0,
image->GetSize().width,
image->GetSize().height);
UpdatePictureRect(rect);
AutoLockTextureClient lock(mTextureClient);
SurfaceDescriptor desc;
if (!static_cast<SharedRGBImage*>(image)->ToSurfaceDescriptor(desc)) {
return false;
}
mTextureClient->SetDescriptor(desc);
} else {
nsRefPtr<gfxASurface> surface = image->GetAsSurface();
MOZ_ASSERT(surface);
EnsureTextureClient(TEXTURE_SHMEM);
nsRefPtr<gfxPattern> pattern = new gfxPattern(surface);
pattern->SetFilter(mFilter);
AutoLockShmemClient clientLock(mTextureClient);
if (!clientLock.Update(image, aContentFlags, pattern)) {
NS_WARNING("failed to update TextureClient");
return false;
}
}
Updated();
if (image->GetFormat() == PLANAR_YCBCR) {
PlanarYCbCrImage* ycbcr = static_cast<PlanarYCbCrImage*>(image);
UpdatePictureRect(ycbcr->GetData()->GetPictureRect());
}
mLastPaintedImageSerial = image->GetSerial();
aContainer->NotifyPaintedImage(image);
return true;
}