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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 SkAutoTUnref<SkPDFArray> patternBBoxArray(new SkPDFArray); | 834 SkAutoTUnref<SkPDFArray> patternBBoxArray(new SkPDFArray); |
834 patternBBoxArray->reserve(4); | 835 patternBBoxArray->reserve(4); |
835 patternBBoxArray->appendScalar(patternBBox.fLeft); | 836 patternBBoxArray->appendScalar(patternBBox.fLeft); |
836 patternBBoxArray->appendScalar(patternBBox.fTop); | 837 patternBBoxArray->appendScalar(patternBBox.fTop); |
837 patternBBoxArray->appendScalar(patternBBox.fRight); | 838 patternBBoxArray->appendScalar(patternBBox.fRight); |
838 patternBBoxArray->appendScalar(patternBBox.fBottom); | 839 patternBBoxArray->appendScalar(patternBBox.fBottom); |
839 | 840 |
840 // Put the canvas into the pattern stream (fContent). | 841 // Put the canvas into the pattern stream (fContent). |
841 SkAutoTUnref<SkStream> content(pattern.content()); | 842 SkAutoTUnref<SkStream> content(pattern.content()); |
842 setData(content.get()); | 843 setData(content.get()); |
843 pattern.getResources(fResources, &fResources, false); | 844 SkPDFResourceDict* resourceDict = pattern.getResourceDict(); |
| 845 resourceDict->getReferencedResources(fResources, &fResources, false); |
844 | 846 |
845 insertName("Type", "Pattern"); | 847 insertName("Type", "Pattern"); |
846 insertInt("PatternType", 1); | 848 insertInt("PatternType", 1); |
847 insertInt("PaintType", 1); | 849 insertInt("PaintType", 1); |
848 insertInt("TilingType", 1); | 850 insertInt("TilingType", 1); |
849 insert("BBox", patternBBoxArray.get()); | 851 insert("BBox", patternBBoxArray.get()); |
850 insertScalar("XStep", patternBBox.width()); | 852 insertScalar("XStep", patternBBox.width()); |
851 insertScalar("YStep", patternBBox.height()); | 853 insertScalar("YStep", patternBBox.height()); |
852 insert("Resources", pattern.getResourceDict()); | 854 insert("Resources", resourceDict); |
853 insert("Matrix", SkPDFUtils::MatrixToArray(finalMatrix))->unref(); | 855 insert("Matrix", SkPDFUtils::MatrixToArray(finalMatrix))->unref(); |
854 | 856 |
855 fState.get()->fImage.unlockPixels(); | 857 fState.get()->fImage.unlockPixels(); |
856 } | 858 } |
857 | 859 |
858 SkPDFStream* SkPDFFunctionShader::makePSFunction(const SkString& psCode, | 860 SkPDFStream* SkPDFFunctionShader::makePSFunction(const SkString& psCode, |
859 SkPDFArray* domain) { | 861 SkPDFArray* domain) { |
860 SkAutoDataUnref funcData(SkData::NewWithCopy(psCode.c_str(), | 862 SkAutoDataUnref funcData(SkData::NewWithCopy(psCode.c_str(), |
861 psCode.size())); | 863 psCode.size())); |
862 SkPDFStream* result = new SkPDFStream(funcData.get()); | 864 SkPDFStream* result = new SkPDFStream(funcData.get()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 fPixelGeneration = fImage.getGenerationID(); | 959 fPixelGeneration = fImage.getGenerationID(); |
958 } else { | 960 } else { |
959 fColorData.set(sk_malloc_throw( | 961 fColorData.set(sk_malloc_throw( |
960 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); | 962 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); |
961 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); | 963 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); |
962 fInfo.fColorOffsets = | 964 fInfo.fColorOffsets = |
963 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); | 965 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); |
964 shader.asAGradient(&fInfo); | 966 shader.asAGradient(&fInfo); |
965 } | 967 } |
966 } | 968 } |
OLD | NEW |