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" |
11 | 11 |
12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
13 #include "SkData.h" | 13 #include "SkData.h" |
14 #include "SkPDFCatalog.h" | 14 #include "SkPDFCatalog.h" |
15 #include "SkPDFDevice.h" | 15 #include "SkPDFDevice.h" |
16 #include "SkPDFTypes.h" | 16 #include "SkPDFTypes.h" |
17 #include "SkPDFResourceDict.h" | |
18 #include "SkPDFUtils.h" | 17 #include "SkPDFUtils.h" |
19 #include "SkScalar.h" | 18 #include "SkScalar.h" |
20 #include "SkStream.h" | 19 #include "SkStream.h" |
21 #include "SkTemplates.h" | 20 #include "SkTemplates.h" |
22 #include "SkThread.h" | 21 #include "SkThread.h" |
23 #include "SkTypes.h" | 22 #include "SkTypes.h" |
24 | 23 |
25 static bool transformBBox(const SkMatrix& matrix, SkRect* bbox) { | 24 static bool transformBBox(const SkMatrix& matrix, SkRect* bbox) { |
26 SkMatrix inverse; | 25 SkMatrix inverse; |
27 if (!matrix.invert(&inverse)) { | 26 if (!matrix.invert(&inverse)) { |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 SkAutoTUnref<SkPDFArray> patternBBoxArray(new SkPDFArray); | 831 SkAutoTUnref<SkPDFArray> patternBBoxArray(new SkPDFArray); |
833 patternBBoxArray->reserve(4); | 832 patternBBoxArray->reserve(4); |
834 patternBBoxArray->appendScalar(patternBBox.fLeft); | 833 patternBBoxArray->appendScalar(patternBBox.fLeft); |
835 patternBBoxArray->appendScalar(patternBBox.fTop); | 834 patternBBoxArray->appendScalar(patternBBox.fTop); |
836 patternBBoxArray->appendScalar(patternBBox.fRight); | 835 patternBBoxArray->appendScalar(patternBBox.fRight); |
837 patternBBoxArray->appendScalar(patternBBox.fBottom); | 836 patternBBoxArray->appendScalar(patternBBox.fBottom); |
838 | 837 |
839 // Put the canvas into the pattern stream (fContent). | 838 // Put the canvas into the pattern stream (fContent). |
840 SkAutoTUnref<SkStream> content(pattern.content()); | 839 SkAutoTUnref<SkStream> content(pattern.content()); |
841 setData(content.get()); | 840 setData(content.get()); |
842 SkPDFResourceDict* resourceDict = pattern.getResourceDict(); | 841 pattern.getResources(fResources, &fResources, false); |
843 resourceDict->getResources(fResources, &fResources, false); | |
844 | 842 |
845 insertName("Type", "Pattern"); | 843 insertName("Type", "Pattern"); |
846 insertInt("PatternType", 1); | 844 insertInt("PatternType", 1); |
847 insertInt("PaintType", 1); | 845 insertInt("PaintType", 1); |
848 insertInt("TilingType", 1); | 846 insertInt("TilingType", 1); |
849 insert("BBox", patternBBoxArray.get()); | 847 insert("BBox", patternBBoxArray.get()); |
850 insertScalar("XStep", patternBBox.width()); | 848 insertScalar("XStep", patternBBox.width()); |
851 insertScalar("YStep", patternBBox.height()); | 849 insertScalar("YStep", patternBBox.height()); |
852 insert("Resources", resourceDict); | 850 insert("Resources", pattern.getResourceDict()); |
853 insert("Matrix", SkPDFUtils::MatrixToArray(finalMatrix))->unref(); | 851 insert("Matrix", SkPDFUtils::MatrixToArray(finalMatrix))->unref(); |
854 | 852 |
855 fState.get()->fImage.unlockPixels(); | 853 fState.get()->fImage.unlockPixels(); |
856 } | 854 } |
857 | 855 |
858 SkPDFStream* SkPDFFunctionShader::makePSFunction(const SkString& psCode, | 856 SkPDFStream* SkPDFFunctionShader::makePSFunction(const SkString& psCode, |
859 SkPDFArray* domain) { | 857 SkPDFArray* domain) { |
860 SkAutoDataUnref funcData(SkData::NewWithCopy(psCode.c_str(), | 858 SkAutoDataUnref funcData(SkData::NewWithCopy(psCode.c_str(), |
861 psCode.size())); | 859 psCode.size())); |
862 SkPDFStream* result = new SkPDFStream(funcData.get()); | 860 SkPDFStream* result = new SkPDFStream(funcData.get()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 fPixelGeneration = fImage.getGenerationID(); | 955 fPixelGeneration = fImage.getGenerationID(); |
958 } else { | 956 } else { |
959 fColorData.set(sk_malloc_throw( | 957 fColorData.set(sk_malloc_throw( |
960 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); | 958 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); |
961 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); | 959 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); |
962 fInfo.fColorOffsets = | 960 fInfo.fColorOffsets = |
963 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); | 961 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); |
964 shader.asAGradient(&fInfo); | 962 shader.asAGradient(&fInfo); |
965 } | 963 } |
966 } | 964 } |
OLD | NEW |