Back out c8f7bace9cf9, 17ec4e01c126 (bug 767480) r=bustage

This commit is contained in:
Kan-Ru Chen (陳侃如) 2012-08-21 17:55:02 +08:00
parent 2225b447e6
commit 22db9a8e93
11 changed files with 124 additions and 357 deletions

View File

@ -63,20 +63,6 @@ ValidatePlane(const VideoData::YCbCrBuffer::Plane& aPlane)
aPlane.mStride > 0;
}
static bool
IsYV12Format(const VideoData::YCbCrBuffer::Plane& aYPlane,
const VideoData::YCbCrBuffer::Plane& aCbPlane,
const VideoData::YCbCrBuffer::Plane& aCrPlane)
{
return
aYPlane.mWidth % 2 == 0 &&
aYPlane.mHeight % 2 == 0 &&
aYPlane.mWidth / 2 == aCbPlane.mWidth &&
aYPlane.mHeight / 2 == aCbPlane.mHeight &&
aCbPlane.mWidth == aCrPlane.mWidth &&
aCbPlane.mHeight == aCrPlane.mHeight;
}
bool
nsVideoInfo::ValidateVideoRegion(const nsIntSize& aFrame,
const nsIntRect& aPicture,
@ -197,46 +183,38 @@ VideoData* VideoData::Create(nsVideoInfo& aInfo,
aKeyframe,
aTimecode,
aInfo.mDisplay));
const YCbCrBuffer::Plane &Y = aBuffer.mPlanes[0];
const YCbCrBuffer::Plane &Cb = aBuffer.mPlanes[1];
const YCbCrBuffer::Plane &Cr = aBuffer.mPlanes[2];
// Currently our decoder only knows how to output to PLANAR_YCBCR
// format.
ImageFormat format[2] = {PLANAR_YCBCR, GRALLOC_PLANAR_YCBCR};
if (IsYV12Format(Y, Cb, Cr)) {
v->mImage = aContainer->CreateImage(format, 2);
} else {
v->mImage = aContainer->CreateImage(format, 1);
}
ImageFormat format = PLANAR_YCBCR;
v->mImage = aContainer->CreateImage(&format, 1);
if (!v->mImage) {
return nullptr;
}
NS_ASSERTION(v->mImage->GetFormat() == PLANAR_YCBCR ||
v->mImage->GetFormat() == GRALLOC_PLANAR_YCBCR,
NS_ASSERTION(v->mImage->GetFormat() == PLANAR_YCBCR,
"Wrong format?");
PlanarYCbCrImage* videoImage = static_cast<PlanarYCbCrImage*>(v->mImage.get());
PlanarYCbCrImage::Data data;
const YCbCrBuffer::Plane &Y = aBuffer.mPlanes[0];
const YCbCrBuffer::Plane &Cb = aBuffer.mPlanes[1];
const YCbCrBuffer::Plane &Cr = aBuffer.mPlanes[2];
data.mYChannel = Y.mData;
data.mYSize = gfxIntSize(Y.mWidth, Y.mHeight);
data.mYStride = Y.mStride;
data.mYOffset = Y.mOffset;
data.mYSkip = Y.mSkip;
data.mCbChannel = Cb.mData;
data.mCrChannel = Cr.mData;
data.mCbCrSize = gfxIntSize(Cb.mWidth, Cb.mHeight);
data.mCbCrStride = Cb.mStride;
data.mCbOffset = Cb.mOffset;
data.mCbSkip = Cb.mSkip;
data.mCrOffset = Cr.mOffset;
data.mCrSkip = Cr.mSkip;
data.mPicX = aPicture.x;
data.mPicY = aPicture.y;
data.mPicSize = gfxIntSize(aPicture.width, aPicture.height);
data.mStereoMode = aInfo.mStereoMode;
videoImage->CopyData(data);
videoImage->CopyData(data,
Y.mOffset, Y.mSkip,
Cb.mOffset, Cb.mSkip,
Cr.mOffset, Cr.mSkip);
return v.forget();
}

View File

