| OLD | NEW |
| 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 #include "SkAnnotationKeys.h" | 9 #include "SkAnnotationKeys.h" |
| 10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 ScopedContentEntry content(this, d, textPaint, true); | 1209 ScopedContentEntry content(this, d, textPaint, true); |
| 1210 if (!content.entry()) { | 1210 if (!content.entry()) { |
| 1211 return; | 1211 return; |
| 1212 } | 1212 } |
| 1213 | 1213 |
| 1214 SkGlyphStorage storage(0); | 1214 SkGlyphStorage storage(0); |
| 1215 const uint16_t* glyphIDs = nullptr; | 1215 const uint16_t* glyphIDs = nullptr; |
| 1216 int numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphIDs); | 1216 int numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphIDs); |
| 1217 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 1217 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| 1218 | 1218 |
| 1219 SkPaint::GlyphCacheProc glyphCacheProc = textPaint.getGlyphCacheProc(true); | 1219 SkPaint::GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(textPain
t.getTextEncoding(), |
| 1220 textPain
t.isDevKernText(), |
| 1221 true); |
| 1220 align_text(glyphCacheProc, textPaint, glyphIDs, numGlyphs, &x, &y); | 1222 align_text(glyphCacheProc, textPaint, glyphIDs, numGlyphs, &x, &y); |
| 1221 content.entry()->fContent.writeText("BT\n"); | 1223 content.entry()->fContent.writeText("BT\n"); |
| 1222 set_text_transform(x, y, textPaint.getTextSkewX(), | 1224 set_text_transform(x, y, textPaint.getTextSkewX(), |
| 1223 &content.entry()->fContent); | 1225 &content.entry()->fContent); |
| 1224 int consumedGlyphCount = 0; | 1226 int consumedGlyphCount = 0; |
| 1225 | 1227 |
| 1226 SkTDArray<uint16_t> glyphIDsCopy(glyphIDs, numGlyphs); | 1228 SkTDArray<uint16_t> glyphIDsCopy(glyphIDs, numGlyphs); |
| 1227 | 1229 |
| 1228 SkPDFGlyphSetMap* fontGlyphUsage = fDocument->getGlyphUsage(); | 1230 SkPDFGlyphSetMap* fontGlyphUsage = fDocument->getGlyphUsage(); |
| 1229 | 1231 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 ScopedContentEntry content(this, d, textPaint, true); | 1288 ScopedContentEntry content(this, d, textPaint, true); |
| 1287 if (!content.entry()) { | 1289 if (!content.entry()) { |
| 1288 return; | 1290 return; |
| 1289 } | 1291 } |
| 1290 | 1292 |
| 1291 SkGlyphStorage storage(0); | 1293 SkGlyphStorage storage(0); |
| 1292 const uint16_t* glyphIDs = nullptr; | 1294 const uint16_t* glyphIDs = nullptr; |
| 1293 size_t numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphID
s); | 1295 size_t numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphID
s); |
| 1294 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 1296 textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| 1295 | 1297 |
| 1296 SkPaint::GlyphCacheProc glyphCacheProc = textPaint.getGlyphCacheProc(true); | 1298 SkPaint::GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(textPain
t.getTextEncoding(), |
| 1299 textPain
t.isDevKernText(), |
| 1300 true); |
| 1297 content.entry()->fContent.writeText("BT\n"); | 1301 content.entry()->fContent.writeText("BT\n"); |
| 1298 this->updateFont(textPaint, glyphIDs[0], content.entry()); | 1302 this->updateFont(textPaint, glyphIDs[0], content.entry()); |
| 1299 GlyphPositioner glyphPositioner(&content.entry()->fContent, | 1303 GlyphPositioner glyphPositioner(&content.entry()->fContent, |
| 1300 textPaint.getTextSkewX(), | 1304 textPaint.getTextSkewX(), |
| 1301 content.entry()->fState.fFont->multiByteGlyp
hs()); | 1305 content.entry()->fState.fFont->multiByteGlyp
hs()); |
| 1302 SkPDFGlyphSetMap* fontGlyphUsage = fDocument->getGlyphUsage(); | 1306 SkPDFGlyphSetMap* fontGlyphUsage = fDocument->getGlyphUsage(); |
| 1303 for (size_t i = 0; i < numGlyphs; i++) { | 1307 for (size_t i = 0; i < numGlyphs; i++) { |
| 1304 SkPDFFont* font = content.entry()->fState.fFont; | 1308 SkPDFFont* font = content.entry()->fState.fFont; |
| 1305 uint16_t encodedValue = glyphIDs[i]; | 1309 uint16_t encodedValue = glyphIDs[i]; |
| 1306 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) { | 1310 if (font->glyphsToPDFFontEncoding(&encodedValue, 1) != 1) { |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 if (!pdfimage) { | 2209 if (!pdfimage) { |
| 2206 return; | 2210 return; |
| 2207 } | 2211 } |
| 2208 fDocument->serialize(pdfimage); // serialize images early. | 2212 fDocument->serialize(pdfimage); // serialize images early. |
| 2209 fDocument->canon()->addPDFBitmap(key, pdfimage); | 2213 fDocument->canon()->addPDFBitmap(key, pdfimage); |
| 2210 } | 2214 } |
| 2211 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject> | 2215 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject> |
| 2212 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), | 2216 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), |
| 2213 &content.entry()->fContent); | 2217 &content.entry()->fContent); |
| 2214 } | 2218 } |
| OLD | NEW |