Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Macros | Functions
ColorPrivTest.cpp File Reference
#include "include/core/SkColor.h"
#include "include/core/SkColorPriv.h"
#include "include/core/SkTypes.h"
#include "include/private/SkColorData.h"
#include "tests/Test.h"
#include <cstdint>

Go to the source code of this file.

Macros

#define ASSERT(expr)   REPORTER_ASSERT(r, expr)
 

Functions

 DEF_TEST (Splay, r)
 
 DEF_TEST (FourByteInterp, r)
 

Macro Definition Documentation

◆ ASSERT

#define ASSERT (   expr)    REPORTER_ASSERT(r, expr)

Definition at line 16 of file ColorPrivTest.cpp.

Function Documentation

◆ DEF_TEST() [1/2]

DEF_TEST ( FourByteInterp  ,
 
)

Definition at line 32 of file ColorPrivTest.cpp.

32 {
33 const SkPMColor src = 0xAB998877, dst = 0x66334455;
34 for (unsigned scale = 0; scale <= 256; scale++) {
36 }
37
38 for (unsigned scale = 0; scale < 256; scale++) {
39 // SkFourByteInterp and SkFastFourByteInterp convert from [0, 255] to [0, 256] differently.
40 // In particular, slow may end up a little too high (weirdly, fast is more accurate).
41 const SkPMColor slow = SkFourByteInterp(src, dst, scale);
42 const SkPMColor fast = SkFastFourByteInterp(src, dst, scale);
43
44 const int deltaA = SkGetPackedA32(slow) - SkGetPackedA32(fast);
45 const int deltaR = SkGetPackedR32(slow) - SkGetPackedR32(fast);
46 const int deltaG = SkGetPackedG32(slow) - SkGetPackedG32(fast);
47 const int deltaB = SkGetPackedB32(slow) - SkGetPackedB32(fast);
48
49 ASSERT(deltaA == 0 || deltaA == 1);
50 ASSERT(deltaR == 0 || deltaR == 1);
51 ASSERT(deltaG == 0 || deltaG == 1);
52 ASSERT(deltaB == 0 || deltaB == 1);
53 }
54}
#define ASSERT(expr)
static SkPMColor SkFastFourByteInterp256(SkPMColor src, SkPMColor dst, unsigned scale)
static SkPMColor SkFastFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight)
static SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight)
static SkPMColor SkFourByteInterp256(SkPMColor src, SkPMColor dst, int scale)
#define SkGetPackedB32(packed)
Definition SkColorPriv.h:95
#define SkGetPackedR32(packed)
Definition SkColorPriv.h:93
#define SkGetPackedA32(packed)
Definition SkColorPriv.h:92
#define SkGetPackedG32(packed)
Definition SkColorPriv.h:94
uint32_t SkPMColor
Definition SkColor.h:205
dst
Definition cp.py:12
const Scalar scale

◆ DEF_TEST() [2/2]

DEF_TEST ( Splay  ,
 
)

Definition at line 18 of file ColorPrivTest.cpp.

18 {
19 const SkPMColor color = 0xA1B2C3D4;
20
21 uint32_t ag, rb;
22 SkSplay(color, &ag, &rb);
23 ASSERT(ag == 0x00A100C3);
24 ASSERT(rb == 0x00B200D4);
25 ASSERT(SkUnsplay(ag << 8, rb << 8) == color);
26
27 const uint64_t agrb = SkSplay(color);
28 ASSERT(agrb == 0x00A100C300B200D4ULL);
29 ASSERT(SkUnsplay(agrb<<8) == color);
30}
SkColor4f color
static void SkSplay(uint32_t color, uint32_t *ag, uint32_t *rb)
static uint32_t SkUnsplay(uint32_t ag, uint32_t rb)