Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/pdf/SkPDFUtils.h

Issue 2151863003: SkPdf: smaller color serialization (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkFixed - 2016-07-15 (Friday) 15:45:32 EDT Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFTypes.cpp ('k') | src/pdf/SkPDFUtils.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #ifndef SkPDFUtils_DEFINED 9 #ifndef SkPDFUtils_DEFINED
10 #define SkPDFUtils_DEFINED 10 #define SkPDFUtils_DEFINED
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 SkPDFUtils::EmitPath(path, paintStyle, true, content); 50 SkPDFUtils::EmitPath(path, paintStyle, true, content);
51 } 51 }
52 void ClosePath(SkWStream* content); 52 void ClosePath(SkWStream* content);
53 void PaintPath(SkPaint::Style style, SkPath::FillType fill, 53 void PaintPath(SkPaint::Style style, SkPath::FillType fill,
54 SkWStream* content); 54 SkWStream* content);
55 void StrokePath(SkWStream* content); 55 void StrokePath(SkWStream* content);
56 void DrawFormXObject(int objectIndex, SkWStream* content); 56 void DrawFormXObject(int objectIndex, SkWStream* content);
57 void ApplyGraphicState(int objectIndex, SkWStream* content); 57 void ApplyGraphicState(int objectIndex, SkWStream* content);
58 void ApplyPattern(int objectIndex, SkWStream* content); 58 void ApplyPattern(int objectIndex, SkWStream* content);
59 59
60 // Converts (value / 255.0) with three significant digits of accuracy.
61 // Writes value as string into result. Returns strlen() of result.
62 size_t ColorToDecimal(uint8_t value, char result[5]);
63 inline void AppendColorComponent(uint8_t value, SkWStream* wStream) {
64 char buffer[5];
65 size_t len = SkPDFUtils::ColorToDecimal(value, buffer);
66 wStream->write(buffer, len);
67 }
68
60 // 3 = '-', '.', and '\0' characters. 69 // 3 = '-', '.', and '\0' characters.
61 // 9 = number of significant digits 70 // 9 = number of significant digits
62 // abs(FLT_MIN_10_EXP) = number of zeros in FLT_MIN 71 // abs(FLT_MIN_10_EXP) = number of zeros in FLT_MIN
63 const size_t kMaximumFloatDecimalLength = 3 + 9 - FLT_MIN_10_EXP; 72 const size_t kMaximumFloatDecimalLength = 3 + 9 - FLT_MIN_10_EXP;
64 // FloatToDecimal is exposed for unit tests. 73 // FloatToDecimal is exposed for unit tests.
65 size_t FloatToDecimal(float value, 74 size_t FloatToDecimal(float value,
66 char output[kMaximumFloatDecimalLength]); 75 char output[kMaximumFloatDecimalLength]);
67 void AppendScalar(SkScalar value, SkWStream* stream); 76 void AppendScalar(SkScalar value, SkWStream* stream);
68 void WriteString(SkWStream* wStream, const char* input, size_t len); 77 void WriteString(SkWStream* wStream, const char* input, size_t len);
69 78
70 inline void WriteUInt16BE(SkDynamicMemoryWStream* wStream, uint16_t value) { 79 inline void WriteUInt16BE(SkDynamicMemoryWStream* wStream, uint16_t value) {
71 static const char gHex[] = "0123456789ABCDEF"; 80 static const char gHex[] = "0123456789ABCDEF";
72 char result[4]; 81 char result[4];
73 result[0] = gHex[ value >> 12 ]; 82 result[0] = gHex[ value >> 12 ];
74 result[1] = gHex[0xF & (value >> 8 )]; 83 result[1] = gHex[0xF & (value >> 8 )];
75 result[2] = gHex[0xF & (value >> 4 )]; 84 result[2] = gHex[0xF & (value >> 4 )];
76 result[3] = gHex[0xF & (value )]; 85 result[3] = gHex[0xF & (value )];
77 wStream->write(result, 4); 86 wStream->write(result, 4);
78 } 87 }
79 88
80 } // namespace SkPDFUtils 89 } // namespace SkPDFUtils
81 90
82 #endif 91 #endif
OLDNEW
« no previous file with comments | « src/pdf/SkPDFTypes.cpp ('k') | src/pdf/SkPDFUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698