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

Unified Diff: src/pdf/SkPDFCanon.h

Issue 842253003: SkPDFCanon (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: did you mean struct here? Created 5 years, 11 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
« no previous file with comments | « gyp/pdf.gypi ('k') | src/pdf/SkPDFCanon.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFCanon.h
diff --git a/src/pdf/SkPDFCanon.h b/src/pdf/SkPDFCanon.h
new file mode 100644
index 0000000000000000000000000000000000000000..5a06a465dd1582eaa3b26b41b369540bd51cade1
--- /dev/null
+++ b/src/pdf/SkPDFCanon.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkPDFCanon_DEFINED
+#define SkPDFCanon_DEFINED
+
+#include "SkPDFShader.h"
+#include "SkThread.h"
+#include "SkTDArray.h"
+
+struct SkIRect;
+class SkMatrix;
+class SkPDFFont;
+class SkPDFGraphicState;
+class SkPaint;
+class SkShader;
+
+// This class's fields and methods will eventually become part of
+// SkPDFDocument/SkDocument_PDF. For now, it exists as a singleton to
+// preflight that transition. This replaces three global arrays in
+// SkPDFFont, SkPDFShader, and SkPDFGraphicsContext.
+//
+// IF YOU ARE LOOKING AT THIS API PLEASE DO NOT WRITE THE CHANGE
+// YOU ARE ABOUT TO WRITE WITHOUT TALKING TO HALCANARY@.
+//
+// Note that this class does not create, delete, reference or
+// dereference the SkPDFObject objects that it indexes. It is up to
+// the caller to manage the lifetime of these objects.
+class SkPDFCanon : SkNoncopyable {
+public:
+ SkPDFCanon();
+ ~SkPDFCanon();
+
+ static SkPDFCanon& GetCanon();
+
+ // This mutexes will be removed once this class is subsumed into
+ // SkPDFDocument.
+ static SkBaseMutex& GetFontMutex();
+ static SkBaseMutex& GetShaderMutex();
+ static SkBaseMutex& GetPaintMutex();
+
+ // Returns exact match if there is one. If not, it returns NULL.
+ // If there is no exact match, but there is a related font, we
+ // still return NULL, but also set *relatedFont.
+ SkPDFFont* findFont(uint32_t fontID,
+ uint16_t glyphID,
+ SkPDFFont** relatedFont) const;
+ void addFont(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID);
+ void removeFont(SkPDFFont*);
+
+ SkPDFShader* findShader(const SkPDFShader::State&) const;
+ void addShader(SkPDFShader*);
+ void removeShader(SkPDFShader*);
+
+ SkPDFGraphicState* findGraphicState(const SkPaint&) const;
+ void addGraphicState(SkPDFGraphicState*);
+ void removeGraphicState(SkPDFGraphicState*);
+
+private:
+ struct FontRec {
+ SkPDFFont* fFont;
+ uint32_t fFontID;
+ uint16_t fGlyphID;
+ };
+ SkTDArray<FontRec> fFontRecords;
+
+ SkTDArray<SkPDFShader*> fShaderRecords;
+
+ SkTDArray<SkPDFGraphicState*> fGraphicStateRecords;
+};
+#endif // SkPDFCanon_DEFINED
« no previous file with comments | « gyp/pdf.gypi ('k') | src/pdf/SkPDFCanon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698