chromium/third_party/skia/include/private/SkColorData.h

/*
 * Copyright 2006 The Android Open Source Project
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkColorData_DEFINED
#define SkColorData_DEFINED

#include "include/core/SkColor.h"
#include "include/core/SkColorPriv.h"
#include "include/private/base/SkTo.h"

////////////////////////////////////////////////////////////////////////////////////////////
// Convert a 16bit pixel to a 32bit pixel

#define SK_R16_BITS
#define SK_G16_BITS
#define SK_B16_BITS

#define SK_R16_SHIFT
#define SK_G16_SHIFT
#define SK_B16_SHIFT

#define SK_R16_MASK
#define SK_G16_MASK
#define SK_B16_MASK

#define SkGetPackedR16(color)
#define SkGetPackedG16(color)
#define SkGetPackedB16(color)

static inline unsigned SkR16ToR32(unsigned r) {}

static inline unsigned SkG16ToG32(unsigned g) {}

static inline unsigned SkB16ToB32(unsigned b) {}

#define SkPacked16ToR32(c)
#define SkPacked16ToG32(c)
#define SkPacked16ToB32(c)

//////////////////////////////////////////////////////////////////////////////

#define SkASSERT_IS_BYTE(x)

// Reverse the bytes coorsponding to RED and BLUE in a packed pixels. Note the
// pair of them are in the same 2 slots in both RGBA and BGRA, thus there is
// no need to pass in the colortype to this function.
static inline uint32_t SkSwizzle_RB(uint32_t c) {}

static inline uint32_t SkPackARGB_as_RGBA(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {}

static inline uint32_t SkPackARGB_as_BGRA(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {}

static inline SkPMColor SkSwizzle_RGBA_to_PMColor(uint32_t c) {}

static inline SkPMColor SkSwizzle_BGRA_to_PMColor(uint32_t c) {}

//////////////////////////////////////////////////////////////////////////////

///@{
/** See ITU-R Recommendation BT.709 at http://www.itu.int/rec/R-REC-BT.709/ .*/
#define SK_ITU_BT709_LUM_COEFF_R
#define SK_ITU_BT709_LUM_COEFF_G
#define SK_ITU_BT709_LUM_COEFF_B
///@}

///@{
/** A float value which specifies this channel's contribution to luminance. */
#define SK_LUM_COEFF_R
#define SK_LUM_COEFF_G
#define SK_LUM_COEFF_B
///@}

/** Computes the luminance from the given r, g, and b in accordance with
    SK_LUM_COEFF_X. For correct results, r, g, and b should be in linear space.
*/
static inline U8CPU SkComputeLuminance(U8CPU r, U8CPU g, U8CPU b) {}

/** Calculates 256 - (value * alpha256) / 255 in range [0,256],
 *  for [0,255] value and [0,256] alpha256.
 */
static inline U16CPU SkAlphaMulInv256(U16CPU value, U16CPU alpha256) {}

//  The caller may want negative values, so keep all params signed (int)
//  so we don't accidentally slip into unsigned math and lose the sign
//  extension when we shift (in SkAlphaMul)
static inline int SkAlphaBlend(int src, int dst, int scale256) {}

static inline uint16_t SkPackRGB16(unsigned r, unsigned g, unsigned b) {}

#define SK_R16_MASK_IN_PLACE
#define SK_G16_MASK_IN_PLACE
#define SK_B16_MASK_IN_PLACE

///////////////////////////////////////////////////////////////////////////////

/**
 * Abstract 4-byte interpolation, implemented on top of SkPMColor
 * utility functions. Third parameter controls blending of the first two:
 *   (src, dst, 0) returns dst
 *   (src, dst, 0xFF) returns src
 *   scale is [0..256], unlike SkFourByteInterp which takes [0..255]
 */
static inline SkPMColor SkFourByteInterp256(SkPMColor src, SkPMColor dst, int scale) {}