@ -1,108 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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 "mozilla/layers/ImageBridgeChild.h"
#include "nsDebug.h"
#include "ImageContainer.h"
#include "GrallocImages.h"
using namespace mozilla::ipc;
using namespace android;
namespace mozilla {
namespace layers {
GrallocPlanarYCbCrImage::GrallocPlanarYCbCrImage()
: PlanarYCbCrImage(nullptr)
{
mFormat = GRALLOC_PLANAR_YCBCR;
}
GrallocPlanarYCbCrImage::~GrallocPlanarYCbCrImage()
{
ImageBridgeChild *ibc = ImageBridgeChild::GetSingleton();
ibc->DeallocSurfaceDescriptorGralloc(mSurfaceDescriptor);
}
void
GrallocPlanarYCbCrImage::SetData(const Data& aData)
{
NS_PRECONDITION(aData.mYSize.width % 2 == 0, "Image should have even width");
NS_PRECONDITION(aData.mYSize.height % 2 == 0, "Image should have even height");
NS_PRECONDITION(aData.mYStride % 16 == 0, "Image should have stride of multiple of 16 pixels");
mData = aData;
mSize = aData.mPicSize;
if (mSurfaceDescriptor.type() == SurfaceDescriptor::T__None) {
ImageBridgeChild *ibc = ImageBridgeChild::GetSingleton();
ibc->AllocSurfaceDescriptorGralloc(aData.mYSize,
HAL_PIXEL_FORMAT_YV12,
GraphicBuffer::USAGE_SW_READ_OFTEN |
GraphicBuffer::USAGE_SW_WRITE_OFTEN |
GraphicBuffer::USAGE_HW_TEXTURE,
&mSurfaceDescriptor);
}
sp<GraphicBuffer> graphicBuffer =
GrallocBufferActor::GetFrom(mSurfaceDescriptor.get_SurfaceDescriptorGralloc());
if (!graphicBuffer.get()) {
return;
}
if (graphicBuffer->initCheck() != NO_ERROR) {
return;
}
void* vaddr;
if (graphicBuffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,
&vaddr) != OK) {
return;
}
PRUint8* yChannel = static_cast<PRUint8*>(vaddr);
gfxIntSize ySize = gfxIntSize(aData.mYSize.width,
aData.mYSize.height);
PRInt32 yStride = graphicBuffer->getStride();
PRUint8* vChannel = yChannel + (yStride * ySize.height);
gfxIntSize uvSize = gfxIntSize(ySize.width / 2,
ySize.height / 2);
// Align to 16 bytes boundary
PRInt32 uvStride = ((yStride / 2) + 15) & ~0x0F;
PRUint8* uChannel = vChannel + (uvStride * uvSize.height);
// Memory outside of the image width may not writable. If the stride
// equals to the image width then we can use only one copy.
if (yStride == mData.mYStride &&
yStride == ySize.width) {
memcpy(yChannel, mData.mYChannel, yStride * ySize.width);
} else {
for (int i = 0; i < ySize.height; i++) {
memcpy(yChannel + i * yStride,
mData.mYChannel + i * mData.mYStride,
ySize.width);
}
}
if (uvStride == mData.mCbCrStride &&
uvStride == uvSize.width) {
memcpy(uChannel, mData.mCbChannel, uvStride * uvSize.width);
memcpy(vChannel, mData.mCrChannel, uvStride * uvSize.width);
} else {
for (int i = 0; i < uvSize.height; i++) {
memcpy(uChannel + i * uvStride,
mData.mCbChannel + i * mData.mCbCrStride,
uvSize.width);
memcpy(vChannel + i * uvStride,
mData.mCrChannel + i * mData.mCbCrStride,
uvSize.width);
}
}
graphicBuffer->unlock();
}
} // namespace layers
} // namespace mozilla

View File

@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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/. */
#ifndef GRALLOCIMAGES_H
#define GRALLOCIMAGES_H
#ifdef MOZ_WIDGET_GONK
#include "mozilla/layers/LayersSurfaces.h"
#include "ImageLayers.h"
#include <ui/GraphicBuffer.h>
namespace mozilla {
namespace layers {
/**
* The YUV format supported by Android HAL
*
* 4:2:0 - CbCr width and height is half that of Y.
*
* This format assumes
* - an even width
* - an even height
* - a horizontal stride multiple of 16 pixels
* - a vertical stride equal to the height
*
* y_size = stride * height
* c_size = ALIGN(stride/2, 16) * height/2
* size = y_size + c_size * 2
* cr_offset = y_size
* cb_offset = y_size + c_size
*
* The Image that is rendered is the picture region defined by
* mPicX, mPicY and mPicSize. The size of the rendered image is
* mPicSize, not mYSize or mCbCrSize.
*/
class THEBES_API GrallocPlanarYCbCrImage : public PlanarYCbCrImage {
typedef PlanarYCbCrImage::Data Data;
public:
GrallocPlanarYCbCrImage();
virtual ~GrallocPlanarYCbCrImage();
/**
* This makes a copy of the data buffers, in order to support functioning
* in all different layer managers.
*/
virtual void SetData(const Data& aData);
virtual PRUint32 GetDataSize() { return 0; }
virtual bool IsValid() { return mSurfaceDescriptor.type() != SurfaceDescriptor::T__None; }
SurfaceDescriptor GetSurfaceDescriptor() {
return mSurfaceDescriptor;
}
private:
SurfaceDescriptor mSurfaceDescriptor;
};
} // namespace layers
} // namespace mozilla
#endif
#endif /* GRALLOCIMAGES_H */

View File

