diff options
author | Hal Canary <halcanary@google.com> | 2017-04-17 16:30:06 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-04 13:08:29 +0000 |
commit | 5c1b360a89f85accd7dc446670f6f062c73e7e77 (patch) | |
tree | a15f476b39778027f982d753719487bc4a6d34ca /src/pdf/SkPDFShader.cpp | |
parent | bc6e5ff7cfbacc28659c0aecbe9f2989cad80336 (diff) |
src/pdf: code cleanup
* SkPDFCanon: remove unnecessary abstraction
* Make use of SkTHashMap<K, sk_sp<T>>.
* Remove unncessary struct constructors.
* More factory fns return sk_sp<T>
* SkPDFUtility::GetCachedT<T> factored out.
Change-Id: I4055a131b43fe2588fd042b769cd09fff8a3466c
Reviewed-on: https://skia-review.googlesource.com/13655
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'src/pdf/SkPDFShader.cpp')
-rw-r--r-- | src/pdf/SkPDFShader.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp index 13a9ecd1d5..b6b096d22c 100644 --- a/src/pdf/SkPDFShader.cpp +++ b/src/pdf/SkPDFShader.cpp @@ -737,7 +737,7 @@ static bool split_perspective(const SkMatrix in, SkMatrix* affine, return true; } -sk_sp<SkPDFArray> SkPDFShader::MakeRangeObject() { +static sk_sp<SkPDFArray> make_range_object() { auto range = sk_make_sp<SkPDFArray>(); range->reserve(6); range->appendInt(0); @@ -933,14 +933,11 @@ static sk_sp<SkPDFDict> make_function_shader(SkPDFCanon* canon, pdfShader->insertObject("Domain", domain); - // Call canon->makeRangeObject() instead of - // SkPDFShader::MakeRangeObject() so that the canon can - // deduplicate. - std::unique_ptr<SkStreamAsset> functionStream( - functionCode.detachAsStream()); - sk_sp<SkPDFStream> function = make_ps_function(std::move(functionStream), - std::move(domain), - canon->makeRangeObject()); + std::unique_ptr<SkStreamAsset> functionStream(functionCode.detachAsStream()); + sk_sp<SkPDFArray> rangeObject = + SkPDFUtils::GetCachedT(&canon->fRangeObject, &make_range_object); + sk_sp<SkPDFStream> function = make_ps_function(std::move(functionStream), std::move(domain), + std::move(rangeObject)); pdfShader->insertObjRef("Function", std::move(function)); } |