Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
9
13
14sk_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
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
39}
40
42 buffer.writeByteArray(fTable.getAddr8(0, 0), 4 * 256);
43}
44
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}
SI F table(const skcms_Curve *curve, F v)
uint8_t * getAddr8(int x, int y) const
Definition SkBitmap.h:1270
void flatten(SkWriteBuffer &buffer) const
static sk_sp< SkColorTable > Make(const uint8_t table[256])
static sk_sp< SkColorTable > Deserialize(SkReadBuffer &buffer)
static bool b
struct MyStruct a[10]
static const uint8_t buffer[]
static SkImageInfo MakeA8(int width, int height)