@ -9,7 +9,6 @@
#include "ImageContainer.h"
#include "GonkIOSurfaceImage.h"
#include "GrallocImages.h"
#include "mozilla/ipc/Shmem.h"
#include "mozilla/ipc/CrossProcessMutex.h"
#include "SharedTextureImage.h"
@ -31,7 +30,6 @@
#endif
using namespace mozilla::ipc;
using namespace android;
using mozilla::gfx::DataSourceSurface;
using mozilla::gfx::SourceSurface;
@ -49,37 +47,22 @@ ImageFactory::CreateImage(const ImageFormat *aFormats,
return nullptr;
}
nsRefPtr<Image> img;
#ifdef MOZ_WIDGET_GONK
if (FormatInList(aFormats, aNumFormats, GRALLOC_PLANAR_YCBCR)) {
img = new GrallocPlanarYCbCrImage();
return img.forget();
}
#endif
if (FormatInList(aFormats, aNumFormats, PLANAR_YCBCR)) {
img = new PlanarYCbCrImage(aRecycleBin);
return img.forget();
}
if (FormatInList(aFormats, aNumFormats, CAIRO_SURFACE)) {
} else if (FormatInList(aFormats, aNumFormats, CAIRO_SURFACE)) {
img = new CairoImage();
return img.forget();
}
if (FormatInList(aFormats, aNumFormats, SHARED_TEXTURE)) {
} else if (FormatInList(aFormats, aNumFormats, SHARED_TEXTURE)) {
img = new SharedTextureImage();
return img.forget();
}
#ifdef XP_MACOSX
if (FormatInList(aFormats, aNumFormats, MAC_IO_SURFACE)) {
} else if (FormatInList(aFormats, aNumFormats, MAC_IO_SURFACE)) {
img = new MacIOSurfaceImage();
return img.forget();
}
#endif
#ifdef MOZ_WIDGET_GONK
if (FormatInList(aFormats, aNumFormats, GONK_IO_SURFACE)) {
} else if (FormatInList(aFormats, aNumFormats, GONK_IO_SURFACE)) {
img = new GonkIOSurfaceImage();
return img.forget();
}
#endif
return nullptr;
}
return img.forget();
}
BufferRecycleBin::BufferRecycleBin()
@ -440,7 +423,10 @@ CopyPlane(PRUint8 *aDst, PRUint8 *aSrc,
}
void
PlanarYCbCrImage::CopyData(const Data& aData)
PlanarYCbCrImage::CopyData(const Data& aData,
PRInt32 aYOffset, PRInt32 aYSkip,
PRInt32 aCbOffset, PRInt32 aCbSkip,
PRInt32 aCrOffset, PRInt32 aCrSkip)
{
mData = aData;
@ -459,13 +445,13 @@ PlanarYCbCrImage::CopyData(const Data& aData)
CopyPlane(mData.mYChannel, aData.mYChannel,
mData.mYSize, mData.mYStride,
mData.mYOffset, mData.mYSkip);
aYOffset, aYSkip);
CopyPlane(mData.mCbChannel, aData.mCbChannel,
mData.mCbCrSize, mData.mCbCrStride,
mData.mCbOffset, mData.mCbSkip);
aCbOffset, aCbSkip);
CopyPlane(mData.mCrChannel, aData.mCrChannel,
mData.mCbCrSize, mData.mCbCrStride,
mData.mCrOffset, mData.mCrSkip);
aCrOffset, aCrSkip);
mSize = aData.mPicSize;
}

View File

