зеркало из https://github.com/mozilla/pjs.git
Bug 565875. Part 1: Refactor PlanarYCbCrImageOGL to make ownership of its temporary buffer more explicit. r=bas
This commit is contained in:
Родитель
4791be9e87
Коммит
1efab30a6d
|
@ -207,25 +207,16 @@ ImageLayerOGL::RenderLayer(int)
|
|||
|
||||
PlanarYCbCrImageOGL::PlanarYCbCrImageOGL(mozilla::layers::LayerManagerOGL* aManager)
|
||||
: PlanarYCbCrImage(NULL)
|
||||
, mLoaded(PR_FALSE)
|
||||
, mHasData(PR_FALSE)
|
||||
, mManager(aManager)
|
||||
, mHasData(PR_FALSE)
|
||||
{
|
||||
memset(mTextures, 0, sizeof(GLuint) * 3);
|
||||
}
|
||||
|
||||
PlanarYCbCrImageOGL::~PlanarYCbCrImageOGL()
|
||||
{
|
||||
if (mHasData) {
|
||||
delete [] mData.mYChannel;
|
||||
delete [] mData.mCbChannel;
|
||||
delete [] mData.mCrChannel;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PlanarYCbCrImageOGL::SetData(const PlanarYCbCrImage::Data &aData)
|
||||
{
|
||||
// For now, we copy the data
|
||||
int width_shift = 0;
|
||||
int height_shift = 0;
|
||||
if (aData.mYSize.width == aData.mCbCrSize.width &&
|
||||
|
@ -252,26 +243,32 @@ PlanarYCbCrImageOGL::SetData(const PlanarYCbCrImage::Data &aData)
|
|||
mData.mCbCrSize.height = aData.mPicSize.height >> height_shift;
|
||||
mData.mYSize = aData.mPicSize;
|
||||
mData.mYStride = mData.mYSize.width;
|
||||
mData.mCbChannel = new PRUint8[mData.mCbCrStride * mData.mCbCrSize.height];
|
||||
mData.mCrChannel = new PRUint8[mData.mCbCrStride * mData.mCbCrSize.height];
|
||||
mData.mYChannel = new PRUint8[mData.mYStride * mData.mYSize.height];
|
||||
mBuffer = new PRUint8[mData.mCbCrStride * mData.mCbCrSize.height * 2 +
|
||||
mData.mYStride * mData.mYSize.height];
|
||||
mData.mYChannel = mBuffer;
|
||||
mData.mCbChannel = mData.mYChannel + mData.mYStride * mData.mYSize.height;
|
||||
mData.mCrChannel = mData.mCbChannel + mData.mCbCrStride * mData.mCbCrSize.height;
|
||||
int cbcr_x = aData.mPicX >> width_shift;
|
||||
int cbcr_y = aData.mPicY >> height_shift;
|
||||
|
||||
for (int i = 0; i < mData.mCbCrSize.height; i++) {
|
||||
memcpy(mData.mCbChannel + i * mData.mCbCrStride,
|
||||
aData.mCbChannel + ((cbcr_y + i) * aData.mCbCrStride) + cbcr_x,
|
||||
mData.mCbCrStride);
|
||||
memcpy(mData.mCrChannel + i * mData.mCbCrStride,
|
||||
aData.mCrChannel + ((cbcr_y + i) * aData.mCbCrStride) + cbcr_x,
|
||||
mData.mCbCrStride);
|
||||
}
|
||||
for (int i = 0; i < mData.mYSize.height; i++) {
|
||||
memcpy(mData.mYChannel + i * mData.mYStride,
|
||||
aData.mYChannel + ((aData.mPicY + i) * aData.mYStride) + aData.mPicX,
|
||||
mData.mYStride);
|
||||
}
|
||||
|
||||
for (int i = 0; i < mData.mCbCrSize.height; i++) {
|
||||
memcpy(mData.mCbChannel + i * mData.mCbCrStride,
|
||||
aData.mCbChannel + ((cbcr_y + i) * aData.mCbCrStride) + cbcr_x,
|
||||
mData.mCbCrStride);
|
||||
}
|
||||
for (int i = 0; i < mData.mCbCrSize.height; i++) {
|
||||
memcpy(mData.mCrChannel + i * mData.mCbCrStride,
|
||||
aData.mCrChannel + ((cbcr_y + i) * aData.mCbCrStride) + cbcr_x,
|
||||
mData.mCbCrStride);
|
||||
}
|
||||
|
||||
// Fix picture rect to be correct
|
||||
mData.mPicX = mData.mPicY = 0;
|
||||
mSize = aData.mPicSize;
|
||||
|
||||
mHasData = PR_TRUE;
|
||||
|
|
|
@ -93,7 +93,6 @@ class THEBES_API PlanarYCbCrImageOGL : public PlanarYCbCrImage
|
|||
{
|
||||
public:
|
||||
PlanarYCbCrImageOGL(LayerManagerOGL *aManager);
|
||||
virtual ~PlanarYCbCrImageOGL();
|
||||
|
||||
virtual void SetData(const Data &aData);
|
||||
|
||||
|
@ -101,7 +100,7 @@ public:
|
|||
* Upload the data from out mData into our textures. For now we use this to
|
||||
* make sure the textures are created and filled on the main thread.
|
||||
*/
|
||||
virtual void AllocateTextures();
|
||||
void AllocateTextures();
|
||||
/**
|
||||
* XXX
|
||||
* Free the textures, we call this from the main thread when we're done
|
||||
|
@ -109,15 +108,15 @@ public:
|
|||
* be destroyed off the main-thread and might not be able to properly clean
|
||||
* up its textures
|
||||
*/
|
||||
virtual void FreeTextures();
|
||||
virtual PRBool HasData() { return mHasData; }
|
||||
void FreeTextures();
|
||||
PRBool HasData() { return mHasData; }
|
||||
|
||||
Data mData;
|
||||
PRBool mLoaded;
|
||||
PRBool mHasData;
|
||||
GLuint mTextures[3];
|
||||
gfxIntSize mSize;
|
||||
nsAutoArrayPtr<PRUint8> mBuffer;
|
||||
LayerManagerOGL *mManager;
|
||||
Data mData;
|
||||
gfxIntSize mSize;
|
||||
GLuint mTextures[3];
|
||||
PRPackedBool mHasData;
|
||||
};
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче