Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
editor.cpp File Reference
#include "modules/skplaintexteditor/include/editor.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkExecutor.h"
#include "include/core/SkPath.h"
#include "src/base/SkUTF.h"
#include "modules/skplaintexteditor/src/shape.h"
#include <algorithm>
#include <cfloat>

Go to the source code of this file.

Functions

static SkRect offset (SkRect r, SkIPoint p)
 
static bool valid_utf8 (const char *ptr, size_t size)
 
template<typename F >
static void readlines (const void *data, size_t size, F f)
 
static StringSlice remove_newline (const char *str, size_t len)
 
static SkPoint to_point (SkIPoint p)
 
static bool is_utf8_continuation (char v)
 
static const char * next_utf8 (const char *p, const char *end)
 
static const char * align_utf8 (const char *p, const char *begin)
 
static const char * prev_utf8 (const char *p, const char *begin)
 
static size_t count_char (const StringSlice &string, char value)
 
static void append (char **dst, size_t *count, const char *src, size_t n)
 
static const char * begin (const StringSlice &s)
 
static const char * end (const StringSlice &s)
 
static size_t align_column (const StringSlice &str, size_t p)
 
template<typename T >
static size_t find_first_larger (const std::vector< T > &list, T value)
 
static size_t find_closest_x (const std::vector< SkRect > &bounds, float x, size_t b, size_t e)
 

Variables

static constexpr SkRect kUnsetRect {-FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX}
 

Function Documentation

◆ align_column()

static size_t align_column ( const StringSlice str,
size_t  p 
)
static

Definition at line 250 of file editor.cpp.

250 {
251 if (p >= str.size()) {
252 return str.size();
253 }
254 return align_utf8(begin(str) + p, begin(str)) - begin(str);
255}
std::size_t size() const
Definition: stringslice.h:27
static const char * align_utf8(const char *p, const char *begin)
Definition: editor.cpp:114
static const char * begin(const StringSlice &s)
Definition: editor.cpp:246

◆ align_utf8()

static const char * align_utf8 ( const char *  p,
const char *  begin 
)
static

Definition at line 114 of file editor.cpp.

114 {
115 while (p > begin && is_utf8_continuation(*p)) {
116 --p;
117 }
118 return p;
119}
static bool is_utf8_continuation(char v)
Definition: editor.cpp:100

◆ append()

static void append ( char **  dst,
size_t *  count,
const char *  src,
size_t  n 
)
static

Definition at line 205 of file editor.cpp.

205 {
206 if (*dst) {
207 ::memcpy(*dst, src, n);
208 *dst += n;
209 }
210 *count += n;
211}
int count
Definition: FontMgrTest.cpp:49
dst
Definition: cp.py:12

◆ begin()

static const char * begin ( const StringSlice s)
inlinestatic

Definition at line 246 of file editor.cpp.

246{ return s.begin(); }
struct MyStruct s

◆ count_char()

static size_t count_char ( const StringSlice string,
char  value 
)
static

Definition at line 141 of file editor.cpp.

141 {
142 size_t count = 0;
143 for (char c : string) { if (c == value) { ++count; } }
144 return count;
145}
uint8_t value

◆ end()

static const char * end ( const StringSlice s)
inlinestatic

Definition at line 248 of file editor.cpp.

248{ return s.end(); }

◆ find_closest_x()

static size_t find_closest_x ( const std::vector< SkRect > &  bounds,
float  x,
size_t  b,
size_t  e 
)
static

Definition at line 264 of file editor.cpp.

264 {
265 if (b >= e) {
266 return b;
267 }
268 SkASSERT(e <= bounds.size());
269 size_t best_index = b;
270 float best_diff = ::fabsf(bounds[best_index].x() - x);
271 for (size_t i = b + 1; i < e; ++i) {
272 float d = ::fabsf(bounds[i].x() - x);
273 if (d < best_diff) {
274 best_diff = d;
275 best_index = i;
276 }
277 }
278 return best_index;
279}
#define SkASSERT(cond)
Definition: SkAssert.h:100
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
static bool b
double x
Optional< SkRect > bounds
Definition: SkRecords.h:183

◆ find_first_larger()

template<typename T >
static size_t find_first_larger ( const std::vector< T > &  list,
T  value 
)
static

Definition at line 260 of file editor.cpp.

260 {
261 return (size_t)(std::upper_bound(list.begin(), list.end(), value) - list.begin());
262}

◆ is_utf8_continuation()

static bool is_utf8_continuation ( char  v)
inlinestatic

Definition at line 100 of file editor.cpp.

100 {
101 return ((unsigned char)v & 0b11000000) ==
102 0b10000000;
103}

◆ next_utf8()

static const char * next_utf8 ( const char *  p,
const char *  end 
)
static

Definition at line 105 of file editor.cpp.

105 {
106 if (p < end) {
107 do {
108 ++p;
109 } while (p < end && is_utf8_continuation(*p));
110 }
111 return p;
112}
glong glong end

◆ offset()

static SkRect offset ( SkRect  r,
SkIPoint  p 
)
inlinestatic

Definition at line 18 of file editor.cpp.

18 {
19 return r.makeOffset((float)p.x(), (float)p.y());
20}
constexpr SkRect makeOffset(float dx, float dy) const
Definition: SkRect.h:976

◆ prev_utf8()

static const char * prev_utf8 ( const char *  p,
const char *  begin 
)
static

Definition at line 121 of file editor.cpp.

121 {
122 return p > begin ? align_utf8(p - 1, begin) : begin;
123}

◆ readlines()

template<typename F >
static void readlines ( const void *  data,
size_t  size,
F  f 
)
static

Definition at line 30 of file editor.cpp.

30 {
31 const char* start = (const char*)data;
32 const char* end = start + size;
33 const char* ptr = start;
34 while (ptr < end) {
35 while (*ptr++ != '\n' && ptr < end) {}
36 size_t len = ptr - start;
37 SkASSERT(len > 0);
38 f(start, len);
39 start = ptr;
40 }
41}
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
float f
Definition: skcms.cc:52

◆ remove_newline()

static StringSlice remove_newline ( const char *  str,
size_t  len 
)
static

Definition at line 43 of file editor.cpp.

43 {
44 return SkASSERT((str != nullptr) || (len == 0)),
45 StringSlice(str, (len > 0 && str[len - 1] == '\n') ? len - 1 : len);
46}

◆ to_point()

static SkPoint to_point ( SkIPoint  p)
static

Definition at line 69 of file editor.cpp.

69{ return {(float)p.x(), (float)p.y()}; }

◆ valid_utf8()

static bool valid_utf8 ( const char *  ptr,
size_t  size 
)
static

Definition at line 24 of file editor.cpp.

24{ return SkUTF::CountUTF8(ptr, size) >= 0; }
SK_SPI int CountUTF8(const char *utf8, size_t byteLength)
Definition: SkUTF.cpp:47

Variable Documentation

◆ kUnsetRect

constexpr SkRect kUnsetRect {-FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX}
staticconstexpr

Definition at line 22 of file editor.cpp.