Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkBuffer.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
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#include "src/base/SkBuffer.h"
9
12
13#include <cstdint>
14
15///////////////////////////////////////////////////////////////////////////////////////////////////
16
17const void* SkRBuffer::skip(size_t size) {
18 if (fValid && size <= this->available()) {
19 const void* pos = fPos;
20 fPos += size;
21 return pos;
22 }
23 fValid = false;
24 return nullptr;
25}
26
27bool SkRBuffer::read(void* buffer, size_t size) {
28 if (const void* src = this->skip(size)) {
30 return true;
31 }
32 return false;
33}
34
36 intptr_t pos = reinterpret_cast<intptr_t>(fPos);
37 size_t n = SkAlign4(pos) - pos;
38 if (fValid && n <= this->available()) {
39 fPos += n;
40 return true;
41 } else {
42 fValid = false;
43 return false;
44 }
45}
46
47///////////////////////////////////////////////////////////////////////////////////////////////////
48
49void* SkWBuffer::skip(size_t size) {
50 void* result = fPos;
51 writeNoSizeCheck(nullptr, size);
52 return fData == nullptr ? nullptr : result;
53}
54
55void SkWBuffer::writeNoSizeCheck(const void* buffer, size_t size) {
56 SkASSERT(fData == nullptr || fStop == nullptr || fPos + size <= fStop);
57 if (fData && buffer) {
58 sk_careful_memcpy(fPos, buffer, size);
59 }
60 fPos += size;
61}
62
64 size_t pos = this->pos();
65 size_t n = SkAlign4(pos) - pos;
66
67 if (n && fData)
68 {
69 char* p = fPos;
70 char* stop = p + n;
71 do {
72 *p++ = 0;
73 } while (p < stop);
74 }
75 fPos += n;
76 return n;
77}
78
79#if 0
80#ifdef SK_DEBUG
81 static void AssertBuffer32(const void* buffer)
82 {
84 SkASSERT(((size_t)buffer & 3) == 0);
85 }
86#else
87 #define AssertBuffer32(buffer)
88#endif
89
90#endif
static constexpr T SkAlign4(T x)
Definition SkAlign.h:16
#define SkASSERT(cond)
Definition SkAssert.h:116
static void * sk_careful_memcpy(void *dst, const void *src, size_t len)
Definition SkMalloc.h:125
bool read(void *buffer, size_t size)
Definition SkBuffer.cpp:27
size_t pos() const
Definition SkBuffer.h:43
size_t available() const
Definition SkBuffer.h:54
size_t size() const
Definition SkBuffer.h:47
const void * skip(size_t bytes)
Definition SkBuffer.cpp:17
bool skipToAlign4()
Definition SkBuffer.cpp:35
void * skip(size_t size)
Definition SkBuffer.cpp:49
size_t padToAlign4()
Definition SkBuffer.cpp:63
size_t pos() const
Definition SkBuffer.h:108
static const uint8_t buffer[]
GAsyncResult * result
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