2013-07-30 13:59:51 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
|
|
|
/* 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 GFX_LAYERS_BLOBSURFACE_H
|
|
|
|
#define GFX_LAYERS_BLOBSURFACE_H
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <stdint.h> // for uint8_t, uint32_t
|
|
|
|
#include "mozilla/Attributes.h" // for MOZ_STACK_CLASS
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h" // for already_AddRefed
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
|
|
|
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
2016-03-14 18:39:12 +03:00
|
|
|
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
2013-07-30 18:25:31 +04:00
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
class DataSourceSurface;
|
2013-10-16 05:00:30 +04:00
|
|
|
class DrawTarget;
|
2013-07-30 13:59:51 +04:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
namespace ImageDataSerializer {
|
|
|
|
|
|
|
|
// RGB
|
|
|
|
|
|
|
|
int32_t ComputeRGBStride(gfx::SurfaceFormat aFormat, int32_t aWidth);
|
|
|
|
|
|
|
|
int32_t GetRGBStride(const RGBDescriptor& aDescriptor);
|
|
|
|
|
|
|
|
uint32_t ComputeRGBBufferSize(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
|
|
|
|
|
|
|
|
|
|
|
|
// YCbCr
|
|
|
|
|
|
|
|
///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.
|
|
|
|
uint32_t ComputeYCbCrBufferSize(const gfx::IntSize& aYSize,
|
|
|
|
int32_t aYStride,
|
|
|
|
const gfx::IntSize& aCbCrSize,
|
|
|
|
int32_t aCbCrStride);
|
|
|
|
uint32_t ComputeYCbCrBufferSize(const gfx::IntSize& aYSize,
|
|
|
|
const gfx::IntSize& aCbCrSize);
|
|
|
|
|
|
|
|
uint32_t ComputeYCbCrBufferSize(uint32_t aBufferSize);
|
|
|
|
|
|
|
|
void ComputeYCbCrOffsets(int32_t yStride, int32_t yHeight,
|
|
|
|
int32_t cbCrStride, int32_t cbCrHeight,
|
|
|
|
uint32_t& outYOffset, uint32_t& outCbOffset, uint32_t& outCrOffset);
|
|
|
|
|
|
|
|
gfx::SurfaceFormat FormatFromBufferDescriptor(const BufferDescriptor& aDescriptor);
|
|
|
|
|
|
|
|
gfx::IntSize SizeFromBufferDescriptor(const BufferDescriptor& aDescriptor);
|
|
|
|
|
2016-06-30 05:12:31 +03:00
|
|
|
Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(const BufferDescriptor& aDescriptor);
|
2016-10-12 05:46:28 +03:00
|
|
|
|
|
|
|
Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& aDescriptor);
|
2016-06-30 05:12:31 +03:00
|
|
|
|
|
|
|
Maybe<StereoMode> StereoModeFromBufferDescriptor(const BufferDescriptor& aDescriptor);
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
uint8_t* GetYChannel(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor);
|
|
|
|
|
|
|
|
uint8_t* GetCbChannel(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor);
|
|
|
|
|
|
|
|
uint8_t* GetCrChannel(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor);
|
|
|
|
|
|
|
|
already_AddRefed<gfx::DataSourceSurface>
|
2016-07-09 04:59:59 +03:00
|
|
|
DataSourceSurfaceFromYCbCrDescriptor(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor, gfx::DataSourceSurface* aSurface = nullptr);
|
2015-12-16 21:50:58 +03:00
|
|
|
|
2016-08-16 04:54:17 +03:00
|
|
|
void ConvertAndScaleFromYCbCrDescriptor(uint8_t* aBuffer,
|
|
|
|
const YCbCrDescriptor& aDescriptor,
|
|
|
|
const gfx::SurfaceFormat& aDestFormat,
|
|
|
|
const gfx::IntSize& aDestSize,
|
|
|
|
unsigned char* aDestBuffer,
|
|
|
|
int32_t aStride);
|
|
|
|
|
2015-12-16 21:50:58 +03:00
|
|
|
} // ImageDataSerializer
|
2013-07-30 13:59:51 +04:00
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|