Flutter Engine
The Flutter Engine
Functions | Variables
SkCharToGlyphCache.cpp File Reference
#include "src/utils/SkCharToGlyphCache.h"

Go to the source code of this file.

Functions

static int find_simple (const SkUnichar base[], int count, SkUnichar value)
 
static int find_with_slope (const SkUnichar base[], int count, SkUnichar value, double denom)
 

Variables

constexpr int kSmallCountLimit = 16
 
constexpr int kMinCountForSlope = 4
 

Function Documentation

◆ find_simple()

static int find_simple ( const SkUnichar  base[],
int  count,
SkUnichar  value 
)
static

Definition at line 38 of file SkCharToGlyphCache.cpp.

38 {
39 int index;
40 for (index = 0;; ++index) {
41 if (value <= base[index]) {
42 if (value < base[index]) {
43 index = ~index; // not found
44 }
45 break;
46 }
47 }
48 return index;
49}
uint8_t value

◆ find_with_slope()

static int find_with_slope ( const SkUnichar  base[],
int  count,
SkUnichar  value,
double  denom 
)
static

Definition at line 51 of file SkCharToGlyphCache.cpp.

51 {
53
54 int index;
55 if (value <= base[1]) {
56 index = 1;
57 if (value < base[index]) {
58 index = ~index;
59 }
60 } else if (value >= base[count - 2]) {
61 index = count - 2;
62 if (value > base[index]) {
63 index = ~(index + 1);
64 }
65 } else {
66 // make our guess based on the "slope" of the current values
67// index = 1 + (int64_t)(count - 2) * (value - base[1]) / (base[count - 2] - base[1]);
68 index = 1 + (int)(denom * (count - 2) * (value - base[1]));
69 SkASSERT(index >= 1 && index <= count - 2);
70
71 if (value >= base[index]) {
72 for (;; ++index) {
73 if (value <= base[index]) {
74 if (value < base[index]) {
75 index = ~index; // not found
76 }
77 break;
78 }
79 }
80 } else {
81 for (--index;; --index) {
82 SkASSERT(index >= 0);
83 if (value >= base[index]) {
84 if (value > base[index]) {
85 index = ~(index + 1);
86 }
87 break;
88 }
89 }
90 }
91 }
92 return index;
93}
int count
Definition: FontMgrTest.cpp:50
#define SkASSERT(cond)
Definition: SkAssert.h:116
constexpr int kMinCountForSlope

Variable Documentation

◆ kMinCountForSlope

constexpr int kMinCountForSlope = 4
constexpr

Definition at line 36 of file SkCharToGlyphCache.cpp.

◆ kSmallCountLimit

constexpr int kSmallCountLimit = 16
constexpr

Definition at line 32 of file SkCharToGlyphCache.cpp.