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 colorMax = SkIntToScalar(0xFF); | 42 SkScalar colorScale = SkScalarInvert(0xFF); |
43 SkPDFUtils::AppendScalar( | 43 SkPDFUtils::AppendScalar(SkColorGetR(color) * colorScale, result); |
44 SkScalarDiv(SkIntToScalar(SkColorGetR(color)), colorMax), result); | |
45 result->writeText(" "); | 44 result->writeText(" "); |
46 SkPDFUtils::AppendScalar( | 45 SkPDFUtils::AppendScalar(SkColorGetG(color) * colorScale, result); |
47 SkScalarDiv(SkIntToScalar(SkColorGetG(color)), colorMax), result); | |
48 result->writeText(" "); | 46 result->writeText(" "); |
49 SkPDFUtils::AppendScalar( | 47 SkPDFUtils::AppendScalar(SkColorGetB(color) * colorScale, result); |
50 SkScalarDiv(SkIntToScalar(SkColorGetB(color)), colorMax), result); | |
51 result->writeText(" "); | 48 result->writeText(" "); |
52 } | 49 } |
53 | 50 |
54 static SkPaint calculate_text_paint(const SkPaint& paint) { | 51 static SkPaint calculate_text_paint(const SkPaint& paint) { |
55 SkPaint result = paint; | 52 SkPaint result = paint; |
56 if (result.isFakeBoldText()) { | 53 if (result.isFakeBoldText()) { |
57 SkScalar fakeBoldScale = SkScalarInterpFunc(result.getTextSize(), | 54 SkScalar fakeBoldScale = SkScalarInterpFunc(result.getTextSize(), |
58 kStdFakeBoldInterpKeys, | 55 kStdFakeBoldInterpKeys, |
59 kStdFakeBoldInterpValues, | 56 kStdFakeBoldInterpValues, |
60 kStdFakeBoldInterpLength); | 57 kStdFakeBoldInterpLength); |
(...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2144 return; | 2141 return; |
2145 } | 2142 } |
2146 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); | 2143 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); |
2147 if (!image) { | 2144 if (!image) { |
2148 return; | 2145 return; |
2149 } | 2146 } |
2150 | 2147 |
2151 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), | 2148 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), |
2152 &content.entry()->fContent); | 2149 &content.entry()->fContent); |
2153 } | 2150 } |
OLD | NEW |