Bug 960524 - Get rid of Image::DeprecatedGetAsSurface (Moz2D migration). r=mattwoodrow

This commit is contained in:
Jonathan Watt 2014-04-10 09:49:53 +01:00
parent 9210ee2835
commit d88be3bc70
19 changed files with 24 additions and 469 deletions

View File

@ -2,13 +2,16 @@
* 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 "MediaEngineTabVideoSource.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h"
#include "nsGlobalWindow.h"
#include "nsDOMWindowUtils.h"
#include "nsIDOMClientRect.h"
#include "nsIDocShell.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "gfxImageSurface.h"
#include "gfxContext.h"
#include "gfx2DGlue.h"
#include "ImageContainer.h"
@ -16,7 +19,6 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDOMDocument.h"
#include "nsITabSource.h"
#include "MediaEngineTabVideoSource.h"
#include "VideoUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsIPrefService.h"
@ -244,13 +246,16 @@ MediaEngineTabVideoSource::Draw() {
uint32_t stride = gfxASurface::FormatStrideForWidth(format, size.width);
nsRefPtr<layers::ImageContainer> container = layers::LayerManager::CreateImageContainer();
nsRefPtr<gfxASurface> surf;
surf = new gfxImageSurface(mData.rwget(),
ThebesIntSize(size), stride, format);
if (surf->CairoStatus() != 0) {
RefPtr<DrawTarget> dt =
Factory::CreateDrawTargetForData(BackendType::CAIRO,
mData.rwget(),
size,
stride,
SurfaceFormat::B8G8R8X8);
if (!dt) {
return;
}
nsRefPtr<gfxContext> context = new gfxContext(surf);
nsRefPtr<gfxContext> context = new gfxContext(dt);
gfxPoint pt(0, 0);
context->Translate(pt);
context->Scale(scale * size.width / srcW, scale * size.height / srcH);
@ -258,10 +263,14 @@ MediaEngineTabVideoSource::Draw() {
NS_ENSURE_SUCCESS_VOID(rv);
RefPtr<SourceSurface> surface = dt->Snapshot();
if (!surface) {
return;
}
layers::CairoImage::Data cairoData;
cairoData.mDeprecatedSurface = surf;
cairoData.mSize = size;
cairoData.mSourceSurface = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr, surf);
cairoData.mSourceSurface = surface;
nsRefPtr<layers::CairoImage> image = new layers::CairoImage();

View File

@ -556,6 +556,7 @@ PluginInstanceParent::RecvShow(const NPRect& updatedRect,
updatedRect.right - updatedRect.left,
updatedRect.bottom - updatedRect.top));
// XXXjwatt rewrite to use Moz2D
nsRefPtr<gfxASurface> surface;
if (newSurface.type() == SurfaceDescriptor::TShmem) {
if (!newSurface.get_Shmem().IsReadable()) {
@ -642,7 +643,6 @@ PluginInstanceParent::RecvShow(const NPRect& updatedRect,
NS_ASSERTION(image->GetFormat() == ImageFormat::CAIRO_SURFACE, "Wrong format?");
CairoImage* cairoImage = static_cast<CairoImage*>(image.get());
CairoImage::Data cairoData;
cairoData.mDeprecatedSurface = surface;
cairoData.mSize = surface->GetSize().ToIntSize();
cairoData.mSourceSurface = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr, surface);
cairoImage->SetData(cairoData);

View File

@ -126,62 +126,6 @@ D3D9SurfaceImage::GetSize()
return mSize;
}
already_AddRefed<gfxASurface>
D3D9SurfaceImage::DeprecatedGetAsSurface()
{
NS_ENSURE_TRUE(mTexture, nullptr);
HRESULT hr;
nsRefPtr<gfxImageSurface> surface =
new gfxImageSurface(gfx::ThebesIntSize(mSize), gfxImageFormat::RGB24);
if (!surface->CairoSurface() || surface->CairoStatus()) {
NS_WARNING("Failed to created Cairo image surface for D3D9SurfaceImage.");
return nullptr;
}
// Ensure that the texture is ready to be used.
EnsureSynchronized();
// Readback the texture from GPU memory into system memory, so that
// we can copy it into the Cairo image. This is expensive.
RefPtr<IDirect3DSurface9> textureSurface;
hr = mTexture->GetSurfaceLevel(0, byRef(textureSurface));
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
RefPtr<IDirect3DDevice9> device;
hr = mTexture->GetDevice(byRef(device));
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
RefPtr<IDirect3DSurface9> systemMemorySurface;
hr = device->CreateOffscreenPlainSurface(mDesc.Width,
mDesc.Height,
D3DFMT_X8R8G8B8,
D3DPOOL_SYSTEMMEM,
byRef(systemMemorySurface),
0);
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
hr = device->GetRenderTargetData(textureSurface, systemMemorySurface);
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
D3DLOCKED_RECT rect;
hr = systemMemorySurface->LockRect(&rect, nullptr, 0);
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
const unsigned char* src = (const unsigned char*)(rect.pBits);
const unsigned srcPitch = rect.Pitch;
for (int y = 0; y < mSize.height; y++) {
memcpy(surface->Data() + surface->Stride() * y,
(unsigned char*)(src) + srcPitch * y,
mSize.width * 4);
}
systemMemorySurface->UnlockRect();
return surface.forget();
}
TextureClient*
D3D9SurfaceImage::GetTextureClient(CompositableClient* aClient)
{

View File

@ -49,7 +49,6 @@ public:
gfx::IntSize GetSize() MOZ_OVERRIDE;
already_AddRefed<gfxASurface> DeprecatedGetAsSurface() MOZ_OVERRIDE;
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;

View File

@ -184,99 +184,6 @@ ConvertYVU420SPToRGB565(void *aYData, uint32_t aYStride,
}
}
already_AddRefed<gfxASurface>
GrallocImage::DeprecatedGetAsSurface()
{
if (!mTextureClient) {
return nullptr;
}
android::sp<GraphicBuffer> graphicBuffer =
mTextureClient->GetGraphicBuffer();
void *buffer;
int32_t rv =
graphicBuffer->lock(android::GraphicBuffer::USAGE_SW_READ_OFTEN, &buffer);
if (rv) {
NS_WARNING("Couldn't lock graphic buffer");
return nullptr;
}
GraphicBufferAutoUnlock unlock(graphicBuffer);
uint32_t format = graphicBuffer->getPixelFormat();
uint32_t omxFormat = 0;
for (int i = 0; sColorIdMap[i]; i += 2) {
if (sColorIdMap[i] == format) {
omxFormat = sColorIdMap[i + 1];
break;
}
}
if (!omxFormat) {
NS_WARNING("Unknown color format");
return nullptr;
}
nsRefPtr<gfxImageSurface> imageSurface =
new gfxImageSurface(gfx::ThebesIntSize(GetSize()), gfxImageFormat::RGB16_565);
uint32_t width = GetSize().width;
uint32_t height = GetSize().height;
if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO) {
// The Adreno hardware decoder aligns image dimensions to a multiple of 32,
// so we have to account for that here
uint32_t alignedWidth = ALIGN(width, 32);
uint32_t alignedHeight = ALIGN(height, 32);
uint32_t uvOffset = ALIGN(alignedHeight * alignedWidth, 4096);
uint32_t uvStride = 2 * ALIGN(width / 2, 32);
uint8_t* buffer_as_bytes = static_cast<uint8_t*>(buffer);
ConvertYVU420SPToRGB565(buffer, alignedWidth,
buffer_as_bytes + uvOffset, uvStride,
imageSurface->Data(),
width, height);
return imageSurface.forget();
} else if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP) {
uint32_t uvOffset = height * width;
ConvertYVU420SPToRGB565(buffer, width,
buffer + uvOffset, width,
imageSurface->Data(),
width, height);
return imageSurface.forget();
} else if (format == HAL_PIXEL_FORMAT_YV12) {
gfx::ConvertYCbCrToRGB(mData,
gfx::ImageFormatToSurfaceFormat(imageSurface->Format()),
mSize,
imageSurface->Data(),
imageSurface->Stride());
return imageSurface.forget();
}
android::ColorConverter colorConverter((OMX_COLOR_FORMATTYPE)omxFormat,
OMX_COLOR_Format16bitRGB565);
if (!colorConverter.isValid()) {
NS_WARNING("Invalid color conversion");
return nullptr;
}
rv = colorConverter.convert(buffer, width, height,
0, 0, width - 1, height - 1 /* source crop */,
imageSurface->Data(), width, height,
0, 0, width - 1, height - 1 /* dest crop */);
if (rv) {
NS_WARNING("OMX color conversion failed");
return nullptr;
}
return imageSurface.forget();
}
TemporaryRef<gfx::SourceSurface>
GrallocImage::GetAsSourceSurface()
{

View File

@ -81,7 +81,6 @@ public:
HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS = 0x7FA30C04,
};
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
void* GetNativeBuffer();

