OLD | NEW |
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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 get_pdf_shader_by_state(canon, dpi, &opaqueState)); | 615 get_pdf_shader_by_state(canon, dpi, &opaqueState)); |
616 if (!colorShader) { | 616 if (!colorShader) { |
617 return nullptr; | 617 return nullptr; |
618 } | 618 } |
619 | 619 |
620 // Create resource dict with alpha graphics state as G0 and | 620 // Create resource dict with alpha graphics state as G0 and |
621 // pattern shader as P0, then write content stream. | 621 // pattern shader as P0, then write content stream. |
622 auto alphaGs = create_smask_graphic_state(canon, dpi, state); | 622 auto alphaGs = create_smask_graphic_state(canon, dpi, state); |
623 | 623 |
624 SkPDFAlphaFunctionShader* alphaFunctionShader = | 624 SkPDFAlphaFunctionShader* alphaFunctionShader = |
625 new SkPDFAlphaFunctionShader(autoState->detach()); | 625 new SkPDFAlphaFunctionShader(autoState->release()); |
626 | 626 |
627 auto resourceDict = | 627 auto resourceDict = |
628 get_gradient_resource_dict(colorShader.get(), alphaGs.get()); | 628 get_gradient_resource_dict(colorShader.get(), alphaGs.get()); |
629 | 629 |
630 SkAutoTDelete<SkStream> colorStream( | 630 SkAutoTDelete<SkStream> colorStream( |
631 create_pattern_fill_content(0, bbox)); | 631 create_pattern_fill_content(0, bbox)); |
632 alphaFunctionShader->setData(colorStream.get()); | 632 alphaFunctionShader->setData(colorStream.get()); |
633 | 633 |
634 populate_tiling_pattern_dict(alphaFunctionShader, bbox, resourceDict.get(), | 634 populate_tiling_pattern_dict(alphaFunctionShader, bbox, resourceDict.get(), |
635 SkMatrix::I()); | 635 SkMatrix::I()); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 pdfShader->insertObject("Domain", sk_ref_sp(domain.get())); | 802 pdfShader->insertObject("Domain", sk_ref_sp(domain.get())); |
803 | 803 |
804 // Call canon->makeRangeObject() instead of | 804 // Call canon->makeRangeObject() instead of |
805 // SkPDFShader::MakeRangeObject() so that the canon can | 805 // SkPDFShader::MakeRangeObject() so that the canon can |
806 // deduplicate. | 806 // deduplicate. |
807 auto function = make_ps_function(functionCode, domain.get(), | 807 auto function = make_ps_function(functionCode, domain.get(), |
808 canon->makeRangeObject()); | 808 canon->makeRangeObject()); |
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->release())); |
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)); |
816 pdfFunctionShader->insertObject("Shading", std::move(pdfShader)); | 816 pdfFunctionShader->insertObject("Shading", std::move(pdfShader)); |
817 | 817 |
818 canon->addFunctionShader(pdfFunctionShader.get()); | 818 canon->addFunctionShader(pdfFunctionShader.get()); |
819 return pdfFunctionShader.release(); | 819 return pdfFunctionShader.release(); |
820 } | 820 } |
821 | 821 |
822 SkPDFImageShader* SkPDFImageShader::Create( | 822 SkPDFImageShader* SkPDFImageShader::Create( |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 bottomMatrix.postTranslate(2 * width, 0); | 1014 bottomMatrix.postTranslate(2 * width, 0); |
1015 drawBitmapMatrix(&canvas, bottom, bottomMatrix); | 1015 drawBitmapMatrix(&canvas, bottom, bottomMatrix); |
1016 } | 1016 } |
1017 patternBBox.fBottom = deviceBounds.height(); | 1017 patternBBox.fBottom = deviceBounds.height(); |
1018 } | 1018 } |
1019 } | 1019 } |
1020 | 1020 |
1021 // Put the canvas into the pattern stream (fContent). | 1021 // Put the canvas into the pattern stream (fContent). |
1022 auto content = patternDevice->content(); | 1022 auto content = patternDevice->content(); |
1023 | 1023 |
1024 SkPDFImageShader* imageShader = new SkPDFImageShader(autoState->detach()); | 1024 SkPDFImageShader* imageShader = new SkPDFImageShader(autoState->release()); |
1025 imageShader->setData(content.get()); | 1025 imageShader->setData(content.get()); |
1026 | 1026 |
1027 auto resourceDict = patternDevice->makeResourceDict(); | 1027 auto resourceDict = patternDevice->makeResourceDict(); |
1028 populate_tiling_pattern_dict(imageShader, patternBBox, | 1028 populate_tiling_pattern_dict(imageShader, patternBBox, |
1029 resourceDict.get(), finalMatrix); | 1029 resourceDict.get(), finalMatrix); |
1030 | 1030 |
1031 imageShader->fShaderState->fImage.unlockPixels(); | 1031 imageShader->fShaderState->fImage.unlockPixels(); |
1032 | 1032 |
1033 canon->addImageShader(imageShader); | 1033 canon->addImageShader(imageShader); |
1034 return imageShader; | 1034 return imageShader; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |