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

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) 15:28:18 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
Index: src/pdf/SkPDFCanon.cpp
diff --git a/src/pdf/SkPDFCanon.cpp b/src/pdf/SkPDFCanon.cpp
index eda255051ad66d54d6d733bfd8cae03356b2c38a..bca803844e0e6fde0e4e70062f55e24fb9cf6129 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,8 @@ void SkPDFCanon::reset() {
fAlphaShaderRecords.reset();
fImageShaderRecords.unrefAll();
fImageShaderRecords.reset();
- fGraphicStateRecords.unrefAll();
+ fGraphicStateRecords.foreach (
+ [](Wrap<SkPDFGraphicState> ptr) { ptr.fPtr->unref(); });
fGraphicStateRecords.reset();
fBitmapRecords.unrefAll();
fBitmapRecords.reset();
@@ -107,12 +107,17 @@ void SkPDFCanon::addImageShader(SkPDFImageShader* pdfShader) {
////////////////////////////////////////////////////////////////////////////////
-SkPDFGraphicState* SkPDFCanon::findGraphicState(const SkPaint& paint) const {
- return find_item(fGraphicStateRecords, paint);
+SkPDFGraphicState* SkPDFCanon::findGraphicState(SkPDFGraphicState& key) const {
+ const Wrap<SkPDFGraphicState>* ptr =
+ fGraphicStateRecords.find(Wrap<SkPDFGraphicState>(&key));
+ return ptr ? ptr->fPtr : NULL;
mtklein 2015/04/01 20:05:39 It does not seem safe to return a non-const pointe
}
void SkPDFCanon::addGraphicState(SkPDFGraphicState* state) {
- fGraphicStateRecords.push(SkRef(state));
+ SkASSERT(state);
+ Wrap<SkPDFGraphicState> w(SkRef(state));
+ SkASSERT(!fGraphicStateRecords.contains(w));
+ fGraphicStateRecords.add(w);
}
////////////////////////////////////////////////////////////////////////////////
« src/pdf/SkPDFCanon.h ('K') | « src/pdf/SkPDFCanon.h ('k') | src/pdf/SkPDFDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698