View File

@ -338,26 +338,6 @@ ImageContainer::UnlockCurrentImage()
}
}
already_AddRefed<gfxASurface>
ImageContainer::DeprecatedGetCurrentAsSurface(gfx::IntSize *aSize)
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mRemoteData) {
CrossProcessMutexAutoLock autoLock(*mRemoteDataMutex);
EnsureActiveImage();
if (!mActiveImage)
return nullptr;
*aSize = mRemoteData->mSize;
} else {
if (!mActiveImage)
return nullptr;
*aSize = mActiveImage->GetSize();
}
return mActiveImage->DeprecatedGetAsSurface();
}
TemporaryRef<gfx::SourceSurface>
ImageContainer::GetCurrentAsSourceSurface(gfx::IntSize *aSize)
{
@ -474,7 +454,6 @@ PlanarYCbCrImage::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
// Ignoring:
// - mData - just wraps mBuffer
// - Surfaces should be reported under gfx-surfaces-*:
// - mDeprecatedSurface
// - mSourceSurface
// - Base class:
// - mImplData is not used
@ -582,33 +561,6 @@ PlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
return mBuffer;
}
already_AddRefed<gfxASurface>
PlanarYCbCrImage::DeprecatedGetAsSurface()
{
if (mDeprecatedSurface) {
nsRefPtr<gfxASurface> result = mDeprecatedSurface.get();
return result.forget();
}
gfx::SurfaceFormat format = gfx::ImageFormatToSurfaceFormat(GetOffscreenFormat());
gfx::IntSize size(mSize);
gfx::GetYCbCrToRGBDestFormatAndSize(mData, format, size);
if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
size.height > PlanarYCbCrImage::MAX_DIMENSION) {
NS_ERROR("Illegal image dest width or height");
return nullptr;
}
nsRefPtr<gfxImageSurface> imageSurface =
new gfxImageSurface(gfx::ThebesIntSize(mSize), gfx::SurfaceFormatToImageFormat(format));
gfx::ConvertYCbCrToRGB(mData, format, mSize, imageSurface->Data(), imageSurface->Stride());
mDeprecatedSurface = imageSurface;
return imageSurface.forget();
}
TemporaryRef<gfx::SourceSurface>
PlanarYCbCrImage::GetAsSourceSurface()
{
@ -634,22 +586,6 @@ PlanarYCbCrImage::GetAsSourceSurface()
return surface.forget();
}
already_AddRefed<gfxASurface>
RemoteBitmapImage::DeprecatedGetAsSurface()
{
nsRefPtr<gfxImageSurface> newSurf =
new gfxImageSurface(ThebesIntSize(mSize),
mFormat == RemoteImageData::BGRX32 ? gfxImageFormat::RGB24 : gfxImageFormat::ARGB32);
for (int y = 0; y < mSize.height; y++) {
memcpy(newSurf->Data() + newSurf->Stride() * y,
mData + mStride * y,
mSize.width * 4);
}
return newSurf.forget();
}
TemporaryRef<gfx::SourceSurface>
RemoteBitmapImage::GetAsSourceSurface()
{

View File

@ -33,62 +33,16 @@
#ifndef XPCOM_GLUE_AVOID_NSPR
/**
* We need to be able to hold a reference to a gfxASurface from Image
* We need to be able to hold a reference to a Moz2D SourceSurface from Image
* subclasses. This is potentially a problem since Images can be addrefed
* or released off the main thread. We can ensure that we never AddRef
* a gfxASurface off the main thread, but we might want to Release due
* a SourceSurface off the main thread, but we might want to Release due
* to an Image being destroyed off the main thread.
*
* We use nsCountedRef<nsMainThreadSurfaceRef> to reference the
* gfxASurface. When AddRefing, we assert that we're on the main thread.
* We use nsCountedRef<nsMainThreadSourceSurfaceRef> to reference the
* SourceSurface. When AddRefing, we assert that we're on the main thread.
* When Releasing, if we're not on the main thread, we post an event to
* the main thread to do the actual release.
*
* This should be removed after after Image::DeprecatedGetAsSurface is
* removed. It is replaced by nsMainThreadSourceSurfaceRef
*/
class nsMainThreadSurfaceRef;
template <>
class nsAutoRefTraits<nsMainThreadSurfaceRef> {
public:
typedef gfxASurface* RawRef;
/**
* The XPCOM event that will do the actual release on the main thread.
*/
class SurfaceReleaser : public nsRunnable {
public:
SurfaceReleaser(RawRef aRef) : mRef(aRef) {}
NS_IMETHOD Run() {
mRef->Release();
return NS_OK;
}
RawRef mRef;
};
static RawRef Void() { return nullptr; }
static void Release(RawRef aRawRef)
{
if (NS_IsMainThread()) {
aRawRef->Release();
return;
}
nsCOMPtr<nsIRunnable> runnable = new SurfaceReleaser(aRawRef);
NS_DispatchToMainThread(runnable);
}
static void AddRef(RawRef aRawRef)
{
NS_ASSERTION(NS_IsMainThread(),
"Can only add a reference on the main thread");
aRawRef->AddRef();
}
};
/**
* Same purpose as nsMainThreadSurfaceRef byt holds a gfx::SourceSurface instead.
* The specialization of nsMainThreadSurfaceRef should be removed after
* Image::DeprecatedGetAsSurface is removed
*/
class nsMainThreadSourceSurfaceRef;
@ -194,7 +148,6 @@ public:
ImageFormat GetFormat() { return mFormat; }
void* GetImplData() { return mImplData; }
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() = 0;
virtual gfx::IntSize GetSize() = 0;
virtual nsIntRect GetPictureRect()
{
@ -504,7 +457,7 @@ public:
void UnlockCurrentImage();
/**
* Get the current image as a gfxASurface. This is useful for fallback
* Get the current image as a SourceSurface. This is useful for fallback
* rendering.
* This can only be called from the main thread, since cairo objects
* can only be used from the main thread.
@ -523,11 +476,6 @@ public:
* the lock methods should be used to avoid the copy, however this should be
* avoided if the surface is required for a long period of time.
*/
already_AddRefed<gfxASurface> DeprecatedGetCurrentAsSurface(gfx::IntSize* aSizeResult);
/**
* Same as GetCurrentAsSurface but for Moz2D
*/
TemporaryRef<gfx::SourceSurface> GetCurrentAsSourceSurface(gfx::IntSize* aSizeResult);
/**
@ -889,7 +837,6 @@ protected:
*/
virtual uint8_t* AllocateBuffer(uint32_t aSize);
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
void SetOffscreenFormat(gfxImageFormat aFormat) { mOffscreenFormat = aFormat; }
@ -900,7 +847,6 @@ protected:
Data mData;
gfx::IntSize mSize;
gfxImageFormat mOffscreenFormat;
nsCountedRef<nsMainThreadSurfaceRef> mDeprecatedSurface;
nsCountedRef<nsMainThreadSourceSurfaceRef> mSourceSurface;
nsRefPtr<BufferRecycleBin> mRecycleBin;
};
@ -914,11 +860,7 @@ class CairoImage : public Image,
public ISharedImage {
public:
struct Data {
gfxASurface* mDeprecatedSurface;
gfx::IntSize mSize;
// mSourceSurface wraps mDeprrecatedSurface's data, therefore it should not
// outlive mDeprecatedSurface
RefPtr<gfx::SourceSurface> mSourceSurface;
};
@ -929,7 +871,6 @@ public:
*/
void SetData(const Data& aData)
{
mDeprecatedSurface = aData.mDeprecatedSurface;
mSize = aData.mSize;
mSourceSurface = aData.mSourceSurface;
}
@ -939,12 +880,6 @@ public:
return mSourceSurface.get();
}
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface()
{
nsRefPtr<gfxASurface> surface = mDeprecatedSurface.get();
return surface.forget();
}
virtual ISharedImage* AsSharedImage() { return this; }
virtual uint8_t* GetBuffer() { return nullptr; }
virtual TextureClient* GetTextureClient(CompositableClient* aClient);
@ -954,11 +889,8 @@ public:
CairoImage();
~CairoImage();
nsCountedRef<nsMainThreadSurfaceRef> mDeprecatedSurface;
gfx::IntSize mSize;
// mSourceSurface wraps mDeprrecatedSurface's data, therefore it should not
// outlive mDeprecatedSurface
nsCountedRef<nsMainThreadSourceSurfaceRef> mSourceSurface;
nsDataHashtable<nsUint32HashKey, RefPtr<TextureClient> > mTextureClients;
};
@ -967,7 +899,6 @@ class RemoteBitmapImage : public Image {
public:
RemoteBitmapImage() : Image(nullptr, ImageFormat::REMOTE_IMAGE_BITMAP) {}
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
gfx::IntSize GetSize() { return mSize; }

View File

@ -28,27 +28,6 @@ public:
virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() {
mSurface->Lock();
size_t bytesPerRow = mSurface->GetBytesPerRow();
size_t ioWidth = mSurface->GetDevicePixelWidth();
size_t ioHeight = mSurface->GetDevicePixelHeight();
unsigned char* ioData = (unsigned char*)mSurface->GetBaseAddress();
nsRefPtr<gfxImageSurface> imgSurface =
new gfxImageSurface(gfxIntSize(ioWidth, ioHeight), gfxImageFormat::ARGB32);
for (size_t i = 0; i < ioHeight; i++) {
memcpy(imgSurface->Data() + i * imgSurface->Stride(),
ioData + i * bytesPerRow, ioWidth * 4);
}
mSurface->Unlock();
return imgSurface.forget();
}
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;

View File

@ -35,10 +35,6 @@ public:
gfx::IntSize GetSize() { return mData.mSize; }
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() {
return nullptr;
}
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE
{
return nullptr;

View File

@ -52,7 +52,6 @@ public:
virtual void SetData(const Data& aData);
virtual void SetDelayedConversion(bool aDelayed) { mDelayedConversion = aDelayed; }
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
@ -132,53 +131,6 @@ BasicPlanarYCbCrImage::SetData(const Data& aData)
mSize = size;
}
static cairo_user_data_key_t imageSurfaceDataKey;
static void
DestroyBuffer(void* aBuffer)
{
delete[] static_cast<uint8_t*>(aBuffer);
}
already_AddRefed<gfxASurface>
BasicPlanarYCbCrImage::DeprecatedGetAsSurface()
{
NS_ASSERTION(NS_IsMainThread(), "Must be main thread");
if (mDeprecatedSurface) {
nsRefPtr<gfxASurface> result = mDeprecatedSurface.get();
return result.forget();
}
if (!mDecodedBuffer) {
return PlanarYCbCrImage::DeprecatedGetAsSurface();
}
gfxImageFormat format = GetOffscreenFormat();
nsRefPtr<gfxImageSurface> imgSurface =
new gfxImageSurface(mDecodedBuffer, gfx::ThebesIntSize(mSize), mStride, format);
if (!imgSurface || imgSurface->CairoStatus() != 0) {
return nullptr;
}
// Pass ownership of the buffer to the surface
imgSurface->SetData(&imageSurfaceDataKey, mDecodedBuffer.forget(), DestroyBuffer);
nsRefPtr<gfxASurface> result = imgSurface.get();
#if defined(XP_MACOSX)
nsRefPtr<gfxQuartzImageSurface> quartzSurface =
new gfxQuartzImageSurface(imgSurface);
if (quartzSurface) {
result = quartzSurface.forget();
}
#endif
mDeprecatedSurface = result;
return result.forget();
}
TemporaryRef<gfx::SourceSurface>
BasicPlanarYCbCrImage::GetAsSourceSurface()
{

View File

@ -419,79 +419,6 @@ ImageLayerD3D10::GetAsTexture(gfx::IntSize* aSize)
return result.forget();
}
already_AddRefed<gfxASurface>
RemoteDXGITextureImage::DeprecatedGetAsSurface()
{
nsRefPtr<ID3D10Device1> device =
gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
if (!device) {
NS_WARNING("Cannot readback from shared texture because no D3D10 device is available.");
return nullptr;
}
TextureD3D10BackendData* data = GetD3D10TextureBackendData(device);
if (!data) {
return nullptr;
}
nsRefPtr<IDXGIKeyedMutex> keyedMutex;
if (FAILED(data->mTexture->QueryInterface(IID_IDXGIKeyedMutex, getter_AddRefs(keyedMutex)))) {
NS_WARNING("Failed to QueryInterface for IDXGIKeyedMutex, strange.");
return nullptr;
}
if (FAILED(keyedMutex->AcquireSync(0, 0))) {
NS_WARNING("Failed to acquire sync for keyedMutex, plugin failed to release?");
return nullptr;
}
D3D10_TEXTURE2D_DESC desc;
data->mTexture->GetDesc(&desc);
desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ;
desc.BindFlags = 0;
desc.MiscFlags = 0;
desc.Usage = D3D10_USAGE_STAGING;
nsRefPtr<ID3D10Texture2D> softTexture;
HRESULT hr = device->CreateTexture2D(&desc, nullptr, getter_AddRefs(softTexture));
if (FAILED(hr)) {
NS_WARNING("Failed to create 2D staging texture.");
return nullptr;
}
device->CopyResource(softTexture, data->mTexture);
keyedMutex->ReleaseSync(0);
nsRefPtr<gfxImageSurface> surface =
new gfxImageSurface(ThebesIntSize(mSize),
mFormat == RemoteImageData::BGRX32 ?
gfxImageFormat::RGB24 :
gfxImageFormat::ARGB32);
if (!surface->CairoSurface() || surface->CairoStatus()) {
NS_WARNING("Failed to created image surface for DXGI texture.");
return nullptr;
}
D3D10_MAPPED_TEXTURE2D mapped;
softTexture->Map(0, D3D10_MAP_READ, 0, &mapped);
for (int y = 0; y < mSize.height; y++) {
memcpy(surface->Data() + surface->Stride() * y,
(unsigned char*)(mapped.pData) + mapped.RowPitch * y,
mSize.width * 4);
}
softTexture->Unmap(0);
return surface.forget();
}
TemporaryRef<gfx::SourceSurface>
RemoteDXGITextureImage::GetAsSourceSurface()
{

View File

@ -58,7 +58,6 @@ class RemoteDXGITextureImage : public Image {
public:
RemoteDXGITextureImage() : Image(nullptr, ImageFormat::REMOTE_IMAGE_DXGI_TEXTURE) {}
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
mozilla::gfx::IntSize GetSize() { return mSize; }

View File

@ -68,16 +68,6 @@ SharedPlanarYCbCrImage::GetBuffer()
return mTextureClient->GetBuffer();
}
already_AddRefed<gfxASurface>
SharedPlanarYCbCrImage::DeprecatedGetAsSurface()
{
if (!mTextureClient->IsAllocated()) {
NS_WARNING("Can't get as surface");
return nullptr;
}
return PlanarYCbCrImage::DeprecatedGetAsSurface();
}
TemporaryRef<gfx::SourceSurface>
SharedPlanarYCbCrImage::GetAsSourceSurface()
{

View File

@ -37,7 +37,6 @@ public:
virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() MOZ_OVERRIDE;
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
virtual void SetData(const PlanarYCbCrData& aData) MOZ_OVERRIDE;
virtual void SetDataNoCopy(const Data &aData) MOZ_OVERRIDE;

View File

@ -113,12 +113,6 @@ SharedRGBImage::GetTextureClient(CompositableClient* aClient)
return mTextureClient.get();
}
already_AddRefed<gfxASurface>
SharedRGBImage::DeprecatedGetAsSurface()
{
return nullptr;
}
TemporaryRef<gfx::SourceSurface>
SharedRGBImage::GetAsSourceSurface()
{

View File

@ -55,8 +55,6 @@ public:
size_t GetBufferSize();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
bool Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);

View File

@ -980,7 +980,6 @@ RasterImage::GetCurrentImage()
}
CairoImage::Data cairoData;
cairoData.mDeprecatedSurface = imageSurface;
GetWidth(&cairoData.mSize.width);
GetHeight(&cairoData.mSize.height);
cairoData.mSourceSurface = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr, imageSurface);

View File

@ -3962,9 +3962,6 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const DisplayItemClip& aClip,
nsRefPtr<Image> image = container->CreateImage(ImageFormat::CAIRO_SURFACE);
NS_ASSERTION(image, "Could not create image container for mask layer.");
CairoImage::Data data;
// XXXjwatt bug 960524 which kills off mDeprecatedSurface, and this will
// land with that.
data.mDeprecatedSurface = nullptr;
data.mSize = surfaceSizeInt;
data.mSourceSurface = surface;