81 unsigned char dataWritten[1024];
82 size_t bytesWrittenToMemory = testObj->writeToMemory(dataWritten);
84 size_t bytesReadFromMemory = testObj->readFromMemory(dataWritten, bytesWrittenToMemory);
208template<
typename T,
bool testInval
id>
212 size_t bytesWritten = writer.bytesWritten();
215 unsigned char dataWritten[1024];
216 writer.writeToMemory(dataWritten);
228 size_t offsetBefore = buffer2.
offset();
231 size_t offsetAfter = buffer2.
offset();
241 TestObjectSerializationNoAlign<T, false>(testObj,
reporter);
250 size_t bytesWritten = writer.bytesWritten();
254 unsigned char dataWritten[4096];
255 writer.writeToMemory(dataWritten);
266 const unsigned char* peekBefore =
static_cast<const unsigned char*
>(buffer2.
skip(0));
269 const unsigned char* peekAfter =
static_cast<const unsigned char*
>(buffer2.
skip(0));
288 size_t bytesWritten = writer.bytesWritten();
292 unsigned char dataWritten[2048];
293 writer.writeToMemory(dataWritten);
321 std::move(invalidBitmapSource),
322 std::move(validBitmapSource),
nullptr));
325 TestFlattenableSerialization<SkImageFilter_Base>(
332 bitmap.allocN32Pixels(24, 24);
334 canvas.
clear(0x00000000);
336 paint.setImageFilter(deserializedFilter);
344 for (
int i = 0;
i < 256; ++
i) {
373 for (
int x = 0;
x < b2.
width(); ++
x) {
385 uint32_t typeface_id = typeface->
uniqueID();
386 stream.write(&typeface_id,
sizeof(typeface_id));
388 return stream.detachAsData();
399 if (!
stream->read(&
id,
sizeof(
id))) {
429 std::unique_ptr<SkStream> inputStream(
stream.detachAsStream());
496 INFOF(
reporter,
"Could not run test because test.ttc not found.");
507 INFOF(
reporter,
"Could not run test because Distortable.ttf not created.");
518 INFOF(
reporter,
"Could not run test because colr.ttf not created.");
528 std::unique_ptr<SkStreamAsset> typefaceStream = typeface.
openStream(&index);
529 if (!typefaceStream) {
532 size_t length = typefaceStream->getLength();
535 s.appendf(
"Index: %d\n", index);
536 s.appendf(
"Length: %zu\n",
length);
542 if (metrics.
fFlags == 0) {
546 m +=
" UnderlineThicknessIsValid\n";
549 m +=
" kUnderlinePositionIsValid\n";
552 m +=
" kStrikeoutThicknessIsValid\n";
555 m +=
" kStrikeoutPositionIsValid\n";
558 m +=
" kBoundsInvalid\n";
562 m.appendf(
"Top: %f\n", metrics.
fTop);
563 m.appendf(
"Ascent: %f\n", metrics.
fAscent);
564 m.appendf(
"Descent: %f\n", metrics.
fDescent);
565 m.appendf(
"Bottom: %f\n", metrics.
fBottom);
566 m.appendf(
"Leading: %f\n", metrics.
fLeading);
569 m.appendf(
"XMin: %f\n", metrics.
fXMin);
570 m.appendf(
"XMax: %f\n", metrics.
fXMax);
571 m.appendf(
"XHeight: %f\n", metrics.
fXHeight);
584 std::unique_ptr<SkStream> typefaceStream = typefaceWStream.
detachAsStream();
594 "Typeface: \"%s\" CloneTypeface: \"%s\"",
name.c_str(), cloneName.
c_str());
596 "Typeface: \"%s\" CloneTypeface: \"%s\"",
name.c_str(), cloneName.
c_str());
599 SkFont clone(cloneTypeface, 12);
601 font.getMetrics(&fontMetrics);
604 "Typeface: \"%s\"\n-Metrics---\n%s-Data---\n%s\n\n"
605 "CloneTypeface: \"%s\"\n-Metrics---\n%s-Data---\n%s",
627 canvas.
clear(0x00000000);
650 canvas->
scale(0.5f, 0.5f);
655 paint.setAntiAlias(
true);
672 p.playback(surf->getCanvas());
673 return surf->makeImageSnapshot();
686 TestObjectSerializationNoAlign<SkPoint3, false>(&point,
reporter);
709 TestObjectSerializationNoAlign<SkString, false>(&
string,
reporter);
710 TestObjectSerializationNoAlign<SkString, true>(&
string,
reporter);
720 SkVector corners[4] = { {1, 2}, {2, 3}, {3,4}, {4,5} };
743 { 1.f, 2.f, 4.f, 8.f }
774 writer.writeToMemory(buf.
get());
789 writer.writeToMemory(buf.
get());
803 writer.writeToMemory(buf.
get());
858 left.write(
d->data(),
d->size());
862 right.write(
d->data(),
d->size());
881 src->serialize(&wstream,
nullptr);
929 const char* str0 =
"rect-with-url";
934 const char* str1 =
"named-destination";
939 const char* str2 =
"link-to-destination";
961 int32_t storage[
kSize/4];
975 writer.reset(storage,
kSize-4);
991 const auto&
run =
builder.allocRun(
font, glyph_count, 1.2f, 2.3f);
993 std::fill(
run.glyphs,
run.glyphs + glyph_count, 0);
997 size_t blob_size = 0u;
998 size_t storage_size = 0u;
1000 blob_size =
SkAlign4(blob->serialize(procs)->size());
1002 storage_size = blob_size - 4;
1003 storage.
realloc(storage_size);
1005 storage_size = blob_size;
1006 storage.
realloc(storage_size);
1013 size_t path_size =
SkAlign4(path_effect->serialize()->size());
1017 size_t storage_size = path_size - 4;
1018 storage.
realloc(storage_size);
1021 storage_size = path_size;
1022 storage.
realloc(storage_size);
1030 writer.writeInt(321);
1032 size_t size = writer.bytesWritten();
1034 writer.writeToMemory(storage.
get());
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
sk_bzero(glyphs, sizeof(glyphs))
std::unique_ptr< SkStreamAsset > GetResourceAsStream(const char *resource, bool useFileStream)
static void TestObjectSerializationNoAlign(T *testObj, skiatest::Reporter *reporter)
static void TestPictureTypefaceSerialization(const SkSerialProcs *serial_procs, const SkDeserialProcs *deserial_procs, skiatest::Reporter *reporter)
static sk_sp< SkPicture > copy_picture_via_serialization(SkPicture *src)
static void setup_bitmap_for_canvas(SkBitmap *bitmap)
static sk_sp< SkTypeface > makeDistortableWithNonDefaultAxes(skiatest::Reporter *reporter)
static void compare_bitmaps(skiatest::Reporter *reporter, const SkBitmap &b1, const SkBitmap &b2)
SkString DumpFontMetrics(const SkFontMetrics &metrics)
static void TestArraySerialization(T *data, skiatest::Reporter *reporter)
static sk_sp< SkImage > make_checkerboard_image()
static void serialize_and_compare_typeface(sk_sp< SkTypeface > typeface, const char *text, const SkSerialProcs *serial_procs, const SkDeserialProcs *deserial_procs, skiatest::Reporter *reporter)
static const int kBitmapSize
static void TestTypefaceSerialization(skiatest::Reporter *reporter, const sk_sp< SkTypeface > &typeface)
static void TestObjectSerialization(T *testObj, skiatest::Reporter *reporter)
static SkBitmap draw_picture(SkPicture &picture)
SkString DumpTypeface(const SkTypeface &typeface)
DEF_TEST(Serialization_Typeface, reporter)
static const uint32_t kArraySize
static void TestBitmapSerialization(const SkBitmap &validBitmap, const SkBitmap &invalidBitmap, bool shouldSucceed, skiatest::Reporter *reporter)
static sk_sp< SkTypeface > makeColrWithNonDefaultPalette(skiatest::Reporter *reporter)
static sk_sp< SkTypeface > deserialize_typeface_proc(const void *data, size_t length, void *ctx)
static sk_sp< SkImage > render(const SkPicture &p)
static void TestColorFilterSerialization(skiatest::Reporter *reporter)
static sk_sp< SkData > serialize_typeface_proc(SkTypeface *typeface, void *ctx)
static void draw_something(SkCanvas *canvas)
static T * TestFlattenableSerialization(T *testObj, bool shouldSucceed, skiatest::Reporter *reporter)
static constexpr T SkAlign4(T x)
SK_API void SkAnnotateRectWithURL(SkCanvas *, const SkRect &, SkData *)
SK_API void SkAnnotateNamedDestination(SkCanvas *, const SkPoint &, SkData *)
SK_API void SkAnnotateLinkToDestination(SkCanvas *, const SkRect &, SkData *)
@ kSrcOver
r = s + (1-sa)*d
static SkColorFilterBase * as_CFB(SkColorFilter *filter)
constexpr SkColor SK_ColorGRAY
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
static bool ok(int result)
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
#define SkScalarRoundToInt(x)
#define SkScalarCeilToInt(x)
static void copy(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
static constexpr SkFourByteTag SkSetFourByteTag(char a, char b, char c, char d)
#define REPORTER_ASSERT(r, cond,...)
#define INFOF(REPORTER,...)
#define REPORT_FAILURE(reporter, cond, message)
static void TestAlignment(T *testObj, skiatest::Reporter *reporter)
static const char * Define_Named_Dest_Key()
static const char * Link_Named_Dest_Key()
static const char * URL_Key()
void writeByteArray(const void *data, size_t size) override
void writeUInt(uint32_t value) override
void writeInt(int32_t value) override
sk_sp< SkImage > asImage() const
SkColor getColor(int x, int y) const
bool setInfo(const SkImageInfo &imageInfo, size_t rowBytes=0)
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void translate(SkScalar dx, SkScalar dy)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
void clear(SkColor color)
void scale(SkScalar sx, SkScalar sy)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
void drawPicture(const SkPicture *picture)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
static sk_sp< SkColorFilter > Table(const uint8_t table[256])
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
static sk_sp< SkData > MakeWithCString(const char cstr[])
static sk_sp< SkData > MakeEmpty()
std::unique_ptr< SkStreamAsset > detachAsStream()
sk_sp< SkTypeface > makeFromStream(std::unique_ptr< SkStreamAsset >, int ttcIndex=0) const
SkScalar getMetrics(SkFontMetrics *metrics) const
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
static sk_sp< SkImageFilter > Blend(SkBlendMode mode, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground=nullptr, const CropRect &cropRect={})
static const SkMatrix & I()
void setColor(SkColor color)
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
sk_sp< SkData > serialize(const SkSerialProcs *procs=nullptr) const
static sk_sp< SkPicture > MakeFromData(const SkData *data, const SkDeserialProcs *procs=nullptr)
static sk_sp< SkPicture > MakeFromStream(SkStream *stream, const SkDeserialProcs *procs=nullptr)
void setRectRadii(const SkRect &rect, const SkVector radii[4])
bool readColor4fArray(SkColor4f *colors, size_t size)
const void * skipByteArray(size_t *size)
void readMatrix(SkMatrix *matrix)
SkFlattenable * readFlattenable(SkFlattenable::Type)
bool readByteArray(void *value, size_t size)
bool readIntArray(int32_t *values, size_t size)
const void * skip(size_t size)
sk_sp< SkData > readByteArrayAsData()
bool readPointArray(SkPoint *points, size_t size)
void readString(SkString *string)
bool readColorArray(SkColor *colors, size_t size)
bool readScalarArray(SkScalar *values, size_t size)
void readPoint3(SkPoint3 *point)
void readRegion(SkRegion *region)
void readPath(SkPath *path)
const char * c_str() const
SkTypefaceID uniqueID() const
void getFamilyName(SkString *name) const
SkFontStyle fontStyle() const
void serialize(SkWStream *, SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
int getVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const
static sk_sp< SkTypeface > MakeDeserialize(SkStream *, sk_sp< SkFontMgr > lastResortMgr)
std::unique_ptr< SkStreamAsset > openStream(int *ttcIndex) const
virtual void writeScalarArray(const SkScalar *value, uint32_t count)=0
virtual void writeRegion(const SkRegion ®ion)=0
virtual void writePointArray(const SkPoint *point, uint32_t count)=0
virtual void writeColor4fArray(const SkColor4f *color, uint32_t count)=0
virtual void writeFlattenable(const SkFlattenable *flattenable)=0
virtual void writeMatrix(const SkMatrix &matrix)=0
virtual void writeByteArray(const void *data, size_t size)=0
virtual void writePoint3(const SkPoint3 &point)=0
virtual void writePath(const SkPath &path)=0
virtual void writeColorArray(const SkColor *color, uint32_t count)=0
virtual void writeIntArray(const int32_t *value, uint32_t count)=0
virtual void writeString(std::string_view value)=0
TestAnnotationCanvas(skiatest::Reporter *reporter, const AnnotationRec rec[], int count)
void onDrawAnnotation(const SkRect &rect, const char key[], SkData *value) override
~TestAnnotationCanvas() override
void realloc(size_t count)
const EmbeddedViewParams * params
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
unsigned useCenter Optional< SkMatrix > matrix
ClipOpAndAA opAA SkRegion region
sk_sp< const SkPicture > picture
sk_sp< SkBlender > blender SkRect rect
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
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
font
Font Metadata and Metrics.
const myers::Point & get(const myers::Segment &)
static void InvalidateData(unsigned char *data)
static void InvalidateData(unsigned char *data)
static void Write(SkWriteBuffer &writer, SkColor4f *data, uint32_t arraySize)
static bool Read(SkReadBuffer &reader, SkColor4f *data, uint32_t arraySize)
static void Write(SkWriteBuffer &writer, SkColor *data, uint32_t arraySize)
static bool Read(SkReadBuffer &reader, SkColor *data, uint32_t arraySize)
static void Read(SkReadBuffer &reader, SkMatrix *matrix)
static void Write(SkWriteBuffer &writer, const SkMatrix *matrix)
static void Write(SkWriteBuffer &writer, const SkPath *path)
static void Read(SkReadBuffer &reader, SkPath *path)
static void Write(SkWriteBuffer &writer, const SkPoint3 *data)
static void Read(SkReadBuffer &reader, SkPoint3 *data)
static bool Read(SkReadBuffer &reader, SkPoint *data, uint32_t arraySize)
static void Write(SkWriteBuffer &writer, SkPoint *data, uint32_t arraySize)
static void Write(SkWriteBuffer &writer, const SkRegion *region)
static void Read(SkReadBuffer &reader, SkRegion *region)
static void Write(SkWriteBuffer &writer, SkScalar *data, uint32_t arraySize)
static bool Read(SkReadBuffer &reader, SkScalar *data, uint32_t arraySize)
static void Read(SkReadBuffer &reader, SkString *string)
static void Write(SkWriteBuffer &writer, const SkString *string)
static bool Read(SkReadBuffer &reader, int32_t *data, uint32_t arraySize)
static void Write(SkWriteBuffer &writer, int32_t *data, uint32_t arraySize)
static void Write(SkWriteBuffer &writer, unsigned char *data, uint32_t arraySize)
static bool Read(SkReadBuffer &reader, unsigned char *data, uint32_t arraySize)
static void Read(SkReadBuffer &reader, T **flattenable)
static void Write(SkWriteBuffer &writer, const T *flattenable)
SkDeserialTypefaceProc fTypefaceProc
SkScalar fTop
greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable ...
SkScalar fLeading
distance to add between lines, typically positive or zero
SkScalar fAvgCharWidth
average character width, zero if unknown
SkScalar fStrikeoutPosition
distance from baseline to bottom of stroke, typically negative
SkScalar fStrikeoutThickness
strikeout thickness
SkScalar fMaxCharWidth
maximum character width, zero if unknown
SkScalar fBottom
greatest extent below origin of any glyph bounding box, typically positive; deprecated with variable ...
uint32_t fFlags
FontMetricsFlags indicating which metrics are valid.
SkScalar fAscent
distance to reserve above baseline, typically negative
SkScalar fXHeight
height of lower-case 'x', zero if unknown, typically negative
SkScalar fUnderlineThickness
underline thickness
@ kStrikeoutPositionIsValid_Flag
set if fStrikeoutPosition is valid
@ kStrikeoutThicknessIsValid_Flag
set if fStrikeoutThickness is valid
@ kUnderlinePositionIsValid_Flag
set if fUnderlinePosition is valid
@ kUnderlineThicknessIsValid_Flag
set if fUnderlineThickness is valid
@ kBoundsInvalid_Flag
set if fTop, fBottom, fXMin, fXMax invalid
SkScalar fDescent
distance to reserve below baseline, typically positive
SkScalar fCapHeight
height of an upper-case letter, zero if unknown, typically negative
SkScalar fXMin
greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with vari...
SkScalar fUnderlinePosition
distance from baseline to top of stroke, typically positive
SkScalar fXMax
greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with var...
constexpr int32_t height() const
constexpr int32_t width() const
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
static SkImageInfo MakeN32Premul(int width, int height)
constexpr float x() const
constexpr float y() const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeWH(float w, float h)
SkSerialImageProc fImageProc
SkSerialTypefaceProc fTypefaceProc
std::shared_ptr< const fml::Mapping > data