本文整理汇总了C++中SharedImage::get_YUVImage方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedImage::get_YUVImage方法的具体用法?C++ SharedImage::get_YUVImage怎么用?C++ SharedImage::get_YUVImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedImage
的用法示例。
在下文中一共展示了SharedImage::get_YUVImage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: surf
void
ShadowImageLayerOGL::Swap(const SharedImage& aNewFront,
SharedImage* aNewBack)
{
if (!mDestroyed) {
if (aNewFront.type() == SharedImage::TSharedImageID) {
// We are using ImageBridge protocol. The image data will be queried at render
// time in the parent side.
PRUint64 newID = aNewFront.get_SharedImageID().id();
if (newID != mImageContainerID) {
mImageContainerID = newID;
mImageVersion = 0;
}
} else if (aNewFront.type() == SharedImage::TSurfaceDescriptor) {
AutoOpenSurface surf(OPEN_READ_ONLY, aNewFront.get_SurfaceDescriptor());
gfxIntSize size = surf.Size();
if (mSize != size || !mTexImage ||
mTexImage->GetContentType() != surf.ContentType()) {
Init(aNewFront);
}
// XXX this is always just ridiculously slow
nsIntRegion updateRegion(nsIntRect(0, 0, size.width, size.height));
mTexImage->DirectUpdate(surf.Get(), updateRegion);
} else {
const YUVImage& yuv = aNewFront.get_YUVImage();
UploadSharedYUVToTexture(yuv);
}
}
*aNewBack = aNewFront;
}
示例2: autoSurf
bool
ShadowImageLayerOGL::Init(const SharedImage& aFront)
{
if (aFront.type() == SharedImage::TSurfaceDescriptor) {
SurfaceDescriptor surface = aFront.get_SurfaceDescriptor();
if (surface.type() == SurfaceDescriptor::TSharedTextureDescriptor) {
SharedTextureDescriptor texture = surface.get_SharedTextureDescriptor();
mSize = texture.size();
mSharedHandle = texture.handle();
mShareType = texture.shareType();
mInverted = texture.inverted();
} else {
AutoOpenSurface autoSurf(OPEN_READ_ONLY, surface);
mSize = autoSurf.Size();
mTexImage = gl()->CreateTextureImage(nsIntSize(mSize.width, mSize.height),
autoSurf.ContentType(),
LOCAL_GL_CLAMP_TO_EDGE,
mForceSingleTile
? TextureImage::ForceSingleTile
: TextureImage::NoFlags);
}
} else {
YUVImage yuv = aFront.get_YUVImage();
AutoOpenSurface surfY(OPEN_READ_ONLY, yuv.Ydata());
AutoOpenSurface surfU(OPEN_READ_ONLY, yuv.Udata());
mSize = surfY.Size();
mCbCrSize = surfU.Size();
if (!mYUVTexture[0].IsAllocated()) {
mYUVTexture[0].Allocate(gl());
mYUVTexture[1].Allocate(gl());
mYUVTexture[2].Allocate(gl());
}
NS_ASSERTION(mYUVTexture[0].IsAllocated() &&
mYUVTexture[1].IsAllocated() &&
mYUVTexture[2].IsAllocated(),
"Texture allocation failed!");
gl()->MakeCurrent();
SetClamping(gl(), mYUVTexture[0].GetTextureID());
SetClamping(gl(), mYUVTexture[1].GetTextureID());
SetClamping(gl(), mYUVTexture[2].GetTextureID());
return true;
}
return false;
}
示例3: gl
bool
ShadowImageLayerOGL::Init(const SharedImage& aFront)
{
if (aFront.type() == SharedImage::TSurfaceDescriptor) {
SurfaceDescriptor desc = aFront.get_SurfaceDescriptor();
nsRefPtr<gfxASurface> surf =
ShadowLayerForwarder::OpenDescriptor(desc);
mSize = surf->GetSize();
mTexImage = gl()->CreateTextureImage(nsIntSize(mSize.width, mSize.height),
surf->GetContentType(),
LOCAL_GL_CLAMP_TO_EDGE,
mForceSingleTile
? TextureImage::ForceSingleTile
: TextureImage::NoFlags);
return true;
} else {
YUVImage yuv = aFront.get_YUVImage();
nsRefPtr<gfxSharedImageSurface> surfY =
gfxSharedImageSurface::Open(yuv.Ydata());
nsRefPtr<gfxSharedImageSurface> surfU =
gfxSharedImageSurface::Open(yuv.Udata());
nsRefPtr<gfxSharedImageSurface> surfV =
gfxSharedImageSurface::Open(yuv.Vdata());
mSize = surfY->GetSize();
mCbCrSize = surfU->GetSize();
if (!mYUVTexture[0].IsAllocated()) {
mYUVTexture[0].Allocate(gl());
mYUVTexture[1].Allocate(gl());
mYUVTexture[2].Allocate(gl());
}
NS_ASSERTION(mYUVTexture[0].IsAllocated() &&
mYUVTexture[1].IsAllocated() &&
mYUVTexture[2].IsAllocated(),
"Texture allocation failed!");
gl()->MakeCurrent();
SetClamping(gl(), mYUVTexture[0].GetTextureID());
SetClamping(gl(), mYUVTexture[1].GetTextureID());
SetClamping(gl(), mYUVTexture[2].GetTextureID());
return true;
}
return false;
}
示例4: shmemImage
void
ShadowImageLayerOGL::RenderLayer(int aPreviousFrameBuffer,
const nsIntPoint& aOffset)
{
if (mOGLManager->CompositingDisabled()) {
return;
}
mOGLManager->MakeCurrent();
if (mImageContainerID) {
ImageContainerParent::SetCompositorIDForImage(mImageContainerID,
mOGLManager->GetCompositorID());
uint32_t imgVersion = ImageContainerParent::GetSharedImageVersion(mImageContainerID);
SharedImage* img = ImageContainerParent::GetSharedImage(mImageContainerID);
if (imgVersion != mImageVersion) {
if (img && (img->type() == SharedImage::TYUVImage)) {
UploadSharedYUVToTexture(img->get_YUVImage());
mImageVersion = imgVersion;
} else if (img && (img->type() == SharedImage::TYCbCrImage)) {
ShmemYCbCrImage shmemImage(img->get_YCbCrImage().data(),
img->get_YCbCrImage().offset());
UploadSharedYCbCrToTexture(shmemImage, img->get_YCbCrImage().picture());
mImageVersion = imgVersion;
} else if (img && (img->type() == SharedImage::TRGBImage)) {
UploadSharedRGBToTexture(&img->get_RGBImage().data(),
img->get_RGBImage().picture(),
img->get_RGBImage().rgbFormat());
mImageVersion = imgVersion;
}
}
#ifdef MOZ_WIDGET_GONK
if (img
&& (img->type() == SharedImage::TSurfaceDescriptor)
&& (img->get_SurfaceDescriptor().type() == SurfaceDescriptor::TSurfaceDescriptorGralloc)) {
const SurfaceDescriptorGralloc& desc = img->get_SurfaceDescriptor().get_SurfaceDescriptorGralloc();
sp<GraphicBuffer> graphicBuffer = GrallocBufferActor::GetFrom(desc);
mSize = gfxIntSize(graphicBuffer->getWidth(), graphicBuffer->getHeight());
if (!mExternalBufferTexture.IsAllocated()) {
mExternalBufferTexture.Allocate(gl());
}
gl()->MakeCurrent();
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
gl()->BindExternalBuffer(mExternalBufferTexture.GetTextureID(), graphicBuffer->getNativeBuffer());
mImageVersion = imgVersion;
}
#endif
}
if (mTexImage) {
NS_ASSERTION(mTexImage->GetContentType() != gfxASurface::CONTENT_ALPHA,
"Image layer has alpha image");
ShaderProgramOGL *colorProgram =
mOGLManager->GetProgram(mTexImage->GetShaderProgramType(), GetMaskLayer());
colorProgram->Activate();
colorProgram->SetTextureUnit(0);
colorProgram->SetLayerTransform(GetEffectiveTransform());
colorProgram->SetLayerOpacity(GetEffectiveOpacity());
colorProgram->SetRenderOffset(aOffset);
colorProgram->LoadMask(GetMaskLayer());
mTexImage->SetFilter(mFilter);
mTexImage->BeginTileIteration();
if (gl()->CanUploadNonPowerOfTwo()) {
do {
nsIntRect rect = mTexImage->GetTileRect();
if (!rect.IsEmpty()) {
TextureImage::ScopedBindTextureAndApplyFilter texBind(mTexImage, LOCAL_GL_TEXTURE0);
colorProgram->SetLayerQuadRect(rect);
mOGLManager->BindAndDrawQuad(colorProgram);
}
} while (mTexImage->NextTile());
} else {
do {
nsIntRect rect = mTexImage->GetTileRect();
if (!rect.IsEmpty()) {
TextureImage::ScopedBindTextureAndApplyFilter texBind(mTexImage, LOCAL_GL_TEXTURE0);
colorProgram->SetLayerQuadRect(rect);
// We can't use BindAndDrawQuad because that always uploads the whole texture from 0.0f -> 1.0f
// in x and y. We use BindAndDrawQuadWithTextureRect to actually draw a subrect of the texture
mOGLManager->BindAndDrawQuadWithTextureRect(colorProgram,
nsIntRect(0, 0, mTexImage->GetTileRect().width,
mTexImage->GetTileRect().height),
mTexImage->GetTileRect().Size());
}
} while (mTexImage->NextTile());
}
#ifdef MOZ_WIDGET_GONK
} else if (mExternalBufferTexture.IsAllocated()) {
gl()->MakeCurrent();
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
gl()->fBindTexture(LOCAL_GL_TEXTURE_EXTERNAL, mExternalBufferTexture.GetTextureID());
ShaderProgramOGL *program = mOGLManager->GetProgram(RGBAExternalLayerProgramType, GetMaskLayer());
gl()->ApplyFilterToBoundTexture(LOCAL_GL_TEXTURE_EXTERNAL, mFilter);
//.........这里部分代码省略.........
示例5: texBind
void
ShadowImageLayerOGL::RenderLayer(int aPreviousFrameBuffer,
const nsIntPoint& aOffset)
{
mOGLManager->MakeCurrent();
if (mImageContainerID) {
ImageContainerParent::SetCompositorIDForImage(mImageContainerID,
mOGLManager->GetCompositorID());
PRUint32 imgVersion = ImageContainerParent::GetSharedImageVersion(mImageContainerID);
if (imgVersion != mImageVersion) {
SharedImage* img = ImageContainerParent::GetSharedImage(mImageContainerID);
if (img && (img->type() == SharedImage::TYUVImage)) {
UploadSharedYUVToTexture(img->get_YUVImage());
mImageVersion = imgVersion;
}
}
}
if (mTexImage) {
NS_ASSERTION(mTexImage->GetContentType() != gfxASurface::CONTENT_ALPHA,
"Image layer has alpha image");
ShaderProgramOGL *colorProgram =
mOGLManager->GetProgram(mTexImage->GetShaderProgramType(), GetMaskLayer());
colorProgram->Activate();
colorProgram->SetTextureUnit(0);
colorProgram->SetLayerTransform(GetEffectiveTransform());
colorProgram->SetLayerOpacity(GetEffectiveOpacity());
colorProgram->SetRenderOffset(aOffset);
colorProgram->LoadMask(GetMaskLayer());
mTexImage->SetFilter(mFilter);
mTexImage->BeginTileIteration();
if (gl()->CanUploadNonPowerOfTwo()) {
do {
TextureImage::ScopedBindTextureAndApplyFilter texBind(mTexImage, LOCAL_GL_TEXTURE0);
colorProgram->SetLayerQuadRect(mTexImage->GetTileRect());
mOGLManager->BindAndDrawQuad(colorProgram);
} while (mTexImage->NextTile());
} else {
do {
TextureImage::ScopedBindTextureAndApplyFilter texBind(mTexImage, LOCAL_GL_TEXTURE0);
colorProgram->SetLayerQuadRect(mTexImage->GetTileRect());
// We can't use BindAndDrawQuad because that always uploads the whole texture from 0.0f -> 1.0f
// in x and y. We use BindAndDrawQuadWithTextureRect to actually draw a subrect of the texture
mOGLManager->BindAndDrawQuadWithTextureRect(colorProgram,
nsIntRect(0, 0, mTexImage->GetTileRect().width,
mTexImage->GetTileRect().height),
mTexImage->GetTileRect().Size());
} while (mTexImage->NextTile());
}
} else {
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mYUVTexture[0].GetTextureID());
gl()->ApplyFilterToBoundTexture(mFilter);
gl()->fActiveTexture(LOCAL_GL_TEXTURE1);
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mYUVTexture[1].GetTextureID());
gl()->ApplyFilterToBoundTexture(mFilter);
gl()->fActiveTexture(LOCAL_GL_TEXTURE2);
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mYUVTexture[2].GetTextureID());
gl()->ApplyFilterToBoundTexture(mFilter);
ShaderProgramOGL *yuvProgram = mOGLManager->GetProgram(YCbCrLayerProgramType, GetMaskLayer());
yuvProgram->Activate();
yuvProgram->SetLayerQuadRect(nsIntRect(0, 0,
mPictureRect.width,
mPictureRect.height));
yuvProgram->SetYCbCrTextureUnits(0, 1, 2);
yuvProgram->SetLayerTransform(GetEffectiveTransform());
yuvProgram->SetLayerOpacity(GetEffectiveOpacity());
yuvProgram->SetRenderOffset(aOffset);
yuvProgram->LoadMask(GetMaskLayer());
mOGLManager->BindAndDrawQuadWithTextureRect(yuvProgram,
mPictureRect,
nsIntSize(mSize.width, mSize.height));
}
}