本文整理汇总了C++中SurfaceDescriptor::type方法的典型用法代码示例。如果您正苦于以下问题:C++ SurfaceDescriptor::type方法的具体用法?C++ SurfaceDescriptor::type怎么用?C++ SurfaceDescriptor::type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SurfaceDescriptor
的用法示例。
在下文中一共展示了SurfaceDescriptor::type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestTextureClientYCbCr
// Same as above, for YCbCr surfaces
void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) {
// client allocation
ASSERT_TRUE(client->AsTextureClientYCbCr() != nullptr);
TextureClientYCbCr* texture = client->AsTextureClientYCbCr();
texture->AllocateForYCbCr(ToIntSize(ycbcrData.mYSize),
ToIntSize(ycbcrData.mCbCrSize),
ycbcrData.mStereoMode);
ASSERT_TRUE(client->IsAllocated());
// client painting
texture->UpdateYCbCr(ycbcrData);
ASSERT_TRUE(client->Lock(OPEN_READ_ONLY));
client->Unlock();
// client serialization
SurfaceDescriptor descriptor;
ASSERT_TRUE(client->ToSurfaceDescriptor(descriptor));
ASSERT_NE(descriptor.type(), SurfaceDescriptor::Tnull_t);
// host deserialization
RefPtr<TextureHost> textureHost = CreateBackendIndependentTextureHost(descriptor, nullptr,
client->GetFlags());
RefPtr<BufferTextureHost> host = static_cast<BufferTextureHost*>(textureHost.get());
ASSERT_TRUE(host.get() != nullptr);
ASSERT_EQ(host->GetFlags(), client->GetFlags());
// This will work iff the compositor is not BasicCompositor
ASSERT_EQ(host->GetFormat(), mozilla::gfx::FORMAT_YUV);
// host read
ASSERT_TRUE(host->Lock());
ASSERT_TRUE(host->GetFormat() == mozilla::gfx::FORMAT_YUV);
YCbCrImageDataDeserializer yuvDeserializer(host->GetBuffer());
ASSERT_TRUE(yuvDeserializer.IsValid());
PlanarYCbCrData data;
data.mYChannel = yuvDeserializer.GetYData();
data.mCbChannel = yuvDeserializer.GetCbData();
data.mCrChannel = yuvDeserializer.GetCrData();
data.mYStride = yuvDeserializer.GetYStride();
data.mCbCrStride = yuvDeserializer.GetCbCrStride();
data.mStereoMode = yuvDeserializer.GetStereoMode();
data.mYSize = yuvDeserializer.GetYSize();
data.mCbCrSize = yuvDeserializer.GetCbCrSize();
data.mYSkip = 0;
data.mCbSkip = 0;
data.mCrSkip = 0;
data.mPicSize = data.mYSize;
data.mPicX = 0;
data.mPicY = 0;
AssertYCbCrSurfacesEqual(&ycbcrData, &data);
host->Unlock();
}
示例2: switch
TemporaryRef<TextureHost>
CreateBackendIndependentTextureHost(uint64_t aID,
const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags)
{
RefPtr<TextureHost> result;
switch (aDesc.type()) {
case SurfaceDescriptor::TSurfaceDescriptorShmem: {
const SurfaceDescriptorShmem& descriptor = aDesc.get_SurfaceDescriptorShmem();
result = new ShmemTextureHost(aID,
descriptor.data(),
descriptor.format(),
aDeallocator,
aFlags);
break;
}
case SurfaceDescriptor::TSurfaceDescriptorMemory: {
const SurfaceDescriptorMemory& descriptor = aDesc.get_SurfaceDescriptorMemory();
result = new MemoryTextureHost(aID,
reinterpret_cast<uint8_t*>(descriptor.data()),
descriptor.format(),
aFlags);
break;
}
default: {
NS_WARNING("No backend independent TextureHost for this descriptor type");
}
}
return result;
}
示例3: SurfaceFormatForAndroidPixelFormat
void
GrallocDeprecatedTextureHostOGL::SwapTexturesImpl(const SurfaceDescriptor& aImage,
nsIntRegion*)
{
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TSurfaceDescriptorGralloc);
if (mBuffer) {
// only done for hacky fix in gecko 23 for bug 862324.
RegisterDeprecatedTextureHostAtGrallocBufferActor(nullptr, *mBuffer);
}
const SurfaceDescriptorGralloc& desc = aImage.get_SurfaceDescriptorGralloc();
mGraphicBuffer = GrallocBufferActor::GetFrom(desc);
mIsRBSwapped = desc.isRBSwapped();
mFormat = SurfaceFormatForAndroidPixelFormat(mGraphicBuffer->getPixelFormat(),
mIsRBSwapped);
mTextureTarget = TextureTargetForAndroidPixelFormat(mGraphicBuffer->getPixelFormat());
DeleteTextures();
// only done for hacky fix in gecko 23 for bug 862324.
// Doing this in SetBuffer is not enough, as DeprecatedImageHostBuffered::SwapTextures can
// change the value of *mBuffer without calling SetBuffer again.
RegisterDeprecatedTextureHostAtGrallocBufferActor(this, aImage);
}
示例4: SurfaceDescriptor
bool
ContentHostDoubleBuffered::EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo)
{
RefPtr<TextureHost> newHost = TextureHost::CreateTextureHost(aSurface.type(),
aTextureInfo.mTextureHostFlags,
aTextureInfo.mTextureFlags);
newHost->SetBuffer(new SurfaceDescriptor(aSurface), aAllocator);
Compositor* compositor = GetCompositor();
if (compositor) {
newHost->SetCompositor(compositor);
}
if (aTextureId == TextureFront) {
mNewFrontHost = newHost;
return true;
}
if (aTextureId == TextureBack) {
mBackHost = newHost;
mBufferRect = nsIntRect();
mBufferRotation = nsIntPoint();
return true;
}
NS_ERROR("Bad texture identifier");
return false;
}
示例5: switch
TemporaryRef<TextureHost>
CreateTextureHostD3D11(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags)
{
RefPtr<TextureHost> result;
switch (aDesc.type()) {
case SurfaceDescriptor::TSurfaceDescriptorShmem:
case SurfaceDescriptor::TSurfaceDescriptorMemory: {
result = CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
break;
}
case SurfaceDescriptor::TSurfaceDescriptorD3D10: {
result = new DXGITextureHostD3D11(aFlags,
aDesc.get_SurfaceDescriptorD3D10());
break;
}
case SurfaceDescriptor::TSurfaceStreamDescriptor: {
MOZ_CRASH("Should never hit this.");
}
default: {
NS_WARNING("Unsupported SurfaceDescriptor type");
}
}
return result;
}
示例6: switch
TemporaryRef<TextureHost>
CreateTextureHostOGL(uint64_t aID,
const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags)
{
RefPtr<TextureHost> result;
switch (aDesc.type()) {
case SurfaceDescriptor::TSurfaceDescriptorShmem:
case SurfaceDescriptor::TSurfaceDescriptorMemory: {
result = CreateBackendIndependentTextureHost(aID, aDesc,
aDeallocator, aFlags);
break;
}
case SurfaceDescriptor::TSharedTextureDescriptor: {
const SharedTextureDescriptor& desc = aDesc.get_SharedTextureDescriptor();
result = new SharedTextureHostOGL(aID, aFlags,
desc.shareType(),
desc.handle(),
gfx::ToIntSize(desc.size()),
desc.inverted());
break;
}
default: return nullptr;
}
return result.forget();
}
示例7: Unlock
void
DeprecatedTextureClientDIB::SetDescriptor(const SurfaceDescriptor& aDescriptor)
{
mDescriptor = aDescriptor;
mDrawTarget = nullptr;
if (aDescriptor.type() == SurfaceDescriptor::T__None) {
mSurface = nullptr;
return;
}
MOZ_ASSERT(aDescriptor.type() == SurfaceDescriptor::TSurfaceDescriptorDIB);
Unlock();
mSurface = reinterpret_cast<gfxWindowsSurface*>(
mDescriptor.get_SurfaceDescriptorDIB().surface());
}
示例8:
void
SurfaceStreamHostOGL::SwapTexturesImpl(const SurfaceDescriptor& aImage,
nsIntRegion* aRegion)
{
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TSurfaceStreamDescriptor,
"Invalid descriptor");
}
示例9: TestTextureClientYCbCr
// Same as above, for YCbCr surfaces
void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) {
client->Lock(OpenMode::OPEN_READ_WRITE);
UpdateYCbCrTextureClient(client, ycbcrData);
client->Unlock();
// client serialization
SurfaceDescriptor descriptor;
ASSERT_TRUE(client->ToSurfaceDescriptor(descriptor));
ASSERT_EQ(descriptor.type(), SurfaceDescriptor::TSurfaceDescriptorBuffer);
auto bufferDesc = descriptor.get_SurfaceDescriptorBuffer();
ASSERT_EQ(bufferDesc.desc().type(), BufferDescriptor::TYCbCrDescriptor);
auto ycbcrDesc = bufferDesc.desc().get_YCbCrDescriptor();
ASSERT_EQ(ycbcrDesc.ySize(), ycbcrData.mYSize);
ASSERT_EQ(ycbcrDesc.cbCrSize(), ycbcrData.mCbCrSize);
ASSERT_EQ(ycbcrDesc.stereoMode(), ycbcrData.mStereoMode);
// host deserialization
RefPtr<TextureHost> textureHost = CreateBackendIndependentTextureHost(descriptor, nullptr,
client->GetFlags());
RefPtr<BufferTextureHost> host = static_cast<BufferTextureHost*>(textureHost.get());
ASSERT_TRUE(host.get() != nullptr);
ASSERT_EQ(host->GetFlags(), client->GetFlags());
// host read
if (host->Lock()) {
// This will work iff the compositor is not BasicCompositor
ASSERT_EQ(host->GetFormat(), mozilla::gfx::SurfaceFormat::YUV);
host->Unlock();
}
}
示例10: yuvDeserializer
void
DeprecatedTextureHostYCbCrD3D11::UpdateImpl(const SurfaceDescriptor& aImage,
nsIntRegion* aRegion,
nsIntPoint* aOffset)
{
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TYCbCrImage);
YCbCrImageDataDeserializer yuvDeserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
gfxIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
gfxIntSize size = yuvDeserializer.GetYSize();
D3D11_SUBRESOURCE_DATA initData;
initData.pSysMem = yuvDeserializer.GetYData();
initData.SysMemPitch = yuvDeserializer.GetYStride();
CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_R8_UNORM, size.width, size.height,
1, 1, D3D11_BIND_SHADER_RESOURCE,
D3D11_USAGE_IMMUTABLE);
mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[0]));
initData.pSysMem = yuvDeserializer.GetCbData();
initData.SysMemPitch = yuvDeserializer.GetCbCrStride();
desc.Width = yuvDeserializer.GetCbCrSize().width;
desc.Height = yuvDeserializer.GetCbCrSize().height;
mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[1]));
initData.pSysMem = yuvDeserializer.GetCrData();
mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[2]));
mSize = IntSize(size.width, size.height);
}
示例11: gfxImageSurface
/*static*/ already_AddRefed<gfxASurface>
ShadowLayerForwarder::PlatformOpenDescriptor(OpenMode aMode,
const SurfaceDescriptor& aSurface)
{
SAMPLE_LABEL("ShadowLayerForwarder", "PlatformOpenDescriptor");
if (SurfaceDescriptor::TSurfaceDescriptorGralloc != aSurface.type()) {
return nullptr;
}
sp<GraphicBuffer> buffer =
GrallocBufferActor::GetFrom(aSurface.get_SurfaceDescriptorGralloc());
uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN;
if (OPEN_READ_WRITE == aMode) {
usage |= GRALLOC_USAGE_SW_WRITE_OFTEN;
}
void *vaddr;
DebugOnly<status_t> status = buffer->lock(usage, &vaddr);
// If we fail to lock, we'll just end up aborting anyway.
MOZ_ASSERT(status == OK);
gfxIntSize size = gfxIntSize(buffer->getWidth(), buffer->getHeight());
gfxImageFormat format = ImageFormatForPixelFormat(buffer->getPixelFormat());
long pixelStride = buffer->getStride();
long byteStride = pixelStride * gfxASurface::BytePerPixelFromFormat(format);
nsRefPtr<gfxASurface> surf =
new gfxImageSurface((unsigned char*)vaddr, size, byteStride, format);
return surf->CairoStatus() ? nullptr : surf.forget();
}
示例12: switch
already_AddRefed<TextureHost>
CreateTextureHostD3D11(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags)
{
RefPtr<TextureHost> result;
switch (aDesc.type()) {
case SurfaceDescriptor::TSurfaceDescriptorShmem:
case SurfaceDescriptor::TSurfaceDescriptorMemory: {
result = CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
break;
}
case SurfaceDescriptor::TSurfaceDescriptorD3D10: {
result = new DXGITextureHostD3D11(aFlags,
aDesc.get_SurfaceDescriptorD3D10());
break;
}
case SurfaceDescriptor::TSurfaceDescriptorDXGIYCbCr: {
result = new DXGIYCbCrTextureHostD3D11(aFlags,
aDesc.get_SurfaceDescriptorDXGIYCbCr());
break;
}
default: {
NS_WARNING("Unsupported SurfaceDescriptor type");
}
}
return result.forget();
}
示例13:
void
SharedDeprecatedTextureHostOGL::SwapTexturesImpl(const SurfaceDescriptor& aImage,
nsIntRegion* aRegion)
{
NS_ASSERTION(aImage.type() == SurfaceDescriptor::TSharedTextureDescriptor,
"Invalid descriptor");
SharedTextureDescriptor texture = aImage.get_SharedTextureDescriptor();
SharedTextureHandle newHandle = texture.handle();
nsIntSize size = texture.size();
mSize = gfx::IntSize(size.width, size.height);
if (texture.inverted()) {
mFlags |= TEXTURE_NEEDS_Y_FLIP;
}
if (mSharedHandle && mSharedHandle != newHandle) {
mGL->ReleaseSharedHandle(mShareType, mSharedHandle);
}
mShareType = texture.shareType();
mSharedHandle = newHandle;
GLContext::SharedHandleDetails handleDetails;
if (mSharedHandle && mGL->GetSharedHandleDetails(mShareType, mSharedHandle, handleDetails)) {
mTextureTarget = handleDetails.mTarget;
mFormat = handleDetails.mTextureFormat;
}
}
示例14:
/*static*/ already_AddRefed<gfxASurface>
ShadowLayerForwarder::PlatformOpenDescriptor(const SurfaceDescriptor& aSurface)
{
if (SurfaceDescriptor::TSurfaceDescriptorX11 != aSurface.type()) {
return nsnull;
}
return aSurface.get_SurfaceDescriptorX11().OpenForeign();
}
示例15: Open
/*static*/ already_AddRefed<gfxASurface>
ShadowLayerForwarder::PlatformOpenDescriptor(OpenMode aMode,
const SurfaceDescriptor& aSurface)
{
if (SurfaceDescriptor::TShmem != aSurface.type()) {
return nullptr;
}
return gfxSharedQuartzSurface::Open(aSurface.get_Shmem());
}