Bug 1890689 accumulate input in LargerReceiverBlockSizeThanDesiredBuffering GTest...
[gecko.git] / gfx / 2d / Swizzle.h
blob333490c8c02093bbb10722f3302a8f41a91c4108
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_
10 #include "Point.h"
11 #include "Rect.h"
13 namespace mozilla {
14 namespace image {
15 struct Orientation;
18 namespace gfx {
20 /**
21 * Premultiplies source and writes it to destination. Source and destination may
22 * be the same to premultiply in-place. The source format must have an alpha
23 * channel.
25 GFX2D_API bool PremultiplyData(const uint8_t* aSrc, int32_t aSrcStride,
26 SurfaceFormat aSrcFormat, uint8_t* aDst,
27 int32_t aDstStride, SurfaceFormat aDstFormat,
28 const IntSize& aSize);
30 /**
31 * Unpremultiplies source and writes it to destination. Source and destination
32 * may be the same to unpremultiply in-place. Both the source and destination
33 * formats must have an alpha channel.
35 GFX2D_API bool UnpremultiplyData(const uint8_t* aSrc, int32_t aSrcStride,
36 SurfaceFormat aSrcFormat, uint8_t* aDst,
37 int32_t aDstStride, SurfaceFormat aDstFormat,
38 const IntSize& aSize);
40 /**
41 * Swizzles source and writes it to destination. Source and destination may be
42 * the same to swizzle in-place.
44 GFX2D_API bool SwizzleData(const uint8_t* aSrc, int32_t aSrcStride,
45 SurfaceFormat aSrcFormat, uint8_t* aDst,
46 int32_t aDstStride, SurfaceFormat aDstFormat,
47 const IntSize& aSize);
49 /**
50 * Flips rows of source and swizzles it to destination. Source and destination
51 * may be the same to swizzle in-place; this will fail if it cannot allocate a
52 * temporary buffer.
54 GFX2D_API bool SwizzleYFlipData(const uint8_t* aSrc, int32_t aSrcStride,
55 SurfaceFormat aSrcFormat, uint8_t* aDst,
56 int32_t aDstStride, SurfaceFormat aDstFormat,
57 const IntSize& aSize);
59 /**
60 * Flips rows of source and premultiplies/swizzles it to destination. Source and
61 * destination may be the same to premultiply/swizzle in-place; this will fail
62 * if it cannot allocate a temporary buffer.
64 GFX2D_API bool PremultiplyYFlipData(const uint8_t* aSrc, int32_t aSrcStride,
65 SurfaceFormat aSrcFormat, uint8_t* aDst,
66 int32_t aDstStride,
67 SurfaceFormat aDstFormat,
68 const IntSize& aSize);
70 /**
71 * Swizzles source and writes it to destination. Source and destination may be
72 * the same to swizzle in-place.
74 typedef void (*SwizzleRowFn)(const uint8_t* aSrc, uint8_t* aDst,
75 int32_t aLength);
77 /**
78 * Get a function pointer to perform premultiplication between two formats.
80 GFX2D_API SwizzleRowFn PremultiplyRow(SurfaceFormat aSrcFormat,
81 SurfaceFormat aDstFormat);
83 /**
84 * Get a function pointer to perform unpremultiplication between two formats.
86 GFX2D_API SwizzleRowFn UnpremultiplyRow(SurfaceFormat aSrcFormat,
87 SurfaceFormat aDstFormat);
89 /**
90 * Get a function pointer to perform swizzling between two formats.
92 GFX2D_API SwizzleRowFn SwizzleRow(SurfaceFormat aSrcFormat,
93 SurfaceFormat aDstFormat);
95 /**
96 * Reorients source and writes it to destination. Returns the dirty rect of
97 * what was changed in aDst.
99 typedef IntRect (*ReorientRowFn)(const uint8_t* aSrc, int32_t aSrcRow,
100 uint8_t* aDst, const IntSize& aDstSize,
101 int32_t aDstStride);
104 * Get a function pointer to perform reorientation by row.
106 GFX2D_API ReorientRowFn
107 ReorientRow(const struct image::Orientation& aOrientation);
109 } // namespace gfx
110 } // namespace mozilla
112 #endif /* MOZILLA_GFX_SWIZZLE_H_ */