tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Swizzle.h (4250B)


      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 MOZILLA_GFX_SWIZZLE_H_
      8 #define MOZILLA_GFX_SWIZZLE_H_
      9 
     10 #include "Point.h"
     11 #include "Rect.h"
     12 
     13 namespace mozilla {
     14 namespace image {
     15 struct Orientation;
     16 }
     17 
     18 namespace gfx {
     19 
     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.
     24 */
     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);
     29 
     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.
     34 */
     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);
     39 
     40 /**
     41 * Swizzles source and writes it to destination. Source and destination may be
     42 * the same to swizzle in-place.
     43 */
     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);
     48 
     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.
     53 */
     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);
     58 
     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.
     63 */
     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);
     69 
     70 /**
     71 * Swizzles source and writes it to destination. Source and destination may be
     72 * the same to swizzle in-place.
     73 */
     74 typedef void (*SwizzleRowFn)(const uint8_t* aSrc, uint8_t* aDst,
     75                             int32_t aLength);
     76 
     77 /**
     78 * Get a function pointer to perform premultiplication between two formats.
     79 */
     80 GFX2D_API SwizzleRowFn PremultiplyRow(SurfaceFormat aSrcFormat,
     81                                      SurfaceFormat aDstFormat);
     82 
     83 /**
     84 * Get a function pointer to perform unpremultiplication between two formats.
     85 */
     86 GFX2D_API SwizzleRowFn UnpremultiplyRow(SurfaceFormat aSrcFormat,
     87                                        SurfaceFormat aDstFormat);
     88 
     89 /**
     90 * Get a function pointer to perform swizzling between two formats.
     91 */
     92 GFX2D_API SwizzleRowFn SwizzleRow(SurfaceFormat aSrcFormat,
     93                                  SurfaceFormat aDstFormat);
     94 
     95 /**
     96 * Reorients source and writes it to destination. Returns the dirty rect of
     97 * what was changed in aDst.
     98 */
     99 typedef IntRect (*ReorientRowFn)(const uint8_t* aSrc, int32_t aSrcRow,
    100                                 uint8_t* aDst, const IntSize& aDstSize,
    101                                 int32_t aDstStride);
    102 
    103 /**
    104 * Get a function pointer to perform reorientation by row.
    105 */
    106 GFX2D_API ReorientRowFn
    107 ReorientRow(const struct image::Orientation& aOrientation);
    108 
    109 }  // namespace gfx
    110 }  // namespace mozilla
    111 
    112 #endif /* MOZILLA_GFX_SWIZZLE_H_ */