2012-09-13 13:52:26 -07:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
2013-05-23 00:17:10 -07:00
|
|
|
#ifndef MOZILLA_LAYERS_BLOBYCBCRSURFACE_H
|
|
|
|
#define MOZILLA_LAYERS_BLOBYCBCRSURFACE_H
|
2012-09-13 13:52:26 -07:00
|
|
|
|
2013-08-11 16:17:23 -07:00
|
|
|
#include <stddef.h> // for size_t
|
|
|
|
#include <stdint.h> // for uint8_t, uint32_t
|
|
|
|
#include "ImageTypes.h" // for StereoMode
|
|
|
|
#include "gfxPoint.h" // for gfxIntSize
|
|
|
|
#include "mozilla/Attributes.h" // for MOZ_STACK_CLASS
|
|
|
|
#include "mozilla/RefPtr.h" // for TemporaryRef
|
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
2012-09-13 13:52:26 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-07-30 02:59:51 -07:00
|
|
|
namespace gfx {
|
2013-08-11 16:17:23 -07:00
|
|
|
class DataSourceSurface;
|
2013-07-30 02:59:51 -07:00
|
|
|
}
|
|
|
|
|
2012-09-13 13:52:26 -07:00
|
|
|
namespace layers {
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
class Image;
|
|
|
|
|
2012-09-13 13:52:26 -07:00
|
|
|
/**
|
2013-05-23 00:17:10 -07:00
|
|
|
* Convenience class to share code between YCbCrImageDataSerializer
|
|
|
|
* and YCbCrImageDataDeserializer.
|
|
|
|
* Do not use it.
|
2012-09-13 13:52:26 -07:00
|
|
|
*/
|
2013-05-23 00:17:10 -07:00
|
|
|
class YCbCrImageDataDeserializerBase
|
2012-09-13 13:52:26 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool IsValid();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the Y channel data pointer.
|
|
|
|
*/
|
|
|
|
uint8_t* GetYData();
|
|
|
|
/**
|
|
|
|
* Returns the Cb channel data pointer.
|
|
|
|
*/
|
|
|
|
uint8_t* GetCbData();
|
|
|
|
/**
|
|
|
|
* Returns the Cr channel data pointer.
|
|
|
|
*/
|
|
|
|
uint8_t* GetCrData();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the Y channel stride.
|
|
|
|
*/
|
|
|
|
uint32_t GetYStride();
|
|
|
|
/**
|
|
|
|
* Returns the stride of the Cb and Cr channels.
|
|
|
|
*/
|
|
|
|
uint32_t GetCbCrStride();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the dimensions of the Y Channel.
|
|
|
|
*/
|
|
|
|
gfxIntSize GetYSize();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the dimensions of the Cb and Cr Channel.
|
|
|
|
*/
|
|
|
|
gfxIntSize GetCbCrSize();
|
|
|
|
|
2013-08-04 00:46:17 -07:00
|
|
|
/**
|
|
|
|
* Stereo mode for the image.
|
|
|
|
*/
|
|
|
|
StereoMode GetStereoMode();
|
|
|
|
|
2013-04-05 10:24:58 -07:00
|
|
|
/**
|
|
|
|
* Return a pointer to the begining of the data buffer.
|
|
|
|
*/
|
|
|
|
uint8_t* GetData();
|
2013-05-23 00:17:10 -07:00
|
|
|
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) {}
|
2013-04-05 10:24:58 -07:00
|
|
|
|
2012-10-29 08:08:06 -07:00
|
|
|
/**
|
2013-05-23 00:17:10 -07:00
|
|
|
* 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.
|
2012-10-29 08:08:06 -07:00
|
|
|
*/
|
2013-05-23 00:17:10 -07:00
|
|
|
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,
|
2013-08-04 00:46:17 -07:00
|
|
|
const gfx::IntSize& aCbCrSize,
|
|
|
|
StereoMode aStereoMode);
|
2013-05-23 00:17:10 -07:00
|
|
|
void InitializeBufferInfo(const gfxIntSize& aYSize,
|
2013-08-04 00:46:17 -07:00
|
|
|
const gfxIntSize& aCbCrSize,
|
|
|
|
StereoMode aStereoMode);
|
2013-05-23 00:17:10 -07:00
|
|
|
|
2012-12-04 02:36:33 -08:00
|
|
|
bool CopyData(const uint8_t* aYData,
|
|
|
|
const uint8_t* aCbData, const uint8_t* aCrData,
|
2012-10-29 08:08:06 -07:00
|
|
|
gfxIntSize aYSize, uint32_t aYStride,
|
2012-12-04 02:36:33 -08:00
|
|
|
gfxIntSize aCbCrSize, uint32_t aCbCrStride,
|
|
|
|
uint32_t aYSkip, uint32_t aCbCrSkip);
|
2013-05-23 00:17:10 -07:00
|
|
|
};
|
2012-10-29 08:08:06 -07:00
|
|
|
|
2013-05-23 00:17:10 -07:00
|
|
|
/**
|
|
|
|
* 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) {}
|
2013-07-30 02:59:51 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert the YCbCr data into RGB and return a DataSourceSurface.
|
|
|
|
* This is a costly operation, so use it only when YCbCr compositing is
|
|
|
|
* not supported.
|
|
|
|
*/
|
|
|
|
TemporaryRef<gfx::DataSourceSurface> ToDataSourceSurface();
|
2012-09-13 13:52:26 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|