Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
core
SkColorTable.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2023 Google LLC
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
8
#include "
include/core/SkColorTable.h
"
9
10
#include "
include/core/SkImageInfo.h
"
11
#include "
src/core/SkReadBuffer.h
"
12
#include "
src/core/SkWriteBuffer.h
"
13
14
sk_sp<SkColorTable>
SkColorTable::Make
(
const
uint8_t tableA[256],
15
const
uint8_t tableR[256],
16
const
uint8_t tableG[256],
17
const
uint8_t tableB[256]) {
18
if
(!tableA && !tableR && !tableG && !tableB) {
19
return
nullptr
;
// The table is the identity
20
}
21
22
SkBitmap
table
;
23
if
(!
table
.tryAllocPixels(
SkImageInfo::MakeA8
(256, 4))) {
24
return
nullptr
;
25
}
26
uint8_t *
a
=
table
.getAddr8(0,0),
27
*r =
table
.getAddr8(0,1),
28
*g =
table
.getAddr8(0,2),
29
*
b
=
table
.getAddr8(0,3);
30
for
(
int
i = 0; i < 256; i++) {
31
a
[i] = tableA ? tableA[i] : i;
32
r[i] = tableR ? tableR[i] : i;
33
g[i] = tableG ? tableG[i] : i;
34
b
[i] = tableB ? tableB[i] : i;
35
}
36
table
.setImmutable();
37
38
return
sk_sp<SkColorTable>
(
new
SkColorTable
(
table
));
39
}
40
41
void
SkColorTable::flatten
(
SkWriteBuffer
&
buffer
)
const
{
42
buffer
.writeByteArray(fTable.
getAddr8
(0, 0), 4 * 256);
43
}
44
45
sk_sp<SkColorTable>
SkColorTable::Deserialize
(
SkReadBuffer
&
buffer
) {
46
uint8_t argb[4*256];
47
if
(
buffer
.readByteArray(argb,
sizeof
(argb))) {
48
return
SkColorTable::Make
(argb+0*256, argb+1*256, argb+2*256, argb+3*256);
49
}
50
return
nullptr
;
51
}
SkColorTable.h
SkImageInfo.h
SkReadBuffer.h
SkWriteBuffer.h
table
SI F table(const skcms_Curve *curve, F v)
Definition
Transform_inl.h:604
SkBitmap
Definition
SkBitmap.h:59
SkBitmap::getAddr8
uint8_t * getAddr8(int x, int y) const
Definition
SkBitmap.h:1270
SkColorTable
Definition
SkColorTable.h:25
SkColorTable::flatten
void flatten(SkWriteBuffer &buffer) const
Definition
SkColorTable.cpp:41
SkColorTable::Make
static sk_sp< SkColorTable > Make(const uint8_t table[256])
Definition
SkColorTable.h:29
SkColorTable::Deserialize
static sk_sp< SkColorTable > Deserialize(SkReadBuffer &buffer)
Definition
SkColorTable.cpp:45
SkReadBuffer
Definition
SkReadBuffer.h:52
SkWriteBuffer
Definition
SkWriteBuffer.h:41
sk_sp
Definition
SkRefCnt.h:220
b
static bool b
Definition
ffi_native_test_module.c:74
a
struct MyStruct a[10]
buffer
static const uint8_t buffer[]
Definition
fl_pixel_buffer_texture_test.cc:44
SkImageInfo::MakeA8
static SkImageInfo MakeA8(int width, int height)
Definition
SkImageInfo.cpp:173
Generated on Fri Apr 26 2024 06:16:42 for Flutter Engine by
1.9.8