Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkPDFOffsetMap Class Reference

#include <SkPDFDocumentPriv.h>

Public Member Functions

void markStartOfDocument (const SkWStream *)
 
void markStartOfObject (int referenceNumber, const SkWStream *)
 
int objectCount () const
 
int emitCrossReferenceTable (SkWStream *s) const
 

Detailed Description

Definition at line 53 of file SkPDFDocumentPriv.h.

Member Function Documentation

◆ emitCrossReferenceTable()

int SkPDFOffsetMap::emitCrossReferenceTable ( SkWStream s) const

Definition at line 97 of file SkPDFDocument.cpp.

97 {
98 int xRefFileOffset = SkToInt(difference(s->bytesWritten(), fBaseOffset));
99 s->writeText("xref\n0 ");
100 s->writeDecAsText(this->objectCount());
101 s->writeText("\n0000000000 65535 f \n");
102 for (int offset : fOffsets) {
103 SkASSERT(offset > 0); // Offset was set.
104 s->writeBigDecAsText(offset, 10);
105 s->writeText(" 00000 n \n");
106 }
107 return xRefFileOffset;
108}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static size_t difference(size_t minuend, size_t subtrahend)
constexpr int SkToInt(S x)
Definition: SkTo.h:29
int objectCount() const
bool writeText(const char text[])
Definition: SkStream.h:247
struct MyStruct s
SeparatedVector2 offset

◆ markStartOfDocument()

void SkPDFOffsetMap::markStartOfDocument ( const SkWStream s)

Definition at line 78 of file SkPDFDocument.cpp.

78{ fBaseOffset = s->bytesWritten(); }

◆ markStartOfObject()

void SkPDFOffsetMap::markStartOfObject ( int  referenceNumber,
const SkWStream s 
)

Definition at line 84 of file SkPDFDocument.cpp.

84 {
85 SkASSERT(referenceNumber > 0);
86 size_t index = SkToSizeT(referenceNumber - 1);
87 if (index >= fOffsets.size()) {
88 fOffsets.resize(index + 1);
89 }
90 fOffsets[index] = SkToInt(difference(s->bytesWritten(), fBaseOffset));
91}
constexpr size_t SkToSizeT(S x)
Definition: SkTo.h:31

◆ objectCount()

int SkPDFOffsetMap::objectCount ( ) const

Definition at line 93 of file SkPDFDocument.cpp.

93 {
94 return SkToInt(fOffsets.size() + 1); // Include the special zeroth object in the count.
95}

The documentation for this class was generated from the following files: