Flutter Engine
The Flutter Engine
SkColorTable.h
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#ifndef SkColorTable_DEFINED
9#define SkColorTable_DEFINED
10
14
15#include <cstdint>
16
17class SkReadBuffer;
18class SkWriteBuffer;
19
20/**
21 * SkColorTable holds the lookup tables for each channel (ARGB) used to define the filter behavior
22 * of `SkColorFilters::Table`, and provides a way to share the table data between client code and
23 * the returned SkColorFilter. Once created, an SkColorTable is immutable.
24*/
26public:
27 // Creates a new SkColorTable with 'table' used for all four channels. The table is copied into
28 // the SkColorTable.
29 static sk_sp<SkColorTable> Make(const uint8_t table[256]) {
30 return Make(table, table, table, table);
31 }
32
33 // Creates a new SkColorTable with the per-channel lookup tables. Each non-null table is copied
34 // into the SkColorTable. Null parameters are interpreted as the identity table.
35 static sk_sp<SkColorTable> Make(const uint8_t tableA[256],
36 const uint8_t tableR[256],
37 const uint8_t tableG[256],
38 const uint8_t tableB[256]);
39
40 // Per-channel constant value lookup (0-255).
41 const uint8_t* alphaTable() const { return fTable.getAddr8(0, 0); }
42 const uint8_t* redTable() const { return fTable.getAddr8(0, 1); }
43 const uint8_t* greenTable() const { return fTable.getAddr8(0, 2); }
44 const uint8_t* blueTable() const { return fTable.getAddr8(0, 3); }
45
46 void flatten(SkWriteBuffer& buffer) const;
47
48 static sk_sp<SkColorTable> Deserialize(SkReadBuffer& buffer);
49
50private:
51 friend class SkTableColorFilter; // for bitmap()
52
53 SkColorTable(const SkBitmap& table) : fTable(table) {}
54
55 // The returned SkBitmap is immutable; attempting to modify its pixel data will trigger asserts
56 // in debug builds and cause undefined behavior in release builds.
57 const SkBitmap& bitmap() const { return fTable; }
58
59 SkBitmap fTable; // A 256x4 A8 image
60};
61
62#endif // SkColorTable_DEFINED
#define SK_API
Definition: SkAPI.h:35
SI F table(const skcms_Curve *curve, F v)
const uint8_t * redTable() const
Definition: SkColorTable.h:42
const uint8_t * alphaTable() const
Definition: SkColorTable.h:41
static sk_sp< SkColorTable > Make(const uint8_t table[256])
Definition: SkColorTable.h:29
const uint8_t * greenTable() const
Definition: SkColorTable.h:43
const uint8_t * blueTable() const
Definition: SkColorTable.h:44
const SkBitmap & bitmap() const
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126