本文整理汇总了C++中SurfaceDescriptor::get_SurfaceDescriptorDIB方法的典型用法代码示例。如果您正苦于以下问题:C++ SurfaceDescriptor::get_SurfaceDescriptorDIB方法的具体用法?C++ SurfaceDescriptor::get_SurfaceDescriptorDIB怎么用?C++ SurfaceDescriptor::get_SurfaceDescriptorDIB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SurfaceDescriptor
的用法示例。
在下文中一共展示了SurfaceDescriptor::get_SurfaceDescriptorDIB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToIntSize
void
DeprecatedTextureHostDIB::UpdateImpl(const SurfaceDescriptor& aImage,
nsIntRegion *aRegion,
nsIntPoint *aOffset)
{
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TSurfaceDescriptorDIB);
MOZ_ASSERT(mCompositor, "Must have compositor to update.");
if (!mCompositor->device()) {
return;
}
// We added an extra ref for transport, so we shouldn't AddRef now.
nsRefPtr<gfxWindowsSurface> surf =
dont_AddRef(reinterpret_cast<gfxWindowsSurface*>(aImage.get_SurfaceDescriptorDIB().surface()));
mSize = ToIntSize(surf->GetSize());
uint32_t bpp = 0;
_D3DFORMAT format = D3DFMT_A8R8G8B8;
switch (gfxPlatform::GetPlatform()->OptimalFormatForContent(surf->GetContentType())) {
case gfxImageFormat::RGB24:
mFormat = SurfaceFormat::B8G8R8X8;
format = D3DFMT_X8R8G8B8;
bpp = 4;
break;
case gfxImageFormat::ARGB32:
mFormat = SurfaceFormat::B8G8R8A8;
format = D3DFMT_A8R8G8B8;
bpp = 4;
break;
case gfxImageFormat::A8:
mFormat = SurfaceFormat::A8;
format = D3DFMT_A8;
bpp = 1;
break;
default:
NS_ERROR("Bad image format");
}
int32_t maxSize = mCompositor->GetMaxTextureSize();
if (mSize.width <= maxSize && mSize.height <= maxSize) {
mTexture = SurfaceToTexture(gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager(),
surf, mSize, format);
if (!mTexture) {
NS_WARNING("Could not upload texture");
Reset();
return;
}
mIsTiled = false;
} else {
mIsTiled = true;
uint32_t tileCount = GetRequiredTilesD3D9(mSize.width, maxSize) *
GetRequiredTilesD3D9(mSize.height, maxSize);
mTileTextures.resize(tileCount);
for (uint32_t i = 0; i < tileCount; i++) {
IntRect tileRect = GetTileRect(i);
nsRefPtr<gfxImageSurface> imgSurface = surf->GetAsImageSurface();
unsigned char* data = imgSurface->Data() +
tileRect.y * imgSurface->Stride() +
tileRect.x * bpp;
mTileTextures[i] = DataToTexture(gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager(),
data,
imgSurface->Stride(),
tileRect.Size(),
format,
bpp);
if (!mTileTextures[i]) {
NS_WARNING("Could not upload texture");
Reset();
return;
}
}
}
}