1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef ImageToI420Converter_h
7 #define ImageToI420Converter_h
9 #include "mozilla/AlreadyAddRefed.h"
11 #include "mozilla/gfx/Point.h"
17 enum class SurfaceFormat
: int8_t;
25 * Gets a SourceSurface from given image.
27 already_AddRefed
<gfx::SourceSurface
> GetSourceSurface(layers::Image
* aImage
);
30 * Converts aImage to an I420 image and writes it to the given buffers.
32 nsresult
ConvertToI420(layers::Image
* aImage
, uint8_t* aDestY
, int aDestStrideY
,
33 uint8_t* aDestU
, int aDestStrideU
, uint8_t* aDestV
,
37 * Converts aImage to an NV12 image and writes it to the given buffers.
39 nsresult
ConvertToNV12(layers::Image
* aImage
, uint8_t* aDestY
, int aDestStrideY
,
40 uint8_t* aDestUV
, int aDestStrideUV
,
41 gfx::IntSize aDestSize
);
44 * Converts aImage into an RGBA image in a specified format and writes it to the
47 nsresult
ConvertToRGBA(layers::Image
* aImage
,
48 const gfx::SurfaceFormat
& aDestFormat
,
49 uint8_t* aDestBuffer
, int aDestStride
);
52 * Convert the RGBA image data from SRGB color into DisplayP3 color.
53 * aSrcBuffer and aDestBuffer can be the same.
55 nsresult
ConvertSRGBBufferToDisplayP3(uint8_t* aSrcBuffer
,
56 const gfx::SurfaceFormat
& aSrcFormat
,
57 uint8_t* aDestBuffer
, int aWidth
,
60 } // namespace mozilla
62 #endif /* ImageToI420Converter_h */