OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkPDFDevice.h" | 8 #include "SkPDFDevice.h" |
9 | 9 |
10 #include "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
11 #include "SkBitmapDevice.h" | 11 #include "SkBitmapDevice.h" |
12 #include "SkColor.h" | 12 #include "SkColor.h" |
13 #include "SkClipStack.h" | 13 #include "SkClipStack.h" |
14 #include "SkData.h" | 14 #include "SkData.h" |
15 #include "SkDraw.h" | 15 #include "SkDraw.h" |
16 #include "SkGlyphCache.h" | 16 #include "SkGlyphCache.h" |
17 #include "SkPaint.h" | 17 #include "SkPaint.h" |
18 #include "SkPath.h" | 18 #include "SkPath.h" |
19 #include "SkPathOps.h" | 19 #include "SkPathOps.h" |
20 #include "SkPDFBitmap.h" | |
21 #include "SkPDFFont.h" | 20 #include "SkPDFFont.h" |
22 #include "SkPDFFormXObject.h" | 21 #include "SkPDFFormXObject.h" |
23 #include "SkPDFGraphicState.h" | 22 #include "SkPDFGraphicState.h" |
| 23 #include "SkPDFImage.h" |
24 #include "SkPDFResourceDict.h" | 24 #include "SkPDFResourceDict.h" |
25 #include "SkPDFShader.h" | 25 #include "SkPDFShader.h" |
26 #include "SkPDFStream.h" | 26 #include "SkPDFStream.h" |
27 #include "SkPDFTypes.h" | 27 #include "SkPDFTypes.h" |
28 #include "SkPDFUtils.h" | 28 #include "SkPDFUtils.h" |
29 #include "SkRect.h" | 29 #include "SkRect.h" |
30 #include "SkRRect.h" | 30 #include "SkRRect.h" |
31 #include "SkString.h" | 31 #include "SkString.h" |
32 #include "SkSurface.h" | 32 #include "SkSurface.h" |
33 #include "SkTextFormatParams.h" | 33 #include "SkTextFormatParams.h" |
(...skipping 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2119 scaled.postScale(SkIntToScalar(subset.width()), | 2119 scaled.postScale(SkIntToScalar(subset.width()), |
2120 SkIntToScalar(subset.height())); | 2120 SkIntToScalar(subset.height())); |
2121 scaled.postConcat(matrix); | 2121 scaled.postConcat(matrix); |
2122 ScopedContentEntry content(this, clipStack, *clipRegion, scaled, paint); | 2122 ScopedContentEntry content(this, clipStack, *clipRegion, scaled, paint); |
2123 if (!content.entry() || (srcRect && !subset.intersect(*srcRect))) { | 2123 if (!content.entry() || (srcRect && !subset.intersect(*srcRect))) { |
2124 return; | 2124 return; |
2125 } | 2125 } |
2126 if (content.needShape()) { | 2126 if (content.needShape()) { |
2127 SkPath shape; | 2127 SkPath shape; |
2128 shape.addRect(SkRect::MakeWH(SkIntToScalar(subset.width()), | 2128 shape.addRect(SkRect::MakeWH(SkIntToScalar(subset.width()), |
2129 SkIntToScalar(subset.height()))); | 2129 SkIntToScalar( subset.height()))); |
2130 shape.transform(matrix); | 2130 shape.transform(matrix); |
2131 content.setShape(shape); | 2131 content.setShape(shape); |
2132 } | 2132 } |
2133 if (!content.needSource()) { | 2133 if (!content.needSource()) { |
2134 return; | 2134 return; |
2135 } | 2135 } |
2136 | 2136 |
2137 SkBitmap subsetBitmap; | 2137 SkAutoTUnref<SkPDFObject> image( |
2138 // Should extractSubset be done by the SkPDFDevice? | 2138 SkPDFCreateImageObject(fCanon, *bitmap, subset)); |
2139 if (!bitmap->extractSubset(&subsetBitmap, subset)) { | |
2140 return; | |
2141 } | |
2142 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); | |
2143 if (!image) { | 2139 if (!image) { |
2144 return; | 2140 return; |
2145 } | 2141 } |
2146 | 2142 |
2147 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), | 2143 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), |
2148 &content.entry()->fContent); | 2144 &content.entry()->fContent); |
2149 } | 2145 } |
OLD | NEW |