本文整理汇总了C++中SurfaceDescriptor::get_SurfaceDescriptorD3D9方法的典型用法代码示例。如果您正苦于以下问题:C++ SurfaceDescriptor::get_SurfaceDescriptorD3D9方法的具体用法?C++ SurfaceDescriptor::get_SurfaceDescriptorD3D9怎么用?C++ SurfaceDescriptor::get_SurfaceDescriptorD3D9使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SurfaceDescriptor
的用法示例。
在下文中一共展示了SurfaceDescriptor::get_SurfaceDescriptorD3D9方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Reset
void
DeprecatedTextureHostSystemMemD3D9::UpdateImpl(const SurfaceDescriptor& aImage,
nsIntRegion *aRegion,
nsIntPoint *aOffset)
{
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TSurfaceDescriptorD3D9);
MOZ_ASSERT(mCompositor, "Must have compositor to update.");
if (!mCompositor->device()) {
return;
}
IDirect3DTexture9* texture =
reinterpret_cast<IDirect3DTexture9*>(aImage.get_SurfaceDescriptorD3D9().texture());
if (!texture) {
Reset();
return;
}
D3DSURFACE_DESC desc;
texture->GetLevelDesc(0, &desc);
HRESULT hr = texture->GetLevelDesc(0, &desc);
if (FAILED(hr)) {
Reset();
return;
}
mSize.width = desc.Width;
mSize.height = desc.Height;
_D3DFORMAT format = desc.Format;
uint32_t bpp = 0;
switch (format) {
case D3DFMT_X8R8G8B8:
mFormat = SurfaceFormat::B8G8R8X8;
bpp = 4;
break;
case D3DFMT_A8R8G8B8:
mFormat = SurfaceFormat::B8G8R8A8;
bpp = 4;
break;
case D3DFMT_A8:
mFormat = SurfaceFormat::A8;
bpp = 1;
break;
default:
NS_ERROR("Bad image format");
}
int32_t maxSize = mCompositor->GetMaxTextureSize();
if (mSize.width <= maxSize && mSize.height <= maxSize) {
mIsTiled = false;
mTexture = TextureToTexture(gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager(),
texture, mSize, format);
if (!mTexture) {
NS_WARNING("Could not upload texture");
Reset();
return;
}
} 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);
RECT d3dTileRect;
d3dTileRect.left = tileRect.x;
d3dTileRect.top = tileRect.y;
d3dTileRect.right = tileRect.XMost();
d3dTileRect.bottom = tileRect.YMost();
D3DLOCKED_RECT lockedRect;
texture->LockRect(0, &lockedRect, &d3dTileRect, 0);
mTileTextures[i] = DataToTexture(gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager(),
reinterpret_cast<unsigned char*>(lockedRect.pBits),
lockedRect.Pitch,
tileRect.Size(),
format,
bpp);
texture->UnlockRect(0);
if (!mTileTextures[i]) {
NS_WARNING("Could not upload texture");
Reset();
return;
}
}
}
}