Flutter Engine
The Flutter Engine
Functions | Variables
SkPDFResourceDict.cpp File Reference
#include "src/pdf/SkPDFResourceDict.h"
#include "include/core/SkStream.h"
#include "include/core/SkString.h"
#include "include/private/base/SkAssert.h"
#include "src/pdf/SkPDFTypes.h"
#include <cstddef>
#include <utility>

Go to the source code of this file.

Functions

static char * get_resource_name (char dst[kMaxResourceNameLength], SkPDFResourceType type, int key)
 
void SkPDFWriteResourceName (SkWStream *dst, SkPDFResourceType type, int key)
 
static const char * resource_name (SkPDFResourceType type)
 
static SkString resource (SkPDFResourceType type, int index)
 
static void add_subdict (const std::vector< SkPDFIndirectReference > &resourceList, SkPDFResourceType type, SkPDFDict *dst)
 
static std::unique_ptr< SkPDFArraymake_proc_set ()
 
std::unique_ptr< SkPDFDictSkPDFMakeResourceDict (const std::vector< SkPDFIndirectReference > &graphicStateResources, const std::vector< SkPDFIndirectReference > &shaderResources, const std::vector< SkPDFIndirectReference > &xObjectResources, const std::vector< SkPDFIndirectReference > &fontResources)
 

Variables

constexpr size_t kMaxResourceNameLength = 1 + kSkStrAppendS32_MaxSize
 

Function Documentation

◆ add_subdict()

static void add_subdict ( const std::vector< SkPDFIndirectReference > &  resourceList,
SkPDFResourceType  type,
SkPDFDict dst 
)
static

Definition at line 68 of file SkPDFResourceDict.cpp.

70 {
71 if (!resourceList.empty()) {
72 auto resources = SkPDFMakeDict();
73 for (SkPDFIndirectReference ref : resourceList) {
74 resources->insertRef(resource(type, ref.fValue), ref);
75 }
76 dst->insertObject(resource_name(type), std::move(resources));
77 }
78}
static SkString resource(SkPDFResourceType type, int index)
static const char * resource_name(SkPDFResourceType type)
static std::unique_ptr< SkPDFDict > SkPDFMakeDict(const char *type=nullptr)
Definition: SkPDFTypes.h:185
GLenum type
dst
Definition: cp.py:12

◆ get_resource_name()

static char * get_resource_name ( char  dst[kMaxResourceNameLength],
SkPDFResourceType  type,
int  key 
)
static

Definition at line 31 of file SkPDFResourceDict.cpp.

31 {
32 static const char kResourceTypePrefixes[] = {
33 'G', // kExtGState
34 'P', // kPattern
35 'X', // kXObject
36 'F' // kFont
37 };
38 SkASSERT((unsigned)type < std::size(kResourceTypePrefixes));
39 dst[0] = kResourceTypePrefixes[(unsigned)type];
40 return SkStrAppendS32(dst + 1, key);
41}
#define SkASSERT(cond)
Definition: SkAssert.h:116
char * SkStrAppendS32(char buffer[], int32_t)
Definition: SkString.cpp:120
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

◆ make_proc_set()

static std::unique_ptr< SkPDFArray > make_proc_set ( )
static

Definition at line 80 of file SkPDFResourceDict.cpp.

80 {
81 auto procSets = SkPDFMakeArray();
82 static const char kProcs[][7] = { "PDF", "Text", "ImageB", "ImageC", "ImageI"};
83 procSets->reserve(std::size(kProcs));
84 for (const char* proc : kProcs) {
85 procSets->appendName(proc);
86 }
87 return procSets;
88}
static std::unique_ptr< SkPDFArray > SkPDFMakeArray(Args... args)
Definition: SkPDFTypes.h:125

◆ resource()

static SkString resource ( SkPDFResourceType  type,
int  index 
)
static

Definition at line 62 of file SkPDFResourceDict.cpp.

62 {
64 char* end = get_resource_name(buffer, type, index);
65 return SkString(buffer, (size_t)(end - buffer));
66}
constexpr size_t kMaxResourceNameLength
static char * get_resource_name(char dst[kMaxResourceNameLength], SkPDFResourceType type, int key)
glong glong end
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
Definition: switches.h:126

◆ resource_name()

static const char * resource_name ( SkPDFResourceType  type)
static

Definition at line 51 of file SkPDFResourceDict.cpp.

51 {
52 static const char* kResourceTypeNames[] = {
53 "ExtGState",
54 "Pattern",
55 "XObject",
56 "Font"
57 };
58 SkASSERT((unsigned)type < std::size(kResourceTypeNames));
59 return kResourceTypeNames[(unsigned)type];
60}

◆ SkPDFMakeResourceDict()

std::unique_ptr< SkPDFDict > SkPDFMakeResourceDict ( const std::vector< SkPDFIndirectReference > &  graphicStateResources,
const std::vector< SkPDFIndirectReference > &  shaderResources,
const std::vector< SkPDFIndirectReference > &  xObjectResources,
const std::vector< SkPDFIndirectReference > &  fontResources 
)

Create a PDF resource dictionary. The full set of ProcSet entries is automatically created for backwards compatibility, as recommended by the PDF spec.

Any arguments can be nullptr.

Definition at line 90 of file SkPDFResourceDict.cpp.

94 {
95 auto dict = SkPDFMakeDict();
96 dict->insertObject("ProcSet", make_proc_set());
97 add_subdict(graphicStateResources, SkPDFResourceType::kExtGState, dict.get());
98 add_subdict(shaderResources, SkPDFResourceType::kPattern, dict.get());
99 add_subdict(xObjectResources, SkPDFResourceType::kXObject, dict.get());
100 add_subdict(fontResources, SkPDFResourceType::kFont, dict.get());
101 return dict;
102}
static void add_subdict(const std::vector< SkPDFIndirectReference > &resourceList, SkPDFResourceType type, SkPDFDict *dst)
static std::unique_ptr< SkPDFArray > make_proc_set()

◆ SkPDFWriteResourceName()

void SkPDFWriteResourceName ( SkWStream dst,
SkPDFResourceType  type,
int  key 
)

Writes the name for the resource that will be generated by the resource dict.

Parameters
typeThe type of resource being entered
keyThe resource key, should be unique within its type.

Definition at line 43 of file SkPDFResourceDict.cpp.

43 {
44 // One extra character for the leading '/'.
46 buffer[0] = '/';
47 char* end = get_resource_name(buffer + 1, type, key);
48 dst->write(buffer, (size_t)(end - buffer));
49}

Variable Documentation

◆ kMaxResourceNameLength

constexpr size_t kMaxResourceNameLength = 1 + kSkStrAppendS32_MaxSize
constexpr

Definition at line 28 of file SkPDFResourceDict.cpp.