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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "SkTextFormatParams.h" | 32 #include "SkTextFormatParams.h" |
33 #include "SkTemplates.h" | 33 #include "SkTemplates.h" |
34 #include "SkTypefacePriv.h" | 34 #include "SkTypefacePriv.h" |
35 | 35 |
36 #define DPI_FOR_RASTER_SCALE_ONE 72 | 36 #define DPI_FOR_RASTER_SCALE_ONE 72 |
37 | 37 |
38 // Utility functions | 38 // Utility functions |
39 | 39 |
40 static void emit_pdf_color(SkColor color, SkWStream* result) { | 40 static void emit_pdf_color(SkColor color, SkWStream* result) { |
41 SkASSERT(SkColorGetA(color) == 0xFF); // We handle alpha elsewhere. | 41 SkASSERT(SkColorGetA(color) == 0xFF); // We handle alpha elsewhere. |
42 SkScalar colorScale = SkScalarInvert(0xFF); | 42 SkScalar colorMax = SkIntToScalar(0xFF); |
43 SkPDFUtils::AppendScalar(SkColorGetR(color) * colorScale, result); | 43 SkPDFUtils::AppendScalar( |
| 44 SkScalarDiv(SkIntToScalar(SkColorGetR(color)), colorMax), result); |
44 result->writeText(" "); | 45 result->writeText(" "); |
45 SkPDFUtils::AppendScalar(SkColorGetG(color) * colorScale, result); | 46 SkPDFUtils::AppendScalar( |
| 47 SkScalarDiv(SkIntToScalar(SkColorGetG(color)), colorMax), result); |
46 result->writeText(" "); | 48 result->writeText(" "); |
47 SkPDFUtils::AppendScalar(SkColorGetB(color) * colorScale, result); | 49 SkPDFUtils::AppendScalar( |
| 50 SkScalarDiv(SkIntToScalar(SkColorGetB(color)), colorMax), result); |
48 result->writeText(" "); | 51 result->writeText(" "); |
49 } | 52 } |
50 | 53 |
51 static SkPaint calculate_text_paint(const SkPaint& paint) { | 54 static SkPaint calculate_text_paint(const SkPaint& paint) { |
52 SkPaint result = paint; | 55 SkPaint result = paint; |
53 if (result.isFakeBoldText()) { | 56 if (result.isFakeBoldText()) { |
54 SkScalar fakeBoldScale = SkScalarInterpFunc(result.getTextSize(), | 57 SkScalar fakeBoldScale = SkScalarInterpFunc(result.getTextSize(), |
55 kStdFakeBoldInterpKeys, | 58 kStdFakeBoldInterpKeys, |
56 kStdFakeBoldInterpValues, | 59 kStdFakeBoldInterpValues, |
57 kStdFakeBoldInterpLength); | 60 kStdFakeBoldInterpLength); |
(...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2141 return; | 2144 return; |
2142 } | 2145 } |
2143 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); | 2146 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); |
2144 if (!image) { | 2147 if (!image) { |
2145 return; | 2148 return; |
2146 } | 2149 } |
2147 | 2150 |
2148 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), | 2151 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), |
2149 &content.entry()->fContent); | 2152 &content.entry()->fContent); |
2150 } | 2153 } |
OLD | NEW |