@ -603,11 +603,6 @@ private:
* The Image that is rendered is the picture region defined by
* mPicX, mPicY and mPicSize. The size of the rendered image is
* mPicSize, not mYSize or mCbCrSize.
*
* mYOffset, mYSkip, mCbOffset, mCbSkip, mCrOffset, mCrSkip are added
* to support various output formats from hardware decoder. m*Offset
* are the extra left stride and m*Skip are per-pixel skips in the
* source image.
*/
class THEBES_API PlanarYCbCrImage : public Image {
public:
@ -616,17 +611,11 @@ public:
PRUint8* mYChannel;
PRInt32 mYStride;
gfxIntSize mYSize;
PRInt32 mYOffset;
PRInt32 mYSkip;
// Chroma buffers
PRUint8* mCbChannel;
PRUint8* mCrChannel;
PRInt32 mCbCrStride;
gfxIntSize mCbCrSize;
PRInt32 mCbOffset;
PRInt32 mCbSkip;
PRInt32 mCrOffset;
PRInt32 mCrSkip;
// Picture region
PRUint32 mPicX;
PRUint32 mPicY;
@ -644,7 +633,7 @@ public:
MAX_DIMENSION = 16384
};
virtual ~PlanarYCbCrImage();
~PlanarYCbCrImage();
/**
* This makes a copy of the data buffers, in order to support functioning
@ -664,24 +653,21 @@ public:
*/
virtual const Data* GetData() { return &mData; }
/**
* Return the number of bytes of heap memory used to store this image.
*/
virtual PRUint32 GetDataSize() { return mBufferSize; }
virtual bool IsValid() { return !!mBufferSize; }
virtual gfxIntSize GetSize() { return mSize; }
PlanarYCbCrImage(BufferRecycleBin *aRecycleBin);
protected:
/**
* Make a copy of the YCbCr data into local storage.
*
* @param aData Input image data.
* @param aYOffset Pixels to skip between lines in the Y plane.
* @param aYSkip Pixels to skip between pixels in the Y plane.
* @param aCbOffset Pixels to skip between lines in the Cb plane.
* @param aCbSkip Pixels to skip between pixels in the Cb plane.
* @param aCrOffset Pixels to skip between lines in the Cr plane.
* @param aCrSkip Pixels to skip between pixels in the Cr plane.
*/
void CopyData(const Data& aData);
void CopyData(const Data& aData,
PRInt32 aYOffset = 0, PRInt32 aYSkip = 0,
PRInt32 aCbOffset = 0, PRInt32 aCbSkip = 0,
PRInt32 aCrOffset = 0, PRInt32 aCrSkip = 0);
/**
* Return a buffer to store image data in.
@ -690,11 +676,19 @@ protected:
*/
virtual PRUint8* AllocateBuffer(PRUint32 aSize);
/**
* Return the number of bytes of heap memory used to store this image.
*/
virtual PRUint32 GetDataSize() { return mBufferSize; }
already_AddRefed<gfxASurface> GetAsSurface();
virtual gfxIntSize GetSize() { return mSize; }
void SetOffscreenFormat(gfxASurface::gfxImageFormat aFormat) { mOffscreenFormat = aFormat; }
gfxASurface::gfxImageFormat GetOffscreenFormat() { return mOffscreenFormat; }
// XXX - not easy to protect these sadly.
nsAutoArrayPtr<PRUint8> mBuffer;
PRUint32 mBufferSize;
Data mData;
@ -702,6 +696,8 @@ protected:
gfxASurface::gfxImageFormat mOffscreenFormat;
nsCountedRef<nsMainThreadSurfaceRef> mSurface;
nsRefPtr<BufferRecycleBin> mRecycleBin;
PlanarYCbCrImage(BufferRecycleBin *aRecycleBin);
};
/**
@ -831,4 +827,4 @@ public:
} //namespace
} //namespace
#endif
#endif

View File

@ -16,13 +16,6 @@ enum ImageFormat {
*/
PLANAR_YCBCR,
/**
* The GRALLOC_PLANAR_YCBCR format creates a GrallocPlanarYCbCrImage, a
* subtype of PlanarYCbCrImage. It takes a PlanarYCbCrImage data and can be
* used as a texture by Gonk backend directly.
*/
GRALLOC_PLANAR_YCBCR,
/**
* The CAIRO_SURFACE format creates a CairoImage. All backends should
* support this format, because video rendering sometimes requires it.
@ -80,4 +73,4 @@ enum StereoMode {
} // namespace
#endif
#endif

View File

@ -172,10 +172,7 @@ endif
# has full system permissions there.
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
EXPORTS_mozilla/layers += ShadowLayerUtilsGralloc.h
CPPSRCS += \
ShadowLayerUtilsGralloc.cpp \
GrallocImages.cpp \
$(NULL)
CPPSRCS += ShadowLayerUtilsGralloc.cpp
endif
include $(topsrcdir)/config/rules.mk

View File

@ -224,7 +224,7 @@ ImageLayerD3D10::RenderLayer()
PlanarYCbCrImage *yuvImage =
static_cast<PlanarYCbCrImage*>(image);
if (!yuvImage->IsValid()) {
if (!yuvImage->mBufferSize) {
return;
}
@ -261,7 +261,7 @@ ImageLayerD3D10::RenderLayer()
*/
if (GetNv3DVUtils()) {
Nv_Stereo_Mode mode;
switch (yuvImage->GetData()->mStereoMode) {
switch (yuvImage->mData.mStereoMode) {
case STEREO_MODE_LEFT_RIGHT:
mode = NV_STEREO_MODE_LEFT_RIGHT;
break;
@ -282,10 +282,10 @@ ImageLayerD3D10::RenderLayer()
// Send control data even in mono case so driver knows to leave stereo mode.
GetNv3DVUtils()->SendNv3DVControl(mode, true, FIREFOX_3DV_APP_HANDLE);
if (yuvImage->GetData()->mStereoMode != STEREO_MODE_MONO) {
if (yuvImage->mData.mStereoMode != STEREO_MODE_MONO) {
// Dst resource is optional
GetNv3DVUtils()->SendNv3DVMetaData((unsigned int)yuvImage->GetData()->mYSize.width,
(unsigned int)yuvImage->GetData()->mYSize.height, (HANDLE)(data->mYTexture), (HANDLE)(NULL));
GetNv3DVUtils()->SendNv3DVMetaData((unsigned int)yuvImage->mData.mYSize.width,
(unsigned int)yuvImage->mData.mYSize.height, (HANDLE)(data->mYTexture), (HANDLE)(NULL));
}
}
@ -299,10 +299,10 @@ ImageLayerD3D10::RenderLayer()
effect()->GetVariableByName("vTextureCoords")->AsVector()->SetFloatVector(
ShaderConstantRectD3D10(
(float)yuvImage->GetData()->mPicX / yuvImage->GetData()->mYSize.width,
(float)yuvImage->GetData()->mPicY / yuvImage->GetData()->mYSize.height,
(float)yuvImage->GetData()->mPicSize.width / yuvImage->GetData()->mYSize.width,
(float)yuvImage->GetData()->mPicSize.height / yuvImage->GetData()->mYSize.height)
(float)yuvImage->mData.mPicX / yuvImage->mData.mYSize.width,
(float)yuvImage->mData.mPicY / yuvImage->mData.mYSize.height,
(float)yuvImage->mData.mPicSize.width / yuvImage->mData.mYSize.width,
(float)yuvImage->mData.mPicSize.height / yuvImage->mData.mYSize.height)
);
}
@ -330,26 +330,26 @@ void ImageLayerD3D10::AllocateTexturesYCbCr(PlanarYCbCrImage *aImage)
nsAutoPtr<PlanarYCbCrD3D10BackendData> backendData(
new PlanarYCbCrD3D10BackendData);
const PlanarYCbCrImage::Data *data = aImage->GetData();
PlanarYCbCrImage::Data &data = aImage->mData;
D3D10_SUBRESOURCE_DATA dataY;
D3D10_SUBRESOURCE_DATA dataCb;
D3D10_SUBRESOURCE_DATA dataCr;
CD3D10_TEXTURE2D_DESC descY(DXGI_FORMAT_R8_UNORM,
data->mYSize.width,
data->mYSize.height, 1, 1);
data.mYSize.width,
data.mYSize.height, 1, 1);
CD3D10_TEXTURE2D_DESC descCbCr(DXGI_FORMAT_R8_UNORM,
data->mCbCrSize.width,
data->mCbCrSize.height, 1, 1);
data.mCbCrSize.width,
data.mCbCrSize.height, 1, 1);
descY.Usage = descCbCr.Usage = D3D10_USAGE_IMMUTABLE;
dataY.pSysMem = data->mYChannel;
dataY.SysMemPitch = data->mYStride;
dataCb.pSysMem = data->mCbChannel;
dataCb.SysMemPitch = data->mCbCrStride;
dataCr.pSysMem = data->mCrChannel;
dataCr.SysMemPitch = data->mCbCrStride;
dataY.pSysMem = data.mYChannel;
dataY.SysMemPitch = data.mYStride;
dataCb.pSysMem = data.mCbChannel;
dataCb.SysMemPitch = data.mCbCrStride;
dataCr.pSysMem = data.mCrChannel;
dataCr.SysMemPitch = data.mCbCrStride;
HRESULT hr = device()->CreateTexture2D(&descY, &dataY, getter_AddRefs(backendData->mYTexture));
if (!FAILED(hr)) {

View File

@ -133,7 +133,7 @@ static void AllocateTexturesYCbCr(PlanarYCbCrImage *aImage,
nsAutoPtr<PlanarYCbCrD3D9BackendData> backendData(
new PlanarYCbCrD3D9BackendData);
const PlanarYCbCrImage::Data *data = aImage->GetData();
PlanarYCbCrImage::Data &data = aImage->mData;
D3DLOCKED_RECT lockrectY;
D3DLOCKED_RECT lockrectCb;
@ -160,31 +160,31 @@ static void AllocateTexturesYCbCr(PlanarYCbCrImage *aImage,
// better idea.
HRESULT hr;
hr = aDevice->CreateTexture(data->mYSize.width, data->mYSize.height,
hr = aDevice->CreateTexture(data.mYSize.width, data.mYSize.height,
1, 0, D3DFMT_L8, D3DPOOL_DEFAULT,
getter_AddRefs(backendData->mYTexture), NULL);
if (!FAILED(hr)) {
hr = aDevice->CreateTexture(data->mCbCrSize.width, data->mCbCrSize.height,
hr = aDevice->CreateTexture(data.mCbCrSize.width, data.mCbCrSize.height,
1, 0, D3DFMT_L8, D3DPOOL_DEFAULT,
getter_AddRefs(backendData->mCbTexture), NULL);
}
if (!FAILED(hr)) {
hr = aDevice->CreateTexture(data->mCbCrSize.width, data->mCbCrSize.height,
hr = aDevice->CreateTexture(data.mCbCrSize.width, data.mCbCrSize.height,
1, 0, D3DFMT_L8, D3DPOOL_DEFAULT,
getter_AddRefs(backendData->mCrTexture), NULL);
}
if (!FAILED(hr)) {
hr = aDevice->CreateTexture(data->mYSize.width, data->mYSize.height,
hr = aDevice->CreateTexture(data.mYSize.width, data.mYSize.height,
1, 0, D3DFMT_L8, D3DPOOL_SYSTEMMEM,
getter_AddRefs(tmpYTexture), NULL);
}
if (!FAILED(hr)) {
hr = aDevice->CreateTexture(data->mCbCrSize.width, data->mCbCrSize.height,
hr = aDevice->CreateTexture(data.mCbCrSize.width, data.mCbCrSize.height,
1, 0, D3DFMT_L8, D3DPOOL_SYSTEMMEM,
getter_AddRefs(tmpCbTexture), NULL);
}
if (!FAILED(hr)) {
hr = aDevice->CreateTexture(data->mCbCrSize.width, data->mCbCrSize.height,
hr = aDevice->CreateTexture(data.mCbCrSize.width, data.mCbCrSize.height,
1, 0, D3DFMT_L8, D3DPOOL_SYSTEMMEM,
getter_AddRefs(tmpCrTexture), NULL);
}
@ -203,16 +203,16 @@ static void AllocateTexturesYCbCr(PlanarYCbCrImage *aImage,
tmpSurfaceCr->LockRect(&lockrectCr, NULL, 0);
} else {
HRESULT hr;
hr = aDevice->CreateTexture(data->mYSize.width, data->mYSize.height,
hr = aDevice->CreateTexture(data.mYSize.width, data.mYSize.height,
1, 0, D3DFMT_L8, D3DPOOL_MANAGED,
getter_AddRefs(backendData->mYTexture), NULL);
if (!FAILED(hr)) {
aDevice->CreateTexture(data->mCbCrSize.width, data->mCbCrSize.height,
aDevice->CreateTexture(data.mCbCrSize.width, data.mCbCrSize.height,
1, 0, D3DFMT_L8, D3DPOOL_MANAGED,
getter_AddRefs(backendData->mCbTexture), NULL);
}
if (!FAILED(hr)) {
aDevice->CreateTexture(data->mCbCrSize.width, data->mCbCrSize.height,
aDevice->CreateTexture(data.mCbCrSize.width, data.mCbCrSize.height,
1, 0, D3DFMT_L8, D3DPOOL_MANAGED,
getter_AddRefs(backendData->mCrTexture), NULL);
}
@ -229,37 +229,37 @@ static void AllocateTexturesYCbCr(PlanarYCbCrImage *aImage,
backendData->mCrTexture->LockRect(0, &lockrectCr, NULL, 0);
}
src = data->mYChannel;
src = data.mYChannel;
//FIX cast
dest = (PRUint8*)lockrectY.pBits;
// copy over data
for (int h=0; h<data->mYSize.height; h++) {
memcpy(dest, src, data->mYSize.width);
for (int h=0; h<data.mYSize.height; h++) {
memcpy(dest, src, data.mYSize.width);
dest += lockrectY.Pitch;
src += data->mYStride;
src += data.mYStride;
}
src = data->mCbChannel;
src = data.mCbChannel;
//FIX cast
dest = (PRUint8*)lockrectCb.pBits;
// copy over data
for (int h=0; h<data->mCbCrSize.height; h++) {
memcpy(dest, src, data->mCbCrSize.width);
for (int h=0; h<data.mCbCrSize.height; h++) {
memcpy(dest, src, data.mCbCrSize.width);
dest += lockrectCb.Pitch;
src += data->mCbCrStride;
src += data.mCbCrStride;
}
src = data->mCrChannel;
src = data.mCrChannel;
//FIX cast
dest = (PRUint8*)lockrectCr.pBits;
// copy over data
for (int h=0; h<data->mCbCrSize.height; h++) {
memcpy(dest, src, data->mCbCrSize.width);
for (int h=0; h<data.mCbCrSize.height; h++) {
memcpy(dest, src, data.mCbCrSize.width);
dest += lockrectCr.Pitch;
src += data->mCbCrStride;
src += data.mCbCrStride;
}
if (isD3D9Ex) {
@ -300,7 +300,7 @@ ImageLayerD3D9::GetTexture(Image *aImage, bool& aHasAlpha)
{
NS_ASSERTION(aImage, "Null image.");
if (aImage->GetFormat() == REMOTE_IMAGE_BITMAP) {
if (aImage->GetFormat() == ImageFormat::REMOTE_IMAGE_BITMAP) {
RemoteBitmapImage *remoteImage =
static_cast<RemoteBitmapImage*>(aImage);
@ -313,7 +313,7 @@ ImageLayerD3D9::GetTexture(Image *aImage, bool& aHasAlpha)
}
aHasAlpha = remoteImage->mFormat == RemoteImageData::BGRA32;
} else if (aImage->GetFormat() == CAIRO_SURFACE) {
} else if (aImage->GetFormat() == ImageFormat::CAIRO_SURFACE) {
CairoImage *cairoImage =
static_cast<CairoImage*>(aImage);
@ -370,10 +370,10 @@ ImageLayerD3D9::RenderLayer()
gfxIntSize size = mScaleMode == SCALE_NONE ? image->GetSize() : mScaleToSize;
if (image->GetFormat() == CAIRO_SURFACE ||
image->GetFormat() == REMOTE_IMAGE_BITMAP)
if (image->GetFormat() == ImageFormat::CAIRO_SURFACE ||
image->GetFormat() == ImageFormat::REMOTE_IMAGE_BITMAP)
{
NS_ASSERTION(image->GetFormat() != CAIRO_SURFACE ||
NS_ASSERTION(image->GetFormat() != ImageFormat::CAIRO_SURFACE ||
!static_cast<CairoImage*>(image)->mSurface ||
static_cast<CairoImage*>(image)->mSurface->GetContentType() != gfxASurface::CONTENT_ALPHA,
"Image layer has alpha image");
@ -412,7 +412,7 @@ ImageLayerD3D9::RenderLayer()
PlanarYCbCrImage *yuvImage =
static_cast<PlanarYCbCrImage*>(image);
if (!yuvImage->IsValid()) {
if (!yuvImage->mBufferSize) {
return;
}
@ -442,10 +442,10 @@ ImageLayerD3D9::RenderLayer()
device()->SetVertexShaderConstantF(CBvTextureCoords,
ShaderConstantRect(
(float)yuvImage->GetData()->mPicX / yuvImage->GetData()->mYSize.width,
(float)yuvImage->GetData()->mPicY / yuvImage->GetData()->mYSize.height,
(float)yuvImage->GetData()->mPicSize.width / yuvImage->GetData()->mYSize.width,
(float)yuvImage->GetData()->mPicSize.height / yuvImage->GetData()->mYSize.height
(float)yuvImage->mData.mPicX / yuvImage->mData.mYSize.width,
(float)yuvImage->mData.mPicY / yuvImage->mData.mYSize.height,
(float)yuvImage->mData.mPicSize.width / yuvImage->mData.mYSize.width,
(float)yuvImage->mData.mPicSize.height / yuvImage->mData.mYSize.height
),
1);
@ -456,7 +456,7 @@ ImageLayerD3D9::RenderLayer()
*/
if (mD3DManager->GetNv3DVUtils()) {
Nv_Stereo_Mode mode;
switch (yuvImage->GetData()->mStereoMode) {
switch (yuvImage->mData.mStereoMode) {
case STEREO_MODE_LEFT_RIGHT:
mode = NV_STEREO_MODE_LEFT_RIGHT;
break;
@ -477,13 +477,13 @@ ImageLayerD3D9::RenderLayer()
// Send control data even in mono case so driver knows to leave stereo mode.
mD3DManager->GetNv3DVUtils()->SendNv3DVControl(mode, true, FIREFOX_3DV_APP_HANDLE);
if (yuvImage->GetData()->mStereoMode != STEREO_MODE_MONO) {
if (yuvImage->mData.mStereoMode != STEREO_MODE_MONO) {
mD3DManager->GetNv3DVUtils()->SendNv3DVControl(mode, true, FIREFOX_3DV_APP_HANDLE);
nsRefPtr<IDirect3DSurface9> renderTarget;
device()->GetRenderTarget(0, getter_AddRefs(renderTarget));
mD3DManager->GetNv3DVUtils()->SendNv3DVMetaData((unsigned int)yuvImage->GetSize().width,
(unsigned int)yuvImage->GetSize().height, (HANDLE)(data->mYTexture), (HANDLE)(renderTarget));
mD3DManager->GetNv3DVUtils()->SendNv3DVMetaData((unsigned int)yuvImage->mSize.width,
(unsigned int)yuvImage->mSize.height, (HANDLE)(data->mYTexture), (HANDLE)(renderTarget));
}
}
@ -522,8 +522,8 @@ ImageLayerD3D9::GetAsTexture(gfxIntSize* aSize)
return nullptr;
}
if (image->GetFormat() != CAIRO_SURFACE &&
image->GetFormat() != REMOTE_IMAGE_BITMAP) {
if (image->GetFormat() != ImageFormat::CAIRO_SURFACE &&
image->GetFormat() != ImageFormat::REMOTE_IMAGE_BITMAP) {
return nullptr;
}
@ -616,7 +616,7 @@ ShadowImageLayerD3D9::RenderLayer()
if (mBuffer) {
mBuffer->RenderTo(mD3DManager, GetEffectiveVisibleRegion());
} else if (mYCbCrImage) {
if (!mYCbCrImage->IsValid()) {
if (!mYCbCrImage->mBufferSize) {
return;
}
@ -631,7 +631,7 @@ ShadowImageLayerD3D9::RenderLayer()
return;
}
if (!mYCbCrImage->IsValid()) {
if (!mYCbCrImage->mBufferSize) {
return;
}
@ -640,8 +640,8 @@ ShadowImageLayerD3D9::RenderLayer()
device()->SetVertexShaderConstantF(CBvLayerQuad,
ShaderConstantRect(0,
0,
mYCbCrImage->GetSize().width,
mYCbCrImage->GetSize().height),
mYCbCrImage->mSize.width,
mYCbCrImage->mSize.height),
1);
mD3DManager->SetShaderMode(DeviceManagerD3D9::YCBCRLAYER, GetMaskLayer());

View File

@ -11,7 +11,6 @@
#include "mozilla/layers/SharedImageUtils.h"
#include "ImageContainer.h"
#include "GonkIOSurfaceImage.h"
#include "GrallocImages.h"
namespace mozilla {
namespace layers {
@ -207,10 +206,6 @@ SharedImage* ImageContainerChild::CreateSharedImageFromData(Image* image)
GonkIOSurfaceImage* gonkImage = static_cast<GonkIOSurfaceImage*>(image);
SharedImage* result = new SharedImage(gonkImage->GetSurfaceDescriptor());
return result;
} else if (image->GetFormat() == GRALLOC_PLANAR_YCBCR) {
GrallocPlanarYCbCrImage* GrallocImage = static_cast<GrallocPlanarYCbCrImage*>(image);
SharedImage* result = new SharedImage(GrallocImage->GetSurfaceDescriptor());
return result;
#endif
} else {
NS_RUNTIMEABORT("TODO: Only YUVImage is supported here right now.");

View File

@ -253,7 +253,7 @@ ImageLayerOGL::RenderLayer(int,
PlanarYCbCrImage *yuvImage =
static_cast<PlanarYCbCrImage*>(image);
if (!yuvImage->IsValid()) {
if (!yuvImage->mBufferSize) {
return;
}
@ -293,8 +293,8 @@ ImageLayerOGL::RenderLayer(int,
program->Activate();
program->SetLayerQuadRect(nsIntRect(0, 0,
yuvImage->GetSize().width,
yuvImage->GetSize().height));
yuvImage->mSize.width,
yuvImage->mSize.height));
program->SetLayerTransform(GetEffectiveTransform());
program->SetLayerOpacity(GetEffectiveOpacity());
program->SetRenderOffset(aOffset);
@ -302,9 +302,9 @@ ImageLayerOGL::RenderLayer(int,
program->LoadMask(GetMaskLayer());
mOGLManager->BindAndDrawQuadWithTextureRect(program,
yuvImage->GetData()->GetPictureRect(),
nsIntSize(yuvImage->GetData()->mYSize.width,
yuvImage->GetData()->mYSize.height));
yuvImage->mData.GetPictureRect(),
nsIntSize(yuvImage->mData.mYSize.width,
yuvImage->mData.mYSize.height));
// We shouldn't need to do this, but do it anyway just in case
// someone else forgets.
@ -532,32 +532,32 @@ ImageLayerOGL::ImageLayerOGL(LayerManagerOGL *aManager)
void
ImageLayerOGL::AllocateTexturesYCbCr(PlanarYCbCrImage *aImage)
{
if (!aImage->IsValid())
if (!aImage->mBufferSize)
return;
nsAutoPtr<PlanarYCbCrOGLBackendData> backendData(
new PlanarYCbCrOGLBackendData);
const PlanarYCbCrImage::Data *data = aImage->GetData();
PlanarYCbCrImage::Data &data = aImage->mData;
gl()->MakeCurrent();
mTextureRecycleBin->GetTexture(TextureRecycleBin::TEXTURE_Y, data->mYSize, gl(), &backendData->mTextures[0]);
mTextureRecycleBin->GetTexture(TextureRecycleBin::TEXTURE_Y, data.mYSize, gl(), &backendData->mTextures[0]);
SetClamping(gl(), backendData->mTextures[0].GetTextureID());
mTextureRecycleBin->GetTexture(TextureRecycleBin::TEXTURE_C, data->mCbCrSize, gl(), &backendData->mTextures[1]);
mTextureRecycleBin->GetTexture(TextureRecycleBin::TEXTURE_C, data.mCbCrSize, gl(), &backendData->mTextures[1]);
SetClamping(gl(), backendData->mTextures[1].GetTextureID());
mTextureRecycleBin->GetTexture(TextureRecycleBin::TEXTURE_C, data->mCbCrSize, gl(), &backendData->mTextures[2]);
mTextureRecycleBin->GetTexture(TextureRecycleBin::TEXTURE_C, data.mCbCrSize, gl(), &backendData->mTextures[2]);
SetClamping(gl(), backendData->mTextures[2].GetTextureID());
UploadYUVToTexture(gl(), *data,
UploadYUVToTexture(gl(), aImage->mData,
&backendData->mTextures[0],
&backendData->mTextures[1],
&backendData->mTextures[2]);
backendData->mYSize = data->mYSize;
backendData->mCbCrSize = data->mCbCrSize;
backendData->mYSize = aImage->mData.mYSize;
backendData->mCbCrSize = aImage->mData.mCbCrSize;
backendData->mTextureRecycleBin = mTextureRecycleBin;
aImage->SetBackendData(LAYERS_OPENGL, backendData.forget());