2013-08-04 07:46:17 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "TextureD3D9.h"
|
|
|
|
#include "CompositorD3D9.h"
|
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxImageSurface.h"
|
|
|
|
#include "Effects.h"
|
|
|
|
#include "ipc/AutoOpenSurface.h"
|
|
|
|
#include "mozilla/layers/YCbCrImageDataSerializer.h"
|
|
|
|
#include "gfxWindowsPlatform.h"
|
2013-11-21 22:07:58 +00:00
|
|
|
#include "gfx2DGlue.h"
|
2014-01-07 16:20:03 +00:00
|
|
|
#include "gfxUtils.h"
|
2014-01-07 16:20:40 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-08-04 07:46:17 +00:00
|
|
|
|
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
TemporaryRef<DeprecatedTextureHost>
|
|
|
|
CreateDeprecatedTextureHostD3D9(SurfaceDescriptorType aDescriptorType,
|
|
|
|
uint32_t aDeprecatedTextureHostFlags,
|
|
|
|
uint32_t aTextureFlags)
|
|
|
|
{
|
|
|
|
RefPtr<DeprecatedTextureHost> result;
|
|
|
|
if (aDescriptorType == SurfaceDescriptor::TYCbCrImage) {
|
|
|
|
result = new DeprecatedTextureHostYCbCrD3D9();
|
|
|
|
} else if (aDescriptorType == SurfaceDescriptor::TSurfaceDescriptorD3D9) {
|
|
|
|
result = new DeprecatedTextureHostSystemMemD3D9();
|
2013-09-24 01:14:12 +00:00
|
|
|
} else if (aDescriptorType == SurfaceDescriptor::TSurfaceDescriptorDIB) {
|
|
|
|
result = new DeprecatedTextureHostDIB();
|
2013-08-04 07:46:17 +00:00
|
|
|
} else {
|
|
|
|
result = new DeprecatedTextureHostShmemD3D9();
|
|
|
|
}
|
|
|
|
|
|
|
|
result->SetFlags(aTextureFlags);
|
2014-01-07 16:20:11 +00:00
|
|
|
return result;
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
TextureSourceD3D9::~TextureSourceD3D9()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mCreatingDeviceManager ||
|
|
|
|
mCreatingDeviceManager->IsInTextureHostList(this),
|
|
|
|
"Inconsistency in list of texture hosts.");
|
|
|
|
// Remove ourselves from the list of d3d9 texture hosts.
|
|
|
|
if (mPreviousHost) {
|
|
|
|
MOZ_ASSERT(mPreviousHost->mNextHost == this);
|
|
|
|
mPreviousHost->mNextHost = mNextHost;
|
|
|
|
} else if (mCreatingDeviceManager) {
|
|
|
|
mCreatingDeviceManager->RemoveTextureListHead(this);
|
|
|
|
}
|
|
|
|
if (mNextHost) {
|
|
|
|
MOZ_ASSERT(mNextHost->mPreviousHost == this);
|
|
|
|
mNextHost->mPreviousHost = mPreviousHost;
|
|
|
|
}
|
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
|
2014-01-07 16:20:03 +00:00
|
|
|
TemporaryRef<TextureHost>
|
|
|
|
CreateTextureHostD3D9(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::TSurfaceDescriptorD3D9: {
|
2014-01-07 16:20:40 +00:00
|
|
|
result = new TextureHostD3D9(aFlags, aDesc);
|
2014-01-07 16:20:03 +00:00
|
|
|
}
|
|
|
|
case SurfaceDescriptor::TSurfaceDescriptorDIB: {
|
2014-01-07 16:20:40 +00:00
|
|
|
result = new DIBTextureHostD3D9(aFlags, aDesc);
|
2014-01-07 16:20:03 +00:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
NS_WARNING("Unsupported SurfaceDescriptor type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result.forget();
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:20:40 +00:00
|
|
|
static SurfaceFormat
|
|
|
|
D3D9FormatToSurfaceFormat(_D3DFORMAT format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case D3DFMT_X8R8G8B8:
|
2014-01-10 19:06:16 +00:00
|
|
|
return SurfaceFormat::B8G8R8X8;
|
2014-01-07 16:20:40 +00:00
|
|
|
case D3DFMT_A8R8G8B8:
|
2014-01-10 19:06:16 +00:00
|
|
|
return SurfaceFormat::B8G8R8A8;
|
2014-01-07 16:20:40 +00:00
|
|
|
case D3DFMT_A8:
|
2014-01-10 19:06:16 +00:00
|
|
|
return SurfaceFormat::A8;
|
2014-01-07 16:20:40 +00:00
|
|
|
default:
|
|
|
|
NS_ERROR("Bad texture format");
|
|
|
|
}
|
2014-01-10 19:06:16 +00:00
|
|
|
return SurfaceFormat::UNKNOWN;
|
2014-01-07 16:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static _D3DFORMAT
|
|
|
|
SurfaceFormatToD3D9Format(SurfaceFormat format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
2014-01-10 19:06:16 +00:00
|
|
|
case SurfaceFormat::B8G8R8X8:
|
2014-01-07 16:20:40 +00:00
|
|
|
return D3DFMT_X8R8G8B8;
|
2014-01-10 19:06:16 +00:00
|
|
|
case SurfaceFormat::B8G8R8A8:
|
2014-01-07 16:20:40 +00:00
|
|
|
return D3DFMT_A8R8G8B8;
|
2014-01-10 19:06:16 +00:00
|
|
|
case SurfaceFormat::A8:
|
2014-01-07 16:20:40 +00:00
|
|
|
return D3DFMT_A8;
|
|
|
|
default:
|
|
|
|
NS_ERROR("Bad texture format");
|
|
|
|
}
|
|
|
|
return D3DFMT_A8R8G8B8;
|
|
|
|
}
|
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
CompositingRenderTargetD3D9::CompositingRenderTargetD3D9(IDirect3DTexture9* aTexture,
|
|
|
|
SurfaceInitMode aInit,
|
2013-11-07 09:53:08 +00:00
|
|
|
const gfx::IntRect& aRect)
|
|
|
|
: CompositingRenderTarget(aRect.TopLeft())
|
|
|
|
, mInitMode(aInit)
|
2013-08-04 07:46:17 +00:00
|
|
|
, mInitialized(false)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CompositingRenderTargetD3D9);
|
|
|
|
MOZ_ASSERT(aTexture);
|
|
|
|
|
2014-01-07 16:20:03 +00:00
|
|
|
mTexture = aTexture;
|
|
|
|
HRESULT hr = mTexture->GetSurfaceLevel(0, getter_AddRefs(mSurface));
|
2013-08-04 07:46:17 +00:00
|
|
|
NS_ASSERTION(mSurface, "Couldn't create surface for texture");
|
2013-11-07 09:53:08 +00:00
|
|
|
TextureSourceD3D9::SetSize(aRect.Size());
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CompositingRenderTargetD3D9::CompositingRenderTargetD3D9(IDirect3DSurface9* aSurface,
|
|
|
|
SurfaceInitMode aInit,
|
2013-11-07 09:53:08 +00:00
|
|
|
const gfx::IntRect& aRect)
|
|
|
|
: CompositingRenderTarget(aRect.TopLeft())
|
|
|
|
, mSurface(aSurface)
|
2013-08-04 07:46:17 +00:00
|
|
|
, mInitMode(aInit)
|
|
|
|
, mInitialized(false)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CompositingRenderTargetD3D9);
|
|
|
|
MOZ_ASSERT(mSurface);
|
2013-11-07 09:53:08 +00:00
|
|
|
TextureSourceD3D9::SetSize(aRect.Size());
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CompositingRenderTargetD3D9::~CompositingRenderTargetD3D9()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CompositingRenderTargetD3D9);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompositingRenderTargetD3D9::BindRenderTarget(IDirect3DDevice9* aDevice)
|
|
|
|
{
|
|
|
|
aDevice->SetRenderTarget(0, mSurface);
|
|
|
|
if (!mInitialized &&
|
|
|
|
mInitMode == INIT_MODE_CLEAR) {
|
|
|
|
mInitialized = true;
|
|
|
|
aDevice->Clear(0, 0, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 0), 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IntSize
|
|
|
|
CompositingRenderTargetD3D9::GetSize() const
|
|
|
|
{
|
|
|
|
return TextureSourceD3D9::GetSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
DeprecatedTextureHostD3D9::DeprecatedTextureHostD3D9()
|
|
|
|
: mIsTiled(false)
|
|
|
|
, mCurrentTile(0)
|
|
|
|
, mIterating(false)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DeprecatedTextureHostD3D9);
|
|
|
|
}
|
|
|
|
|
|
|
|
DeprecatedTextureHostD3D9::~DeprecatedTextureHostD3D9()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DeprecatedTextureHostD3D9);
|
|
|
|
}
|
|
|
|
|
|
|
|
IntSize
|
|
|
|
DeprecatedTextureHostD3D9::GetSize() const
|
|
|
|
{
|
|
|
|
if (mIterating) {
|
2013-11-21 22:07:56 +00:00
|
|
|
IntRect rect = GetTileRect(mCurrentTile);
|
|
|
|
return rect.Size();
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
return TextureSourceD3D9::GetSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect
|
|
|
|
DeprecatedTextureHostD3D9::GetTileRect()
|
|
|
|
{
|
|
|
|
IntRect rect = GetTileRect(mCurrentTile);
|
|
|
|
return nsIntRect(rect.x, rect.y, rect.width, rect.height);
|
|
|
|
}
|
|
|
|
|
2013-11-18 02:06:23 +00:00
|
|
|
static uint32_t GetRequiredTilesD3D9(uint32_t aSize, uint32_t aMaxSize)
|
2013-08-04 07:46:17 +00:00
|
|
|
{
|
|
|
|
uint32_t requiredTiles = aSize / aMaxSize;
|
|
|
|
if (aSize % aMaxSize) {
|
|
|
|
requiredTiles++;
|
|
|
|
}
|
|
|
|
return requiredTiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DeprecatedTextureHostD3D9::SetCompositor(Compositor* aCompositor)
|
|
|
|
{
|
|
|
|
mCompositor = static_cast<CompositorD3D9*>(aCompositor);
|
|
|
|
}
|
|
|
|
|
2013-09-24 01:14:11 +00:00
|
|
|
/**
|
|
|
|
* Helper method for DataToTexture and SurfaceToTexture.
|
2013-11-21 22:07:56 +00:00
|
|
|
* The last three params are out params.
|
|
|
|
* Returns the created texture, or null if we fail.
|
2013-09-24 01:14:11 +00:00
|
|
|
*/
|
2013-11-21 22:07:56 +00:00
|
|
|
TemporaryRef<IDirect3DTexture9>
|
|
|
|
TextureSourceD3D9::InitTextures(DeviceManagerD3D9* aDeviceManager,
|
|
|
|
const IntSize &aSize,
|
|
|
|
_D3DFORMAT aFormat,
|
|
|
|
RefPtr<IDirect3DSurface9>& aSurface,
|
|
|
|
D3DLOCKED_RECT& aLockedRect)
|
2013-08-04 07:46:17 +00:00
|
|
|
{
|
2013-11-21 22:07:56 +00:00
|
|
|
if (!aDeviceManager) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
RefPtr<IDirect3DTexture9> result;
|
2013-11-21 22:07:57 +00:00
|
|
|
// D3D9Ex doesn't support managed textures and we don't want the hassle even
|
|
|
|
// if we don't have Ex. We could use dynamic textures
|
|
|
|
// here but since Images are immutable that probably isn't such a great
|
|
|
|
// idea.
|
|
|
|
result = aDeviceManager->CreateTexture(aSize, aFormat, D3DPOOL_DEFAULT, this);
|
|
|
|
if (!result) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
|
2013-11-21 22:07:57 +00:00
|
|
|
RefPtr<IDirect3DTexture9> tmpTexture =
|
|
|
|
aDeviceManager->CreateTexture(aSize, aFormat, D3DPOOL_SYSTEMMEM, this);
|
|
|
|
if (!tmpTexture) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
|
2013-11-21 22:07:57 +00:00
|
|
|
tmpTexture->GetSurfaceLevel(0, byRef(aSurface));
|
2014-01-06 15:06:04 +00:00
|
|
|
aSurface->LockRect(&aLockedRect, nullptr, 0);
|
2013-11-21 22:07:57 +00:00
|
|
|
if (!aLockedRect.pBits) {
|
|
|
|
NS_WARNING("Could not lock surface");
|
|
|
|
return nullptr;
|
2013-09-24 01:14:11 +00:00
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
return result;
|
2013-09-24 01:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper method for DataToTexture and SurfaceToTexture.
|
|
|
|
*/
|
|
|
|
static void
|
2013-11-21 22:07:56 +00:00
|
|
|
FinishTextures(DeviceManagerD3D9* aDeviceManager,
|
|
|
|
IDirect3DTexture9* aTexture,
|
|
|
|
IDirect3DSurface9* aSurface)
|
2013-09-24 01:14:11 +00:00
|
|
|
{
|
2013-11-21 22:07:56 +00:00
|
|
|
if (!aDeviceManager) {
|
|
|
|
return;
|
|
|
|
}
|
2013-11-21 22:07:57 +00:00
|
|
|
|
|
|
|
aSurface->UnlockRect();
|
|
|
|
nsRefPtr<IDirect3DSurface9> dstSurface;
|
|
|
|
aTexture->GetSurfaceLevel(0, getter_AddRefs(dstSurface));
|
2014-01-06 15:06:04 +00:00
|
|
|
aDeviceManager->device()->UpdateSurface(aSurface, nullptr, dstSurface,
|
|
|
|
nullptr);
|
2013-09-24 01:14:11 +00:00
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
TemporaryRef<IDirect3DTexture9>
|
|
|
|
TextureSourceD3D9::DataToTexture(DeviceManagerD3D9* aDeviceManager,
|
|
|
|
unsigned char *aData,
|
|
|
|
int aStride,
|
|
|
|
const IntSize &aSize,
|
|
|
|
_D3DFORMAT aFormat,
|
|
|
|
uint32_t aBPP)
|
2013-09-24 01:14:11 +00:00
|
|
|
{
|
|
|
|
RefPtr<IDirect3DSurface9> surface;
|
|
|
|
D3DLOCKED_RECT lockedRect;
|
2013-11-21 22:07:56 +00:00
|
|
|
RefPtr<IDirect3DTexture9> texture = InitTextures(aDeviceManager, aSize, aFormat,
|
|
|
|
surface, lockedRect);
|
|
|
|
if (!texture) {
|
2013-09-24 01:14:11 +00:00
|
|
|
return nullptr;
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t width = aSize.width * aBPP;
|
|
|
|
|
|
|
|
for (int y = 0; y < aSize.height; y++) {
|
|
|
|
memcpy((char*)lockedRect.pBits + lockedRect.Pitch * y,
|
|
|
|
aData + aStride * y,
|
|
|
|
width);
|
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
FinishTextures(aDeviceManager, texture, surface);
|
2013-08-04 07:46:17 +00:00
|
|
|
|
2014-01-07 16:20:11 +00:00
|
|
|
return texture;
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:58 +00:00
|
|
|
void
|
|
|
|
DeprecatedTextureHostD3D9::Reset()
|
|
|
|
{
|
|
|
|
mSize.width = 0;
|
|
|
|
mSize.height = 0;
|
2014-01-07 16:20:03 +00:00
|
|
|
mTexture = nullptr;
|
2013-11-21 22:07:58 +00:00
|
|
|
mIsTiled = false;
|
|
|
|
}
|
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
void
|
|
|
|
DeprecatedTextureHostShmemD3D9::UpdateImpl(const SurfaceDescriptor& aImage,
|
|
|
|
nsIntRegion *aRegion,
|
|
|
|
nsIntPoint *aOffset)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TShmem ||
|
|
|
|
aImage.type() == SurfaceDescriptor::TMemoryImage);
|
|
|
|
MOZ_ASSERT(mCompositor, "Must have compositor to update.");
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
if (!mCompositor->device()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
AutoOpenSurface openSurf(OPEN_READ_ONLY, aImage);
|
|
|
|
|
|
|
|
nsRefPtr<gfxImageSurface> surf = openSurf.GetAsImage();
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
mSize = ToIntSize(surf->GetSize());
|
2013-08-04 07:46:17 +00:00
|
|
|
|
|
|
|
uint32_t bpp = 0;
|
|
|
|
|
|
|
|
_D3DFORMAT format = D3DFMT_A8R8G8B8;
|
|
|
|
switch (surf->Format()) {
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxImageFormat::RGB24:
|
2014-01-10 19:06:16 +00:00
|
|
|
mFormat = SurfaceFormat::B8G8R8X8;
|
2013-08-04 07:46:17 +00:00
|
|
|
format = D3DFMT_X8R8G8B8;
|
|
|
|
bpp = 4;
|
|
|
|
break;
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxImageFormat::ARGB32:
|
2014-01-10 19:06:16 +00:00
|
|
|
mFormat = SurfaceFormat::B8G8R8A8;
|
2013-08-04 07:46:17 +00:00
|
|
|
format = D3DFMT_A8R8G8B8;
|
|
|
|
bpp = 4;
|
|
|
|
break;
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxImageFormat::A8:
|
2014-01-10 19:06:16 +00:00
|
|
|
mFormat = SurfaceFormat::A8;
|
2013-08-04 07:46:17 +00:00
|
|
|
format = D3DFMT_A8;
|
|
|
|
bpp = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("Bad image format");
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t maxSize = mCompositor->GetMaxTextureSize();
|
2013-11-21 22:07:56 +00:00
|
|
|
if (mSize.width <= maxSize && mSize.height <= maxSize) {
|
2014-01-07 16:20:03 +00:00
|
|
|
mTexture = DataToTexture(gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager(),
|
|
|
|
surf->Data(), surf->Stride(),
|
|
|
|
mSize, format, bpp);
|
|
|
|
if (!mTexture) {
|
2013-11-21 22:07:56 +00:00
|
|
|
NS_WARNING("Could not upload texture");
|
2013-11-21 22:07:58 +00:00
|
|
|
Reset();
|
2013-11-21 22:07:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
mIsTiled = false;
|
|
|
|
} else {
|
|
|
|
mIsTiled = true;
|
2013-11-21 22:07:56 +00:00
|
|
|
uint32_t tileCount = GetRequiredTilesD3D9(mSize.width, maxSize) *
|
|
|
|
GetRequiredTilesD3D9(mSize.height, maxSize);
|
2013-08-04 07:46:17 +00:00
|
|
|
mTileTextures.resize(tileCount);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < tileCount; i++) {
|
|
|
|
IntRect tileRect = GetTileRect(i);
|
|
|
|
unsigned char* data = surf->Data() +
|
|
|
|
tileRect.y * surf->Stride() +
|
|
|
|
tileRect.x * bpp;
|
2013-11-21 22:07:56 +00:00
|
|
|
mTileTextures[i] = DataToTexture(gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager(),
|
2013-08-04 07:46:17 +00:00
|
|
|
data,
|
|
|
|
surf->Stride(),
|
2013-11-21 22:07:56 +00:00
|
|
|
tileRect.Size(),
|
2013-08-04 07:46:17 +00:00
|
|
|
format,
|
|
|
|
bpp);
|
2013-11-21 22:07:56 +00:00
|
|
|
if (!mTileTextures[i]) {
|
|
|
|
NS_WARNING("Could not upload texture");
|
2013-11-21 22:07:58 +00:00
|
|
|
Reset();
|
2013-11-21 22:07:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IntRect
|
|
|
|
DeprecatedTextureHostD3D9::GetTileRect(uint32_t aID) const
|
|
|
|
{
|
|
|
|
uint32_t maxSize = mCompositor->GetMaxTextureSize();
|
2013-11-18 02:06:23 +00:00
|
|
|
uint32_t horizontalTiles = GetRequiredTilesD3D9(mSize.width, maxSize);
|
|
|
|
uint32_t verticalTiles = GetRequiredTilesD3D9(mSize.height, maxSize);
|
2013-08-04 07:46:17 +00:00
|
|
|
|
|
|
|
uint32_t verticalTile = aID / horizontalTiles;
|
|
|
|
uint32_t horizontalTile = aID % horizontalTiles;
|
|
|
|
|
|
|
|
return IntRect(horizontalTile * maxSize,
|
|
|
|
verticalTile * maxSize,
|
|
|
|
horizontalTile < (horizontalTiles - 1) ? maxSize : mSize.width % maxSize,
|
|
|
|
verticalTile < (verticalTiles - 1) ? maxSize : mSize.height % maxSize);
|
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
DeprecatedTextureHostYCbCrD3D9::DeprecatedTextureHostYCbCrD3D9()
|
2014-01-07 16:20:03 +00:00
|
|
|
: mCompositor(nullptr)
|
2013-11-21 22:07:56 +00:00
|
|
|
{
|
2014-01-10 19:06:16 +00:00
|
|
|
mFormat = SurfaceFormat::YUV;
|
2014-01-07 16:20:03 +00:00
|
|
|
|
|
|
|
MOZ_COUNT_CTOR(DeprecatedTextureHostYCbCrD3D9);
|
2013-11-21 22:07:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DeprecatedTextureHostYCbCrD3D9::~DeprecatedTextureHostYCbCrD3D9()
|
|
|
|
{
|
2014-01-07 16:20:03 +00:00
|
|
|
MOZ_COUNT_DTOR(DeprecatedTextureHostYCbCrD3D9);
|
2013-11-21 22:07:56 +00:00
|
|
|
}
|
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
void
|
|
|
|
DeprecatedTextureHostYCbCrD3D9::SetCompositor(Compositor* aCompositor)
|
|
|
|
{
|
2013-11-21 22:07:56 +00:00
|
|
|
mCompositor = static_cast<CompositorD3D9*>(aCompositor);
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IntSize
|
|
|
|
DeprecatedTextureHostYCbCrD3D9::GetSize() const
|
|
|
|
{
|
2014-01-07 16:20:03 +00:00
|
|
|
return mSize;
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DeprecatedTextureHostYCbCrD3D9::UpdateImpl(const SurfaceDescriptor& aImage,
|
|
|
|
nsIntRegion *aRegion,
|
|
|
|
nsIntPoint *aOffset)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TYCbCrImage);
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
if (!mCompositor->device()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
YCbCrImageDataDeserializer yuvDeserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
|
|
|
|
|
2013-12-20 16:46:30 +00:00
|
|
|
mSize = yuvDeserializer.GetYSize();
|
|
|
|
IntSize cbCrSize = yuvDeserializer.GetCbCrSize();
|
2013-08-04 07:46:17 +00:00
|
|
|
mStereoMode = yuvDeserializer.GetStereoMode();
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
DeviceManagerD3D9* deviceManager = gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager();
|
2014-01-07 16:20:03 +00:00
|
|
|
RefPtr<DataTextureSource> srcY;
|
2014-01-07 16:20:11 +00:00
|
|
|
RefPtr<DataTextureSource> srcCb;
|
|
|
|
RefPtr<DataTextureSource> srcCr;
|
2014-01-07 16:20:03 +00:00
|
|
|
if (!mFirstSource) {
|
2014-01-10 19:06:16 +00:00
|
|
|
srcY = new DataTextureSourceD3D9(SurfaceFormat::A8, mCompositor,
|
2014-01-07 16:20:11 +00:00
|
|
|
TEXTURE_DISALLOW_BIGIMAGE, mStereoMode);
|
2014-01-10 19:06:16 +00:00
|
|
|
srcCb = new DataTextureSourceD3D9(SurfaceFormat::A8, mCompositor,
|
2014-01-07 16:20:11 +00:00
|
|
|
TEXTURE_DISALLOW_BIGIMAGE, mStereoMode);
|
2014-01-10 19:06:16 +00:00
|
|
|
srcCr = new DataTextureSourceD3D9(SurfaceFormat::A8, mCompositor,
|
2014-01-07 16:20:11 +00:00
|
|
|
TEXTURE_DISALLOW_BIGIMAGE, mStereoMode);
|
2014-01-07 16:20:03 +00:00
|
|
|
mFirstSource = srcY;
|
2014-01-07 16:20:11 +00:00
|
|
|
srcY->SetNextSibling(srcCb);
|
|
|
|
srcCb->SetNextSibling(srcCr);
|
2014-01-07 16:20:03 +00:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(mFirstSource->GetNextSibling());
|
|
|
|
MOZ_ASSERT(mFirstSource->GetNextSibling()->GetNextSibling());
|
|
|
|
srcY = mFirstSource;
|
2014-01-07 16:20:11 +00:00
|
|
|
srcCb = mFirstSource->GetNextSibling()->AsDataTextureSource();
|
|
|
|
srcCr = mFirstSource->GetNextSibling()->GetNextSibling()->AsDataTextureSource();
|
2014-01-07 16:20:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<DataSourceSurface> wrapperY =
|
|
|
|
Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetYData(),
|
|
|
|
yuvDeserializer.GetYStride(),
|
|
|
|
yuvDeserializer.GetYSize(),
|
2014-01-10 19:06:16 +00:00
|
|
|
SurfaceFormat::A8);
|
2014-01-07 16:20:03 +00:00
|
|
|
RefPtr<DataSourceSurface> wrapperCb =
|
|
|
|
Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCbData(),
|
|
|
|
yuvDeserializer.GetCbCrStride(),
|
|
|
|
yuvDeserializer.GetCbCrSize(),
|
2014-01-10 19:06:16 +00:00
|
|
|
SurfaceFormat::A8);
|
2014-01-07 16:20:03 +00:00
|
|
|
RefPtr<DataSourceSurface> wrapperCr =
|
|
|
|
Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCrData(),
|
|
|
|
yuvDeserializer.GetCbCrStride(),
|
|
|
|
yuvDeserializer.GetCbCrSize(),
|
2014-01-10 19:06:16 +00:00
|
|
|
SurfaceFormat::A8);
|
2014-01-07 16:20:11 +00:00
|
|
|
// We don't support partial updates for YCbCr textures
|
2014-01-07 16:20:03 +00:00
|
|
|
NS_ASSERTION(!aRegion, "Unsupported partial updates for YCbCr textures");
|
2014-01-07 16:20:11 +00:00
|
|
|
if (!srcY->Update(wrapperY) ||
|
|
|
|
!srcCb->Update(wrapperCb) ||
|
|
|
|
!srcCr->Update(wrapperCr)) {
|
2014-01-07 16:20:03 +00:00
|
|
|
NS_WARNING("failed to update the DataTextureSource");
|
|
|
|
mSize.width = 0;
|
|
|
|
mSize.height = 0;
|
|
|
|
mFirstSource = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
TemporaryRef<IDirect3DTexture9>
|
|
|
|
TextureSourceD3D9::TextureToTexture(DeviceManagerD3D9* aDeviceManager,
|
|
|
|
IDirect3DTexture9* aTexture,
|
|
|
|
const IntSize& aSize,
|
|
|
|
_D3DFORMAT aFormat)
|
2013-08-04 07:46:17 +00:00
|
|
|
{
|
2013-11-25 21:54:13 +00:00
|
|
|
if (!aDeviceManager) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
RefPtr<IDirect3DTexture9> texture =
|
|
|
|
aDeviceManager->CreateTexture(aSize, aFormat, D3DPOOL_DEFAULT, this);
|
|
|
|
if (!texture) {
|
2013-08-04 07:46:17 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
HRESULT hr = aDeviceManager->device()->UpdateTexture(aTexture, texture);
|
2013-08-04 07:46:17 +00:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:20:11 +00:00
|
|
|
return texture;
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DeprecatedTextureHostSystemMemD3D9::UpdateImpl(const SurfaceDescriptor& aImage,
|
|
|
|
nsIntRegion *aRegion,
|
|
|
|
nsIntPoint *aOffset)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TSurfaceDescriptorD3D9);
|
|
|
|
MOZ_ASSERT(mCompositor, "Must have compositor to update.");
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
if (!mCompositor->device()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
IDirect3DTexture9* texture =
|
|
|
|
reinterpret_cast<IDirect3DTexture9*>(aImage.get_SurfaceDescriptorD3D9().texture());
|
|
|
|
|
|
|
|
if (!texture) {
|
2013-11-21 22:07:58 +00:00
|
|
|
Reset();
|
2013-08-04 07:46:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
D3DSURFACE_DESC desc;
|
|
|
|
texture->GetLevelDesc(0, &desc);
|
2013-11-21 22:07:58 +00:00
|
|
|
HRESULT hr = texture->GetLevelDesc(0, &desc);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
Reset();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
mSize.width = desc.Width;
|
|
|
|
mSize.height = desc.Height;
|
|
|
|
|
|
|
|
_D3DFORMAT format = desc.Format;
|
|
|
|
uint32_t bpp = 0;
|
|
|
|
switch (format) {
|
|
|
|
case D3DFMT_X8R8G8B8:
|
2014-01-10 19:06:16 +00:00
|
|
|
mFormat = SurfaceFormat::B8G8R8X8;
|
2013-08-04 07:46:17 +00:00
|
|
|
bpp = 4;
|
|
|
|
break;
|
|
|
|
case D3DFMT_A8R8G8B8:
|
2014-01-10 19:06:16 +00:00
|
|
|
mFormat = SurfaceFormat::B8G8R8A8;
|
2013-08-04 07:46:17 +00:00
|
|
|
bpp = 4;
|
|
|
|
break;
|
|
|
|
case D3DFMT_A8:
|
2014-01-10 19:06:16 +00:00
|
|
|
mFormat = SurfaceFormat::A8;
|
2013-08-04 07:46:17 +00:00
|
|
|
bpp = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("Bad image format");
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t maxSize = mCompositor->GetMaxTextureSize();
|
|
|
|
if (mSize.width <= maxSize && mSize.height <= maxSize) {
|
|
|
|
mIsTiled = false;
|
|
|
|
|
2014-01-07 16:20:03 +00:00
|
|
|
mTexture = TextureToTexture(gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager(),
|
|
|
|
texture, mSize, format);
|
|
|
|
if (!mTexture) {
|
2013-11-21 22:07:56 +00:00
|
|
|
NS_WARNING("Could not upload texture");
|
2013-11-21 22:07:58 +00:00
|
|
|
Reset();
|
2013-11-21 22:07:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
} else {
|
|
|
|
mIsTiled = true;
|
|
|
|
|
2013-11-18 02:06:23 +00:00
|
|
|
uint32_t tileCount = GetRequiredTilesD3D9(mSize.width, maxSize) *
|
|
|
|
GetRequiredTilesD3D9(mSize.height, maxSize);
|
2013-08-04 07:46:17 +00:00
|
|
|
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);
|
2013-11-21 22:07:56 +00:00
|
|
|
mTileTextures[i] = DataToTexture(gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager(),
|
2013-08-04 07:46:17 +00:00
|
|
|
reinterpret_cast<unsigned char*>(lockedRect.pBits),
|
|
|
|
lockedRect.Pitch,
|
2013-11-21 22:07:56 +00:00
|
|
|
tileRect.Size(),
|
2013-08-04 07:46:17 +00:00
|
|
|
format,
|
|
|
|
bpp);
|
|
|
|
texture->UnlockRect(0);
|
2013-09-24 01:14:11 +00:00
|
|
|
if (!mTileTextures[i]) {
|
|
|
|
NS_WARNING("Could not upload texture");
|
2013-11-21 22:07:58 +00:00
|
|
|
Reset();
|
2013-09-24 01:14:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
TemporaryRef<IDirect3DTexture9>
|
|
|
|
TextureSourceD3D9::SurfaceToTexture(DeviceManagerD3D9* aDeviceManager,
|
|
|
|
gfxWindowsSurface* aSurface,
|
|
|
|
const IntSize& aSize,
|
|
|
|
_D3DFORMAT aFormat)
|
2013-09-24 01:14:11 +00:00
|
|
|
{
|
|
|
|
RefPtr<IDirect3DSurface9> surface;
|
|
|
|
D3DLOCKED_RECT lockedRect;
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
RefPtr<IDirect3DTexture9> texture = InitTextures(aDeviceManager, aSize, aFormat,
|
|
|
|
surface, lockedRect);
|
|
|
|
if (!texture) {
|
2013-09-24 01:14:11 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<gfxImageSurface> imgSurface =
|
|
|
|
new gfxImageSurface(reinterpret_cast<unsigned char*>(lockedRect.pBits),
|
|
|
|
gfxIntSize(aSize.width, aSize.height),
|
|
|
|
lockedRect.Pitch,
|
|
|
|
gfxPlatform::GetPlatform()->OptimalFormatForContent(aSurface->GetContentType()));
|
|
|
|
|
|
|
|
nsRefPtr<gfxContext> context = new gfxContext(imgSurface);
|
|
|
|
context->SetSource(aSurface);
|
|
|
|
context->SetOperator(gfxContext::OPERATOR_SOURCE);
|
|
|
|
context->Paint();
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
FinishTextures(aDeviceManager, texture, surface);
|
2013-09-24 01:14:11 +00:00
|
|
|
|
2014-01-07 16:20:11 +00:00
|
|
|
return texture;
|
2013-09-24 01:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DeprecatedTextureHostDIB::UpdateImpl(const SurfaceDescriptor& aImage,
|
|
|
|
nsIntRegion *aRegion,
|
|
|
|
nsIntPoint *aOffset)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TSurfaceDescriptorDIB);
|
|
|
|
MOZ_ASSERT(mCompositor, "Must have compositor to update.");
|
|
|
|
|
2013-09-24 01:14:12 +00:00
|
|
|
if (!mCompositor->device()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We added an extra ref for transport, so we shouldn't AddRef now.
|
2013-09-24 01:14:11 +00:00
|
|
|
nsRefPtr<gfxWindowsSurface> surf =
|
2013-09-24 01:14:12 +00:00
|
|
|
dont_AddRef(reinterpret_cast<gfxWindowsSurface*>(aImage.get_SurfaceDescriptorDIB().surface()));
|
2013-09-24 01:14:11 +00:00
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
mSize = ToIntSize(surf->GetSize());
|
2013-09-24 01:14:11 +00:00
|
|
|
|
|
|
|
uint32_t bpp = 0;
|
|
|
|
|
|
|
|
_D3DFORMAT format = D3DFMT_A8R8G8B8;
|
|
|
|
switch (gfxPlatform::GetPlatform()->OptimalFormatForContent(surf->GetContentType())) {
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxImageFormat::RGB24:
|
2014-01-10 19:06:16 +00:00
|
|
|
mFormat = SurfaceFormat::B8G8R8X8;
|
2013-09-24 01:14:11 +00:00
|
|
|
format = D3DFMT_X8R8G8B8;
|
|
|
|
bpp = 4;
|
|
|
|
break;
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxImageFormat::ARGB32:
|
2014-01-10 19:06:16 +00:00
|
|
|
mFormat = SurfaceFormat::B8G8R8A8;
|
2013-09-24 01:14:11 +00:00
|
|
|
format = D3DFMT_A8R8G8B8;
|
|
|
|
bpp = 4;
|
|
|
|
break;
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxImageFormat::A8:
|
2014-01-10 19:06:16 +00:00
|
|
|
mFormat = SurfaceFormat::A8;
|
2013-09-24 01:14:11 +00:00
|
|
|
format = D3DFMT_A8;
|
|
|
|
bpp = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("Bad image format");
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t maxSize = mCompositor->GetMaxTextureSize();
|
2013-11-21 22:07:56 +00:00
|
|
|
if (mSize.width <= maxSize && mSize.height <= maxSize) {
|
2014-01-07 16:20:03 +00:00
|
|
|
mTexture = SurfaceToTexture(gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager(),
|
|
|
|
surf, mSize, format);
|
|
|
|
if (!mTexture) {
|
2013-11-21 22:07:56 +00:00
|
|
|
NS_WARNING("Could not upload texture");
|
2013-11-21 22:07:58 +00:00
|
|
|
Reset();
|
2013-11-21 22:07:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-09-24 01:14:11 +00:00
|
|
|
mIsTiled = false;
|
|
|
|
} else {
|
|
|
|
mIsTiled = true;
|
|
|
|
|
2013-11-18 02:06:23 +00:00
|
|
|
uint32_t tileCount = GetRequiredTilesD3D9(mSize.width, maxSize) *
|
|
|
|
GetRequiredTilesD3D9(mSize.height, maxSize);
|
2013-09-24 01:14:11 +00:00
|
|
|
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;
|
2013-11-21 22:07:56 +00:00
|
|
|
mTileTextures[i] = DataToTexture(gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager(),
|
2013-09-24 01:14:11 +00:00
|
|
|
data,
|
|
|
|
imgSurface->Stride(),
|
2013-11-21 22:07:56 +00:00
|
|
|
tileRect.Size(),
|
2013-09-24 01:14:11 +00:00
|
|
|
format,
|
|
|
|
bpp);
|
2013-11-21 22:07:56 +00:00
|
|
|
if (!mTileTextures[i]) {
|
|
|
|
NS_WARNING("Could not upload texture");
|
2013-11-21 22:07:58 +00:00
|
|
|
Reset();
|
2013-11-21 22:07:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DeprecatedTextureClientD3D9::DeprecatedTextureClientD3D9(CompositableForwarder* aCompositableForwarder,
|
|
|
|
const TextureInfo& aTextureInfo)
|
|
|
|
: DeprecatedTextureClient(aCompositableForwarder, aTextureInfo)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DeprecatedTextureClientD3D9);
|
|
|
|
}
|
|
|
|
|
|
|
|
DeprecatedTextureClientD3D9::~DeprecatedTextureClientD3D9()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DeprecatedTextureClientD3D9);
|
|
|
|
Unlock();
|
|
|
|
mDescriptor = SurfaceDescriptor();
|
|
|
|
|
2013-09-24 01:14:11 +00:00
|
|
|
mDrawTarget = nullptr;
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DeprecatedTextureClientD3D9::EnsureAllocated(gfx::IntSize aSize,
|
2013-09-24 20:45:13 +00:00
|
|
|
gfxContentType aType)
|
2013-08-04 07:46:17 +00:00
|
|
|
{
|
|
|
|
if (mTexture) {
|
|
|
|
D3DSURFACE_DESC desc;
|
|
|
|
mTexture->GetLevelDesc(0, &desc);
|
|
|
|
|
|
|
|
if (desc.Width == aSize.width &&
|
|
|
|
desc.Height == aSize.height) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Unlock();
|
|
|
|
mD3D9Surface = nullptr;
|
|
|
|
mTexture = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
mSize = aSize;
|
|
|
|
|
|
|
|
_D3DFORMAT format = D3DFMT_A8R8G8B8;
|
|
|
|
switch (aType) {
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxContentType::COLOR:
|
2013-08-04 07:46:17 +00:00
|
|
|
format = D3DFMT_X8R8G8B8;
|
|
|
|
break;
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxContentType::COLOR_ALPHA:
|
2013-09-24 01:14:11 +00:00
|
|
|
// fallback to DIB texture client
|
|
|
|
return false;
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxContentType::ALPHA:
|
2013-08-04 07:46:17 +00:00
|
|
|
format = D3DFMT_A8;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("Bad image type");
|
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:56 +00:00
|
|
|
DeviceManagerD3D9* deviceManager = gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager();
|
|
|
|
if (!deviceManager ||
|
|
|
|
!(mTexture = deviceManager->CreateTexture(aSize, format, D3DPOOL_SYSTEMMEM, nullptr))) {
|
2013-08-04 07:46:17 +00:00
|
|
|
NS_WARNING("Could not create texture");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(mTexture);
|
|
|
|
mDescriptor = SurfaceDescriptorD3D9(reinterpret_cast<uintptr_t>(mTexture.get()));
|
|
|
|
|
|
|
|
mContentType = aType;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxASurface*
|
|
|
|
DeprecatedTextureClientD3D9::LockSurface()
|
|
|
|
{
|
2013-11-21 22:07:56 +00:00
|
|
|
if (!gfxWindowsPlatform::GetPlatform()->GetD3D9Device()) {
|
|
|
|
// If the device has failed then we should not lock the surface,
|
|
|
|
// even if we could.
|
|
|
|
Unlock();
|
|
|
|
mD3D9Surface = nullptr;
|
|
|
|
mTexture = nullptr;
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
if (mSurface) {
|
|
|
|
return mSurface.get();
|
|
|
|
}
|
|
|
|
|
2013-11-21 22:07:55 +00:00
|
|
|
if (!mTexture) {
|
|
|
|
NS_WARNING("No texture to lock");
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
|
2013-09-24 01:14:11 +00:00
|
|
|
if (!mD3D9Surface) {
|
|
|
|
HRESULT hr = mTexture->GetSurfaceLevel(0, getter_AddRefs(mD3D9Surface));
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
NS_WARNING("Failed to get texture surface level.");
|
|
|
|
return nullptr;
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
2013-09-24 01:14:11 +00:00
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
|
2013-09-24 01:14:11 +00:00
|
|
|
mSurface = new gfxWindowsSurface(mD3D9Surface);
|
|
|
|
if (!mSurface || mSurface->CairoStatus()) {
|
|
|
|
NS_WARNING("Could not create surface for d3d9 surface");
|
|
|
|
mSurface = nullptr;
|
|
|
|
return nullptr;
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return mSurface.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawTarget*
|
|
|
|
DeprecatedTextureClientD3D9::LockDrawTarget()
|
|
|
|
{
|
|
|
|
if (!mDrawTarget) {
|
2013-09-24 01:14:11 +00:00
|
|
|
if (gfxASurface* surface = LockSurface()) {
|
|
|
|
mDrawTarget =
|
|
|
|
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(LockSurface(), mSize);
|
|
|
|
}
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return mDrawTarget.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DeprecatedTextureClientD3D9::Unlock()
|
|
|
|
{
|
|
|
|
if (mDrawTarget) {
|
|
|
|
mDrawTarget->Flush();
|
|
|
|
mDrawTarget = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mSurface) {
|
|
|
|
mSurface = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DeprecatedTextureClientD3D9::SetDescriptor(const SurfaceDescriptor& aDescriptor)
|
|
|
|
{
|
|
|
|
if (aDescriptor.type() == SurfaceDescriptor::Tnull_t) {
|
|
|
|
EnsureAllocated(mSize, mContentType);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mDescriptor = aDescriptor;
|
|
|
|
mSurface = nullptr;
|
2013-09-24 01:14:11 +00:00
|
|
|
mDrawTarget = nullptr;
|
2013-08-04 07:46:17 +00:00
|
|
|
|
|
|
|
if (aDescriptor.type() == SurfaceDescriptor::T__None) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(aDescriptor.type() == SurfaceDescriptor::TSurfaceDescriptorD3D9);
|
|
|
|
Unlock();
|
|
|
|
mD3D9Surface = nullptr;
|
|
|
|
mTexture = reinterpret_cast<IDirect3DTexture9*>(
|
|
|
|
mDescriptor.get_SurfaceDescriptorD3D9().texture());
|
|
|
|
}
|
|
|
|
|
2013-09-24 01:14:11 +00:00
|
|
|
DeprecatedTextureClientDIB::DeprecatedTextureClientDIB(CompositableForwarder* aCompositableForwarder,
|
|
|
|
const TextureInfo& aTextureInfo)
|
|
|
|
: DeprecatedTextureClient(aCompositableForwarder, aTextureInfo)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DeprecatedTextureClientDIB);
|
|
|
|
}
|
|
|
|
|
|
|
|
DeprecatedTextureClientDIB::~DeprecatedTextureClientDIB()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DeprecatedTextureClientDIB);
|
|
|
|
Unlock();
|
2013-09-24 01:14:12 +00:00
|
|
|
// It is OK not to dealloc the surface descriptor because it is only a pointer
|
|
|
|
// to mSurface and we will release our strong reference to that automatically.
|
2013-09-24 01:14:11 +00:00
|
|
|
mDescriptor = SurfaceDescriptor();
|
|
|
|
mDrawTarget = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DeprecatedTextureClientDIB::EnsureAllocated(gfx::IntSize aSize,
|
2013-09-24 20:45:13 +00:00
|
|
|
gfxContentType aType)
|
2013-09-24 01:14:11 +00:00
|
|
|
{
|
|
|
|
if (mSurface) {
|
2013-12-20 16:46:30 +00:00
|
|
|
gfx::IntSize size = gfx::ToIntSize(mSurface->GetSize());
|
2013-09-24 01:14:11 +00:00
|
|
|
if (size.width == aSize.width &&
|
|
|
|
size.height == aSize.height) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Unlock();
|
|
|
|
mSurface = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
mSurface = new gfxWindowsSurface(gfxIntSize(aSize.width, aSize.height),
|
|
|
|
gfxPlatform::GetPlatform()->OptimalFormatForContent(aType));
|
|
|
|
if (!mSurface || mSurface->CairoStatus())
|
|
|
|
{
|
|
|
|
NS_WARNING("Could not create surface");
|
|
|
|
mSurface = nullptr;
|
2013-09-24 01:14:12 +00:00
|
|
|
mDescriptor = SurfaceDescriptor();
|
2013-09-24 01:14:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mSize = aSize;
|
|
|
|
mContentType = aType;
|
|
|
|
|
|
|
|
mDescriptor = SurfaceDescriptorDIB(reinterpret_cast<uintptr_t>(mSurface.get()));
|
2013-09-24 01:14:12 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
SurfaceDescriptor*
|
|
|
|
DeprecatedTextureClientDIB::LockSurfaceDescriptor()
|
|
|
|
{
|
2013-09-24 01:14:11 +00:00
|
|
|
// The host will release this ref when it receives the surface descriptor.
|
|
|
|
// We AddRef in case we die before the host receives the pointer.
|
2013-09-24 01:14:12 +00:00
|
|
|
NS_ASSERTION(mSurface == reinterpret_cast<gfxWindowsSurface*>(mDescriptor.get_SurfaceDescriptorDIB().surface()),
|
|
|
|
"SurfaceDescriptor is not up to date");
|
2013-09-24 01:14:11 +00:00
|
|
|
mSurface->AddRef();
|
2013-09-24 01:14:12 +00:00
|
|
|
return GetDescriptor();
|
2013-09-24 01:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxASurface*
|
|
|
|
DeprecatedTextureClientDIB::LockSurface()
|
|
|
|
{
|
|
|
|
if (mSurface) {
|
|
|
|
return mSurface.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawTarget*
|
|
|
|
DeprecatedTextureClientDIB::LockDrawTarget()
|
|
|
|
{
|
|
|
|
if (!mDrawTarget) {
|
|
|
|
if (gfxASurface* surface = LockSurface()) {
|
|
|
|
mDrawTarget =
|
|
|
|
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(LockSurface(), mSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return mDrawTarget.get();
|
|
|
|
}
|
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
void
|
2013-09-24 01:14:11 +00:00
|
|
|
DeprecatedTextureClientDIB::Unlock()
|
2013-08-04 07:46:17 +00:00
|
|
|
{
|
|
|
|
if (mDrawTarget) {
|
2013-09-24 01:14:11 +00:00
|
|
|
mDrawTarget->Flush();
|
2013-08-04 07:46:17 +00:00
|
|
|
mDrawTarget = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-24 01:14:11 +00:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:20:40 +00:00
|
|
|
class D3D9TextureClientData : public TextureClientData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
D3D9TextureClientData(IDirect3DTexture9* aTexture)
|
|
|
|
: mTexture(aTexture)
|
|
|
|
{}
|
|
|
|
|
|
|
|
D3D9TextureClientData(gfxWindowsSurface* aWindowSurface)
|
|
|
|
: mWindowSurface(aWindowSurface)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual void DeallocateSharedData(ISurfaceAllocator*) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
mWindowSurface = nullptr;
|
|
|
|
mTexture = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
RefPtr<IDirect3DTexture9> mTexture;
|
|
|
|
nsRefPtr<gfxWindowsSurface> mWindowSurface;
|
|
|
|
};
|
|
|
|
|
2014-01-07 16:20:03 +00:00
|
|
|
DataTextureSourceD3D9::DataTextureSourceD3D9(gfx::SurfaceFormat aFormat,
|
|
|
|
CompositorD3D9* aCompositor,
|
2014-01-07 16:20:11 +00:00
|
|
|
TextureFlags aFlags,
|
2014-01-07 16:20:03 +00:00
|
|
|
StereoMode aStereoMode)
|
|
|
|
: mFormat(aFormat)
|
|
|
|
, mCompositor(aCompositor)
|
|
|
|
, mCurrentTile(0)
|
2014-01-07 16:20:11 +00:00
|
|
|
, mFlags(aFlags)
|
2014-01-07 16:20:03 +00:00
|
|
|
, mIsTiled(false)
|
|
|
|
, mIterating(false)
|
|
|
|
{
|
|
|
|
mStereoMode = aStereoMode;
|
|
|
|
MOZ_COUNT_CTOR(DataTextureSourceD3D9);
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:20:40 +00:00
|
|
|
DataTextureSourceD3D9::DataTextureSourceD3D9(gfx::SurfaceFormat aFormat,
|
2014-01-29 16:27:01 +00:00
|
|
|
gfx::IntSize aSize,
|
2014-01-07 16:20:40 +00:00
|
|
|
CompositorD3D9* aCompositor,
|
|
|
|
IDirect3DTexture9* aTexture,
|
|
|
|
TextureFlags aFlags)
|
|
|
|
: mFormat(aFormat)
|
|
|
|
, mCompositor(aCompositor)
|
|
|
|
, mCurrentTile(0)
|
|
|
|
, mFlags(aFlags)
|
|
|
|
, mIsTiled(false)
|
|
|
|
, mIterating(false)
|
|
|
|
{
|
2014-01-29 16:27:01 +00:00
|
|
|
mSize = aSize;
|
2014-01-07 16:20:40 +00:00
|
|
|
mTexture = aTexture;
|
2014-01-30 22:58:49 +00:00
|
|
|
mStereoMode = StereoMode::MONO;
|
2014-01-07 16:20:40 +00:00
|
|
|
MOZ_COUNT_CTOR(DataTextureSourceD3D9);
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:20:03 +00:00
|
|
|
DataTextureSourceD3D9::~DataTextureSourceD3D9()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DataTextureSourceD3D9);
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:20:11 +00:00
|
|
|
IDirect3DTexture9*
|
|
|
|
DataTextureSourceD3D9::GetD3D9Texture()
|
|
|
|
{
|
|
|
|
return mIterating ? mTileTextures[mCurrentTile]
|
|
|
|
: mTexture;
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:20:03 +00:00
|
|
|
bool
|
|
|
|
DataTextureSourceD3D9::Update(gfx::DataSourceSurface* aSurface,
|
|
|
|
nsIntRegion* aDestRegion,
|
|
|
|
gfx::IntPoint* aSrcOffset)
|
|
|
|
{
|
|
|
|
// Right now we only support null aDestRegion and aSrcOffset (which means
|
|
|
|
// full surface update). Incremental update is only used on Mac so it is
|
|
|
|
// not clear that we ever will need to support it for D3D.
|
|
|
|
MOZ_ASSERT(!aDestRegion && !aSrcOffset);
|
|
|
|
|
|
|
|
if (!mCompositor || !mCompositor->device()) {
|
2014-01-07 16:20:11 +00:00
|
|
|
NS_WARNING("No D3D device to update the texture.");
|
2014-01-07 16:20:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mSize = aSurface->GetSize();
|
|
|
|
|
|
|
|
uint32_t bpp = 0;
|
|
|
|
|
|
|
|
_D3DFORMAT format = D3DFMT_A8R8G8B8;
|
|
|
|
mFormat = aSurface->GetFormat();
|
|
|
|
switch (mFormat) {
|
2014-01-10 19:06:16 +00:00
|
|
|
case SurfaceFormat::B8G8R8X8:
|
2014-01-07 16:20:03 +00:00
|
|
|
format = D3DFMT_X8R8G8B8;
|
|
|
|
bpp = 4;
|
|
|
|
break;
|
2014-01-10 19:06:16 +00:00
|
|
|
case SurfaceFormat::B8G8R8A8:
|
2014-01-07 16:20:03 +00:00
|
|
|
format = D3DFMT_A8R8G8B8;
|
|
|
|
bpp = 4;
|
|
|
|
break;
|
2014-01-10 19:06:16 +00:00
|
|
|
case SurfaceFormat::A8:
|
2014-01-07 16:20:03 +00:00
|
|
|
format = D3DFMT_A8;
|
|
|
|
bpp = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_WARNING("Bad image format");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t maxSize = mCompositor->GetMaxTextureSize();
|
|
|
|
DeviceManagerD3D9* deviceManager = gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager();
|
2014-01-07 16:20:11 +00:00
|
|
|
if ((mSize.width <= maxSize && mSize.height <= maxSize) ||
|
|
|
|
(mFlags & TEXTURE_DISALLOW_BIGIMAGE)) {
|
2014-01-07 16:20:03 +00:00
|
|
|
mTexture = DataToTexture(deviceManager,
|
|
|
|
aSurface->GetData(), aSurface->Stride(),
|
2014-01-07 16:20:40 +00:00
|
|
|
IntSize(mSize), format, bpp);
|
2014-01-07 16:20:03 +00:00
|
|
|
if (!mTexture) {
|
|
|
|
NS_WARNING("Could not upload texture");
|
|
|
|
Reset();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mIsTiled = false;
|
|
|
|
} else {
|
|
|
|
mIsTiled = true;
|
|
|
|
uint32_t tileCount = GetRequiredTilesD3D9(mSize.width, maxSize) *
|
|
|
|
GetRequiredTilesD3D9(mSize.height, maxSize);
|
|
|
|
mTileTextures.resize(tileCount);
|
2014-01-07 16:20:11 +00:00
|
|
|
mTexture = nullptr;
|
2014-01-07 16:20:03 +00:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < tileCount; i++) {
|
|
|
|
IntRect tileRect = GetTileRect(i);
|
|
|
|
unsigned char* data = aSurface->GetData() +
|
|
|
|
tileRect.y * aSurface->Stride() +
|
|
|
|
tileRect.x * bpp;
|
|
|
|
mTileTextures[i] = DataToTexture(deviceManager,
|
|
|
|
data,
|
|
|
|
aSurface->Stride(),
|
2014-01-07 16:20:40 +00:00
|
|
|
IntSize(tileRect.width, tileRect.height),
|
|
|
|
format,
|
|
|
|
bpp);
|
|
|
|
if (!mTileTextures[i]) {
|
|
|
|
NS_WARNING("Could not upload texture");
|
|
|
|
Reset();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DataTextureSourceD3D9::Update(gfxWindowsSurface* aSurface)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aSurface);
|
|
|
|
if (!mCompositor || !mCompositor->device()) {
|
|
|
|
NS_WARNING("No D3D device to update the texture.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mSize = ToIntSize(aSurface->GetSize());
|
|
|
|
|
|
|
|
uint32_t bpp = 0;
|
|
|
|
|
|
|
|
_D3DFORMAT format = D3DFMT_A8R8G8B8;
|
|
|
|
mFormat = ImageFormatToSurfaceFormat(
|
|
|
|
gfxPlatform::GetPlatform()->OptimalFormatForContent(aSurface->GetContentType()));
|
|
|
|
switch (mFormat) {
|
2014-01-10 19:06:16 +00:00
|
|
|
case SurfaceFormat::B8G8R8X8:
|
2014-01-07 16:20:40 +00:00
|
|
|
format = D3DFMT_X8R8G8B8;
|
|
|
|
bpp = 4;
|
|
|
|
break;
|
2014-01-10 19:06:16 +00:00
|
|
|
case SurfaceFormat::B8G8R8A8:
|
2014-01-07 16:20:40 +00:00
|
|
|
format = D3DFMT_A8R8G8B8;
|
|
|
|
bpp = 4;
|
|
|
|
break;
|
2014-01-10 19:06:16 +00:00
|
|
|
case SurfaceFormat::A8:
|
2014-01-07 16:20:40 +00:00
|
|
|
format = D3DFMT_A8;
|
|
|
|
bpp = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_WARNING("Bad image format");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t maxSize = mCompositor->GetMaxTextureSize();
|
|
|
|
DeviceManagerD3D9* deviceManager = gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager();
|
|
|
|
if ((mSize.width <= maxSize && mSize.height <= maxSize) ||
|
|
|
|
(mFlags & TEXTURE_DISALLOW_BIGIMAGE)) {
|
|
|
|
mTexture = SurfaceToTexture(deviceManager, aSurface, mSize, format);
|
|
|
|
|
|
|
|
if (!mTexture) {
|
|
|
|
NS_WARNING("Could not upload texture");
|
|
|
|
Reset();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mIsTiled = false;
|
|
|
|
} else {
|
|
|
|
mIsTiled = true;
|
|
|
|
uint32_t tileCount = GetRequiredTilesD3D9(mSize.width, maxSize) *
|
|
|
|
GetRequiredTilesD3D9(mSize.height, maxSize);
|
|
|
|
mTileTextures.resize(tileCount);
|
|
|
|
mTexture = nullptr;
|
|
|
|
nsRefPtr<gfxImageSurface> imgSurface = aSurface->GetAsImageSurface();
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < tileCount; i++) {
|
|
|
|
IntRect tileRect = GetTileRect(i);
|
|
|
|
unsigned char* data = imgSurface->Data() +
|
|
|
|
tileRect.y * imgSurface->Stride() +
|
|
|
|
tileRect.x * bpp;
|
|
|
|
mTileTextures[i] = DataToTexture(deviceManager,
|
|
|
|
data,
|
|
|
|
imgSurface->Stride(),
|
|
|
|
IntSize(tileRect.width, tileRect.height),
|
2014-01-07 16:20:03 +00:00
|
|
|
format,
|
|
|
|
bpp);
|
|
|
|
if (!mTileTextures[i]) {
|
|
|
|
NS_WARNING("Could not upload texture");
|
|
|
|
Reset();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:20:11 +00:00
|
|
|
void
|
|
|
|
DataTextureSourceD3D9::SetCompositor(Compositor* aCompositor)
|
|
|
|
{
|
|
|
|
CompositorD3D9* d3dCompositor = static_cast<CompositorD3D9*>(aCompositor);
|
|
|
|
|
|
|
|
if (d3dCompositor != mCompositor) {
|
|
|
|
Reset();
|
|
|
|
mCompositor = d3dCompositor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:20:03 +00:00
|
|
|
void
|
|
|
|
DataTextureSourceD3D9::Reset()
|
|
|
|
{
|
|
|
|
mSize.width = 0;
|
|
|
|
mSize.height = 0;
|
|
|
|
mIsTiled = false;
|
|
|
|
mTexture = nullptr;
|
2014-01-07 16:20:11 +00:00
|
|
|
mTileTextures.clear();
|
2014-01-07 16:20:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IntRect
|
|
|
|
DataTextureSourceD3D9::GetTileRect(uint32_t aTileIndex) const
|
|
|
|
{
|
|
|
|
uint32_t maxSize = mCompositor->GetMaxTextureSize();
|
|
|
|
uint32_t horizontalTiles = GetRequiredTilesD3D9(mSize.width, maxSize);
|
|
|
|
uint32_t verticalTiles = GetRequiredTilesD3D9(mSize.height, maxSize);
|
|
|
|
|
|
|
|
uint32_t verticalTile = aTileIndex / horizontalTiles;
|
|
|
|
uint32_t horizontalTile = aTileIndex % horizontalTiles;
|
|
|
|
|
|
|
|
return IntRect(horizontalTile * maxSize,
|
|
|
|
verticalTile * maxSize,
|
|
|
|
horizontalTile < (horizontalTiles - 1) ? maxSize : mSize.width % maxSize,
|
|
|
|
verticalTile < (verticalTiles - 1) ? maxSize : mSize.height % maxSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect
|
|
|
|
DataTextureSourceD3D9::GetTileRect()
|
|
|
|
{
|
|
|
|
return ThebesIntRect(GetTileRect(mCurrentTile));
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:20:40 +00:00
|
|
|
CairoTextureClientD3D9::CairoTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags)
|
|
|
|
: TextureClient(aFlags)
|
|
|
|
, mFormat(aFormat)
|
|
|
|
, mIsLocked(false)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CairoTextureClientD3D9);
|
|
|
|
}
|
|
|
|
|
|
|
|
CairoTextureClientD3D9::~CairoTextureClientD3D9()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CairoTextureClientD3D9);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CairoTextureClientD3D9::Lock(OpenMode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsLocked);
|
2014-01-24 14:25:04 +00:00
|
|
|
if (!IsValid() || !IsAllocated()) {
|
2014-01-07 16:20:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mIsLocked = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CairoTextureClientD3D9::Unlock()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsLocked, "Unlocked called while the texture is not locked!");
|
|
|
|
if (mDrawTarget) {
|
|
|
|
mDrawTarget->Flush();
|
|
|
|
mDrawTarget = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mSurface) {
|
|
|
|
mSurface = nullptr;
|
|
|
|
}
|
|
|
|
mIsLocked = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CairoTextureClientD3D9::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (!IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
aOutDescriptor = SurfaceDescriptorD3D9(reinterpret_cast<uintptr_t>(mTexture.get()));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<gfx::DrawTarget>
|
|
|
|
CairoTextureClientD3D9::GetAsDrawTarget()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsLocked && mTexture);
|
|
|
|
if (mDrawTarget) {
|
|
|
|
return mDrawTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gfxWindowsPlatform::GetPlatform()->GetD3D9Device()) {
|
|
|
|
// If the device has failed then we should not lock the surface,
|
|
|
|
// even if we could.
|
|
|
|
mD3D9Surface = nullptr;
|
|
|
|
mTexture = nullptr;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mD3D9Surface) {
|
|
|
|
HRESULT hr = mTexture->GetSurfaceLevel(0, getter_AddRefs(mD3D9Surface));
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
NS_WARNING("Failed to get texture surface level.");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mSurface = new gfxWindowsSurface(mD3D9Surface);
|
|
|
|
if (!mSurface || mSurface->CairoStatus()) {
|
|
|
|
NS_WARNING("Could not create surface for d3d9 surface");
|
|
|
|
mSurface = nullptr;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
mDrawTarget =
|
|
|
|
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(mSurface, mSize);
|
|
|
|
|
|
|
|
return mDrawTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CairoTextureClientD3D9::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!IsAllocated());
|
|
|
|
mSize = aSize;
|
|
|
|
_D3DFORMAT format = SurfaceFormatToD3D9Format(mFormat);
|
|
|
|
|
|
|
|
DeviceManagerD3D9* deviceManager = gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager();
|
|
|
|
if (!deviceManager ||
|
|
|
|
!(mTexture = deviceManager->CreateTexture(mSize, format, D3DPOOL_SYSTEMMEM, nullptr))) {
|
|
|
|
NS_WARNING("Could not create d3d9 texture");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-20 13:52:12 +00:00
|
|
|
if (aFlags & ALLOC_CLEAR_BUFFER) {
|
|
|
|
DebugOnly<bool> locked = Lock(OPEN_WRITE_ONLY);
|
|
|
|
MOZ_ASSERT(locked);
|
|
|
|
RefPtr<DrawTarget> dt = GetAsDrawTarget();
|
|
|
|
dt->ClearRect(Rect(0, 0, GetSize().width, GetSize().height));
|
|
|
|
Unlock();
|
|
|
|
}
|
|
|
|
|
2014-01-07 16:20:40 +00:00
|
|
|
MOZ_ASSERT(mTexture);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureClientData*
|
|
|
|
CairoTextureClientD3D9::DropTextureData()
|
|
|
|
{
|
|
|
|
TextureClientData* data = new D3D9TextureClientData(mTexture);
|
|
|
|
mTexture = nullptr;
|
|
|
|
MarkInvalid();
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
DIBTextureClientD3D9::DIBTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags)
|
|
|
|
: TextureClient(aFlags)
|
|
|
|
, mFormat(aFormat)
|
|
|
|
, mIsLocked(false)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DIBTextureClientD3D9);
|
|
|
|
}
|
|
|
|
|
|
|
|
DIBTextureClientD3D9::~DIBTextureClientD3D9()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DIBTextureClientD3D9);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DIBTextureClientD3D9::Lock(OpenMode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsLocked);
|
|
|
|
if (!IsValid()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mIsLocked = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DIBTextureClientD3D9::Unlock()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsLocked, "Unlocked called while the texture is not locked!");
|
|
|
|
if (mDrawTarget) {
|
|
|
|
mDrawTarget->Flush();
|
|
|
|
mDrawTarget = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
mIsLocked = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DIBTextureClientD3D9::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (!IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mSurface);
|
|
|
|
// The host will release this ref when it receives the surface descriptor.
|
|
|
|
// We AddRef in case we die before the host receives the pointer.
|
|
|
|
aOutDescriptor = SurfaceDescriptorDIB(reinterpret_cast<uintptr_t>(mSurface.get()));
|
|
|
|
mSurface->AddRef();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TemporaryRef<gfx::DrawTarget>
|
|
|
|
DIBTextureClientD3D9::GetAsDrawTarget()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsLocked && IsAllocated());
|
|
|
|
|
|
|
|
if (!mDrawTarget) {
|
|
|
|
mDrawTarget =
|
|
|
|
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(mSurface, mSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mDrawTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DIBTextureClientD3D9::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!IsAllocated());
|
|
|
|
mSize = aSize;
|
|
|
|
|
|
|
|
mSurface = new gfxWindowsSurface(gfxIntSize(aSize.width, aSize.height),
|
|
|
|
SurfaceFormatToImageFormat(mFormat));
|
|
|
|
if (!mSurface || mSurface->CairoStatus())
|
|
|
|
{
|
|
|
|
NS_WARNING("Could not create surface");
|
|
|
|
mSurface = nullptr;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureClientData*
|
|
|
|
DIBTextureClientD3D9::DropTextureData()
|
|
|
|
{
|
|
|
|
TextureClientData* data = new D3D9TextureClientData(mSurface);
|
|
|
|
mSurface = nullptr;
|
|
|
|
MarkInvalid();
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedTextureClientD3D9::SharedTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags)
|
|
|
|
: TextureClient(aFlags)
|
|
|
|
, mFormat(aFormat)
|
|
|
|
, mHandle(0)
|
|
|
|
, mIsLocked(false)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(SharedTextureClientD3D9);
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedTextureClientD3D9::~SharedTextureClientD3D9()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(SharedTextureClientD3D9);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureClientData*
|
|
|
|
SharedTextureClientD3D9::DropTextureData()
|
|
|
|
{
|
|
|
|
TextureClientData* data = new D3D9TextureClientData(mTexture);
|
|
|
|
mTexture = nullptr;
|
|
|
|
MarkInvalid();
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SharedTextureClientD3D9::Lock(OpenMode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsLocked);
|
|
|
|
if (!IsValid()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mIsLocked = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SharedTextureClientD3D9::Unlock()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsLocked, "Unlock called while the texture is not locked!");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SharedTextureClientD3D9::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
if (!IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
aOutDescriptor = SurfaceDescriptorD3D10((WindowsHandle)(mHandle), mFormat);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureHostD3D9::TextureHostD3D9(TextureFlags aFlags,
|
|
|
|
const SurfaceDescriptorD3D9& aDescriptor)
|
|
|
|
: TextureHost(aFlags)
|
2014-01-10 19:06:16 +00:00
|
|
|
, mFormat(SurfaceFormat::UNKNOWN)
|
2014-01-07 16:20:40 +00:00
|
|
|
, mIsLocked(false)
|
|
|
|
{
|
|
|
|
mTexture = reinterpret_cast<IDirect3DTexture9*>(aDescriptor.texture());
|
|
|
|
MOZ_ASSERT(mTexture);
|
|
|
|
D3DSURFACE_DESC desc;
|
|
|
|
HRESULT hr = mTexture->GetLevelDesc(0, &desc);
|
|
|
|
if (!FAILED(hr)) {
|
|
|
|
mFormat = D3D9FormatToSurfaceFormat(desc.Format);
|
|
|
|
mSize.width = desc.Width;
|
|
|
|
mSize.height = desc.Height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-29 16:27:01 +00:00
|
|
|
bool
|
|
|
|
DataTextureSourceD3D9::UpdateFromTexture(IDirect3DTexture9* aTexture,
|
|
|
|
const nsIntRegion* aRegion)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aTexture);
|
|
|
|
|
|
|
|
D3DSURFACE_DESC desc;
|
|
|
|
HRESULT hr = aTexture->GetLevelDesc(0, &desc);
|
|
|
|
if (!FAILED(hr)) {
|
|
|
|
MOZ_ASSERT(mFormat == D3D9FormatToSurfaceFormat(desc.Format));
|
|
|
|
MOZ_ASSERT(mSize.width == desc.Width);
|
|
|
|
MOZ_ASSERT(mSize.height == desc.Height);
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceManagerD3D9* dm = gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager();
|
|
|
|
if (!mTexture) {
|
|
|
|
mTexture = dm->CreateTexture(mSize, SurfaceFormatToD3D9Format(mFormat),
|
|
|
|
D3DPOOL_DEFAULT, this);
|
|
|
|
if (!mTexture) {
|
|
|
|
NS_WARNING("Failed to create a texture");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<IDirect3DSurface9> srcSurface;
|
|
|
|
RefPtr<IDirect3DSurface9> dstSurface;
|
|
|
|
|
|
|
|
hr = aTexture->GetSurfaceLevel(0, byRef(srcSurface));
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
hr = mTexture->GetSurfaceLevel(0, byRef(dstSurface));
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRegion) {
|
|
|
|
nsIntRegionRectIterator iter(*aRegion);
|
|
|
|
const nsIntRect *iterRect;
|
|
|
|
while ((iterRect = iter.Next())) {
|
|
|
|
RECT rect;
|
|
|
|
rect.left = iterRect->x;
|
|
|
|
rect.top = iterRect->y;
|
|
|
|
rect.right = iterRect->XMost();
|
|
|
|
rect.bottom = iterRect->YMost();
|
|
|
|
|
|
|
|
POINT point;
|
|
|
|
point.x = iterRect->x;
|
|
|
|
point.y = iterRect->y;
|
|
|
|
dm->device()->UpdateSurface(srcSurface, &rect, dstSurface, &point);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dm->device()->UpdateSurface(srcSurface, nullptr, dstSurface, nullptr);
|
|
|
|
}
|
|
|
|
mIsTiled = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextureHostD3D9::Updated(const nsIntRegion* aRegion)
|
|
|
|
{
|
|
|
|
if (!mTexture) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mTextureSource) {
|
|
|
|
mTextureSource = new DataTextureSourceD3D9(mFormat, mSize, mCompositor,
|
|
|
|
nullptr, mFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
mTextureSource->UpdateFromTexture(mTexture, aRegion);
|
|
|
|
}
|
2014-01-07 16:20:40 +00:00
|
|
|
|
|
|
|
IDirect3DDevice9*
|
|
|
|
TextureHostD3D9::GetDevice()
|
|
|
|
{
|
|
|
|
return mCompositor ? mCompositor->device() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextureHostD3D9::SetCompositor(Compositor* aCompositor)
|
|
|
|
{
|
|
|
|
mCompositor = static_cast<CompositorD3D9*>(aCompositor);
|
|
|
|
if (mTextureSource) {
|
|
|
|
mTextureSource->SetCompositor(aCompositor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NewTextureSource*
|
|
|
|
TextureHostD3D9::GetTextureSources()
|
|
|
|
{
|
2014-01-29 16:27:01 +00:00
|
|
|
MOZ_ASSERT(mIsLocked);
|
2014-01-07 16:20:40 +00:00
|
|
|
return mTextureSource;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TextureHostD3D9::Lock()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsLocked);
|
|
|
|
mIsLocked = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextureHostD3D9::Unlock()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsLocked);
|
|
|
|
mIsLocked = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TextureHostD3D9::DeallocateDeviceData()
|
|
|
|
{
|
|
|
|
mTextureSource = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
DIBTextureHostD3D9::DIBTextureHostD3D9(TextureFlags aFlags,
|
|
|
|
const SurfaceDescriptorDIB& aDescriptor)
|
|
|
|
: TextureHost(aFlags)
|
|
|
|
, mIsLocked(false)
|
|
|
|
{
|
|
|
|
// We added an extra ref for transport, so we shouldn't AddRef now.
|
|
|
|
mSurface =
|
|
|
|
dont_AddRef(reinterpret_cast<gfxWindowsSurface*>(aDescriptor.surface()));
|
|
|
|
MOZ_ASSERT(mSurface);
|
|
|
|
|
|
|
|
mSize = ToIntSize(mSurface->GetSize());
|
|
|
|
mFormat = ImageFormatToSurfaceFormat(
|
|
|
|
gfxPlatform::GetPlatform()->OptimalFormatForContent(mSurface->GetContentType()));
|
|
|
|
}
|
|
|
|
|
|
|
|
NewTextureSource*
|
|
|
|
DIBTextureHostD3D9::GetTextureSources()
|
|
|
|
{
|
|
|
|
if (!mTextureSource) {
|
|
|
|
Updated();
|
|
|
|
}
|
|
|
|
|
|
|
|
return mTextureSource;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DIBTextureHostD3D9::Updated(const nsIntRegion*)
|
|
|
|
{
|
|
|
|
if (!mTextureSource) {
|
|
|
|
mTextureSource = new DataTextureSourceD3D9(mFormat, mCompositor, mFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mTextureSource->Update(mSurface)) {
|
|
|
|
mTextureSource = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DIBTextureHostD3D9::Lock()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsLocked);
|
|
|
|
mIsLocked = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DIBTextureHostD3D9::Unlock()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsLocked);
|
|
|
|
mIsLocked = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DIBTextureHostD3D9::SetCompositor(Compositor* aCompositor)
|
|
|
|
{
|
|
|
|
mCompositor = static_cast<CompositorD3D9*>(aCompositor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DIBTextureHostD3D9::DeallocateDeviceData()
|
|
|
|
{
|
|
|
|
mTextureSource = nullptr;
|
|
|
|
}
|
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
}
|
|
|
|
}
|