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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFDevice.cpp
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 564fdc212393b82b6a5700ce9c3622abb7ca157b..736c50b9a6d8b0151ca8fbd7c1f445b545078883 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1124,17 +1124,21 @@ void SkPDFDevice::drawText(const SkDraw& d, const void* text, size_t len,
set_text_transform(x, y, textPaint.getTextSkewX(),
&content.entry()->fContent);
int consumedGlyphCount = 0;
+
+ SkTDArray<uint16_t> glyphIDsCopy(glyphIDs, numGlyphs);
+
while (numGlyphs > consumedGlyphCount) {
updateFont(textPaint, glyphIDs[consumedGlyphCount], content.entry());
SkPDFFont* font = content.entry()->fState.fFont;
- //TODO: the const_cast here is a bug if the encoding started out as glyph encoding.
- int availableGlyphs =
- font->glyphsToPDFFontEncoding(const_cast<uint16_t*>(glyphIDs) + consumedGlyphCount,
- numGlyphs - consumedGlyphCount);
- fFontGlyphUsage->noteGlyphUsage(font, glyphIDs + consumedGlyphCount,
- availableGlyphs);
+
+ int availableGlyphs = font->glyphsToPDFFontEncoding(
+ glyphIDsCopy.begin() + consumedGlyphCount,
+ numGlyphs - consumedGlyphCount);
+ fFontGlyphUsage->noteGlyphUsage(
+ font, glyphIDsCopy.begin() + consumedGlyphCount,
+ availableGlyphs);
SkString encodedString =
- SkPDFString::FormatString(glyphIDs + consumedGlyphCount,
+ SkPDFString::FormatString(glyphIDsCopy.begin() + consumedGlyphCount,
availableGlyphs, font->multiByteGlyphs());
content.entry()->fContent.writeText(encodedString.c_str());
consumedGlyphCount += availableGlyphs;
« 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