8#ifndef skgpu_BufferWriter_DEFINED
9#define skgpu_BufferWriter_DEFINED
38 : fMark(reinterpret_cast<uintptr_t>(ptr) +
offset) {
51 explicit operator bool()
const {
return *
this !=
Mark(); }
56 explicit operator bool()
const {
return fPtr !=
nullptr; }
96 void*
p = SkTAddOffset<void>(
fPtr, offsetInBytes);
143 return this->BufferWriter::makeOffset<VertexWriter>(offsetInBytes);
146 template <
typename T>
152 template <
typename T>
154 return {condition,
value};
157 template <
typename T>
166 template <
typename T>
168 return {array,
count};
171 template<
int kCount,
typename T>
176 template <
int kCount,
typename T>
200 template <
typename T>
203 template <
typename T>
207 case 0:
w <<
l <<
t;
return;
208 case 1:
w <<
l <<
b;
return;
209 case 2:
w <<
r <<
t;
return;
210 case 3:
w <<
r <<
b;
return;
225 template <
typename T>
229 case 0:
w <<
l <<
t;
return;
230 case 1:
w <<
l <<
b;
return;
231 case 2:
w <<
r <<
b;
return;
232 case 3:
w <<
r <<
t;
return;
243 template <
typename... Args>
245 this->writeQuadVertex<0>(remainder...);
246 this->writeQuadVertex<1>(remainder...);
247 this->writeQuadVertex<2>(remainder...);
248 this->writeQuadVertex<3>(remainder...);
252 template <
int kCornerIdx,
typename T,
typename... Args>
254 const Args&... remainder) {
256 this->writeQuadVertex<kCornerIdx>(remainder...);
259 template <
int kCornerIdx,
typename Q,
typename... Args>
261 const Args&... remainder) {
262 quad.writeVertex(kCornerIdx, *
this);
263 this->writeQuadVertex<kCornerIdx>(remainder...);
266 template <
int kCornerIdx>
267 void writeQuadVertex() {}
269 template <
typename T>
272 template <
typename T>
279 w.validate(
sizeof(
T));
280 memcpy(
w.fPtr, &val,
sizeof(
T));
281 w =
w.makeOffset(
sizeof(
T));
296 w =
w.makeOffset(
sizeof(
T));
303 w.validate(array.
fCount *
sizeof(
T));
305 w =
w.makeOffset(
sizeof(
T) * array.
fCount);
309template <
int kCount,
typename T>
311 for (
int i = 0;
i < kCount; ++
i) {
319 w.validate(
sizeof(vector));
321 w =
w.makeOffset(
sizeof(vector));
345 this->
set(color, wideColor);
350 memcpy(fColor,
color.vec(),
sizeof(fColor));
352 fColor[0] =
color.toBytes_RGBA();
354 fWideColor = wideColor;
357 size_t size()
const {
return fWideColor ? 16 : 4; }
360 template <
typename T>
370 if (
color.fWideColor) {
396 return this->BufferWriter::makeOffset<IndexWriter>(numIndices *
sizeof(uint16_t));
400 size_t arraySize =
count *
sizeof(uint16_t);
402 memcpy(
fPtr, array, arraySize);
403 fPtr = SkTAddOffset<void>(
fPtr, arraySize);
411 w.validate(
sizeof(uint16_t));
412 memcpy(
w.fPtr, &val,
sizeof(uint16_t));
442 fPtr = SkTAddOffset<void>(
fPtr, bytes);
446 fPtr = SkTAddOffset<void>(
fPtr, bytes);
468 void write(
size_t offset,
const void*
src,
size_t srcRowBytes,
size_t dstRowBytes,
469 size_t trimRowBytes,
int rowCount) {
470 this->
validate(offset + dstRowBytes * rowCount);
487 int rowPixels,
int rowCount) {
488 this->
validate(offset + dstRowBytes * rowCount);
490 auto* sRow =
reinterpret_cast<const char*
>(
src);
491 auto* dRow =
reinterpret_cast<char*
>(
dst);
493 for (
int y = 0;
y < rowCount; ++
y) {
494 for (
int x = 0;
x < rowPixels; ++
x) {
495 memcpy(dRow + 3*
x, sRow+4*
x, 3);
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
static unsigned repeat(SkFixed fx, int max)
bool SkConvertPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRB, const SkImageInfo &srcInfo, const void *srcPixels, size_t srcRB)
static void SkRectMemcpy(void *dst, size_t dstRB, const void *src, size_t srcRB, size_t trimRowBytes, int rowCount)
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
VertexColor(const SkPMColor4f &color, bool wideColor)
friend VertexWriter & operator<<(VertexWriter &, const T &)
void set(const SkPMColor4f &color, bool wideColor)
sk_sp< SkBlender > blender SkRect rect
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
VertexWriter & operator<<(VertexWriter &w, const T &val)
SkScalar fBottom
larger y-axis bounds
SkScalar fLeft
smaller x-axis bounds
SkScalar fRight
larger x-axis bounds
SkScalar fTop
smaller y-axis bounds
bool operator==(const Mark &o) const
ptrdiff_t operator-(const Mark &o) const
Mark(void *ptr, size_t offset=0)
bool operator>=(const Mark &o) const
bool operator<=(const Mark &o) const
bool operator!=(const Mark &o) const
bool operator<(const Mark &o) const
bool operator>(const Mark &o) const
BufferWriter & operator=(const BufferWriter &)=delete
BufferWriter(void *ptr, Mark end={})
BufferWriter & operator=(BufferWriter &&that)
W makeOffset(size_t offsetInBytes) const
Mark mark(size_t offset=0) const
BufferWriter(void *ptr, size_t size)
void validate(size_t bytesToWrite) const
IndexWriter(IndexWriter &&that)
IndexWriter(const IndexWriter &)=delete
IndexWriter(void *ptr, Mark end)
friend IndexWriter & operator<<(IndexWriter &w, uint16_t val)
IndexWriter(void *ptr, size_t size)
IndexWriter makeOffset(int numIndices) const
void writeArray(const uint16_t *array, int count)
IndexWriter & operator=(const IndexWriter &)=delete
IndexWriter & operator=(IndexWriter &&that)
TextureUploadWriter & operator=(TextureUploadWriter &&that)
TextureUploadWriter & operator=(const TextureUploadWriter &)=delete
void convertAndWrite(size_t offset, const SkImageInfo &srcInfo, const void *src, size_t srcRowBytes, const SkImageInfo &dstInfo, size_t dstRowBytes)
TextureUploadWriter(const TextureUploadWriter &)=delete
void writeRGBFromRGBx(size_t offset, const void *src, size_t srcRowBytes, size_t dstRowBytes, int rowPixels, int rowCount)
void write(size_t offset, const void *src, size_t srcRowBytes, size_t dstRowBytes, size_t trimRowBytes, int rowCount)
TextureUploadWriter(void *ptr, size_t size)
TextureUploadWriter()=default
TextureUploadWriter(TextureUploadWriter &&that)
void writeVertex(int cornerIdx, VertexWriter &w) const
void writeVertex(int cornerIdx, VertexWriter &w) const
VertexWriter(const VertexWriter &)=delete
static RepeatDesc< kCount, T > Repeat(const T &val)
static ArrayDesc< T > Array(const T *array, int count)
static TriStrip< uint16_t > TriStripFromUVs(const std::array< uint16_t, 4 > &rect)
friend VertexWriter & operator<<(VertexWriter &, const T &)
VertexWriter & operator=(VertexWriter &&that)
static TriFan< float > TriFanFromRect(const SkRect &r)
VertexWriter(void *ptr, Mark end)
void writeQuad(const Args &... remainder)
static Conditional< T > If(bool condition, const T &value)
static TriStrip< float > TriStripFromRect(const SkRect &r)
static constexpr uint32_t kIEEE_32_infinity
VertexWriter & operator=(const VertexWriter &)=delete
VertexWriter(void *ptr, size_t size)
VertexWriter makeOffset(size_t offsetInBytes) const
VertexWriter(VertexWriter &&that)
SKVX_ALWAYS_INLINE void store(void *ptr) const