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/. */
7 #ifndef MOZILLA_GFX_SWIZZLE_H_
8 #define MOZILLA_GFX_SWIZZLE_H_
16 * Premultiplies source and writes it to destination. Source and destination may
17 * be the same to premultiply in-place. The source format must have an alpha
20 GFX2D_API
bool PremultiplyData(const uint8_t* aSrc
, int32_t aSrcStride
,
21 SurfaceFormat aSrcFormat
, uint8_t* aDst
,
22 int32_t aDstStride
, SurfaceFormat aDstFormat
,
23 const IntSize
& aSize
);
26 * Unpremultiplies source and writes it to destination. Source and destination
27 * may be the same to unpremultiply in-place. Both the source and destination
28 * formats must have an alpha channel.
30 GFX2D_API
bool UnpremultiplyData(const uint8_t* aSrc
, int32_t aSrcStride
,
31 SurfaceFormat aSrcFormat
, uint8_t* aDst
,
32 int32_t aDstStride
, SurfaceFormat aDstFormat
,
33 const IntSize
& aSize
);
36 * Swizzles source and writes it to destination. Source and destination may be
37 * the same to swizzle in-place.
39 GFX2D_API
bool SwizzleData(const uint8_t* aSrc
, int32_t aSrcStride
,
40 SurfaceFormat aSrcFormat
, uint8_t* aDst
,
41 int32_t aDstStride
, SurfaceFormat aDstFormat
,
42 const IntSize
& aSize
);
45 * Swizzles source and writes it to destination. Source and destination may be
46 * the same to swizzle in-place.
48 typedef void (*SwizzleRowFn
)(const uint8_t* aSrc
, uint8_t* aDst
,
52 * Get a function pointer to perform premultiplication between two formats.
54 GFX2D_API SwizzleRowFn
PremultiplyRow(SurfaceFormat aSrcFormat
,
55 SurfaceFormat aDstFormat
);
58 * Get a function pointer to perform unpremultiplication between two formats.
60 GFX2D_API SwizzleRowFn
UnpremultiplyRow(SurfaceFormat aSrcFormat
,
61 SurfaceFormat aDstFormat
);
64 * Get a function pointer to perform swizzling between two formats.
66 GFX2D_API SwizzleRowFn
SwizzleRow(SurfaceFormat aSrcFormat
,
67 SurfaceFormat aDstFormat
);
70 } // namespace mozilla
72 #endif /* MOZILLA_GFX_SWIZZLE_H_ */