Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef GFX_LAYERS_BLOBSURFACE_H
8
#define GFX_LAYERS_BLOBSURFACE_H
9
10
#include <stdint.h> // for uint8_t, uint32_t
11
#include "mozilla/Attributes.h" // for MOZ_STACK_CLASS
12
#include "mozilla/RefPtr.h" // for already_AddRefed
13
#include "mozilla/gfx/Point.h" // for IntSize
14
#include "mozilla/gfx/Types.h" // for SurfaceFormat
15
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
16
17
namespace mozilla {
18
namespace gfx {
19
class DataSourceSurface;
20
class DrawTarget;
21
} // namespace gfx
22
} // namespace mozilla
23
24
namespace mozilla {
25
namespace layers {
26
27
namespace ImageDataSerializer {
28
29
// RGB
30
31
int32_t ComputeRGBStride(gfx::SurfaceFormat aFormat, int32_t aWidth);
32
33
int32_t GetRGBStride(const RGBDescriptor& aDescriptor);
34
35
uint32_t ComputeRGBBufferSize(gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
36
37
// YCbCr
38
39
/// This function is meant as a helper to know how much shared memory we need
40
/// to allocate in a shmem in order to place a shared YCbCr image blob of
41
/// given dimensions.
42
uint32_t ComputeYCbCrBufferSize(const gfx::IntSize& aYSize, int32_t aYStride,
43
const gfx::IntSize& aCbCrSize,
44
int32_t aCbCrStride);
45
uint32_t ComputeYCbCrBufferSize(const gfx::IntSize& aYSize, int32_t aYStride,
46
const gfx::IntSize& aCbCrSize,
47
int32_t aCbCrStride, uint32_t aYOffset,
48
uint32_t aCbOffset, uint32_t aCrOffset);
49
uint32_t ComputeYCbCrBufferSize(uint32_t aBufferSize);
50
51
void ComputeYCbCrOffsets(int32_t yStride, int32_t yHeight, int32_t cbCrStride,
52
int32_t cbCrHeight, uint32_t& outYOffset,
53
uint32_t& outCbOffset, uint32_t& outCrOffset);
54
55
gfx::SurfaceFormat FormatFromBufferDescriptor(
56
const BufferDescriptor& aDescriptor);
57
58
gfx::IntSize SizeFromBufferDescriptor(const BufferDescriptor& aDescriptor);
59
60
Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(
61
const BufferDescriptor& aDescriptor);
62
63
Maybe<gfx::YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
64
const BufferDescriptor& aDescriptor);
65
66
Maybe<gfx::ColorDepth> ColorDepthFromBufferDescriptor(
67
const BufferDescriptor& aDescriptor);
68
69
Maybe<gfx::ColorRange> ColorRangeFromBufferDescriptor(
70
const BufferDescriptor& aDescriptor);
71
72
Maybe<StereoMode> StereoModeFromBufferDescriptor(
73
const BufferDescriptor& aDescriptor);
74
75
uint8_t* GetYChannel(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor);
76
77
uint8_t* GetCbChannel(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor);
78
79
uint8_t* GetCrChannel(uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor);
80
81
already_AddRefed<gfx::DataSourceSurface> DataSourceSurfaceFromYCbCrDescriptor(
82
uint8_t* aBuffer, const YCbCrDescriptor& aDescriptor,
83
gfx::DataSourceSurface* aSurface = nullptr);
84
85
void ConvertAndScaleFromYCbCrDescriptor(uint8_t* aBuffer,
86
const YCbCrDescriptor& aDescriptor,
87
const gfx::SurfaceFormat& aDestFormat,
88
const gfx::IntSize& aDestSize,
89
unsigned char* aDestBuffer,
90
int32_t aStride);
91
92
} // namespace ImageDataSerializer
93
94
} // namespace layers
95
} // namespace mozilla
96
97
#endif