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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT 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/SkPDFResourceDict.cpp ('k') | src/pdf/SkPDFTypes.h » ('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"
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 511 }
512 } 512 }
513 513
514 // static 514 // static
515 SkPDFObject* SkPDFShader::GetPDFShader(SkPDFCanon* canon, 515 SkPDFObject* SkPDFShader::GetPDFShader(SkPDFCanon* canon,
516 SkScalar dpi, 516 SkScalar dpi,
517 const SkShader& shader, 517 const SkShader& shader,
518 const SkMatrix& matrix, 518 const SkMatrix& matrix,
519 const SkIRect& surfaceBBox, 519 const SkIRect& surfaceBBox,
520 SkScalar rasterScale) { 520 SkScalar rasterScale) {
521 SkAutoTDelete<SkPDFShader::State> state( 521 SkAutoTDelete<SkPDFShader::State> state(new State(shader, matrix, surfaceBBo x, rasterScale));
522 SkNEW_ARGS(State, (shader, matrix, surfaceBBox, rasterScale)));
523 return get_pdf_shader_by_state(canon, dpi, &state); 522 return get_pdf_shader_by_state(canon, dpi, &state);
524 } 523 }
525 524
526 static SkPDFDict* get_gradient_resource_dict( 525 static SkPDFDict* get_gradient_resource_dict(
527 SkPDFObject* functionShader, 526 SkPDFObject* functionShader,
528 SkPDFObject* gState) { 527 SkPDFObject* gState) {
529 SkTDArray<SkPDFObject*> patterns; 528 SkTDArray<SkPDFObject*> patterns;
530 if (functionShader) { 529 if (functionShader) {
531 patterns.push(functionShader); 530 patterns.push(functionShader);
532 } 531 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 if (!colorShader) { 617 if (!colorShader) {
619 return NULL; 618 return NULL;
620 } 619 }
621 620
622 // Create resource dict with alpha graphics state as G0 and 621 // Create resource dict with alpha graphics state as G0 and
623 // pattern shader as P0, then write content stream. 622 // pattern shader as P0, then write content stream.
624 SkAutoTUnref<SkPDFObject> alphaGs( 623 SkAutoTUnref<SkPDFObject> alphaGs(
625 create_smask_graphic_state(canon, dpi, state)); 624 create_smask_graphic_state(canon, dpi, state));
626 625
627 SkPDFAlphaFunctionShader* alphaFunctionShader = 626 SkPDFAlphaFunctionShader* alphaFunctionShader =
628 SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach())); 627 new SkPDFAlphaFunctionShader(autoState->detach());
629 628
630 SkAutoTUnref<SkPDFDict> resourceDict( 629 SkAutoTUnref<SkPDFDict> resourceDict(
631 get_gradient_resource_dict(colorShader.get(), alphaGs.get())); 630 get_gradient_resource_dict(colorShader.get(), alphaGs.get()));
632 631
633 SkAutoTDelete<SkStream> colorStream( 632 SkAutoTDelete<SkStream> colorStream(
634 create_pattern_fill_content(0, bbox)); 633 create_pattern_fill_content(0, bbox));
635 alphaFunctionShader->setData(colorStream.get()); 634 alphaFunctionShader->setData(colorStream.get());
636 635
637 populate_tiling_pattern_dict(alphaFunctionShader, bbox, resourceDict.get(), 636 populate_tiling_pattern_dict(alphaFunctionShader, bbox, resourceDict.get(),
638 SkMatrix::I()); 637 SkMatrix::I());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 namespace { 680 namespace {
682 SkPDFObject* create_range_object() { 681 SkPDFObject* create_range_object() {
683 SkPDFArray* range = SkNEW(SkPDFArray); 682 SkPDFArray* range = new SkPDFArray;
684 range->reserve(6); 683 range->reserve(6);
685 range->appendInt(0); 684 range->appendInt(0);
686 range->appendInt(1); 685 range->appendInt(1);
687 range->appendInt(0); 686 range->appendInt(0);
688 range->appendInt(1); 687 range->appendInt(1);
689 range->appendInt(0); 688 range->appendInt(0);
690 range->appendInt(1); 689 range->appendInt(1);
691 return range; 690 return range;
692 } 691 }
693 692
694 template <typename T> void unref(T* ptr) { ptr->unref();} 693 template <typename T> void unref(T* ptr) { ptr->unref();}
695 } // namespace 694 } // namespace
696 695
697 SK_DECLARE_STATIC_LAZY_PTR(SkPDFObject, rangeObject, 696 SK_DECLARE_STATIC_LAZY_PTR(SkPDFObject, rangeObject,
698 create_range_object, unref<SkPDFObject>); 697 create_range_object, unref<SkPDFObject>);
699 698
700 static SkPDFStream* make_ps_function(const SkString& psCode, 699 static SkPDFStream* make_ps_function(const SkString& psCode,
701 SkPDFArray* domain) { 700 SkPDFArray* domain) {
702 SkAutoDataUnref funcData( 701 SkAutoDataUnref funcData(
703 SkData::NewWithCopy(psCode.c_str(), psCode.size())); 702 SkData::NewWithCopy(psCode.c_str(), psCode.size()));
704 SkPDFStream* result = SkNEW_ARGS(SkPDFStream, (funcData.get())); 703 SkPDFStream* result = new SkPDFStream(funcData.get());
705 result->insertInt("FunctionType", 4); 704 result->insertInt("FunctionType", 4);
706 result->insertObject("Domain", SkRef(domain)); 705 result->insertObject("Domain", SkRef(domain));
707 result->insertObject("Range", SkRef(rangeObject.get())); 706 result->insertObject("Range", SkRef(rangeObject.get()));
708 return result; 707 return result;
709 } 708 }
710 709
711 SkPDFFunctionShader* SkPDFFunctionShader::Create( 710 SkPDFFunctionShader* SkPDFFunctionShader::Create(
712 SkPDFCanon* canon, SkAutoTDelete<SkPDFShader::State>* autoState) { 711 SkPDFCanon* canon, SkAutoTDelete<SkPDFShader::State>* autoState) {
713 const SkPDFShader::State& state = **autoState; 712 const SkPDFShader::State& state = **autoState;
714 713
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 806
808 SkAutoTUnref<SkPDFDict> pdfShader(new SkPDFDict); 807 SkAutoTUnref<SkPDFDict> pdfShader(new SkPDFDict);
809 pdfShader->insertInt("ShadingType", 1); 808 pdfShader->insertInt("ShadingType", 1);
810 pdfShader->insertName("ColorSpace", "DeviceRGB"); 809 pdfShader->insertName("ColorSpace", "DeviceRGB");
811 pdfShader->insertObject("Domain", SkRef(domain.get())); 810 pdfShader->insertObject("Domain", SkRef(domain.get()));
812 811
813 SkAutoTUnref<SkPDFStream> function( 812 SkAutoTUnref<SkPDFStream> function(
814 make_ps_function(functionCode, domain.get())); 813 make_ps_function(functionCode, domain.get()));
815 pdfShader->insertObjRef("Function", function.detach()); 814 pdfShader->insertObjRef("Function", function.detach());
816 815
817 SkPDFFunctionShader* pdfFunctionShader = 816 SkPDFFunctionShader* pdfFunctionShader = new SkPDFFunctionShader(autoState-> detach());
818 SkNEW_ARGS(SkPDFFunctionShader, (autoState->detach()));
819 817
820 pdfFunctionShader->insertInt("PatternType", 2); 818 pdfFunctionShader->insertInt("PatternType", 2);
821 pdfFunctionShader->insertObject("Matrix", 819 pdfFunctionShader->insertObject("Matrix",
822 SkPDFUtils::MatrixToArray(finalMatrix)); 820 SkPDFUtils::MatrixToArray(finalMatrix));
823 pdfFunctionShader->insertObject("Shading", pdfShader.detach()); 821 pdfFunctionShader->insertObject("Shading", pdfShader.detach());
824 822
825 canon->addFunctionShader(pdfFunctionShader); 823 canon->addFunctionShader(pdfFunctionShader);
826 return pdfFunctionShader; 824 return pdfFunctionShader;
827 } 825 }
828 826
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 bottomMatrix.postTranslate(2 * width, 0); 1019 bottomMatrix.postTranslate(2 * width, 0);
1022 drawBitmapMatrix(&canvas, bottom, bottomMatrix); 1020 drawBitmapMatrix(&canvas, bottom, bottomMatrix);
1023 } 1021 }
1024 patternBBox.fBottom = deviceBounds.height(); 1022 patternBBox.fBottom = deviceBounds.height();
1025 } 1023 }
1026 } 1024 }
1027 1025
1028 // Put the canvas into the pattern stream (fContent). 1026 // Put the canvas into the pattern stream (fContent).
1029 SkAutoTDelete<SkStreamAsset> content(patternDevice->content()); 1027 SkAutoTDelete<SkStreamAsset> content(patternDevice->content());
1030 1028
1031 SkPDFImageShader* imageShader = 1029 SkPDFImageShader* imageShader = new SkPDFImageShader(autoState->detach());
1032 SkNEW_ARGS(SkPDFImageShader, (autoState->detach()));
1033 imageShader->setData(content.get()); 1030 imageShader->setData(content.get());
1034 1031
1035 SkAutoTUnref<SkPDFDict> resourceDict( 1032 SkAutoTUnref<SkPDFDict> resourceDict(
1036 patternDevice->createResourceDict()); 1033 patternDevice->createResourceDict());
1037 populate_tiling_pattern_dict(imageShader, patternBBox, 1034 populate_tiling_pattern_dict(imageShader, patternBBox,
1038 resourceDict.get(), finalMatrix); 1035 resourceDict.get(), finalMatrix);
1039 1036
1040 imageShader->fShaderState->fImage.unlockPixels(); 1037 imageShader->fShaderState->fImage.unlockPixels();
1041 1038
1042 canon->addImageShader(imageShader); 1039 canon->addImageShader(imageShader);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 return false; 1229 return false;
1233 } 1230 }
1234 1231
1235 void SkPDFShader::State::AllocateGradientInfoStorage() { 1232 void SkPDFShader::State::AllocateGradientInfoStorage() {
1236 fColorData.set(sk_malloc_throw( 1233 fColorData.set(sk_malloc_throw(
1237 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); 1234 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar))));
1238 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); 1235 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get());
1239 fInfo.fColorOffsets = 1236 fInfo.fColorOffsets =
1240 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); 1237 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount);
1241 } 1238 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFResourceDict.cpp ('k') | src/pdf/SkPDFTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698