Bug 964732 - Remove calls to DeprecatedGetAsSurface in ImageLayerD3D9 (Moz2D migration). r=mattwoodrow

This commit is contained in:
Jonathan Watt 2014-04-02 12:32:54 +01:00
Родитель 8dc6701a08
Коммит a69270480e
1 изменённых файлов: 19 добавлений и 19 удалений

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

@ -4,7 +4,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ipc/AutoOpenSurface.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/RefPtr.h"
#include "mozilla/layers/PLayerTransaction.h"
#include "gfxSharedImageSurface.h"
@ -25,9 +27,9 @@ namespace layers {
using namespace mozilla::gfx;
static inline _D3DFORMAT
D3dFormatForGfxFormat(gfxImageFormat aFormat)
D3dFormatForSurfaceFormat(SurfaceFormat aFormat)
{
if (aFormat == gfxImageFormat::A8) {
if (aFormat == SurfaceFormat::A8) {
return D3DFMT_A8;
}
@ -133,24 +135,22 @@ OpenSharedTexture(const D3DSURFACE_DESC& aDesc,
static already_AddRefed<IDirect3DTexture9>
SurfaceToTexture(IDirect3DDevice9 *aDevice,
gfxASurface *aSurface,
SourceSurface *aSurface,
const IntSize &aSize)
{
nsRefPtr<gfxImageSurface> imageSurface = aSurface->GetAsImageSurface();
if (!imageSurface) {
imageSurface = new gfxImageSurface(ThebesIntSize(aSize),
gfxImageFormat::ARGB32);
nsRefPtr<gfxContext> context = new gfxContext(imageSurface);
context->SetSource(aSurface);
context->SetOperator(gfxContext::OPERATOR_SOURCE);
context->Paint();
RefPtr<DataSourceSurface> dataSurface = aSurface->GetDataSurface();
if (!dataSurface) {
return nullptr;
}
return DataToTexture(aDevice, imageSurface->Data(), imageSurface->Stride(),
aSize, D3dFormatForGfxFormat(imageSurface->Format()));
DataSourceSurface::MappedSurface map;
if (!dataSurface->Map(DataSourceSurface::MapType::READ, &map)) {
return nullptr;
}
nsRefPtr<IDirect3DTexture9> texture =
DataToTexture(aDevice, map.mData, map.mStride, aSize,
D3dFormatForSurfaceFormat(dataSurface->GetFormat()));
dataSurface->Unmap();
return texture.forget();
}
static void AllocateTexturesYCbCr(PlanarYCbCrImage *aImage,
@ -344,7 +344,7 @@ ImageLayerD3D9::GetTexture(Image *aImage, bool& aHasAlpha)
CairoImage *cairoImage =
static_cast<CairoImage*>(aImage);
nsRefPtr<gfxASurface> surf = cairoImage->DeprecatedGetAsSurface();
RefPtr<SourceSurface> surf = cairoImage->GetAsSourceSurface();
if (!surf) {
return nullptr;
}
@ -357,7 +357,7 @@ ImageLayerD3D9::GetTexture(Image *aImage, bool& aHasAlpha)
}
}
aHasAlpha = surf->GetContentType() == gfxContentType::COLOR_ALPHA;
aHasAlpha = surf->GetFormat() == SurfaceFormat::B8G8R8A8;
} else if (aImage->GetFormat() == ImageFormat::D3D9_RGB32_TEXTURE) {
if (!aImage->GetBackendData(mozilla::layers::LayersBackend::LAYERS_D3D9)) {
// The texture in which the frame is stored belongs to DXVA's D3D9 device.