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 | 8 |
9 #ifndef SkPDFUtils_DEFINED | 9 #ifndef SkPDFUtils_DEFINED |
10 #define SkPDFUtils_DEFINED | 10 #define SkPDFUtils_DEFINED |
11 | 11 |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 #include "SkPath.h" | 13 #include "SkPath.h" |
14 #include "SkStream.h" | 14 #include "SkStream.h" |
15 #include "SkUtils.h" | |
16 | 15 |
17 class SkMatrix; | 16 class SkMatrix; |
18 class SkPDFArray; | 17 class SkPDFArray; |
19 struct SkRect; | 18 struct SkRect; |
20 | 19 |
21 #if 0 | 20 #if 0 |
22 #define PRINT_NOT_IMPL(str) fprintf(stderr, str) | 21 #define PRINT_NOT_IMPL(str) fprintf(stderr, str) |
23 #else | 22 #else |
24 #define PRINT_NOT_IMPL(str) | 23 #define PRINT_NOT_IMPL(str) |
25 #endif | 24 #endif |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 result[3] = gHex[0xF & (value )]; | 85 result[3] = gHex[0xF & (value )]; |
87 wStream->write(result, 4); | 86 wStream->write(result, 4); |
88 } | 87 } |
89 inline void WriteUInt8(SkDynamicMemoryWStream* wStream, uint8_t value) { | 88 inline void WriteUInt8(SkDynamicMemoryWStream* wStream, uint8_t value) { |
90 static const char gHex[] = "0123456789ABCDEF"; | 89 static const char gHex[] = "0123456789ABCDEF"; |
91 char result[2]; | 90 char result[2]; |
92 result[0] = gHex[value >> 4 ]; | 91 result[0] = gHex[value >> 4 ]; |
93 result[1] = gHex[0xF & value]; | 92 result[1] = gHex[0xF & value]; |
94 wStream->write(result, 2); | 93 wStream->write(result, 2); |
95 } | 94 } |
96 inline void WriteUTF16beHex(SkDynamicMemoryWStream* wStream, SkUnichar utf32) { | 95 |
97 uint16_t utf16[2] = {0, 0}; | |
98 size_t len = SkUTF16_FromUnichar(utf32, utf16); | |
99 SkASSERT(len == 1 || len == 2); | |
100 SkPDFUtils::WriteUInt16BE(wStream, utf16[0]); | |
101 if (len == 2) { | |
102 SkPDFUtils::WriteUInt16BE(wStream, utf16[1]); | |
103 } | |
104 } | |
105 } // namespace SkPDFUtils | 96 } // namespace SkPDFUtils |
106 | 97 |
107 #endif | 98 #endif |
OLD | NEW |