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" |
15 | 16 |
16 class SkMatrix; | 17 class SkMatrix; |
17 class SkPDFArray; | 18 class SkPDFArray; |
18 struct SkRect; | 19 struct SkRect; |
19 | 20 |
20 #if 0 | 21 #if 0 |
21 #define PRINT_NOT_IMPL(str) fprintf(stderr, str) | 22 #define PRINT_NOT_IMPL(str) fprintf(stderr, str) |
22 #else | 23 #else |
23 #define PRINT_NOT_IMPL(str) | 24 #define PRINT_NOT_IMPL(str) |
24 #endif | 25 #endif |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 result[3] = gHex[0xF & (value )]; | 86 result[3] = gHex[0xF & (value )]; |
86 wStream->write(result, 4); | 87 wStream->write(result, 4); |
87 } | 88 } |
88 inline void WriteUInt8(SkDynamicMemoryWStream* wStream, uint8_t value) { | 89 inline void WriteUInt8(SkDynamicMemoryWStream* wStream, uint8_t value) { |
89 static const char gHex[] = "0123456789ABCDEF"; | 90 static const char gHex[] = "0123456789ABCDEF"; |
90 char result[2]; | 91 char result[2]; |
91 result[0] = gHex[value >> 4 ]; | 92 result[0] = gHex[value >> 4 ]; |
92 result[1] = gHex[0xF & value]; | 93 result[1] = gHex[0xF & value]; |
93 wStream->write(result, 2); | 94 wStream->write(result, 2); |
94 } | 95 } |
95 | 96 inline void WriteUTF16beHex(SkDynamicMemoryWStream* wStream, SkUnichar utf32) { |
| 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 } |
96 } // namespace SkPDFUtils | 105 } // namespace SkPDFUtils |
97 | 106 |
98 #endif | 107 #endif |
OLD | NEW |