Flutter Engine
The Flutter Engine
SkClusterator.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2018 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
9
10#include "include/core/SkSpan.h"
13#include "src/text/GlyphRun.h"
14
15static bool is_reversed(const uint32_t* clusters, uint32_t count) {
16 // "ReversedChars" is how PDF deals with RTL text.
17 // return true if more than one cluster and monotonicly decreasing to zero.
18 if (count < 2 || clusters[0] == 0 || clusters[count - 1] != 0) {
19 return false;
20 }
21 for (uint32_t i = 0; i + 1 < count; ++i) {
22 if (clusters[i + 1] > clusters[i]) {
23 return false;
24 }
25 }
26 return true;
27}
28
30 : fClusters(run.clusters().data())
31 , fUtf8Text(run.text().data())
32 , fGlyphCount(SkToU32(run.glyphsIDs().size()))
33 , fTextByteLength(SkToU32(run.text().size()))
34 , fReversedChars(fClusters ? is_reversed(fClusters, fGlyphCount) : false)
35{
36 if (fClusters) {
37 SkASSERT(fUtf8Text && fTextByteLength > 0 && fGlyphCount > 0);
38 } else {
39 SkASSERT(!fUtf8Text && fTextByteLength == 0);
40 }
41}
42
44 if (fCurrentGlyphIndex >= fGlyphCount) {
45 return Cluster{nullptr, 0, 0, 0};
46 }
47 if (!fClusters || !fUtf8Text) {
48 return Cluster{nullptr, 0, fCurrentGlyphIndex++, 1};
49 }
50 uint32_t clusterGlyphIndex = fCurrentGlyphIndex;
51 uint32_t cluster = fClusters[clusterGlyphIndex];
52 do {
53 ++fCurrentGlyphIndex;
54 } while (fCurrentGlyphIndex < fGlyphCount && cluster == fClusters[fCurrentGlyphIndex]);
55 uint32_t clusterGlyphCount = fCurrentGlyphIndex - clusterGlyphIndex;
56 uint32_t clusterEnd = fTextByteLength;
57 for (unsigned i = 0; i < fGlyphCount; ++i) {
58 uint32_t c = fClusters[i];
59 if (c > cluster && c < clusterEnd) {
60 clusterEnd = c;
61 }
62 }
63 uint32_t clusterLen = clusterEnd - cluster;
64 return Cluster{fUtf8Text + cluster, clusterLen, clusterGlyphIndex, clusterGlyphCount};
65}
int count
Definition: FontMgrTest.cpp:50
#define SkASSERT(cond)
Definition: SkAssert.h:116
static bool is_reversed(const uint32_t *clusters, uint32_t count)
constexpr uint32_t SkToU32(S x)
Definition: SkTo.h:26
SkClusterator(const sktext::GlyphRun &run)
Cluster next()
std::u16string text
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
Definition: run.py:1
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63