Bug 958489 - Implement base Image::GetAsSourceSurface. r=nical

Added an Image::GetAsSourceSurface to return a gfx::SourceSurface
and implemented in terms of gfxPlatform::GetSourceSurfaceForSurface.

Deprecated GetAsSurface.
This commit is contained in:
Ali Akhtarzada 2014-01-15 10:06:43 -05:00
Родитель b239177978
Коммит 9d5c2a81a1
16 изменённых файлов: 42 добавлений и 31 удалений

Просмотреть файл

@ -117,7 +117,7 @@ D3D9SurfaceImage::GetSize()
}
already_AddRefed<gfxASurface>
D3D9SurfaceImage::GetAsSurface()
D3D9SurfaceImage::DeprecatedGetAsSurface()
{
NS_ENSURE_TRUE(mTexture, nullptr);

Просмотреть файл

@ -46,7 +46,7 @@ public:
gfx::IntSize GetSize() MOZ_OVERRIDE;
already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
already_AddRefed<gfxASurface> DeprecatedGetAsSurface() MOZ_OVERRIDE;
private:

Просмотреть файл

@ -197,7 +197,7 @@ ConvertYVU420SPToRGB565(void *aYData, uint32_t aYStride,
}
already_AddRefed<gfxASurface>
GrallocImage::GetAsSurface()
GrallocImage::DeprecatedGetAsSurface()
{
android::sp<GraphicBuffer> graphicBuffer =
GrallocBufferActor::GetFrom(GetSurfaceDescriptor());

Просмотреть файл

@ -109,7 +109,7 @@ public:
HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS = 0x7FA30C04,
};
virtual already_AddRefed<gfxASurface> GetAsSurface();
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
void* GetNativeBuffer()
{

Просмотреть файл

@ -21,6 +21,7 @@
#ifdef MOZ_WIDGET_GONK
#include "GrallocImages.h"
#endif
#include "gfx2DGlue.h"
#ifdef XP_MACOSX
#include "mozilla/gfx/QuartzSupport.h"
@ -49,6 +50,13 @@ class SourceSurface;
Atomic<int32_t> Image::sSerialCounter(0);
TemporaryRef<gfx::SourceSurface>
Image::GetAsSourceSurface()
{
nsRefPtr<gfxASurface> surface = DeprecatedGetAsSurface();
return gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr, surface);
}
already_AddRefed<Image>
ImageFactory::CreateImage(const ImageFormat *aFormats,
uint32_t aNumFormats,
@ -323,7 +331,7 @@ ImageContainer::LockCurrentAsSurface(gfx::IntSize *aSize, Image** aCurrentImage)
}
*aSize = mActiveImage->GetSize();
return mActiveImage->GetAsSurface();
return mActiveImage->DeprecatedGetAsSurface();
}
if (aCurrentImage) {
@ -336,7 +344,7 @@ ImageContainer::LockCurrentAsSurface(gfx::IntSize *aSize, Image** aCurrentImage)
}
*aSize = mActiveImage->GetSize();
return mActiveImage->GetAsSurface();
return mActiveImage->DeprecatedGetAsSurface();
}
void
@ -365,7 +373,7 @@ ImageContainer::GetCurrentAsSurface(gfx::IntSize *aSize)
return nullptr;
*aSize = mActiveImage->GetSize();
}
return mActiveImage->GetAsSurface();
return mActiveImage->DeprecatedGetAsSurface();
}
gfx::IntSize
@ -553,7 +561,7 @@ PlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
}
already_AddRefed<gfxASurface>
PlanarYCbCrImage::GetAsSurface()
PlanarYCbCrImage::DeprecatedGetAsSurface()
{
if (mSurface) {
nsRefPtr<gfxASurface> result = mSurface.get();
@ -580,7 +588,7 @@ PlanarYCbCrImage::GetAsSurface()
}
already_AddRefed<gfxASurface>
RemoteBitmapImage::GetAsSurface()
RemoteBitmapImage::DeprecatedGetAsSurface()
{
nsRefPtr<gfxImageSurface> newSurf =
new gfxImageSurface(ThebesIntSize(mSize),

Просмотреть файл

@ -27,6 +27,7 @@
#include "nsTArray.h" // for nsTArray
#include "mozilla/Atomics.h"
#include "nsThreadUtils.h"
#include "mozilla/gfx/2D.h"
#ifndef XPCOM_GLUE_AVOID_NSPR
/**
@ -146,7 +147,7 @@ public:
ImageFormat GetFormat() { return mFormat; }
void* GetImplData() { return mImplData; }
virtual already_AddRefed<gfxASurface> GetAsSurface() = 0;
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() = 0;
virtual gfx::IntSize GetSize() = 0;
virtual nsIntRect GetPictureRect()
{
@ -163,6 +164,8 @@ public:
void MarkSent() { mSent = true; }
bool IsSentToCompositor() { return mSent; }
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
protected:
Image(void* aImplData, ImageFormat aFormat) :
mImplData(aImplData),
@ -841,7 +844,7 @@ protected:
*/
virtual uint8_t* AllocateBuffer(uint32_t aSize);
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
void SetOffscreenFormat(gfxImageFormat aFormat) { mOffscreenFormat = aFormat; }
gfxImageFormat GetOffscreenFormat();
@ -879,7 +882,7 @@ public:
}
virtual already_AddRefed<gfxASurface> GetAsSurface()
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface()
{
nsRefPtr<gfxASurface> surface = mSurface.get();
return surface.forget();
@ -897,7 +900,7 @@ class RemoteBitmapImage : public Image {
public:
RemoteBitmapImage() : Image(nullptr, REMOTE_IMAGE_BITMAP) {}
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
gfx::IntSize GetSize() { return mSize; }

Просмотреть файл

@ -28,7 +28,7 @@ public:
virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
virtual already_AddRefed<gfxASurface> GetAsSurface() {
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() {
mSurface->Lock();
size_t bytesPerRow = mSurface->GetBytesPerRow();
size_t ioWidth = mSurface->GetDevicePixelWidth();

Просмотреть файл

@ -35,7 +35,7 @@ public:
gfx::IntSize GetSize() { return mData.mSize; }
virtual already_AddRefed<gfxASurface> GetAsSurface() {
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() {
return nullptr;
}

Просмотреть файл

@ -52,7 +52,7 @@ public:
virtual void SetData(const Data& aData);
virtual void SetDelayedConversion(bool aDelayed) { mDelayedConversion = aDelayed; }
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
private:
nsAutoArrayPtr<uint8_t> mDecodedBuffer;
@ -133,7 +133,7 @@ DestroyBuffer(void* aBuffer)
}
already_AddRefed<gfxASurface>
BasicPlanarYCbCrImage::GetAsSurface()
BasicPlanarYCbCrImage::DeprecatedGetAsSurface()
{
NS_ASSERTION(NS_IsMainThread(), "Must be main thread");
@ -143,7 +143,7 @@ BasicPlanarYCbCrImage::GetAsSurface()
}
if (!mDecodedBuffer) {
return PlanarYCbCrImage::GetAsSurface();
return PlanarYCbCrImage::DeprecatedGetAsSurface();
}
gfxImageFormat format = GetOffscreenFormat();

Просмотреть файл

@ -221,7 +221,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
GetForwarder()->UseTexture(this, mFrontBuffer);
} else {
nsRefPtr<gfxASurface> surface = image->GetAsSurface();
nsRefPtr<gfxASurface> surface = image->DeprecatedGetAsSurface();
MOZ_ASSERT(surface);
gfx::IntSize size = gfx::IntSize(image->GetSize().width, image->GetSize().height);
@ -435,7 +435,7 @@ DeprecatedImageClientSingle::UpdateImage(ImageContainer* aContainer,
mDeprecatedTextureClient->SetDescriptor(desc);
#endif
} else {
nsRefPtr<gfxASurface> surface = image->GetAsSurface();
nsRefPtr<gfxASurface> surface = image->DeprecatedGetAsSurface();
MOZ_ASSERT(surface);
EnsureDeprecatedTextureClient(TEXTURE_SHMEM);

Просмотреть файл

@ -421,7 +421,7 @@ ImageLayerD3D10::GetAsTexture(gfx::IntSize* aSize)
}
already_AddRefed<gfxASurface>
RemoteDXGITextureImage::GetAsSurface()
RemoteDXGITextureImage::DeprecatedGetAsSurface()
{
nsRefPtr<ID3D10Device1> device =
gfxWindowsPlatform::GetPlatform()->GetD3D10Device();

Просмотреть файл

@ -60,7 +60,7 @@ class RemoteDXGITextureImage : public Image {
public:
RemoteDXGITextureImage() : Image(nullptr, REMOTE_IMAGE_DXGI_TEXTURE) {}
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
IntSize GetSize() { return mSize; }

Просмотреть файл

@ -75,13 +75,13 @@ SharedPlanarYCbCrImage::GetBuffer()
}
already_AddRefed<gfxASurface>
SharedPlanarYCbCrImage::GetAsSurface()
SharedPlanarYCbCrImage::DeprecatedGetAsSurface()
{
if (!mTextureClient->IsAllocated()) {
NS_WARNING("Can't get as surface");
return nullptr;
}
return PlanarYCbCrImage::GetAsSurface();
return PlanarYCbCrImage::DeprecatedGetAsSurface();
}
void

Просмотреть файл

@ -39,13 +39,13 @@ public:
return this;
}
virtual already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() MOZ_OVERRIDE
{
if (!mAllocated) {
NS_WARNING("Can't get as surface");
return nullptr;
}
return PlanarYCbCrImage::GetAsSurface();
return PlanarYCbCrImage::DeprecatedGetAsSurface();
}
virtual void SetData(const PlanarYCbCrData& aData) MOZ_OVERRIDE;
@ -100,7 +100,7 @@ public:
virtual TextureClient* GetTextureClient() MOZ_OVERRIDE;
virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
virtual already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() MOZ_OVERRIDE;
virtual void SetData(const PlanarYCbCrData& aData) MOZ_OVERRIDE;
virtual void SetDataNoCopy(const Data &aData) MOZ_OVERRIDE;

Просмотреть файл

@ -131,7 +131,7 @@ DeprecatedSharedRGBImage::AllocateBuffer(nsIntSize aSize, gfxImageFormat aImageF
}
already_AddRefed<gfxASurface>
DeprecatedSharedRGBImage::GetAsSurface()
DeprecatedSharedRGBImage::DeprecatedGetAsSurface()
{
return nullptr;
}
@ -235,7 +235,7 @@ SharedRGBImage::GetTextureClient()
}
already_AddRefed<gfxASurface>
SharedRGBImage::GetAsSurface()
SharedRGBImage::DeprecatedGetAsSurface()
{
return nullptr;
}

Просмотреть файл

@ -60,7 +60,7 @@ public:
size_t GetBufferSize();
static uint8_t BytesPerPixel(gfxImageFormat aImageFormat);
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
/**
* Setup the Surface descriptor to contain this image's shmem, while keeping
@ -117,7 +117,7 @@ public:
size_t GetBufferSize();
already_AddRefed<gfxASurface> GetAsSurface();
already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
bool Allocate(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
private: