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

Side by Side Diff: experimental/PdfViewer/SkPdfParser.cpp

Issue 18117005: more work on pdf fonts, more to come (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkForceLinking.h" 10 #include "SkForceLinking.h"
(...skipping 16 matching lines...) Expand all
27 27
28 28
29 __SK_FORCE_IMAGE_DECODER_LINKING; 29 __SK_FORCE_IMAGE_DECODER_LINKING;
30 30
31 // TODO(edisonn): tool, show what objects were read at least, show the ones not even read 31 // TODO(edisonn): tool, show what objects were read at least, show the ones not even read
32 // keep for each object pos in file 32 // keep for each object pos in file
33 // plug in for VS? syntax coloring, show selected object ... from the text, or f rom rendered x,y 33 // plug in for VS? syntax coloring, show selected object ... from the text, or f rom rendered x,y
34 34
35 // TODO(edisonn): security - validate all the user input, all pdf! 35 // TODO(edisonn): security - validate all the user input, all pdf!
36 36
37 // TODO(edisonn): put drawtext in #ifdefs, so comparations will ignore minor cha nges in text positioning and font
38 // this way, we look more at other features and layout in diffs
37 39
38 #include "SkPdfHeaders_autogen.h" 40 #include "SkPdfHeaders_autogen.h"
39 #include "SkPdfPodofoMapper_autogen.h" 41 #include "SkPdfPodofoMapper_autogen.h"
40 #include "SkPdfParser.h" 42 #include "SkPdfParser.h"
41 43
42 #include "SkPdfBasics.h" 44 #include "SkPdfBasics.h"
43 #include "SkPdfUtils.h" 45 #include "SkPdfUtils.h"
44 46
45 #include "SkPdfFont.h" 47 #include "SkPdfFont.h"
46 48
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // TODO(edisonn): post rotate, skew 381 // TODO(edisonn): post rotate, skew
380 mirror.postTranslate(0, point1.y()); 382 mirror.postTranslate(0, point1.y());
381 383
382 matrix.postConcat(mirror); 384 matrix.postConcat(mirror);
383 385
384 canvas->setMatrix(matrix); 386 canvas->setMatrix(matrix);
385 387
386 SkTraceMatrix(matrix, "mirrored"); 388 SkTraceMatrix(matrix, "mirrored");
387 #endif 389 #endif
388 390
389 skfont->drawText(decoded, &paint, pdfContext, canvas, &pdfContext->fGraphics State.fMatrixTm); 391 skfont->drawText(decoded, &paint, pdfContext, canvas);
390 canvas->restore(); 392 canvas->restore();
391 393
392 return kPartial_PdfResult; 394 return kPartial_PdfResult;
393 } 395 }
394 396
395 // TODO(edisonn): create header files with declarations! 397 // TODO(edisonn): create header files with declarations!
396 PdfResult PdfOp_q(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per); 398 PdfResult PdfOp_q(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per);
397 PdfResult PdfOp_Q(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per); 399 PdfResult PdfOp_Q(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per);
398 PdfResult PdfOp_Tw(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper); 400 PdfResult PdfOp_Tw(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper);
399 PdfResult PdfOp_Tc(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper); 401 PdfResult PdfOp_Tc(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper);
(...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 setup_bitmap(&bitmap, (int)SkScalarToDouble(rect.width()), (int) SkScalarToDouble(rect.height())); 2329 setup_bitmap(&bitmap, (int)SkScalarToDouble(rect.width()), (int) SkScalarToDouble(rect.height()));
2328 #endif 2330 #endif
2329 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap))); 2331 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap)));
2330 SkCanvas canvas(device); 2332 SkCanvas canvas(device);
2331 2333
2332 gDumpBitmap = &bitmap; 2334 gDumpBitmap = &bitmap;
2333 2335
2334 doc.drawPage(pn, &canvas); 2336 doc.drawPage(pn, &canvas);
2335 2337
2336 SkString out; 2338 SkString out;
2337 out.appendf("%s-%i.png", inputFileName.c_str(), pn); 2339 if (doc.pages() > 1) {
2340 out.appendf("%s-%i.png", inputFileName.c_str(), pn);
2341 } else {
2342 out = inputFileName;
2343 // .pdf -> .png
2344 out[out.size() - 2] = 'n';
2345 out[out.size() - 1] = 'g';
2346 }
2338 SkImageEncoder::EncodeFile(out.c_str(), bitmap, SkImageEncoder:: kPNG_Type, 100); 2347 SkImageEncoder::EncodeFile(out.c_str(), bitmap, SkImageEncoder:: kPNG_Type, 100);
2339 } 2348 }
2340 return true; 2349 return true;
2341 } 2350 }
2342 } 2351 }
2343 catch( PdfError & e ) 2352 catch( PdfError & e )
2344 { 2353 {
2345 std::cout << "ERROR: PDF can't be parsed!" << inputFileName.c_str() << s td::endl; 2354 std::cout << "ERROR: PDF can't be parsed!" << inputFileName.c_str() << s td::endl;
2346 return false; 2355 return false;
2347 } 2356 }
2348 2357
2349 return true; 2358 return true;
2350 } 2359 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkPdfFont.cpp ('k') | experimental/PdfViewer/autogen/SkPdfALinkAnnotationDictionary_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698