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

Unified Diff: src/pdf/SkPDFCanon.cpp

Issue 1046293002: SkPDF: SkPDFGraphicState Lookup hashtabled (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-04-01 (Wednesday) 16:16:21 EDT Created 5 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
« no previous file with comments | « src/pdf/SkPDFCanon.h ('k') | src/pdf/SkPDFDevice.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFCanon.cpp
diff --git a/src/pdf/SkPDFCanon.cpp b/src/pdf/SkPDFCanon.cpp
index eda255051ad66d54d6d733bfd8cae03356b2c38a..b6187cbb3335bde106f42f32f2192c6959b5f884 100644
--- a/src/pdf/SkPDFCanon.cpp
+++ b/src/pdf/SkPDFCanon.cpp
@@ -8,7 +8,6 @@
#include "SkPDFBitmap.h"
#include "SkPDFCanon.h"
#include "SkPDFFont.h"
-#include "SkPDFGraphicState.h"
#include "SkPDFShader.h"
////////////////////////////////////////////////////////////////////////////////
@@ -24,7 +23,7 @@ void SkPDFCanon::reset() {
fAlphaShaderRecords.reset();
fImageShaderRecords.unrefAll();
fImageShaderRecords.reset();
- fGraphicStateRecords.unrefAll();
+ fGraphicStateRecords.foreach ([](WrapGS w) { w.fPtr->unref(); });
fGraphicStateRecords.reset();
fBitmapRecords.unrefAll();
fBitmapRecords.reset();
@@ -107,12 +106,17 @@ void SkPDFCanon::addImageShader(SkPDFImageShader* pdfShader) {
////////////////////////////////////////////////////////////////////////////////
-SkPDFGraphicState* SkPDFCanon::findGraphicState(const SkPaint& paint) const {
- return find_item(fGraphicStateRecords, paint);
+const SkPDFGraphicState* SkPDFCanon::findGraphicState(
+ const SkPDFGraphicState& key) const {
+ const WrapGS* ptr = fGraphicStateRecords.find(WrapGS(&key));
+ return ptr ? ptr->fPtr : NULL;
}
-void SkPDFCanon::addGraphicState(SkPDFGraphicState* state) {
- fGraphicStateRecords.push(SkRef(state));
+void SkPDFCanon::addGraphicState(const SkPDFGraphicState* state) {
+ SkASSERT(state);
+ WrapGS w(SkRef(state));
+ SkASSERT(!fGraphicStateRecords.contains(w));
+ fGraphicStateRecords.add(w);
}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/pdf/SkPDFCanon.h ('k') | src/pdf/SkPDFDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698