From 94fd66cc2502383628b2c5fb72a445460b752c35 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Wed, 5 Jul 2017 11:25:42 -0400 Subject: SkPDF: Refactor PDFShader to use ShTHashMap<> my tests run ~14% faster. - Split out gradient shaders from image shaders. new compilation unit: SkPDFGradientShader - Common functions InverseTransformBBox and PopulateTilingPatternDict moved to SkPDFUtils - Split SkPDFShader::State into image and gradient structures. - SkPDFCanon is now a simpler structure, with no logic of its own. I am considering just moving all of its fields into SkPDFDocument - SkPDFShader::State (the image/fallback shader) now is POD, making the use of a hashmap for canonicalization straightforward. Formerly, we used a linear search. - Do not bother trying to canonicalize the falback image shader. - SkPDFGradientShader::Key is not POD; comparison of two objects requires looking at the contents of two variable-sized arrays. We now pre-calculate the hash of the arrays using SkOpts::hash and store a hash for the object in the fHash field. Using that hash, we can now canonicalize using a hashmap instead of a linar search! - several static functions renamed to follow style guidelines - stop using codeFunction function pointer; I find that less clear than it could be. - operator==() for SkPDFShader::State and SkPDFGradientShader::Key is now much simpler and can now be inlined. - SkArrayEqual template in SkPDFUtils.h No change to PDF output. BUG=skia:3585 Change-Id: I354ad1b600be6d6749abccb58d13db257370bc0b Reviewed-on: https://skia-review.googlesource.com/21376 Reviewed-by: Ben Wagner Commit-Queue: Hal Canary --- gn/pdf.gni | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gn/pdf.gni') diff --git a/gn/pdf.gni b/gn/pdf.gni index f7de23d613..6b140e0839 100644 --- a/gn/pdf.gni +++ b/gn/pdf.gni @@ -28,6 +28,8 @@ skia_pdf_sources = [ "$_src/pdf/SkPDFFont.h", "$_src/pdf/SkPDFFormXObject.cpp", "$_src/pdf/SkPDFFormXObject.h", + "$_src/pdf/SkPDFGradientShader.cpp", + "$_src/pdf/SkPDFGradientShader.h", "$_src/pdf/SkPDFGraphicState.cpp", "$_src/pdf/SkPDFGraphicState.h", "$_src/pdf/SkPDFMakeCIDGlyphWidthsArray.cpp", -- cgit v1.2.3