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

Side by Side Diff: src/pdf/SkPDFShader.cpp

Issue 1334523002: Revert of Port uses of SkLazyPtr to SkOncePtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | src/utils/SkEventTracer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkPDFShader.h" 10 #include "SkPDFShader.h"
11 11
12 #include "SkData.h" 12 #include "SkData.h"
13 #include "SkOncePtr.h"
14 #include "SkPDFCanon.h" 13 #include "SkPDFCanon.h"
15 #include "SkPDFDevice.h" 14 #include "SkPDFDevice.h"
16 #include "SkPDFFormXObject.h" 15 #include "SkPDFFormXObject.h"
17 #include "SkPDFGraphicState.h" 16 #include "SkPDFGraphicState.h"
18 #include "SkPDFResourceDict.h" 17 #include "SkPDFResourceDict.h"
19 #include "SkPDFUtils.h" 18 #include "SkPDFUtils.h"
20 #include "SkScalar.h" 19 #include "SkScalar.h"
21 #include "SkStream.h" 20 #include "SkStream.h"
22 #include "SkTemplates.h" 21 #include "SkTemplates.h"
23 #include "SkTypes.h" 22 #include "SkTypes.h"
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 zero, one, zero, 670 zero, one, zero,
672 -p0/p2, -p1/p2, 1/p2); 671 -p0/p2, -p1/p2, 1/p2);
673 672
674 affine->setAll(sx - p0 * tx / p2, kx - p1 * tx / p2, tx / p2, 673 affine->setAll(sx - p0 * tx / p2, kx - p1 * tx / p2, tx / p2,
675 ky - p0 * ty / p2, sy - p1 * ty / p2, ty / p2, 674 ky - p0 * ty / p2, sy - p1 * ty / p2, ty / p2,
676 zero, zero, one); 675 zero, zero, one);
677 676
678 return true; 677 return true;
679 } 678 }
680 679
681 static SkPDFObject* create_range_object() { 680 namespace {
681 SkPDFObject* create_range_object() {
682 SkPDFArray* range = new SkPDFArray; 682 SkPDFArray* range = new SkPDFArray;
683 range->reserve(6); 683 range->reserve(6);
684 range->appendInt(0); 684 range->appendInt(0);
685 range->appendInt(1); 685 range->appendInt(1);
686 range->appendInt(0); 686 range->appendInt(0);
687 range->appendInt(1); 687 range->appendInt(1);
688 range->appendInt(0); 688 range->appendInt(0);
689 range->appendInt(1); 689 range->appendInt(1);
690 return range; 690 return range;
691 } 691 }
692 SK_DECLARE_STATIC_ONCE_PTR(SkPDFObject, rangeObject); 692
693 template <typename T> void unref(T* ptr) { ptr->unref();}
694 } // namespace
695
696 SK_DECLARE_STATIC_LAZY_PTR(SkPDFObject, rangeObject,
697 create_range_object, unref<SkPDFObject>);
693 698
694 static SkPDFStream* make_ps_function(const SkString& psCode, 699 static SkPDFStream* make_ps_function(const SkString& psCode,
695 SkPDFArray* domain) { 700 SkPDFArray* domain) {
696 SkAutoDataUnref funcData( 701 SkAutoDataUnref funcData(
697 SkData::NewWithCopy(psCode.c_str(), psCode.size())); 702 SkData::NewWithCopy(psCode.c_str(), psCode.size()));
698 SkPDFStream* result = new SkPDFStream(funcData.get()); 703 SkPDFStream* result = new SkPDFStream(funcData.get());
699 result->insertInt("FunctionType", 4); 704 result->insertInt("FunctionType", 4);
700 result->insertObject("Domain", SkRef(domain)); 705 result->insertObject("Domain", SkRef(domain));
701 result->insertObject("Range", SkRef(rangeObject.get(create_range_object))); 706 result->insertObject("Range", SkRef(rangeObject.get()));
702 return result; 707 return result;
703 } 708 }
704 709
705 SkPDFFunctionShader* SkPDFFunctionShader::Create( 710 SkPDFFunctionShader* SkPDFFunctionShader::Create(
706 SkPDFCanon* canon, SkAutoTDelete<SkPDFShader::State>* autoState) { 711 SkPDFCanon* canon, SkAutoTDelete<SkPDFShader::State>* autoState) {
707 const SkPDFShader::State& state = **autoState; 712 const SkPDFShader::State& state = **autoState;
708 713
709 SkString (*codeFunction)(const SkShader::GradientInfo& info, 714 SkString (*codeFunction)(const SkShader::GradientInfo& info,
710 const SkMatrix& perspectiveRemover) = nullptr; 715 const SkMatrix& perspectiveRemover) = nullptr;
711 SkPoint transformPoints[2]; 716 SkPoint transformPoints[2];
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 return false; 1229 return false;
1225 } 1230 }
1226 1231
1227 void SkPDFShader::State::AllocateGradientInfoStorage() { 1232 void SkPDFShader::State::AllocateGradientInfoStorage() {
1228 fColorData.set(sk_malloc_throw( 1233 fColorData.set(sk_malloc_throw(
1229 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); 1234 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar))));
1230 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); 1235 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get());
1231 fInfo.fColorOffsets = 1236 fInfo.fColorOffsets =
1232 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); 1237 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount);
1233 } 1238 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | src/utils/SkEventTracer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698