/**
 * Abstract 4-byte interpolation, implemented on top of SkPMColor
 * utility functions. Third parameter controls blending of the first two:
 *   (src, dst, 0) returns dst
 *   (src, dst, 0xFF) returns src
 */
static inline SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight) {}

/**
 * 0xAARRGGBB -> 0x00AA00GG, 0x00RR00BB
 */
static inline void SkSplay(uint32_t color, uint32_t* ag, uint32_t* rb) {}

/**
 * 0xAARRGGBB -> 0x00AA00GG00RR00BB
 * (note, ARGB -> AGRB)
 */
static inline uint64_t SkSplay(uint32_t color) {}

/**
 * 0xAAxxGGxx, 0xRRxxBBxx-> 0xAARRGGBB
 */
static inline uint32_t SkUnsplay(uint32_t ag, uint32_t rb) {}

/**
 * 0xAAxxGGxxRRxxBBxx -> 0xAARRGGBB
 * (note, AGRB -> ARGB)
 */
static inline uint32_t SkUnsplay(uint64_t agrb) {}

static inline SkPMColor SkFastFourByteInterp256_32(SkPMColor src, SkPMColor dst, unsigned scale) {}

static inline SkPMColor SkFastFourByteInterp256_64(SkPMColor src, SkPMColor dst, unsigned scale) {}

// TODO(mtklein): Replace slow versions with fast versions, using scale + (scale>>7) everywhere.

/**
 * Same as SkFourByteInterp256, but faster.
 */
static inline SkPMColor SkFastFourByteInterp256(SkPMColor src, SkPMColor dst, unsigned scale) {}

/**
 * Nearly the same as SkFourByteInterp, but faster and a touch more accurate, due to better
 * srcWeight scaling to [0, 256].
 */
static inline SkPMColor SkFastFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight) {}

/**
 * Interpolates between colors src and dst using [0,256] scale.
 */
static inline SkPMColor SkPMLerp(SkPMColor src, SkPMColor dst, unsigned scale) {}

static inline SkPMColor SkBlendARGB32(SkPMColor src, SkPMColor dst, U8CPU aa) {}

////////////////////////////////////////////////////////////////////////////////////////////
// Convert a 32bit pixel to a 16bit pixel (no dither)

#define SkR32ToR16_MACRO(r)
#define SkG32ToG16_MACRO(g)
#define SkB32ToB16_MACRO(b)

#ifdef SK_DEBUG
    static inline unsigned SkR32ToR16(unsigned r) {}
    static inline unsigned SkG32ToG16(unsigned g) {}
    static inline unsigned SkB32ToB16(unsigned b) {}
#else
    #define SkR32ToR16
    #define SkG32ToG16
    #define SkB32ToB16
#endif

static inline U16CPU SkPixel32ToPixel16(SkPMColor c) {}

static inline U16CPU SkPack888ToRGB16(U8CPU r, U8CPU g, U8CPU b) {}

/////////////////////////////////////////////////////////////////////////////////////////

static inline SkColor SkPixel16ToColor(U16CPU src) {}

///////////////////////////////////////////////////////////////////////////////

SkPMColor16;

// Put in OpenGL order (r g b a)
#define SK_A4444_SHIFT
#define SK_R4444_SHIFT
#define SK_G4444_SHIFT
#define SK_B4444_SHIFT

static inline U8CPU SkReplicateNibble(unsigned nib) {}

#define SkGetPackedA4444(c)
#define SkGetPackedR4444(c)
#define SkGetPackedG4444(c)
#define SkGetPackedB4444(c)

#define SkPacked4444ToA32(c)

static inline SkPMColor SkPixel4444ToPixel32(U16CPU c) {}

SkPMColor4f;

constexpr SkPMColor4f SK_PMColor4fTRANSPARENT =;
constexpr SkPMColor4f SK_PMColor4fBLACK =;
constexpr SkPMColor4f SK_PMColor4fWHITE =;
constexpr SkPMColor4f SK_PMColor4fILLEGAL =;
#endif  // SkColorData_DEFINED