Flutter Engine
The Flutter Engine
ColorTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
13#include "src/base/SkMathPriv.h"
14#include "src/base/SkRandom.h"
15#include "tests/Test.h"
16
17DEF_TEST(ColorPremul, reporter) {
18 for (int a = 0; a <= 255; a++) {
19 for (int x = 0; x <= 255; x++) {
20 SkColor c0 = SkColorSetARGB(a, x, x, x);
22
25
26 // we can't promise that c0 == c1, since c0 -> p0 is a many to one
27 // function, however, we can promise that p0 -> c1 -> p1 : p0 == p1
28 REPORTER_ASSERT(reporter, p0 == p1);
29
30 {
31 int ax = SkMulDiv255Ceiling(x, a);
33 }
34 }
35 }
36}
37
38/**
39 This test fails: SkFourByteInterp does *not* preserve opaque destinations.
40 SkAlpha255To256 implemented as (alpha + 1) is faster than
41 (alpha + (alpha >> 7)), but inaccurate, and Skia intends to phase it out.
42*/
43DEF_TEST(ColorInterp, reporter) {
44 SkRandom r;
45
46 U8CPU a0 = 0;
47 U8CPU a255 = 255;
48 for (int i = 0; i < 200; i++) {
49 SkColor colorSrc = r.nextU();
50 SkColor colorDst = r.nextU();
53
54 if ((false)) {
57 }
58 }
59}
60
61DEF_TEST(ColorFastIterp, reporter) {
62 SkRandom r;
63
64 U8CPU a0 = 0;
65 U8CPU a255 = 255;
66 for (int i = 0; i < 200; i++) {
67 SkColor colorSrc = r.nextU();
68 SkColor colorDst = r.nextU();
71
74 }
75}
DEF_TEST(ColorPremul, reporter)
Definition: ColorTest.cpp:17
reporter
Definition: FontMgrTest.cpp:39
unsigned U8CPU
Definition: SkCPUTypes.h:18
static SkPMColor SkFastFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight)
Definition: SkColorData.h:260
static SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight)
Definition: SkColorData.h:177
SK_API SkPMColor SkPreMultiplyColor(SkColor c)
Definition: SkColor.cpp:21
uint32_t SkColor
Definition: SkColor.h:37
uint32_t SkPMColor
Definition: SkColor.h:205
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
static U8CPU SkMulDiv255Ceiling(U8CPU a, U8CPU b)
Definition: SkMathPriv.h:102
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
uint32_t nextU()
Definition: SkRandom.h:42
static SkColor PMColorToColor(SkPMColor c)
struct MyStruct a[10]
double x
dst
Definition: cp.py:12