Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
SkParsePath.cpp File Reference
#include "include/core/SkPath.h"
#include "include/core/SkPoint.h"
#include "include/core/SkScalar.h"
#include "include/core/SkStream.h"
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/utils/SkParse.h"
#include "include/utils/SkParsePath.h"
#include "src/core/SkGeometry.h"
#include <cstdio>

Go to the source code of this file.

Functions

static bool is_between (int c, int min, int max)
 
static bool is_ws (int c)
 
static bool is_digit (int c)
 
static bool is_sep (int c)
 
static bool is_lower (int c)
 
static int to_upper (int c)
 
static const char * skip_ws (const char str[])
 
static const char * skip_sep (const char str[])
 
static const char * find_points (const char str[], SkPoint value[], int count, bool isRelative, SkPoint *relative)
 
static const char * find_scalar (const char str[], SkScalar *value, bool isRelative, SkScalar relative)
 
static const char * find_flag (const char str[], bool *value)
 
static void write_scalar (SkWStream *stream, SkScalar value)
 

Function Documentation

◆ find_flag()

static const char * find_flag ( const char  str[],
bool *  value 
)
static

Definition at line 91 of file SkParsePath.cpp.

91 {
92 if (!str) {
93 return nullptr;
94 }
95 if (str[0] != '1' && str[0] != '0') {
96 return nullptr;
97 }
98 *value = str[0] != '0';
99 str = skip_sep(str + 1);
100 return str;
101}
static const char * skip_sep(const char str[])
uint8_t value

◆ find_points()

static const char * find_points ( const char  str[],
SkPoint  value[],
int  count,
bool  isRelative,
SkPoint relative 
)
static

Definition at line 62 of file SkParsePath.cpp.

63 {
64 str = SkParse::FindScalars(str, &value[0].fX, count * 2);
65 if (isRelative) {
66 for (int index = 0; index < count; index++) {
67 value[index].fX += relative->fX;
68 value[index].fY += relative->fY;
69 }
70 }
71 return str;
72}
int count
static const char * FindScalars(const char str[], SkScalar value[], int count)
Definition SkParse.cpp:231
float fX
x-axis value
float fY
y-axis value

◆ find_scalar()

static const char * find_scalar ( const char  str[],
SkScalar value,
bool  isRelative,
SkScalar  relative 
)
static

Definition at line 74 of file SkParsePath.cpp.

75 {
76 str = SkParse::FindScalar(str, value);
77 if (!str) {
78 return nullptr;
79 }
80 if (isRelative) {
81 *value += relative;
82 }
83 str = skip_sep(str);
84 return str;
85}
static const char * FindScalar(const char str[], SkScalar *value)
Definition SkParse.cpp:216

◆ is_between()

static bool is_between ( int  c,
int  min,
int  max 
)
inlinestatic

Definition at line 22 of file SkParsePath.cpp.

22 {
23 return (unsigned)(c - min) <= (unsigned)(max - min);
24}
static float max(float r, float g, float b)
Definition hsl.cpp:49
static float min(float r, float g, float b)
Definition hsl.cpp:48

◆ is_digit()

static bool is_digit ( int  c)
inlinestatic

Definition at line 30 of file SkParsePath.cpp.

30 {
31 return is_between(c, '0', '9');
32}
static bool is_between(int c, int min, int max)

◆ is_lower()

static bool is_lower ( int  c)
inlinestatic

Definition at line 38 of file SkParsePath.cpp.

38 {
39 return is_between(c, 'a', 'z');
40}

◆ is_sep()

static bool is_sep ( int  c)
inlinestatic

Definition at line 34 of file SkParsePath.cpp.

34 {
35 return is_ws(c) || c == ',';
36}
static bool is_ws(int c)

◆ is_ws()

static bool is_ws ( int  c)
inlinestatic

Definition at line 26 of file SkParsePath.cpp.

26 {
27 return is_between(c, 1, 32);
28}

◆ skip_sep()

static const char * skip_sep ( const char  str[])
static

Definition at line 53 of file SkParsePath.cpp.

53 {
54 if (!str) {
55 return nullptr;
56 }
57 while (is_sep(*str))
58 str++;
59 return str;
60}
static bool is_sep(int c)

◆ skip_ws()

static const char * skip_ws ( const char  str[])
static

Definition at line 46 of file SkParsePath.cpp.

46 {
47 SkASSERT(str);
48 while (is_ws(*str))
49 str++;
50 return str;
51}
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ to_upper()

static int to_upper ( int  c)
inlinestatic

Definition at line 42 of file SkParsePath.cpp.

42 {
43 return c - 'a' + 'A';
44}

◆ write_scalar()

static void write_scalar ( SkWStream stream,
SkScalar  value 
)
static

Definition at line 236 of file SkParsePath.cpp.

236 {
237 char buffer[64];
238 int len = snprintf(buffer, sizeof(buffer), "%g", value);
239 char* stop = buffer + len;
240 stream->write(buffer, stop - buffer);
241}
static const uint8_t buffer[]