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 1777923002: SkPDF: use sk_ref_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFResourceDict.cpp ('k') | no next file » | 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"
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 const int kColoredTilingPattern_PaintType = 1; 545 const int kColoredTilingPattern_PaintType = 1;
546 const int kConstantSpacing_TilingType = 1; 546 const int kConstantSpacing_TilingType = 1;
547 547
548 pattern->insertName("Type", "Pattern"); 548 pattern->insertName("Type", "Pattern");
549 pattern->insertInt("PatternType", kTiling_PatternType); 549 pattern->insertInt("PatternType", kTiling_PatternType);
550 pattern->insertInt("PaintType", kColoredTilingPattern_PaintType); 550 pattern->insertInt("PaintType", kColoredTilingPattern_PaintType);
551 pattern->insertInt("TilingType", kConstantSpacing_TilingType); 551 pattern->insertInt("TilingType", kConstantSpacing_TilingType);
552 pattern->insertObject("BBox", SkPDFUtils::RectToArray(bbox)); 552 pattern->insertObject("BBox", SkPDFUtils::RectToArray(bbox));
553 pattern->insertScalar("XStep", bbox.width()); 553 pattern->insertScalar("XStep", bbox.width());
554 pattern->insertScalar("YStep", bbox.height()); 554 pattern->insertScalar("YStep", bbox.height());
555 pattern->insertObject("Resources", sk_sp<SkPDFDict>(SkRef(resources))); 555 pattern->insertObject("Resources", sk_ref_sp(resources));
556 if (!matrix.isIdentity()) { 556 if (!matrix.isIdentity()) {
557 pattern->insertObject("Matrix", SkPDFUtils::MatrixToArray(matrix)); 557 pattern->insertObject("Matrix", SkPDFUtils::MatrixToArray(matrix));
558 } 558 }
559 } 559 }
560 560
561 /** 561 /**
562 * Creates a content stream which fills the pattern P0 across bounds. 562 * Creates a content stream which fills the pattern P0 across bounds.
563 * @param gsIndex A graphics state resource index to apply, or <0 if no 563 * @param gsIndex A graphics state resource index to apply, or <0 if no
564 * graphics state to apply. 564 * graphics state to apply.
565 */ 565 */
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 return range; 690 return range;
691 } 691 }
692 SK_DECLARE_STATIC_ONCE_PTR(SkPDFObject, rangeObject); 692 SK_DECLARE_STATIC_ONCE_PTR(SkPDFObject, rangeObject);
693 693
694 static SkPDFStream* make_ps_function(const SkString& psCode, 694 static SkPDFStream* make_ps_function(const SkString& psCode,
695 SkPDFArray* domain) { 695 SkPDFArray* domain) {
696 SkAutoDataUnref funcData( 696 SkAutoDataUnref funcData(
697 SkData::NewWithCopy(psCode.c_str(), psCode.size())); 697 SkData::NewWithCopy(psCode.c_str(), psCode.size()));
698 SkPDFStream* result = new SkPDFStream(funcData.get()); 698 SkPDFStream* result = new SkPDFStream(funcData.get());
699 result->insertInt("FunctionType", 4); 699 result->insertInt("FunctionType", 4);
700 result->insertObject("Domain", sk_sp<SkPDFObject>(SkRef(domain))); 700 result->insertObject("Domain", sk_ref_sp(domain));
701 result->insertObject("Range", sk_sp<SkPDFObject>(SkRef(rangeObject.get(creat e_range_object)))); 701 result->insertObject("Range", sk_ref_sp(rangeObject.get(create_range_object) ));
702 return result; 702 return result;
703 } 703 }
704 704
705 SkPDFFunctionShader* SkPDFFunctionShader::Create( 705 SkPDFFunctionShader* SkPDFFunctionShader::Create(
706 SkPDFCanon* canon, SkAutoTDelete<SkPDFShader::State>* autoState) { 706 SkPDFCanon* canon, SkAutoTDelete<SkPDFShader::State>* autoState) {
707 const SkPDFShader::State& state = **autoState; 707 const SkPDFShader::State& state = **autoState;
708 708
709 SkString (*codeFunction)(const SkShader::GradientInfo& info, 709 SkString (*codeFunction)(const SkShader::GradientInfo& info,
710 const SkMatrix& perspectiveRemover) = nullptr; 710 const SkMatrix& perspectiveRemover) = nullptr;
711 SkPoint transformPoints[2]; 711 SkPoint transformPoints[2];
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 twoPointRadialInfo.fRadius[1] = 795 twoPointRadialInfo.fRadius[1] =
796 inverseMapperMatrix.mapRadius(info->fRadius[1]); 796 inverseMapperMatrix.mapRadius(info->fRadius[1]);
797 functionCode = codeFunction(twoPointRadialInfo, perspectiveInverseOnly); 797 functionCode = codeFunction(twoPointRadialInfo, perspectiveInverseOnly);
798 } else { 798 } else {
799 functionCode = codeFunction(*info, perspectiveInverseOnly); 799 functionCode = codeFunction(*info, perspectiveInverseOnly);
800 } 800 }
801 801
802 auto pdfShader = sk_make_sp<SkPDFDict>(); 802 auto pdfShader = sk_make_sp<SkPDFDict>();
803 pdfShader->insertInt("ShadingType", 1); 803 pdfShader->insertInt("ShadingType", 1);
804 pdfShader->insertName("ColorSpace", "DeviceRGB"); 804 pdfShader->insertName("ColorSpace", "DeviceRGB");
805 pdfShader->insertObject("Domain", sk_sp<SkPDFObject>(SkRef(domain.get()))); 805 pdfShader->insertObject("Domain", sk_ref_sp(domain.get()));
806 806
807 sk_sp<SkPDFStream> function( 807 sk_sp<SkPDFStream> function(
808 make_ps_function(functionCode, domain.get())); 808 make_ps_function(functionCode, domain.get()));
809 pdfShader->insertObjRef("Function", std::move(function)); 809 pdfShader->insertObjRef("Function", std::move(function));
810 810
811 sk_sp<SkPDFFunctionShader> pdfFunctionShader( 811 sk_sp<SkPDFFunctionShader> pdfFunctionShader(
812 new SkPDFFunctionShader(autoState->detach())); 812 new SkPDFFunctionShader(autoState->detach()));
813 pdfFunctionShader->insertInt("PatternType", 2); 813 pdfFunctionShader->insertInt("PatternType", 2);
814 pdfFunctionShader->insertObject("Matrix", 814 pdfFunctionShader->insertObject("Matrix",
815 SkPDFUtils::MatrixToArray(finalMatrix)); 815 SkPDFUtils::MatrixToArray(finalMatrix));
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 return false; 1223 return false;
1224 } 1224 }
1225 1225
1226 void SkPDFShader::State::AllocateGradientInfoStorage() { 1226 void SkPDFShader::State::AllocateGradientInfoStorage() {
1227 fColorData.set(sk_malloc_throw( 1227 fColorData.set(sk_malloc_throw(
1228 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); 1228 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar))));
1229 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); 1229 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get());
1230 fInfo.fColorOffsets = 1230 fInfo.fColorOffsets =
1231 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); 1231 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount);
1232 } 1232 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFResourceDict.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698