Flutter Engine
The Flutter Engine
third_party
skia
include
core
SkUnPreMultiply.h
Go to the documentation of this file.
1
2
/*
3
* Copyright 2008 The Android Open Source Project
4
*
5
* Use of this source code is governed by a BSD-style license that can be
6
* found in the LICENSE file.
7
*/
8
#ifndef SkUnPreMultiply_DEFINED
9
#define SkUnPreMultiply_DEFINED
10
11
#include "
include/core/SkColor.h
"
12
#include "
include/core/SkTypes.h
"
13
#include "
include/private/base/SkCPUTypes.h
"
14
15
#include <cstdint>
16
17
class
SK_API
SkUnPreMultiply
{
18
public
:
19
typedef
uint32_t
Scale
;
20
21
// index this table with alpha [0..255]
22
static
const
Scale
*
GetScaleTable
() {
23
return
gTable;
24
}
25
26
static
Scale
GetScale
(
U8CPU
alpha) {
27
SkASSERT
(alpha <= 255);
28
return
gTable[alpha];
29
}
30
31
/** Usage:
32
33
const Scale* table = SkUnPreMultiply::GetScaleTable();
34
35
for (...) {
36
unsigned a = ...
37
SkUnPreMultiply::Scale scale = table[a];
38
39
red = SkUnPreMultiply::ApplyScale(scale, red);
40
...
41
// now red is unpremultiplied
42
}
43
*/
44
static
U8CPU
ApplyScale
(
Scale
scale
,
U8CPU
component) {
45
SkASSERT
(component <= 255);
46
return
(
scale
* component + (1 << 23)) >> 24;
47
}
48
49
static
SkColor
PMColorToColor(
SkPMColor
c);
50
51
private
:
52
static
const
uint32_t gTable[256];
53
};
54
55
#endif
SK_API
#define SK_API
Definition:
SkAPI.h:35
SkASSERT
#define SkASSERT(cond)
Definition:
SkAssert.h:116
SkCPUTypes.h
U8CPU
unsigned U8CPU
Definition:
SkCPUTypes.h:18
SkColor.h
SkColor
uint32_t SkColor
Definition:
SkColor.h:37
SkPMColor
uint32_t SkPMColor
Definition:
SkColor.h:205
SkTypes.h
SkUnPreMultiply
Definition:
SkUnPreMultiply.h:17
SkUnPreMultiply::GetScaleTable
static const Scale * GetScaleTable()
Definition:
SkUnPreMultiply.h:22
SkUnPreMultiply::ApplyScale
static U8CPU ApplyScale(Scale scale, U8CPU component)
Definition:
SkUnPreMultiply.h:44
SkUnPreMultiply::Scale
uint32_t Scale
Definition:
SkUnPreMultiply.h:19
SkUnPreMultiply::GetScale
static Scale GetScale(U8CPU alpha)
Definition:
SkUnPreMultiply.h:26
Scale
Definition:
dart.idl:629
scale
const Scalar scale
Definition:
stroke_path_geometry.cc:308
Generated on Sun Jun 23 2024 21:56:02 for Flutter Engine by
1.9.4