Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Unified Diff: src/pdf/SkPDFDevice.h

Issue 1839633003: SkPDF: PDFDevice::ContentEntry now implemented with SinglyLinkedList (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-03-28 (Monday) 12:15:25 EDT Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/pdf/SkPDFDevice.h
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h
index d1afee218e7a7140940222b2ce8e5db5f2e61bd6..5fa26374a30bd68df60440c4ea5d33a22e7a7d21 100644
--- a/src/pdf/SkPDFDevice.h
+++ b/src/pdf/SkPDFDevice.h
@@ -23,6 +23,8 @@
#include "SkTDArray.h"
#include "SkTemplates.h"
+#include "SkSinglyLinkedList.h"
+
class SkPDFArray;
class SkPDFCanon;
class SkPDFDevice;
@@ -37,10 +39,6 @@ class SkPDFShader;
class SkPDFStream;
class SkRRect;
-// Private classes.
-struct ContentEntry;
-struct GraphicStateEntry;
-
/** \class SkPDFDevice
The drawing context for the PDF backend.
@@ -175,6 +173,38 @@ public:
SkPDFCanon* getCanon() const;
+ // It is important to not confuse GraphicStateEntry with SkPDFGraphicState, the
+ // later being our representation of an object in the PDF file.
+ struct GraphicStateEntry {
+ GraphicStateEntry();
+
+ // Compare the fields we care about when setting up a new content entry.
+ bool compareInitialState(const GraphicStateEntry& b);
+
+ SkMatrix fMatrix;
+ // We can't do set operations on Paths, though PDF natively supports
+ // intersect. If the clip stack does anything other than intersect,
+ // we have to fall back to the region. Treat fClipStack as authoritative.
+ // See https://bugs.skia.org/221
+ SkClipStack fClipStack;
+ SkRegion fClipRegion;
+
+ // When emitting the content entry, we will ensure the graphic state
+ // is set to these values first.
+ SkColor fColor;
+ SkScalar fTextScaleX; // Zero means we don't care what the value is.
+ SkPaint::Style fTextFill; // Only if TextScaleX is non-zero.
+ int fShaderIndex;
+ int fGraphicStateIndex;
+
+ // We may change the font (i.e. for Type1 support) within a
+ // ContentEntry. This is the one currently in effect, or nullptr if none.
+ SkPDFFont* fFont;
+ // In PDF, text size has no default value. It is only valid if fFont is
+ // not nullptr.
+ SkScalar fTextSize;
+ };
+
protected:
const SkBitmap& onAccessBitmap() override {
return fLegacyBitmap;
@@ -232,8 +262,11 @@ private:
SkTDArray<SkPDFFont*> fFontResources;
SkTDArray<SkPDFObject*> fShaderResources;
- std::unique_ptr<ContentEntry> fContentEntries;
- ContentEntry* fLastContentEntry;
+ struct ContentEntry {
+ GraphicStateEntry fState;
+ SkDynamicMemoryWStream fContent;
+ };
+ SkSinglyLinkedList<ContentEntry> fContentEntries;
const SkClipStack* fClipStack;

Powered by Google App Engine
This is Rietveld 408576698