40 case Type::kByteStringSkS:
41 case Type::kTextStringSkS:
56 case Type::kDestroyed:
59 case Type::kColorComponent:
66 case Type::kColorComponentF:
71 case Type::kByteString:
72 case Type::kTextString:
76 case Type::kByteStringSkS:
77 case Type::kTextStringSkS:
81 new (&
fObject) PDFObject(std::move(that.fObject));
84 SkDEBUGFAIL(
"SkPDFUnion::SkPDFUnion with bad type");
86 that.fType = Type::kDestroyed;
98 return Type::kName == fType || Type::kNameSkS == fType;
104 static const char kControlChars[] =
"/%()<>[]{}";
106 if (*n < '!' || *n >
'~' || strchr(kControlChars, *n)) {
117 static const char kToEscape[] =
"#/%()<>[]{}";
118 for (
const uint8_t* n =
reinterpret_cast<const uint8_t*
>(
name); *n; ++n) {
120 if (v < '!' || v >
'~' || strchr(kToEscape, v)) {
133 for (
size_t i = 0;
i <
len;
i++) {
134 uint8_t c =
static_cast<uint8_t
>(cin[
i]);
135 if (c <
' ' ||
'~' < c) {
136 uint8_t octal[4] = {
'\\',
137 (uint8_t)(
'0' | ( c >> 6 )),
138 (uint8_t)(
'0' | ((c >> 3) & 0x07)),
139 (uint8_t)(
'0' | ( c & 0x07)) };
140 wStream->
write(octal, 4);
142 if (c ==
'\\' || c ==
'(' || c ==
')') {
145 wStream->
write(&c, 1);
156 for (
size_t i = 0;
i <
len;
i++) {
157 uint8_t c =
static_cast<uint8_t
>(cin[
i]);
160 wStream->
write(hexValue, 2);
166 size_t literalExtras) {
167 const size_t hexLength = 2 + 2*
len;
168 const size_t literalLength = 2 +
len + literalExtras;
169 if (literalLength <= hexLength) {
180 size_t literalExtras = 0;
182 for (
size_t i = 0;
i <
len;
i++) {
183 uint8_t c =
static_cast<uint8_t
>(cin[
i]);
184 if (c <
' ' ||
'~' < c) {
186 }
else if (c ==
'\\' || c ==
'(' || c ==
')') {
198 bool inputIsValidUTF8 =
true;
199 bool inputIsPDFDocEncoding =
true;
200 size_t literalExtras = 0;
202 const char* textPtr = cin;
203 const char* textEnd = cin +
len;
204 while (textPtr < textEnd) {
207 inputIsValidUTF8 =
false;
212 if ((0x15 < unichar && unichar < 0x20) || 0x7E < unichar) {
213 inputIsPDFDocEncoding =
false;
216 if (unichar <
' ' ||
'~' < unichar) {
218 }
else if (unichar ==
'\\' || unichar ==
'(' || unichar ==
')') {
224 if (!inputIsValidUTF8) {
230 if (inputIsPDFDocEncoding) {
236 const char* textPtr = cin;
237 const char* textEnd = cin +
len;
238 while (textPtr < textEnd) {
257 case Type::kColorComponent:
260 case Type::kColorComponentF:
274 case Type::kByteString:
278 case Type::kTextString:
286 case Type::kByteStringSkS:
289 case Type::kTextStringSkS:
298 stream->writeText(
" 0 R");
301 SkDEBUGFAIL(
"SkPDFUnion::emitObject with bad type");
346 return SkPDFUnion(Type::kByteStringSkS, std::move(
s));
350 return SkPDFUnion(Type::kTextStringSkS, std::move(
s));
355 return SkPDFUnion(Type::kObject, std::move(objSp));
367 fValue.emitObject(
stream);
385 for (
size_t i = 0;
i < fValues.size();
i++) {
387 if (
i + 1 < fValues.size()) {
395 fValues.emplace_back(std::move(
value));
458 for (
size_t i = 0;
i < fRecords.size(); ++
i) {
459 const std::pair<SkPDFUnion, SkPDFUnion>& record = fRecords[
i];
460 record.first.emitObject(
stream);
462 record.second.emitObject(
stream);
463 if (
i + 1 < fRecords.size()) {
552 std::unique_ptr<SkStreamAsset> tmp;
554 SkPDFDict& dict = origDict ? *origDict : tmpDict;
555 static const size_t kMinimumSavings = strlen(
"/Filter_/FlateDecode_");
558 stream->getLength() > kMinimumSavings)
564 #ifdef SK_PDF_BASE85_BINARY
566 SkPDFUtils::Base85Encode(compressedData.
detachAsStream(), &compressedData);
570 filters->appendName(
"ASCII85Decode");
571 filters->appendName(
"FlateDecode");
592 std::unique_ptr<SkStreamAsset>
content,
602 executor->add([dictPtr, contentPtr, compress, doc, ref]() {
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
static bool is_valid_name(const SkString &name)
#define SkDEBUGFAIL(message)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static void write_byte_string(SkWStream *wStream, const char *cin, size_t len)
static void write_optimized_byte_string(SkWStream *wStream, const char *cin, size_t len, size_t literalExtras)
static void write_name_escaped(SkWStream *o, const char *name)
void SkPDFWriteByteString(SkWStream *wStream, const char *cin, size_t len)
static void write_hex_byte_string(SkWStream *wStream, const char *cin, size_t len)
static void write_literal_byte_string(SkWStream *wStream, const char *cin, size_t len)
static void write_text_string(SkWStream *wStream, const char *cin, size_t len)
void SkPDFWriteTextString(SkWStream *wStream, const char *cin, size_t len)
static void serialize_stream(SkPDFDict *origDict, SkStreamAsset *stream, SkPDFSteamCompressionEnabled compress, SkPDFDocument *doc, SkPDFIndirectReference ref)
SkPDFIndirectReference SkPDFStreamOut(std::unique_ptr< SkPDFDict > dict, std::unique_ptr< SkStreamAsset > content, SkPDFDocument *doc, SkPDFSteamCompressionEnabled compress)
static std::unique_ptr< SkPDFArray > SkPDFMakeArray(Args... args)
SkPDFSteamCompressionEnabled
bool SkStreamCopy(SkWStream *out, SkStream *input)
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
constexpr int32_t SkToS32(S x)
constexpr int SkToInt(S x)
constexpr uint8_t SkToU8(S x)
size_t bytesWritten() const override
std::unique_ptr< SkStreamAsset > detachAsStream()
void appendRef(SkPDFIndirectReference)
void appendTextString(const char[])
void appendByteString(const char[])
void appendObject(std::unique_ptr< SkPDFObject > &&)
void appendColorComponent(uint8_t)
void appendName(const char[])
void appendScalar(SkScalar)
void emitObject(SkWStream *stream) const override
void insertName(const char key[], const char nameValue[])
void insertObject(const char key[], std::unique_ptr< SkPDFObject > &&)
void insertColorComponentF(const char key[], SkScalar value)
void insertUnion(const char key[], SkPDFUnion &&)
void insertInt(const char key[], int32_t value)
void insertTextString(const char key[], const char value[])
void insertRef(const char key[], SkPDFIndirectReference)
void insertScalar(const char key[], SkScalar value)
void insertByteString(const char key[], const char value[])
void emitObject(SkWStream *stream) const override
void insertBool(const char key[], bool value)
SkPDFDict(const char type[]=nullptr)
SkExecutor * executor() const
const SkPDF::Metadata & metadata() const
void emitStream(const SkPDFDict &dict, T writeStream, SkPDFIndirectReference ref)
SkPDFIndirectReference reserveRef()
static SkPDFUnion Ref(SkPDFIndirectReference)
static SkPDFUnion ColorComponentF(float)
SkPDFUnion(SkPDFUnion &&)
static SkPDFUnion Bool(bool)
static SkPDFUnion Int(int32_t)
static SkPDFUnion TextString(const char *)
void emitObject(SkWStream *) const
static SkPDFUnion ByteString(const char *)
static SkPDFUnion Object(std::unique_ptr< SkPDFObject >)
SkPDFUnion & operator=(SkPDFUnion &&)
static SkPDFUnion Name(const char *)
const char * fStaticString
static SkPDFUnion Scalar(SkScalar)
static SkPDFUnion ColorComponent(uint8_t)
const char * c_str() const
virtual bool write(const void *buffer, size_t size)=0
bool writeText(const char text[])
union flutter::testing::@2836::KeyboardChange::@76 content
void AppendColorComponent(uint8_t value, SkWStream *wStream)
void AppendScalar(SkScalar value, SkWStream *stream)
void AppendColorComponentF(float value, SkWStream *wStream)
void WriteUTF16beHex(SkWStream *wStream, SkUnichar utf32)
SK_SPI SkUnichar NextUTF8(const char **ptr, const char *end)
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