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

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

Issue 656143002: Const-correctness in PDF drawText() call (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 | no next file » | 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 "SkAnnotation.h" 10 #include "SkAnnotation.h"
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 const uint16_t* glyphIDs = NULL; 1117 const uint16_t* glyphIDs = NULL;
1118 int numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphIDs); 1118 int numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphIDs);
1119 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 1119 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
1120 1120
1121 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc(); 1121 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc();
1122 align_text(glyphCacheProc, textPaint, glyphIDs, numGlyphs, &x, &y); 1122 align_text(glyphCacheProc, textPaint, glyphIDs, numGlyphs, &x, &y);
1123 content.entry()->fContent.writeText("BT\n"); 1123 content.entry()->fContent.writeText("BT\n");
1124 set_text_transform(x, y, textPaint.getTextSkewX(), 1124 set_text_transform(x, y, textPaint.getTextSkewX(),
1125 &content.entry()->fContent); 1125 &content.entry()->fContent);
1126 int consumedGlyphCount = 0; 1126 int consumedGlyphCount = 0;
1127
1128 SkTDArray<uint16_t> glyphIDsCopy(glyphIDs, numGlyphs);
1129
1127 while (numGlyphs > consumedGlyphCount) { 1130 while (numGlyphs > consumedGlyphCount) {
1128 updateFont(textPaint, glyphIDs[consumedGlyphCount], content.entry()); 1131 updateFont(textPaint, glyphIDs[consumedGlyphCount], content.entry());
1129 SkPDFFont* font = content.entry()->fState.fFont; 1132 SkPDFFont* font = content.entry()->fState.fFont;
1130 //TODO: the const_cast here is a bug if the encoding started out as glyp h encoding. 1133
1131 int availableGlyphs = 1134 int availableGlyphs = font->glyphsToPDFFontEncoding(
1132 font->glyphsToPDFFontEncoding(const_cast<uint16_t*>(glyphIDs) + cons umedGlyphCount, 1135 glyphIDsCopy.begin() + consumedGlyphCount,
1133 numGlyphs - consumedGlyphCount); 1136 numGlyphs - consumedGlyphCount);
1134 fFontGlyphUsage->noteGlyphUsage(font, glyphIDs + consumedGlyphCount, 1137 fFontGlyphUsage->noteGlyphUsage(
1135 availableGlyphs); 1138 font, glyphIDsCopy.begin() + consumedGlyphCount,
1139 availableGlyphs);
1136 SkString encodedString = 1140 SkString encodedString =
1137 SkPDFString::FormatString(glyphIDs + consumedGlyphCount, 1141 SkPDFString::FormatString(glyphIDsCopy.begin() + consumedGlyphCount,
1138 availableGlyphs, font->multiByteGlyphs()); 1142 availableGlyphs, font->multiByteGlyphs());
1139 content.entry()->fContent.writeText(encodedString.c_str()); 1143 content.entry()->fContent.writeText(encodedString.c_str());
1140 consumedGlyphCount += availableGlyphs; 1144 consumedGlyphCount += availableGlyphs;
1141 content.entry()->fContent.writeText(" Tj\n"); 1145 content.entry()->fContent.writeText(" Tj\n");
1142 } 1146 }
1143 content.entry()->fContent.writeText("ET\n"); 1147 content.entry()->fContent.writeText("ET\n");
1144 } 1148 }
1145 1149
1146 void SkPDFDevice::drawPosText(const SkDraw& d, const void* text, size_t len, 1150 void SkPDFDevice::drawPosText(const SkDraw& d, const void* text, size_t len,
1147 const SkScalar pos[], int scalarsPerPos, 1151 const SkScalar pos[], int scalarsPerPos,
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 SkAutoTUnref<SkPDFObject> image( 2193 SkAutoTUnref<SkPDFObject> image(
2190 SkPDFCreateImageObject(*bitmap, subset, fEncoder)); 2194 SkPDFCreateImageObject(*bitmap, subset, fEncoder));
2191 if (!image) { 2195 if (!image) {
2192 return; 2196 return;
2193 } 2197 }
2194 2198
2195 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), 2199 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()),
2196 &content.entry()->fContent); 2200 &content.entry()->fContent);
2197 } 2201 }
2198 2202
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698