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

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

Issue 605533002: Fix SkTextBlob offset semantics. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: default run positioning fix 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 | « src/gpu/SkGpuDevice.cpp ('k') | src/pdf/SkPDFDeviceFlattener.h » ('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 "SkAnnotation.h" 10 #include "SkAnnotation.h"
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 SkPDFString::FormatString(glyphIDs + consumedGlyphCount, 1137 SkPDFString::FormatString(glyphIDs + consumedGlyphCount,
1138 availableGlyphs, font->multiByteGlyphs()); 1138 availableGlyphs, font->multiByteGlyphs());
1139 content.entry()->fContent.writeText(encodedString.c_str()); 1139 content.entry()->fContent.writeText(encodedString.c_str());
1140 consumedGlyphCount += availableGlyphs; 1140 consumedGlyphCount += availableGlyphs;
1141 content.entry()->fContent.writeText(" Tj\n"); 1141 content.entry()->fContent.writeText(" Tj\n");
1142 } 1142 }
1143 content.entry()->fContent.writeText("ET\n"); 1143 content.entry()->fContent.writeText("ET\n");
1144 } 1144 }
1145 1145
1146 void SkPDFDevice::drawPosText(const SkDraw& d, const void* text, size_t len, 1146 void SkPDFDevice::drawPosText(const SkDraw& d, const void* text, size_t len,
1147 const SkScalar pos[], SkScalar constY, 1147 const SkScalar pos[], int scalarsPerPos,
1148 int scalarsPerPos, const SkPaint& paint) { 1148 const SkPoint& offset, const SkPaint& paint) {
1149 NOT_IMPLEMENTED(paint.getMaskFilter() != NULL, false); 1149 NOT_IMPLEMENTED(paint.getMaskFilter() != NULL, false);
1150 if (paint.getMaskFilter() != NULL) { 1150 if (paint.getMaskFilter() != NULL) {
1151 // Don't pretend we support drawing MaskFilters, it makes for artifacts 1151 // Don't pretend we support drawing MaskFilters, it makes for artifacts
1152 // making text unreadable (e.g. same text twice when using CSS shadows). 1152 // making text unreadable (e.g. same text twice when using CSS shadows).
1153 return; 1153 return;
1154 } 1154 }
1155 SkASSERT(1 == scalarsPerPos || 2 == scalarsPerPos); 1155 SkASSERT(1 == scalarsPerPos || 2 == scalarsPerPos);
1156 SkPaint textPaint = calculate_text_paint(paint); 1156 SkPaint textPaint = calculate_text_paint(paint);
1157 ScopedContentEntry content(this, d, textPaint, true); 1157 ScopedContentEntry content(this, d, textPaint, true);
1158 if (!content.entry()) { 1158 if (!content.entry()) {
(...skipping 11 matching lines...) Expand all
1170 updateFont(textPaint, glyphIDs[0], content.entry()); 1170 updateFont(textPaint, glyphIDs[0], content.entry());
1171 for (size_t i = 0; i < numGlyphs; i++) { 1171 for (size_t i = 0; i < numGlyphs; i++) {
1172 SkPDFFont* font = content.entry()->fState.fFont; 1172 SkPDFFont* font = content.entry()->fState.fFont;
1173 uint16_t encodedValue = glyphIDs[i]; 1173 uint16_t encodedValue = glyphIDs[i];
1174 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) { 1174 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) {
1175 updateFont(textPaint, glyphIDs[i], content.entry()); 1175 updateFont(textPaint, glyphIDs[i], content.entry());
1176 i--; 1176 i--;
1177 continue; 1177 continue;
1178 } 1178 }
1179 fFontGlyphUsage->noteGlyphUsage(font, &encodedValue, 1); 1179 fFontGlyphUsage->noteGlyphUsage(font, &encodedValue, 1);
1180 SkScalar x = pos[i * scalarsPerPos]; 1180 SkScalar x = offset.x() + pos[i * scalarsPerPos];
1181 SkScalar y = scalarsPerPos == 1 ? constY : pos[i * scalarsPerPos + 1]; 1181 SkScalar y = offset.y() + (2 == scalarsPerPos ? pos[i * scalarsPerPos + 1] : 0);
1182
1182 align_text(glyphCacheProc, textPaint, glyphIDs + i, 1, &x, &y); 1183 align_text(glyphCacheProc, textPaint, glyphIDs + i, 1, &x, &y);
1183 set_text_transform(x, y, textPaint.getTextSkewX(), 1184 set_text_transform(x, y, textPaint.getTextSkewX(),
1184 &content.entry()->fContent); 1185 &content.entry()->fContent);
1185 SkString encodedString = 1186 SkString encodedString =
1186 SkPDFString::FormatString(&encodedValue, 1, 1187 SkPDFString::FormatString(&encodedValue, 1,
1187 font->multiByteGlyphs()); 1188 font->multiByteGlyphs());
1188 content.entry()->fContent.writeText(encodedString.c_str()); 1189 content.entry()->fContent.writeText(encodedString.c_str());
1189 content.entry()->fContent.writeText(" Tj\n"); 1190 content.entry()->fContent.writeText(" Tj\n");
1190 } 1191 }
1191 content.entry()->fContent.writeText("ET\n"); 1192 content.entry()->fContent.writeText("ET\n");
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 SkAutoTUnref<SkPDFObject> image( 2186 SkAutoTUnref<SkPDFObject> image(
2186 SkPDFCreateImageObject(*bitmap, subset, fEncoder)); 2187 SkPDFCreateImageObject(*bitmap, subset, fEncoder));
2187 if (!image) { 2188 if (!image) {
2188 return; 2189 return;
2189 } 2190 }
2190 2191
2191 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), 2192 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()),
2192 &content.entry()->fContent); 2193 &content.entry()->fContent);
2193 } 2194 }
2194 2195
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/pdf/SkPDFDeviceFlattener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698