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

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

Issue 1214853025: Propagate SkSurfaceProps when known (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « src/pdf/SkPDFDevice.h ('k') | 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 "SkAnnotation.h" 10 #include "SkAnnotation.h"
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc(); 1154 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc();
1155 align_text(glyphCacheProc, textPaint, glyphIDs, numGlyphs, &x, &y); 1155 align_text(glyphCacheProc, textPaint, glyphIDs, numGlyphs, &x, &y);
1156 content.entry()->fContent.writeText("BT\n"); 1156 content.entry()->fContent.writeText("BT\n");
1157 set_text_transform(x, y, textPaint.getTextSkewX(), 1157 set_text_transform(x, y, textPaint.getTextSkewX(),
1158 &content.entry()->fContent); 1158 &content.entry()->fContent);
1159 int consumedGlyphCount = 0; 1159 int consumedGlyphCount = 0;
1160 1160
1161 SkTDArray<uint16_t> glyphIDsCopy(glyphIDs, numGlyphs); 1161 SkTDArray<uint16_t> glyphIDsCopy(glyphIDs, numGlyphs);
1162 1162
1163 while (numGlyphs > consumedGlyphCount) { 1163 while (numGlyphs > consumedGlyphCount) {
1164 updateFont(textPaint, glyphIDs[consumedGlyphCount], content.entry()); 1164 this->updateFont(textPaint, glyphIDs[consumedGlyphCount], content.entry( ));
1165 SkPDFFont* font = content.entry()->fState.fFont; 1165 SkPDFFont* font = content.entry()->fState.fFont;
1166 1166
1167 int availableGlyphs = font->glyphsToPDFFontEncoding( 1167 int availableGlyphs = font->glyphsToPDFFontEncoding(
1168 glyphIDsCopy.begin() + consumedGlyphCount, 1168 glyphIDsCopy.begin() + consumedGlyphCount,
1169 numGlyphs - consumedGlyphCount); 1169 numGlyphs - consumedGlyphCount);
1170 fFontGlyphUsage->noteGlyphUsage( 1170 fFontGlyphUsage->noteGlyphUsage(
1171 font, glyphIDsCopy.begin() + consumedGlyphCount, 1171 font, glyphIDsCopy.begin() + consumedGlyphCount,
1172 availableGlyphs); 1172 availableGlyphs);
1173 SkString encodedString = 1173 SkString encodedString =
1174 format_wide_string(glyphIDsCopy.begin() + consumedGlyphCount, 1174 format_wide_string(glyphIDsCopy.begin() + consumedGlyphCount,
(...skipping 24 matching lines...) Expand all
1199 return; 1199 return;
1200 } 1200 }
1201 1201
1202 SkGlyphStorage storage(0); 1202 SkGlyphStorage storage(0);
1203 const uint16_t* glyphIDs = NULL; 1203 const uint16_t* glyphIDs = NULL;
1204 size_t numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphID s); 1204 size_t numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphID s);
1205 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 1205 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
1206 1206
1207 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc(); 1207 SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc();
1208 content.entry()->fContent.writeText("BT\n"); 1208 content.entry()->fContent.writeText("BT\n");
1209 updateFont(textPaint, glyphIDs[0], content.entry()); 1209 this->updateFont(textPaint, glyphIDs[0], content.entry());
1210 for (size_t i = 0; i < numGlyphs; i++) { 1210 for (size_t i = 0; i < numGlyphs; i++) {
1211 SkPDFFont* font = content.entry()->fState.fFont; 1211 SkPDFFont* font = content.entry()->fState.fFont;
1212 uint16_t encodedValue = glyphIDs[i]; 1212 uint16_t encodedValue = glyphIDs[i];
1213 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) { 1213 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) {
1214 // The current pdf font cannot encode the current glyph. 1214 // The current pdf font cannot encode the current glyph.
1215 // Try to get a pdf font which can encode the current glyph. 1215 // Try to get a pdf font which can encode the current glyph.
1216 updateFont(textPaint, glyphIDs[i], content.entry()); 1216 this->updateFont(textPaint, glyphIDs[i], content.entry());
1217 font = content.entry()->fState.fFont; 1217 font = content.entry()->fState.fFont;
1218 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) { 1218 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) {
1219 SkDEBUGFAIL("PDF could not encode glyph."); 1219 SkDEBUGFAIL("PDF could not encode glyph.");
1220 continue; 1220 continue;
1221 } 1221 }
1222 } 1222 }
1223 1223
1224 fFontGlyphUsage->noteGlyphUsage(font, &encodedValue, 1); 1224 fFontGlyphUsage->noteGlyphUsage(font, &encodedValue, 1);
1225 SkScalar x = offset.x() + pos[i * scalarsPerPos]; 1225 SkScalar x = offset.x() + pos[i * scalarsPerPos];
1226 SkScalar y = offset.y() + (2 == scalarsPerPos ? pos[i * scalarsPerPos + 1] : 0); 1226 SkScalar y = offset.y() + (2 == scalarsPerPos ? pos[i * scalarsPerPos + 1] : 0);
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 return; 2195 return;
2196 } 2196 }
2197 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); 2197 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap));
2198 if (!image) { 2198 if (!image) {
2199 return; 2199 return;
2200 } 2200 }
2201 2201
2202 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), 2202 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()),
2203 &content.entry()->fContent); 2203 &content.entry()->fContent);
2204 } 2204 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDevice.h ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698