Backed out changeset f594e6f00208 (bug 1940883) for causing crashes in bug 1941164.
[gecko.git] / dom / media / ImageConversion.h
blobe14c6a4f2aba9c6a7913cbf1a98ab51c17d2a1d4
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"
10 #include "nsError.h"
11 #include "mozilla/gfx/Point.h"
13 namespace mozilla {
15 namespace gfx {
16 class SourceSurface;
17 enum class SurfaceFormat : int8_t;
18 } // namespace gfx
20 namespace layers {
21 class Image;
22 } // namespace layers
24 /**
25 * Gets a SourceSurface from given image.
27 already_AddRefed<gfx::SourceSurface> GetSourceSurface(layers::Image* aImage);
29 /**
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,
34 int aDestStrideV);
36 /**
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);
43 /**
44 * Converts aImage into an RGBA image in a specified format and writes it to the
45 * given buffer.
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,
58 int aHeight);
60 } // namespace mozilla
62 #endif /* ImageToI420Converter_h */