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