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" | |
13 #include "SkData.h" | 12 #include "SkData.h" |
14 #include "SkPDFCatalog.h" | 13 #include "SkPDFCatalog.h" |
15 #include "SkPDFDevice.h" | 14 #include "SkPDFDevice.h" |
16 #include "SkPDFFormXObject.h" | 15 #include "SkPDFFormXObject.h" |
17 #include "SkPDFGraphicState.h" | 16 #include "SkPDFGraphicState.h" |
18 #include "SkPDFResourceDict.h" | 17 #include "SkPDFResourceDict.h" |
19 #include "SkPDFUtils.h" | 18 #include "SkPDFUtils.h" |
20 #include "SkScalar.h" | 19 #include "SkScalar.h" |
21 #include "SkStream.h" | 20 #include "SkStream.h" |
22 #include "SkTemplates.h" | 21 #include "SkTemplates.h" |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 if (tileModes[0] != SkShader::kClamp_TileMode || | 862 if (tileModes[0] != SkShader::kClamp_TileMode || |
864 tileModes[1] != SkShader::kClamp_TileMode) { | 863 tileModes[1] != SkShader::kClamp_TileMode) { |
865 deviceBounds.join(bitmapBounds); | 864 deviceBounds.join(bitmapBounds); |
866 } | 865 } |
867 | 866 |
868 SkMatrix unflip; | 867 SkMatrix unflip; |
869 unflip.setTranslate(0, SkScalarRoundToScalar(deviceBounds.height())); | 868 unflip.setTranslate(0, SkScalarRoundToScalar(deviceBounds.height())); |
870 unflip.preScale(SK_Scalar1, -SK_Scalar1); | 869 unflip.preScale(SK_Scalar1, -SK_Scalar1); |
871 SkISize size = SkISize::Make(SkScalarRound(deviceBounds.width()), | 870 SkISize size = SkISize::Make(SkScalarRound(deviceBounds.width()), |
872 SkScalarRound(deviceBounds.height())); | 871 SkScalarRound(deviceBounds.height())); |
| 872 // TODO(edisonn): should we pass here the DCT encoder of the destination dev
ice? |
| 873 // TODO(edisonn): NYI Perspective, use SkPDFDeviceFlattener. |
873 SkPDFDevice pattern(size, size, unflip); | 874 SkPDFDevice pattern(size, size, unflip); |
874 SkCanvas canvas(&pattern); | 875 SkCanvas canvas(&pattern); |
875 | 876 |
876 SkRect patternBBox; | 877 SkRect patternBBox; |
877 image->getBounds(&patternBBox); | 878 image->getBounds(&patternBBox); |
878 | 879 |
879 // Translate the canvas so that the bitmap origin is at (0, 0). | 880 // Translate the canvas so that the bitmap origin is at (0, 0). |
880 canvas.translate(-deviceBounds.left(), -deviceBounds.top()); | 881 canvas.translate(-deviceBounds.left(), -deviceBounds.top()); |
881 patternBBox.offset(-deviceBounds.left(), -deviceBounds.top()); | 882 patternBBox.offset(-deviceBounds.left(), -deviceBounds.top()); |
882 // Undo the translation in the final matrix | 883 // Undo the translation in the final matrix |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 return false; | 1218 return false; |
1218 } | 1219 } |
1219 | 1220 |
1220 void SkPDFShader::State::AllocateGradientInfoStorage() { | 1221 void SkPDFShader::State::AllocateGradientInfoStorage() { |
1221 fColorData.set(sk_malloc_throw( | 1222 fColorData.set(sk_malloc_throw( |
1222 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); | 1223 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); |
1223 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); | 1224 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); |
1224 fInfo.fColorOffsets = | 1225 fInfo.fColorOffsets = |
1225 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); | 1226 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); |
1226 } | 1227 } |
OLD | NEW |