2017-10-27 23:10:06 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-07-30 09:59:51 +00:00
|
|
|
/* 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-11 23:17:23 +00:00
|
|
|
#include <stdint.h> // for uint8_t, uint32_t
|
|
|
|
#include "mozilla/Attributes.h" // for MOZ_STACK_CLASS
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h" // for already_AddRefed
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
|
|
|
#include "mozilla/gfx/Types.h" // for SurfaceFormat
|
2016-03-14 15:39:12 +00:00
|
|
|
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
|
2013-07-30 14:25:31 +00:00
|
|
|
|
2013-07-30 09:59:51 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
class DataSourceSurface;
|
2013-10-16 01:00:30 +00:00
|
|
|
class DrawTarget;
|
2013-07-30 09:59:51 +00:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2015-12-16 18:50:58 +00: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);
|
2018-05-22 15:25:49 +00:00
|
|
|
uint32_t ComputeYCbCrBufferSize(const gfx::IntSize& aYSize, int32_t aYStride,
|
|
|
|
const gfx::IntSize& aCbCrSize,
|
|
|
|
int32_t aCbCrStride, uint32_t aYOffset,
|
|
|
|
uint32_t aCbOffset, uint32_t aCrOffset);
|
2015-12-16 18:50:58 +00:00
|
|
|
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 02:12:31 +00:00
|
|
|
Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(
|
|
|
|
const BufferDescriptor& aDescriptor);
|
2016-10-12 02:46:28 +00:00
|
|
|
|
2019-04-11 12:41:33 +00:00
|
|
|
Maybe<gfx::YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
|
2016-10-12 02:46:28 +00:00
|
|
|
const BufferDescriptor& aDescriptor);
|
2017-09-29 14:37:56 +00:00
|
|
|
|
2018-09-25 20:44:55 +00:00
|
|
|
Maybe<gfx::ColorDepth> ColorDepthFromBufferDescriptor(
|
|
|
|
const BufferDescriptor& aDescriptor);
|
2019-07-26 08:45:31 +00:00
|
|
|
|
|
|
|
Maybe<gfx::ColorRange> ColorRangeFromBufferDescriptor(
|
|
|
|
const BufferDescriptor& aDescriptor);
|
2016-06-30 02:12:31 +00:00
|
|
|
|
|
|
|
Maybe<StereoMode> StereoModeFromBufferDescriptor(
|
|
|
|
const BufferDescriptor& aDescriptor);
|
|
|
|
|
2015-12-16 18:50:58 +00: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);
|
|
|
|
|
2016-07-09 01:59:59 +00:00
|
|
|
already_AddRefed<gfx::DataSourceSurface> DataSourceSurfaceFromYCbCrDescriptor(
|
|
|
|
uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor,
|
|
|
|
gfx::DataSourceSurface* aSurface = nullptr);
|
2015-12-16 18:50:58 +00:00
|
|
|
|
2016-08-16 01:54:17 +00: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 18:50:58 +00:00
|
|
|
} // namespace ImageDataSerializer
|
2013-07-30 09:59:51 +00:00
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|