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

Side by Side Diff: src/pdf/SkPDFDevice.cpp

Issue 2120533002: SkPDF: Fix encoding of unichr outside of basic plane (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « no previous file | src/pdf/SkPDFFont.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 #include "SkPDFDevice.h" 8 #include "SkPDFDevice.h"
9 9
10 #include "SkAnnotationKeys.h" 10 #include "SkAnnotationKeys.h"
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 // significant and should be encoded and not 1056 // significant and should be encoded and not
1057 // discarded. If true, the upper byte is encoded 1057 // discarded. If true, the upper byte is encoded
1058 // first. Otherwise, we assert the upper byte is 1058 // first. Otherwise, we assert the upper byte is
1059 // zero. 1059 // zero.
1060 static void write_wide_string(SkDynamicMemoryWStream* wStream, 1060 static void write_wide_string(SkDynamicMemoryWStream* wStream,
1061 const uint16_t* input, 1061 const uint16_t* input,
1062 size_t len, 1062 size_t len,
1063 bool wideChars) { 1063 bool wideChars) {
1064 if (wideChars) { 1064 if (wideChars) {
1065 SkASSERT(2 * len < 65535); 1065 SkASSERT(2 * len < 65535);
1066 static const char gHex[] = "0123456789ABCDEF";
1067 wStream->writeText("<"); 1066 wStream->writeText("<");
1068 for (size_t i = 0; i < len; i++) { 1067 for (size_t i = 0; i < len; i++) {
1069 char result[4]; // Big-endian 1068 SkPDFUtils::WriteUInt16BE(wStream, input[i]);
1070 result[0] = gHex[(input[i] >> 12) & 0xF];
1071 result[1] = gHex[(input[i] >> 8) & 0xF];
1072 result[2] = gHex[(input[i] >> 4) & 0xF];
1073 result[3] = gHex[(input[i]) & 0xF];
1074 wStream->write(result, 4);
1075 } 1069 }
1076 wStream->writeText(">"); 1070 wStream->writeText(">");
1077 } else { 1071 } else {
1078 SkASSERT(len <= 65535); 1072 SkASSERT(len <= 65535);
1079 SkAutoMalloc buffer(len); // Remove every other byte. 1073 SkAutoMalloc buffer(len); // Remove every other byte.
1080 uint8_t* ptr = (uint8_t*)buffer.get(); 1074 uint8_t* ptr = (uint8_t*)buffer.get();
1081 for (size_t i = 0; i < len; i++) { 1075 for (size_t i = 0; i < len; i++) {
1082 SkASSERT(0 == input[i] >> 8); 1076 SkASSERT(0 == input[i] >> 8);
1083 ptr[i] = static_cast<uint8_t>(input[i]); 1077 ptr[i] = static_cast<uint8_t>(input[i]);
1084 } 1078 }
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 if (!pdfimage) { 2122 if (!pdfimage) {
2129 return; 2123 return;
2130 } 2124 }
2131 fDocument->serialize(pdfimage); // serialize images early. 2125 fDocument->serialize(pdfimage); // serialize images early.
2132 fDocument->canon()->addPDFBitmap(key, pdfimage); 2126 fDocument->canon()->addPDFBitmap(key, pdfimage);
2133 } 2127 }
2134 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject> 2128 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject>
2135 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), 2129 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()),
2136 &content.entry()->fContent); 2130 &content.entry()->fContent);
2137 } 2131 }
OLDNEW
« no previous file with comments | « no previous file | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698