mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 874726 -split ShmemYCbCrImage into YCbCrImageDataSerializer and YCbCrImageDataDeserializer. r=jrmuizel
--HG-- rename : gfx/layers/ipc/ShmemYCbCrImage.cpp => gfx/layers/YCbCrImageDataSerializer.cpp rename : gfx/layers/ipc/ShmemYCbCrImage.h => gfx/layers/YCbCrImageDataSerializer.h
This commit is contained in:
parent
6d6b236316
commit
9b4532e327
@ -46,7 +46,7 @@ enum TextureClientType
|
||||
{
|
||||
TEXTURE_CONTENT, // dynamically drawn content
|
||||
TEXTURE_SHMEM, // shared memory
|
||||
TEXTURE_YCBCR, // ShmemYCbCrImage
|
||||
TEXTURE_YCBCR, // YCbCr in a shmem
|
||||
TEXTURE_SHARED_GL, // GLContext::SharedTextureHandle
|
||||
TEXTURE_SHARED_GL_EXTERNAL, // GLContext::SharedTextureHandle, the ownership of
|
||||
// the SurfaceDescriptor passed to the texture
|
||||
|
@ -134,7 +134,6 @@ CPPSRCS += \
|
||||
LayerTransactionChild.cpp \
|
||||
LayerTransactionParent.cpp \
|
||||
SharedPlanarYCbCrImage.cpp \
|
||||
ShmemYCbCrImage.cpp \
|
||||
SharedRGBImage.cpp \
|
||||
TaskThrottler.cpp \
|
||||
ImageClient.cpp \
|
||||
@ -146,6 +145,7 @@ CPPSRCS += \
|
||||
TextureHostOGL.cpp \
|
||||
TiledContentClient.cpp \
|
||||
TiledContentHost.cpp \
|
||||
YCbCrImageDataSerializer.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_X11 #{
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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 "ShmemYCbCrImage.h"
|
||||
#include "mozilla/layers/YCbCrImageDataSerializer.h"
|
||||
|
||||
#define MOZ_ALIGN_WORD(x) (((x) + 3) & ~3)
|
||||
|
||||
@ -14,11 +14,7 @@ namespace layers {
|
||||
|
||||
// The Data is layed out as follows:
|
||||
//
|
||||
// +-----------------+ -+ <-- Beginning of the Shmem
|
||||
// | | |
|
||||
// | ... | | offset
|
||||
// | | |
|
||||
// +-----------------+ -++ --+ --+
|
||||
// +-----------------+ -++ --+ --+ <-- Beginning of the buffer
|
||||
// | YCbCrBufferInfo | | | |
|
||||
// +-----------------+ --+ | |
|
||||
// | data | | | YCbCrBufferInfo->[mY/mCb/mCr]Offset
|
||||
@ -44,69 +40,68 @@ struct YCbCrBufferInfo
|
||||
uint32_t mCbCrHeight;
|
||||
};
|
||||
|
||||
static YCbCrBufferInfo* GetYCbCrBufferInfo(Shmem& aShmem, size_t aOffset)
|
||||
static YCbCrBufferInfo* GetYCbCrBufferInfo(uint8_t* aData)
|
||||
{
|
||||
return reinterpret_cast<YCbCrBufferInfo*>(aShmem.get<uint8_t>() + aOffset);
|
||||
return reinterpret_cast<YCbCrBufferInfo*>(aData);
|
||||
}
|
||||
|
||||
|
||||
uint8_t* ShmemYCbCrImage::GetYData()
|
||||
bool YCbCrImageDataDeserializerBase::IsValid()
|
||||
{
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mShmem, mOffset);
|
||||
if (mData == nullptr) {
|
||||
return false;
|
||||
}
|
||||
size_t bufferInfoSize = MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t* YCbCrImageDataDeserializerBase::GetYData()
|
||||
{
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
|
||||
return reinterpret_cast<uint8_t*>(info) + info->mYOffset;
|
||||
}
|
||||
|
||||
uint8_t* ShmemYCbCrImage::GetCbData()
|
||||
uint8_t* YCbCrImageDataDeserializerBase::GetCbData()
|
||||
{
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mShmem, mOffset);
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
|
||||
return reinterpret_cast<uint8_t*>(info) + info->mCbOffset;
|
||||
}
|
||||
|
||||
uint8_t* ShmemYCbCrImage::GetCrData()
|
||||
uint8_t* YCbCrImageDataDeserializerBase::GetCrData()
|
||||
{
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mShmem, mOffset);
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
|
||||
return reinterpret_cast<uint8_t*>(info) + info->mCrOffset;
|
||||
}
|
||||
|
||||
uint8_t* ShmemYCbCrImage::GetData()
|
||||
uint8_t* YCbCrImageDataDeserializerBase::GetData()
|
||||
{
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mShmem, mOffset);
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
|
||||
return (reinterpret_cast<uint8_t*>(info)) + MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
|
||||
}
|
||||
|
||||
uint32_t ShmemYCbCrImage::GetYStride()
|
||||
uint32_t YCbCrImageDataDeserializerBase::GetYStride()
|
||||
{
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mShmem, mOffset);
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
|
||||
return info->mYWidth;
|
||||
}
|
||||
|
||||
uint32_t ShmemYCbCrImage::GetCbCrStride()
|
||||
uint32_t YCbCrImageDataDeserializerBase::GetCbCrStride()
|
||||
{
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mShmem, mOffset);
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
|
||||
return info->mCbCrWidth;
|
||||
}
|
||||
|
||||
gfxIntSize ShmemYCbCrImage::GetYSize()
|
||||
gfxIntSize YCbCrImageDataDeserializerBase::GetYSize()
|
||||
{
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mShmem, mOffset);
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
|
||||
return gfxIntSize(info->mYWidth, info->mYHeight);
|
||||
}
|
||||
|
||||
gfxIntSize ShmemYCbCrImage::GetCbCrSize()
|
||||
gfxIntSize YCbCrImageDataDeserializerBase::GetCbCrSize()
|
||||
{
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mShmem, mOffset);
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
|
||||
return gfxIntSize(info->mCbCrWidth, info->mCbCrHeight);
|
||||
}
|
||||
|
||||
|
||||
bool ShmemYCbCrImage::Open(Shmem& aShmem, size_t aOffset)
|
||||
{
|
||||
mShmem = aShmem;
|
||||
mOffset = aOffset;
|
||||
|
||||
return IsValid();
|
||||
}
|
||||
|
||||
// Offset in bytes
|
||||
static size_t ComputeOffset(uint32_t aHeight, uint32_t aStride)
|
||||
{
|
||||
@ -114,8 +109,9 @@ static size_t ComputeOffset(uint32_t aHeight, uint32_t aStride)
|
||||
}
|
||||
|
||||
// Minimum required shmem size in bytes
|
||||
size_t ShmemYCbCrImage::ComputeMinBufferSize(const gfxIntSize& aYSize,
|
||||
const gfxIntSize& aCbCrSize)
|
||||
size_t
|
||||
YCbCrImageDataSerializer::ComputeMinBufferSize(const gfx::IntSize& aYSize,
|
||||
const gfx::IntSize& aCbCrSize)
|
||||
{
|
||||
uint32_t yStride = aYSize.width;
|
||||
uint32_t CbCrStride = aCbCrSize.width;
|
||||
@ -125,6 +121,13 @@ size_t ShmemYCbCrImage::ComputeMinBufferSize(const gfxIntSize& aYSize,
|
||||
+ MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
|
||||
}
|
||||
|
||||
size_t
|
||||
YCbCrImageDataSerializer::ComputeMinBufferSize(const gfxIntSize& aYSize,
|
||||
const gfxIntSize& aCbCrSize)
|
||||
{
|
||||
return ComputeMinBufferSize(gfx::IntSize(aYSize.width, aYSize.height),
|
||||
gfx::IntSize(aCbCrSize.width, aCbCrSize.height));
|
||||
}
|
||||
// Offset in bytes
|
||||
static size_t ComputeOffset(uint32_t aSize)
|
||||
{
|
||||
@ -132,17 +135,17 @@ static size_t ComputeOffset(uint32_t aSize)
|
||||
}
|
||||
|
||||
// Minimum required shmem size in bytes
|
||||
size_t ShmemYCbCrImage::ComputeMinBufferSize(uint32_t aSize)
|
||||
size_t
|
||||
YCbCrImageDataSerializer::ComputeMinBufferSize(uint32_t aSize)
|
||||
{
|
||||
|
||||
return ComputeOffset(aSize) + MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
|
||||
}
|
||||
|
||||
void ShmemYCbCrImage::InitializeBufferInfo(uint8_t* aBuffer,
|
||||
const gfxIntSize& aYSize,
|
||||
const gfxIntSize& aCbCrSize)
|
||||
void
|
||||
YCbCrImageDataSerializer::InitializeBufferInfo(const gfx::IntSize& aYSize,
|
||||
const gfx::IntSize& aCbCrSize)
|
||||
{
|
||||
YCbCrBufferInfo* info = reinterpret_cast<YCbCrBufferInfo*>(aBuffer);
|
||||
YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
|
||||
info->mYOffset = MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
|
||||
info->mCbOffset = info->mYOffset
|
||||
+ MOZ_ALIGN_WORD(aYSize.width * aYSize.height);
|
||||
@ -155,18 +158,12 @@ void ShmemYCbCrImage::InitializeBufferInfo(uint8_t* aBuffer,
|
||||
info->mCbCrHeight = aCbCrSize.height;
|
||||
}
|
||||
|
||||
bool ShmemYCbCrImage::IsValid()
|
||||
void
|
||||
YCbCrImageDataSerializer::InitializeBufferInfo(const gfxIntSize& aYSize,
|
||||
const gfxIntSize& aCbCrSize)
|
||||
{
|
||||
if (mShmem == Shmem()) {
|
||||
return false;
|
||||
}
|
||||
size_t bufferInfoSize = MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
|
||||
if (mShmem.Size<uint8_t>() < bufferInfoSize ||
|
||||
GetYCbCrBufferInfo(mShmem, mOffset)->mYOffset != bufferInfoSize ||
|
||||
mShmem.Size<uint8_t>() < mOffset + ComputeMinBufferSize(GetYSize(),GetCbCrSize())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
InitializeBufferInfo(gfx::IntSize(aYSize.width, aYSize.height),
|
||||
gfx::IntSize(aCbCrSize.width, aCbCrSize.height));
|
||||
}
|
||||
|
||||
static void CopyLineWithSkip(const uint8_t* src, uint8_t* dst, uint32_t len, uint32_t skip) {
|
||||
@ -177,11 +174,12 @@ static void CopyLineWithSkip(const uint8_t* src, uint8_t* dst, uint32_t len, uin
|
||||
}
|
||||
}
|
||||
|
||||
bool ShmemYCbCrImage::CopyData(const uint8_t* aYData,
|
||||
const uint8_t* aCbData, const uint8_t* aCrData,
|
||||
gfxIntSize aYSize, uint32_t aYStride,
|
||||
gfxIntSize aCbCrSize, uint32_t aCbCrStride,
|
||||
uint32_t aYSkip, uint32_t aCbCrSkip)
|
||||
bool
|
||||
YCbCrImageDataSerializer::CopyData(const uint8_t* aYData,
|
||||
const uint8_t* aCbData, const uint8_t* aCrData,
|
||||
gfxIntSize aYSize, uint32_t aYStride,
|
||||
gfxIntSize aCbCrSize, uint32_t aCbCrStride,
|
||||
uint32_t aYSkip, uint32_t aCbCrSkip)
|
||||
{
|
||||
if (!IsValid() || GetYSize() != aYSize || GetCbCrSize() != aCbCrSize) {
|
||||
return false;
|
@ -3,8 +3,8 @@
|
||||
* 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 MOZILLA_LAYERS_SHMEMYCBCRIMAGE_H
|
||||
#define MOZILLA_LAYERS_SHMEMYCBCRIMAGE_H
|
||||
#ifndef MOZILLA_LAYERS_BLOBYCBCRSURFACE_H
|
||||
#define MOZILLA_LAYERS_BLOBYCBCRSURFACE_H
|
||||
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
||||
@ -21,49 +21,13 @@ namespace layers {
|
||||
class Image;
|
||||
|
||||
/**
|
||||
* This class is a view on a YCbCrImage stored in a Shmem at a certain offset.
|
||||
* It is only meant as a convenience to access the image data, and does not own
|
||||
* the data. The instance can live on the stack and used as follows:
|
||||
*
|
||||
* const YCbCrImage& yuv = sharedImage.get_YCbCrImage();
|
||||
* ShmemYCbCrImage shmImg(yuv.data(), yuv.offset());
|
||||
* if (!shmImg.IsValid()) {
|
||||
* // handle error
|
||||
* }
|
||||
* mYSize = shmImg.GetYSize(); // work with the data, etc...
|
||||
* Convenience class to share code between YCbCrImageDataSerializer
|
||||
* and YCbCrImageDataDeserializer.
|
||||
* Do not use it.
|
||||
*/
|
||||
class ShmemYCbCrImage
|
||||
class YCbCrImageDataDeserializerBase
|
||||
{
|
||||
public:
|
||||
typedef mozilla::ipc::Shmem Shmem;
|
||||
|
||||
ShmemYCbCrImage() : mOffset(0) {}
|
||||
|
||||
ShmemYCbCrImage(Shmem& shm, size_t offset = 0) {
|
||||
DebugOnly<bool> status = Open(shm,offset);
|
||||
NS_ASSERTION(status, "Invalid data in the shmem");
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is meant as a helper to know how much shared memory we need
|
||||
* to allocate in a shmem in order to place a shared YCbCr image blob of
|
||||
* given dimensions.
|
||||
*/
|
||||
static size_t ComputeMinBufferSize(const gfxIntSize& aYSize,
|
||||
const gfxIntSize& aCbCrSize);
|
||||
static size_t ComputeMinBufferSize(uint32_t aSize);
|
||||
/**
|
||||
* Write the image informations in a buffer for given dimensions.
|
||||
* The provided pointer should point to the beginning of the (chunk of)
|
||||
* buffer on which we want to store th image.
|
||||
*/
|
||||
static void InitializeBufferInfo(uint8_t* aBuffer,
|
||||
const gfxIntSize& aYSize,
|
||||
const gfxIntSize& aCbCrSize);
|
||||
|
||||
/**
|
||||
* Returns true if the shmem's data blob contains a valid YCbCr image.
|
||||
*/
|
||||
bool IsValid();
|
||||
|
||||
/**
|
||||
@ -102,21 +66,74 @@ public:
|
||||
* Return a pointer to the begining of the data buffer.
|
||||
*/
|
||||
uint8_t* GetData();
|
||||
protected:
|
||||
YCbCrImageDataDeserializerBase(uint8_t* aData)
|
||||
: mData (aData) {}
|
||||
|
||||
uint8_t* mData;
|
||||
};
|
||||
|
||||
/**
|
||||
* A view on a YCbCr image stored with its metadata in a blob of memory.
|
||||
* It is only meant as a convenience to access the image data, and does not own
|
||||
* the data. The instance can live on the stack and used as follows:
|
||||
*
|
||||
* const YCbCrImage& yuv = sharedImage.get_YCbCrImage();
|
||||
* YCbCrImageDataDeserializer deserializer(yuv.data().get<uint8_t>());
|
||||
* if (!deserializer.IsValid()) {
|
||||
* // handle error
|
||||
* }
|
||||
* size = deserializer.GetYSize(); // work with the data, etc...
|
||||
*/
|
||||
class MOZ_STACK_CLASS YCbCrImageDataSerializer : public YCbCrImageDataDeserializerBase
|
||||
{
|
||||
public:
|
||||
YCbCrImageDataSerializer(uint8_t* aData) : YCbCrImageDataDeserializerBase(aData) {}
|
||||
|
||||
/**
|
||||
* Copies the data passed in parameter into the shmem.
|
||||
* This function is meant as a helper to know how much shared memory we need
|
||||
* to allocate in a shmem in order to place a shared YCbCr image blob of
|
||||
* given dimensions.
|
||||
*/
|
||||
static size_t ComputeMinBufferSize(const gfx::IntSize& aYSize,
|
||||
const gfx::IntSize& aCbCrSize);
|
||||
static size_t ComputeMinBufferSize(const gfxIntSize& aYSize,
|
||||
const gfxIntSize& aCbCrSize);
|
||||
static size_t ComputeMinBufferSize(uint32_t aSize);
|
||||
|
||||
/**
|
||||
* Write the image informations in the buffer for given dimensions.
|
||||
* The provided pointer should point to the beginning of the (chunk of)
|
||||
* buffer on which we want to store the image.
|
||||
*/
|
||||
void InitializeBufferInfo(const gfx::IntSize& aYSize,
|
||||
const gfx::IntSize& aCbCrSize);
|
||||
void InitializeBufferInfo(const gfxIntSize& aYSize,
|
||||
const gfxIntSize& aCbCrSize);
|
||||
|
||||
bool CopyData(const uint8_t* aYData,
|
||||
const uint8_t* aCbData, const uint8_t* aCrData,
|
||||
gfxIntSize aYSize, uint32_t aYStride,
|
||||
gfxIntSize aCbCrSize, uint32_t aCbCrStride,
|
||||
uint32_t aYSkip, uint32_t aCbCrSkip);
|
||||
};
|
||||
|
||||
private:
|
||||
bool Open(Shmem& aShmem, size_t aOffset = 0);
|
||||
|
||||
ipc::Shmem mShmem;
|
||||
size_t mOffset;
|
||||
/**
|
||||
* A view on a YCbCr image stored with its metadata in a blob of memory.
|
||||
* It is only meant as a convenience to access the image data, and does not own
|
||||
* the data. The instance can live on the stack and used as follows:
|
||||
*
|
||||
* const YCbCrImage& yuv = sharedImage.get_YCbCrImage();
|
||||
* YCbCrImageDataDeserializer deserializer(yuv.data().get<uint8_t>());
|
||||
* if (!deserializer.IsValid()) {
|
||||
* // handle error
|
||||
* }
|
||||
* size = deserializer.GetYSize(); // work with the data, etc...
|
||||
*/
|
||||
class MOZ_STACK_CLASS YCbCrImageDataDeserializer : public YCbCrImageDataDeserializerBase
|
||||
{
|
||||
public:
|
||||
YCbCrImageDataDeserializer(uint8_t* aData) : YCbCrImageDataDeserializerBase(aData) {}
|
||||
};
|
||||
|
||||
} // namespace
|
@ -13,9 +13,10 @@
|
||||
#include "mozilla/layers/SharedPlanarYCbCrImage.h"
|
||||
#include "GLContext.h"
|
||||
#include "BasicLayers.h" // for PaintContext
|
||||
#include "ShmemYCbCrImage.h"
|
||||
#include "mozilla/layers/YCbCrImageDataSerializer.h"
|
||||
#include "gfxReusableSurfaceWrapper.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "mozilla/StandardInteger.h"
|
||||
|
||||
using namespace mozilla::gl;
|
||||
|
||||
@ -277,8 +278,8 @@ AutoLockYCbCrClient::Update(PlanarYCbCrImage* aImage)
|
||||
|
||||
ipc::Shmem& shmem = mDescriptor->get_YCbCrImage().data();
|
||||
|
||||
ShmemYCbCrImage shmemImage(shmem);
|
||||
if (!shmemImage.CopyData(data->mYChannel, data->mCbChannel, data->mCrChannel,
|
||||
YCbCrImageDataSerializer serializer(shmem.get<uint8_t>());
|
||||
if (!serializer.CopyData(data->mYChannel, data->mCbChannel, data->mCrChannel,
|
||||
data->mYSize, data->mYStride,
|
||||
data->mCbCrSize, data->mCbCrStride,
|
||||
data->mYSkip, data->mCbSkip)) {
|
||||
@ -306,9 +307,9 @@ bool AutoLockYCbCrClient::EnsureTextureClient(PlanarYCbCrImage* aImage)
|
||||
needsAllocation = true;
|
||||
} else {
|
||||
ipc::Shmem& shmem = mDescriptor->get_YCbCrImage().data();
|
||||
ShmemYCbCrImage shmemImage(shmem);
|
||||
if (shmemImage.GetYSize() != data->mYSize ||
|
||||
shmemImage.GetCbCrSize() != data->mCbCrSize) {
|
||||
YCbCrImageDataSerializer serializer(shmem.get<uint8_t>());
|
||||
if (serializer.GetYSize() != data->mYSize ||
|
||||
serializer.GetCbCrSize() != data->mCbCrSize) {
|
||||
needsAllocation = true;
|
||||
}
|
||||
}
|
||||
@ -320,19 +321,18 @@ bool AutoLockYCbCrClient::EnsureTextureClient(PlanarYCbCrImage* aImage)
|
||||
mTextureClient->ReleaseResources();
|
||||
|
||||
ipc::SharedMemory::SharedMemoryType shmType = OptimalShmemType();
|
||||
size_t size = ShmemYCbCrImage::ComputeMinBufferSize(data->mYSize,
|
||||
data->mCbCrSize);
|
||||
size_t size = YCbCrImageDataSerializer::ComputeMinBufferSize(data->mYSize,
|
||||
data->mCbCrSize);
|
||||
ipc::Shmem shmem;
|
||||
if (!mTextureClient->GetForwarder()->AllocUnsafeShmem(size, shmType, &shmem)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ShmemYCbCrImage::InitializeBufferInfo(shmem.get<uint8_t>(),
|
||||
data->mYSize,
|
||||
data->mCbCrSize);
|
||||
YCbCrImageDataSerializer serializer(shmem.get<uint8_t>());
|
||||
serializer.InitializeBufferInfo(data->mYSize,
|
||||
data->mCbCrSize);
|
||||
|
||||
|
||||
*mDescriptor = YCbCrImage(shmem, 0, 0);
|
||||
*mDescriptor = YCbCrImage(shmem, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "gfxImageSurface.h"
|
||||
#include "Effects.h"
|
||||
#include "ipc/AutoOpenSurface.h"
|
||||
#include "ShmemYCbCrImage.h"
|
||||
#include "mozilla/layers/YCbCrImageDataSerializer.h"
|
||||
#include "gfxWindowsPlatform.h"
|
||||
#include "gfxD2DSurface.h"
|
||||
|
||||
@ -460,30 +460,29 @@ TextureHostYCbCrD3D11::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
{
|
||||
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TYCbCrImage);
|
||||
|
||||
ShmemYCbCrImage shmemImage(aImage.get_YCbCrImage().data(),
|
||||
aImage.get_YCbCrImage().offset());
|
||||
YCbCrImageDataDeserializer yuvDeserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
|
||||
|
||||
gfxIntSize gfxCbCrSize = shmemImage.GetCbCrSize();
|
||||
gfxIntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
|
||||
|
||||
gfxIntSize size = shmemImage.GetYSize();
|
||||
gfxIntSize size = yuvDeserializer.GetYSize();
|
||||
|
||||
D3D11_SUBRESOURCE_DATA initData;
|
||||
initData.pSysMem = shmemImage.GetYData();
|
||||
initData.SysMemPitch = shmemImage.GetYStride();
|
||||
initData.pSysMem = yuvDeserializer.GetYData();
|
||||
initData.SysMemPitch = yuvDeserializer.GetYStride();
|
||||
|
||||
CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_R8_UNORM, size.width, size.height,
|
||||
1, 1, D3D11_BIND_SHADER_RESOURCE, D3D11_USAGE_IMMUTABLE);
|
||||
|
||||
mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[0]));
|
||||
|
||||
initData.pSysMem = shmemImage.GetCbData();
|
||||
initData.SysMemPitch = shmemImage.GetCbCrStride();
|
||||
desc.Width = shmemImage.GetCbCrSize().width;
|
||||
desc.Height = shmemImage.GetCbCrSize().height;
|
||||
initData.pSysMem = yuvDeserializer.GetCbData();
|
||||
initData.SysMemPitch = yuvDeserializer.GetCbCrStride();
|
||||
desc.Width = yuvDeserializer.GetCbCrSize().width;
|
||||
desc.Height = yuvDeserializer.GetCbCrSize().height;
|
||||
|
||||
mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[1]));
|
||||
|
||||
initData.pSysMem = shmemImage.GetCrData();
|
||||
initData.pSysMem = yuvDeserializer.GetCrData();
|
||||
mDevice->CreateTexture2D(&desc, &initData, byRef(mTextures[2]));
|
||||
|
||||
mSize = IntSize(size.width, size.height);
|
||||
|
@ -71,7 +71,6 @@ struct SurfaceStreamDescriptor {
|
||||
|
||||
struct YCbCrImage {
|
||||
Shmem data;
|
||||
size_t offset;
|
||||
uint64_t owner;
|
||||
};
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SharedPlanarYCbCrImage.h"
|
||||
#include "ShmemYCbCrImage.h"
|
||||
#include "mozilla/layers/YCbCrImageDataSerializer.h"
|
||||
#include "ISurfaceAllocator.h"
|
||||
#include "mozilla/layers/LayersSurfaces.h"
|
||||
|
||||
@ -40,21 +40,21 @@ SharedPlanarYCbCrImage::SetData(const PlanarYCbCrImage::Data& aData)
|
||||
// do not set mBuffer like in PlanarYCbCrImage because the later
|
||||
// will try to manage this memory without knowing it belongs to a
|
||||
// shmem.
|
||||
mBufferSize = ShmemYCbCrImage::ComputeMinBufferSize(mData.mYSize,
|
||||
mData.mCbCrSize);
|
||||
mBufferSize = YCbCrImageDataSerializer::ComputeMinBufferSize(mData.mYSize,
|
||||
mData.mCbCrSize);
|
||||
mSize = mData.mPicSize;
|
||||
|
||||
ShmemYCbCrImage shmImg(mShmem);
|
||||
YCbCrImageDataSerializer serializer(mShmem.get<uint8_t>());
|
||||
MOZ_ASSERT(aData.mCbSkip == aData.mCrSkip);
|
||||
if (!shmImg.CopyData(aData.mYChannel, aData.mCbChannel, aData.mCrChannel,
|
||||
aData.mYSize, aData.mYStride,
|
||||
aData.mCbCrSize, aData.mCbCrStride,
|
||||
aData.mYSkip, aData.mCbSkip)) {
|
||||
if (!serializer.CopyData(aData.mYChannel, aData.mCbChannel, aData.mCrChannel,
|
||||
aData.mYSize, aData.mYStride,
|
||||
aData.mCbCrSize, aData.mCbCrStride,
|
||||
aData.mYSkip, aData.mCbSkip)) {
|
||||
NS_WARNING("Failed to copy image data!");
|
||||
}
|
||||
mData.mYChannel = shmImg.GetYData();
|
||||
mData.mCbChannel = shmImg.GetCbData();
|
||||
mData.mCrChannel = shmImg.GetCrData();
|
||||
mData.mYChannel = serializer.GetYData();
|
||||
mData.mCbChannel = serializer.GetCbData();
|
||||
mData.mCrChannel = serializer.GetCrData();
|
||||
}
|
||||
|
||||
// needs to be overriden because the parent class sets mBuffer which we
|
||||
@ -63,15 +63,15 @@ uint8_t*
|
||||
SharedPlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!mAllocated, "This image already has allocated data");
|
||||
size_t size = ShmemYCbCrImage::ComputeMinBufferSize(aSize);
|
||||
size_t size = YCbCrImageDataSerializer::ComputeMinBufferSize(aSize);
|
||||
// update buffer size
|
||||
mBufferSize = size;
|
||||
|
||||
// get new buffer _without_ setting mBuffer.
|
||||
AllocateBuffer(mBufferSize);
|
||||
ShmemYCbCrImage shmImg(mShmem);
|
||||
YCbCrImageDataSerializer serializer(mShmem.get<uint8_t>());
|
||||
|
||||
return shmImg.GetData();
|
||||
return serializer.GetData();
|
||||
}
|
||||
|
||||
|
||||
@ -80,9 +80,9 @@ SharedPlanarYCbCrImage::SetDataNoCopy(const Data &aData)
|
||||
{
|
||||
mData = aData;
|
||||
mSize = aData.mPicSize;
|
||||
ShmemYCbCrImage::InitializeBufferInfo(mShmem.get<uint8_t>(),
|
||||
aData.mYSize,
|
||||
aData.mCbCrSize);
|
||||
YCbCrImageDataSerializer serializer(mShmem.get<uint8_t>());
|
||||
serializer.InitializeBufferInfo(aData.mYSize,
|
||||
aData.mCbCrSize);
|
||||
}
|
||||
|
||||
uint8_t*
|
||||
@ -103,25 +103,24 @@ SharedPlanarYCbCrImage::Allocate(PlanarYCbCrImage::Data& aData)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!mAllocated, "This image already has allocated data");
|
||||
|
||||
size_t size = ShmemYCbCrImage::ComputeMinBufferSize(aData.mYSize,
|
||||
aData.mCbCrSize);
|
||||
size_t size = YCbCrImageDataSerializer::ComputeMinBufferSize(aData.mYSize,
|
||||
aData.mCbCrSize);
|
||||
|
||||
if (AllocateBuffer(static_cast<uint32_t>(size)) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ShmemYCbCrImage::InitializeBufferInfo(mShmem.get<uint8_t>(),
|
||||
aData.mYSize,
|
||||
aData.mCbCrSize);
|
||||
ShmemYCbCrImage shmImg(mShmem);
|
||||
if (!shmImg.IsValid() || mShmem.Size<uint8_t>() < size) {
|
||||
YCbCrImageDataSerializer serializer(mShmem.get<uint8_t>());
|
||||
serializer.InitializeBufferInfo(aData.mYSize,
|
||||
aData.mCbCrSize);
|
||||
if (!serializer.IsValid() || mShmem.Size<uint8_t>() < size) {
|
||||
mSurfaceAllocator->DeallocShmem(mShmem);
|
||||
return false;
|
||||
}
|
||||
|
||||
aData.mYChannel = shmImg.GetYData();
|
||||
aData.mCbChannel = shmImg.GetCbData();
|
||||
aData.mCrChannel = shmImg.GetCrData();
|
||||
aData.mYChannel = serializer.GetYData();
|
||||
aData.mCbChannel = serializer.GetCbData();
|
||||
aData.mCrChannel = serializer.GetCrData();
|
||||
|
||||
// copy some of aData's values in mData (most of them)
|
||||
mData.mYChannel = aData.mYChannel;
|
||||
@ -150,7 +149,7 @@ SharedPlanarYCbCrImage::ToSurfaceDescriptor(SurfaceDescriptor& aDesc) {
|
||||
if (!mAllocated) {
|
||||
return false;
|
||||
}
|
||||
aDesc = YCbCrImage(mShmem, 0, reinterpret_cast<uint64_t>(this));
|
||||
aDesc = YCbCrImage(mShmem, reinterpret_cast<uint64_t>(this));
|
||||
this->AddRef();
|
||||
return true;
|
||||
}
|
||||
@ -160,7 +159,7 @@ SharedPlanarYCbCrImage::DropToSurfaceDescriptor(SurfaceDescriptor& aDesc) {
|
||||
if (!mAllocated) {
|
||||
return false;
|
||||
}
|
||||
aDesc = YCbCrImage(mShmem, 0, 0);
|
||||
aDesc = YCbCrImage(mShmem, 0);
|
||||
mShmem = Shmem();
|
||||
mAllocated = false;
|
||||
return true;
|
||||
|
@ -40,7 +40,6 @@ EXPORTS += [
|
||||
'ReadbackLayer.h',
|
||||
'ShadowLayersManager.h',
|
||||
'SharedTextureImage.h',
|
||||
'ShmemYCbCrImage.h',
|
||||
'TexturePoolOGL.h',
|
||||
]
|
||||
|
||||
@ -105,7 +104,6 @@ EXPORTS.mozilla.layers += [
|
||||
'ShadowLayersManager.h',
|
||||
'SharedPlanarYCbCrImage.h',
|
||||
'SharedRGBImage.h',
|
||||
'ShmemYCbCrImage.h',
|
||||
'TaskThrottler.h',
|
||||
'TextureClient.h',
|
||||
'TextureClientOGL.h',
|
||||
@ -113,6 +111,7 @@ EXPORTS.mozilla.layers += [
|
||||
'TextureHostOGL.h',
|
||||
'ThebesLayerComposite.h',
|
||||
'TiledContentClient.h',
|
||||
'YCbCrImageDataSerializer.h',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_X11']:
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "gfxSharedImageSurface.h"
|
||||
|
||||
#include "ImageContainer.h" // for PlanarYCBCRImage
|
||||
#include "mozilla/layers/ShmemYCbCrImage.h"
|
||||
#include "ipc/AutoOpenSurface.h"
|
||||
#include "ImageLayerOGL.h"
|
||||
#include "gfxImageSurface.h"
|
||||
|
@ -19,7 +19,7 @@ namespace layers {
|
||||
|
||||
class CairoImage;
|
||||
class PlanarYCbCrImage;
|
||||
class ShmemYCbCrImage;
|
||||
class BlobYCbCrSurface;
|
||||
|
||||
/**
|
||||
* This class wraps a GL texture. It includes a GLContext reference
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "TextureHostOGL.h"
|
||||
#include "ipc/AutoOpenSurface.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "ShmemYCbCrImage.h"
|
||||
#include "mozilla/layers/YCbCrImageDataSerializer.h"
|
||||
#include "GLContext.h"
|
||||
#include "gfxImageSurface.h"
|
||||
#include "SurfaceStream.h"
|
||||
@ -491,11 +491,10 @@ YCbCrTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
}
|
||||
NS_ASSERTION(aImage.type() == SurfaceDescriptor::TYCbCrImage, "SurfaceDescriptor mismatch");
|
||||
|
||||
ShmemYCbCrImage shmemImage(aImage.get_YCbCrImage().data(),
|
||||
aImage.get_YCbCrImage().offset());
|
||||
YCbCrImageDataDeserializer deserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
|
||||
|
||||
gfxIntSize gfxSize = shmemImage.GetYSize();
|
||||
gfxIntSize gfxCbCrSize = shmemImage.GetCbCrSize();
|
||||
gfxIntSize gfxSize = deserializer.GetYSize();
|
||||
gfxIntSize gfxCbCrSize = deserializer.GetCbCrSize();
|
||||
|
||||
if (!mYTexture->mTexImage || mYTexture->mTexImage->GetSize() != gfxSize) {
|
||||
mYTexture->mTexImage = CreateBasicTextureImage(mGL,
|
||||
@ -519,14 +518,14 @@ YCbCrTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
FlagsToGLFlags(mFlags));
|
||||
}
|
||||
|
||||
RefPtr<gfxImageSurface> tempY = new gfxImageSurface(shmemImage.GetYData(),
|
||||
gfxSize, shmemImage.GetYStride(),
|
||||
gfxASurface::ImageFormatA8);
|
||||
RefPtr<gfxImageSurface> tempCb = new gfxImageSurface(shmemImage.GetCbData(),
|
||||
gfxCbCrSize, shmemImage.GetCbCrStride(),
|
||||
RefPtr<gfxImageSurface> tempY = new gfxImageSurface(deserializer.GetYData(),
|
||||
gfxSize, deserializer.GetYStride(),
|
||||
gfxASurface::ImageFormatA8);
|
||||
RefPtr<gfxImageSurface> tempCr = new gfxImageSurface(shmemImage.GetCrData(),
|
||||
gfxCbCrSize, shmemImage.GetCbCrStride(),
|
||||
RefPtr<gfxImageSurface> tempCb = new gfxImageSurface(deserializer.GetCbData(),
|
||||
gfxCbCrSize, deserializer.GetCbCrStride(),
|
||||
gfxASurface::ImageFormatA8);
|
||||
RefPtr<gfxImageSurface> tempCr = new gfxImageSurface(deserializer.GetCrData(),
|
||||
gfxCbCrSize, deserializer.GetCbCrStride(),
|
||||
gfxASurface::ImageFormatA8);
|
||||
|
||||
nsIntRegion yRegion(nsIntRect(0, 0, gfxSize.width, gfxSize.height));
|
||||
|
Loading…
Reference in New Issue
Block a user