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

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

Issue 18293014: pdfviewer: fix warnings on mac (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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // Utilities 75 // Utilities
76 static void setup_bitmap(SkBitmap* bitmap, int width, int height, SkColor color = SK_ColorWHITE) { 76 static void setup_bitmap(SkBitmap* bitmap, int width, int height, SkColor color = SK_ColorWHITE) {
77 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); 77 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height);
78 78
79 bitmap->allocPixels(); 79 bitmap->allocPixels();
80 bitmap->eraseColor(color); 80 bitmap->eraseColor(color);
81 } 81 }
82 82
83 // TODO(edisonn): synonyms? DeviceRGB and RGB ... 83 // TODO(edisonn): synonyms? DeviceRGB and RGB ...
84 int GetColorSpaceComponents(const std::string& colorSpace) { 84 static int GetColorSpaceComponents(const std::string& colorSpace) {
85 if (colorSpace == "DeviceCMYK") { 85 if (colorSpace == "DeviceCMYK") {
86 return 4; 86 return 4;
87 } else if (colorSpace == "DeviceGray" || 87 } else if (colorSpace == "DeviceGray" ||
88 colorSpace == "CalGray" || 88 colorSpace == "CalGray" ||
89 colorSpace == "Indexed") { 89 colorSpace == "Indexed") {
90 return 1; 90 return 1;
91 } else if (colorSpace == "DeviceRGB" || 91 } else if (colorSpace == "DeviceRGB" ||
92 colorSpace == "CalRGB" || 92 colorSpace == "CalRGB" ||
93 colorSpace == "Lab") { 93 colorSpace == "Lab") {
94 return 3; 94 return 3;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 129
130 SkBitmap* gDumpBitmap = NULL; 130 SkBitmap* gDumpBitmap = NULL;
131 SkCanvas* gDumpCanvas = NULL; 131 SkCanvas* gDumpCanvas = NULL;
132 char gLastKeyword[100] = ""; 132 char gLastKeyword[100] = "";
133 int gLastOpKeyword = -1; 133 int gLastOpKeyword = -1;
134 char allOpWithVisualEffects[100] = ",S,s,f,F,f*,B,B*,b,b*,n,Tj,TJ,\',\",d0,d1,sh ,EI,Do,EX,"; 134 char allOpWithVisualEffects[100] = ",S,s,f,F,f*,B,B*,b,b*,n,Tj,TJ,\',\",d0,d1,sh ,EI,Do,EX,";
135 int gReadOp = 0; 135 int gReadOp = 0;
136 136
137 137
138 138 #ifdef PDF_TRACE_DIFF_IN_PNG
139 bool hasVisualEffect(const char* pdfOp) { 139 static bool hasVisualEffect(const char* pdfOp) {
140 return true; 140 return true;
141 if (*pdfOp == '\0') return false; 141 if (*pdfOp == '\0') return false;
142 142
143 char markedPdfOp[100] = ","; 143 char markedPdfOp[100] = ",";
144 strcat(markedPdfOp, pdfOp); 144 strcat(markedPdfOp, pdfOp);
145 strcat(markedPdfOp, ","); 145 strcat(markedPdfOp, ",");
146 146
147 return (strstr(allOpWithVisualEffects, markedPdfOp) != NULL); 147 return (strstr(allOpWithVisualEffects, markedPdfOp) != NULL);
148 } 148 }
149 #endif // PDF_TRACE_DIFF_IN_PNG
149 150
150 // TODO(edisonn): Pass PdfContext and SkCanvasd only with the define for instrum entation. 151 // TODO(edisonn): Pass PdfContext and SkCanvasd only with the define for instrum entation.
151 static bool readToken(SkPdfNativeTokenizer* fTokenizer, PdfToken* token) { 152 static bool readToken(SkPdfNativeTokenizer* fTokenizer, PdfToken* token) {
152 bool ret = fTokenizer->readToken(token); 153 bool ret = fTokenizer->readToken(token);
153 154
154 gReadOp++; 155 gReadOp++;
155 156
156 #ifdef PDF_TRACE_DIFF_IN_PNG 157 #ifdef PDF_TRACE_DIFF_IN_PNG
157 // TODO(edisonn): compare with old bitmap, and save only new bits are availa ble, and save 158 // TODO(edisonn): compare with old bitmap, and save only new bits are availa ble, and save
158 // the numbar and name of last operation, so the file name will reflect op t hat changed. 159 // the numbar and name of last operation, so the file name will reflect op t hat changed.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 250
250 const char* gRenderStatsNames[kCount_PdfResult] = { 251 const char* gRenderStatsNames[kCount_PdfResult] = {
251 "Success", 252 "Success",
252 "Partially implemented", 253 "Partially implemented",
253 "Not yet implemented", 254 "Not yet implemented",
254 "Ignore Error", 255 "Ignore Error",
255 "Error", 256 "Error",
256 "Unsupported/Unknown" 257 "Unsupported/Unknown"
257 }; 258 };
258 259
259 PdfResult DrawText(PdfContext* pdfContext, 260 static PdfResult DrawText(PdfContext* pdfContext,
260 const SkPdfObject* _str, 261 const SkPdfObject* _str,
261 SkCanvas* canvas) 262 SkCanvas* canvas)
262 { 263 {
263 264
264 SkPdfFont* skfont = pdfContext->fGraphicsState.fSkFont; 265 SkPdfFont* skfont = pdfContext->fGraphicsState.fSkFont;
265 if (skfont == NULL) { 266 if (skfont == NULL) {
266 skfont = SkPdfFont::Default(); 267 skfont = SkPdfFont::Default();
267 } 268 }
268 269
269 270
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 if (grayColortable == NULL) { 339 if (grayColortable == NULL) {
339 SkPMColor* colors = new SkPMColor[256]; 340 SkPMColor* colors = new SkPMColor[256];
340 for (int i = 0 ; i < 256; i++) { 341 for (int i = 0 ; i < 256; i++) {
341 colors[i] = SkPreMultiplyARGB(255, i, i, i); 342 colors[i] = SkPreMultiplyARGB(255, i, i, i);
342 } 343 }
343 grayColortable = new SkColorTable(colors, 256); 344 grayColortable = new SkColorTable(colors, 256);
344 } 345 }
345 return grayColortable; 346 return grayColortable;
346 } 347 }
347 348
348 SkBitmap transferImageStreamToBitmap(unsigned char* uncompressedStream, size_t u ncompressedStreamLength, 349 static SkBitmap transferImageStreamToBitmap(unsigned char* uncompressedStream, s ize_t uncompressedStreamLength,
349 int width, int height, int bytesPerLine, 350 int width, int height, int bytesPerLine,
350 int bpc, const std::string& colorSpace, 351 int bpc, const std::string& colorSpace,
351 bool transparencyMask) { 352 bool transparencyMask) {
352 SkBitmap bitmap; 353 SkBitmap bitmap;
353 354
354 //int components = GetColorSpaceComponents(colorSpace); 355 //int components = GetColorSpaceComponents(colorSpace);
355 //#define MAX_COMPONENTS 10 356 //#define MAX_COMPONENTS 10
356 357
357 // TODO(edisonn): assume start of lines are aligned at 32 bits? 358 // TODO(edisonn): assume start of lines are aligned at 32 bits?
358 // Is there a faster way to load the uncompressed stream into a bitmap? 359 // Is there a faster way to load the uncompressed stream into a bitmap?
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 391
391 bitmap.setConfig(transparencyMask ? SkBitmap::kA8_Config : SkBitmap::kIn dex8_Config, 392 bitmap.setConfig(transparencyMask ? SkBitmap::kA8_Config : SkBitmap::kIn dex8_Config,
392 width, height); 393 width, height);
393 bitmap.setPixels(uncompressedStreamA8, transparencyMask ? NULL : getGray Colortable()); 394 bitmap.setPixels(uncompressedStreamA8, transparencyMask ? NULL : getGray Colortable());
394 } 395 }
395 396
396 // TODO(edisonn): Report Warning, NYI, or error 397 // TODO(edisonn): Report Warning, NYI, or error
397 return bitmap; 398 return bitmap;
398 } 399 }
399 400
400 bool transferImageStreamToARGB(unsigned char* uncompressedStream, size_t uncompr essedStreamLength,
401 int width, int bytesPerLine,
402 int bpc, const std::string& colorSpace,
403 SkColor** uncompressedStreamArgb,
404 size_t* uncompressedStreamLengthInBytesArgb) {
405 //int components = GetColorSpaceComponents(colorSpace);
406 //#define MAX_COMPONENTS 10
407
408 // TODO(edisonn): assume start of lines are aligned at 32 bits?
409 int height = uncompressedStreamLength / bytesPerLine;
410
411 // minimal support for now
412 if ((colorSpace == "DeviceRGB" || colorSpace == "RGB") && bpc == 8) {
413 *uncompressedStreamLengthInBytesArgb = width * height * 4;
414 *uncompressedStreamArgb = (SkColor*)malloc(*uncompressedStreamLengthInBy tesArgb);
415
416 for (int h = 0 ; h < height; h++) {
417 long i = width * (h);
418 for (int w = 0 ; w < width; w++) {
419 (*uncompressedStreamArgb)[i] = SkColorSetRGB(uncompressedStream[ 3 * w],
420 uncompressedStream[ 3 * w + 1],
421 uncompressedStream[ 3 * w + 2]);
422 i++;
423 }
424 uncompressedStream += bytesPerLine;
425 }
426 return true;
427 }
428
429 if ((colorSpace == "DeviceGray" || colorSpace == "Gray") && bpc == 8) {
430 *uncompressedStreamLengthInBytesArgb = width * height * 4;
431 *uncompressedStreamArgb = (SkColor*)malloc(*uncompressedStreamLengthInBy tesArgb);
432
433 for (int h = 0 ; h < height; h++) {
434 long i = width * (h);
435 for (int w = 0 ; w < width; w++) {
436 (*uncompressedStreamArgb)[i] = SkColorSetRGB(uncompressedStream[ w],
437 uncompressedStream[ w],
438 uncompressedStream[ w]);
439 i++;
440 }
441 uncompressedStream += bytesPerLine;
442 }
443 return true;
444 }
445
446 return false;
447 }
448
449 // utils 401 // utils
450 402
451 // TODO(edisonn): add cache, or put the bitmap property directly on the PdfObjec t 403 // TODO(edisonn): add cache, or put the bitmap property directly on the PdfObjec t
452 // TODO(edisonn): deal with colorSpaces, we could add them to SkBitmap::Config 404 // TODO(edisonn): deal with colorSpaces, we could add them to SkBitmap::Config
453 // TODO(edisonn): preserve A1 format that skia knows, + fast convert from 111, 2 22, 444 to closest 405 // TODO(edisonn): preserve A1 format that skia knows, + fast convert from 111, 2 22, 444 to closest
454 // skia format, through a table 406 // skia format, through a table
455 407
456 // this functions returns the image, it does not look at the smask. 408 // this functions returns the image, it does not look at the smask.
457 409
458 SkBitmap getImageFromObject(PdfContext* pdfContext, SkPdfImageDictionary* image, bool transparencyMask) { 410 static SkBitmap getImageFromObject(PdfContext* pdfContext, SkPdfImageDictionary* image, bool transparencyMask) {
459 if (image == NULL || !image->hasStream()) { 411 if (image == NULL || !image->hasStream()) {
460 // TODO(edisonn): report warning to be used in testing. 412 // TODO(edisonn): report warning to be used in testing.
461 return SkBitmap(); 413 return SkBitmap();
462 } 414 }
463 415
464 long bpc = image->BitsPerComponent(pdfContext->fPdfDoc); 416 int64_t bpc = image->BitsPerComponent(pdfContext->fPdfDoc);
465 long width = image->Width(pdfContext->fPdfDoc); 417 int64_t width = image->Width(pdfContext->fPdfDoc);
466 long height = image->Height(pdfContext->fPdfDoc); 418 int64_t height = image->Height(pdfContext->fPdfDoc);
467 std::string colorSpace = "DeviceRGB"; 419 std::string colorSpace = "DeviceRGB";
468 420
469 // TODO(edisonn): color space can be an array too! 421 // TODO(edisonn): color space can be an array too!
470 if (image->isColorSpaceAName(pdfContext->fPdfDoc)) { 422 if (image->isColorSpaceAName(pdfContext->fPdfDoc)) {
471 colorSpace = image->getColorSpaceAsName(pdfContext->fPdfDoc); 423 colorSpace = image->getColorSpaceAsName(pdfContext->fPdfDoc);
472 } 424 }
473 425
474 /* 426 /*
475 bool imageMask = image->imageMask(); 427 bool imageMask = image->imageMask();
476 428
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 475
524 int bytesPerLine = uncompressedStreamLength / height; 476 int bytesPerLine = uncompressedStreamLength / height;
525 #ifdef PDF_TRACE 477 #ifdef PDF_TRACE
526 if (uncompressedStreamLength % height != 0) { 478 if (uncompressedStreamLength % height != 0) {
527 printf("Warning uncompressedStreamLength modulo height != 0 !!!\n"); 479 printf("Warning uncompressedStreamLength modulo height != 0 !!!\n");
528 } 480 }
529 #endif 481 #endif
530 482
531 SkBitmap bitmap = transferImageStreamToBitmap( 483 SkBitmap bitmap = transferImageStreamToBitmap(
532 (unsigned char*)uncompressedStream, uncompressedStreamLength, 484 (unsigned char*)uncompressedStream, uncompressedStreamLength,
533 width, height, bytesPerLine, 485 (int)width, (int)height, bytesPerLine,
534 bpc, colorSpace, 486 (int)bpc, colorSpace,
535 transparencyMask); 487 transparencyMask);
536 488
537 return bitmap; 489 return bitmap;
538 } 490 }
539 491
540 SkBitmap getSmaskFromObject(PdfContext* pdfContext, SkPdfImageDictionary* obj) { 492 static SkBitmap getSmaskFromObject(PdfContext* pdfContext, SkPdfImageDictionary* obj) {
541 SkPdfImageDictionary* sMask = obj->SMask(pdfContext->fPdfDoc); 493 SkPdfImageDictionary* sMask = obj->SMask(pdfContext->fPdfDoc);
542 494
543 if (sMask) { 495 if (sMask) {
544 return getImageFromObject(pdfContext, sMask, true); 496 return getImageFromObject(pdfContext, sMask, true);
545 } 497 }
546 498
547 // TODO(edisonn): implement GS SMask. Default to empty right now. 499 // TODO(edisonn): implement GS SMask. Default to empty right now.
548 return pdfContext->fGraphicsState.fSMask; 500 return pdfContext->fGraphicsState.fSMask;
549 } 501 }
550 502
551 PdfResult doXObject_Image(PdfContext* pdfContext, SkCanvas* canvas, SkPdfImageDi ctionary* skpdfimage) { 503 static PdfResult doXObject_Image(PdfContext* pdfContext, SkCanvas* canvas, SkPdf ImageDictionary* skpdfimage) {
552 if (skpdfimage == NULL) { 504 if (skpdfimage == NULL) {
553 return kIgnoreError_PdfResult; 505 return kIgnoreError_PdfResult;
554 } 506 }
555 507
556 SkBitmap image = getImageFromObject(pdfContext, skpdfimage, false); 508 SkBitmap image = getImageFromObject(pdfContext, skpdfimage, false);
557 SkBitmap sMask = getSmaskFromObject(pdfContext, skpdfimage); 509 SkBitmap sMask = getSmaskFromObject(pdfContext, skpdfimage);
558 510
559 canvas->save(); 511 canvas->save();
560 canvas->setMatrix(pdfContext->fGraphicsState.fMatrix); 512 canvas->setMatrix(pdfContext->fGraphicsState.fMatrix);
561 513
(...skipping 25 matching lines...) Expand all
587 } 539 }
588 540
589 canvas->restore(); 541 canvas->restore();
590 542
591 return kPartial_PdfResult; 543 return kPartial_PdfResult;
592 } 544 }
593 545
594 546
595 547
596 548
597 PdfResult doXObject_Form(PdfContext* pdfContext, SkCanvas* canvas, SkPdfType1For mDictionary* skobj) { 549 static PdfResult doXObject_Form(PdfContext* pdfContext, SkCanvas* canvas, SkPdfT ype1FormDictionary* skobj) {
598 if (!skobj || !skobj->hasStream()) { 550 if (!skobj || !skobj->hasStream()) {
599 return kIgnoreError_PdfResult; 551 return kIgnoreError_PdfResult;
600 } 552 }
601 553
602 PdfOp_q(pdfContext, canvas, NULL); 554 PdfOp_q(pdfContext, canvas, NULL);
603 canvas->save(); 555 canvas->save();
604 556
605 557
606 if (skobj->Resources(pdfContext->fPdfDoc)) { 558 if (skobj->Resources(pdfContext->fPdfDoc)) {
607 pdfContext->fGraphicsState.fResources = skobj->Resources(pdfContext->fPd fDoc); 559 pdfContext->fGraphicsState.fResources = skobj->Resources(pdfContext->fPd fDoc);
(...skipping 28 matching lines...) Expand all
636 delete tokenizer; 588 delete tokenizer;
637 } 589 }
638 590
639 // TODO(edisonn): should we restore the variable stack at the same state? 591 // TODO(edisonn): should we restore the variable stack at the same state?
640 // There could be operands left, that could be consumed by a parent tokenize r when we pop. 592 // There could be operands left, that could be consumed by a parent tokenize r when we pop.
641 canvas->restore(); 593 canvas->restore();
642 PdfOp_Q(pdfContext, canvas, NULL); 594 PdfOp_Q(pdfContext, canvas, NULL);
643 return kPartial_PdfResult; 595 return kPartial_PdfResult;
644 } 596 }
645 597
646 PdfResult doXObject_PS(PdfContext* pdfContext, SkCanvas* canvas, const SkPdfObje ct* obj) { 598 //static PdfResult doXObject_PS(PdfContext* pdfContext, SkCanvas* canvas, const SkPdfObject* obj) {
647 return kNYI_PdfResult; 599 // return kNYI_PdfResult;
648 } 600 //}
649 601
650 PdfResult doType3Char(PdfContext* pdfContext, SkCanvas* canvas, const SkPdfObjec t* skobj, SkRect bBox, SkMatrix matrix, double textSize) { 602 PdfResult doType3Char(PdfContext* pdfContext, SkCanvas* canvas, const SkPdfObjec t* skobj, SkRect bBox, SkMatrix matrix, double textSize) {
651 if (!skobj || !skobj->hasStream()) { 603 if (!skobj || !skobj->hasStream()) {
652 return kIgnoreError_PdfResult; 604 return kIgnoreError_PdfResult;
653 } 605 }
654 606
655 PdfOp_q(pdfContext, canvas, NULL); 607 PdfOp_q(pdfContext, canvas, NULL);
656 canvas->save(); 608 canvas->save();
657 609
658 pdfContext->fGraphicsState.fMatrixTm.preConcat(matrix); 610 pdfContext->fGraphicsState.fMatrixTm.preConcat(matrix);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 ~CheckRecursiveRendering() { 658 ~CheckRecursiveRendering() {
707 //SkASSERT(fObj.fInRendering); 659 //SkASSERT(fObj.fInRendering);
708 gInRendering.erase(fUniqueData); 660 gInRendering.erase(fUniqueData);
709 } 661 }
710 662
711 static bool IsInRendering(const SkPdfObject* obj) { 663 static bool IsInRendering(const SkPdfObject* obj) {
712 return gInRendering.find(obj) != gInRendering.end(); 664 return gInRendering.find(obj) != gInRendering.end();
713 } 665 }
714 }; 666 };
715 667
716 PdfResult doXObject(PdfContext* pdfContext, SkCanvas* canvas, const SkPdfObject* obj) { 668 static PdfResult doXObject(PdfContext* pdfContext, SkCanvas* canvas, const SkPdf Object* obj) {
717 if (CheckRecursiveRendering::IsInRendering(obj)) { 669 if (CheckRecursiveRendering::IsInRendering(obj)) {
718 // Oops, corrupt PDF! 670 // Oops, corrupt PDF!
719 return kIgnoreError_PdfResult; 671 return kIgnoreError_PdfResult;
720 } 672 }
721 673
722 CheckRecursiveRendering checkRecursion(obj); 674 CheckRecursiveRendering checkRecursion(obj);
723 675
724 switch (pdfContext->fPdfDoc->mapper()->mapXObjectDictionary(obj)) 676 switch (pdfContext->fPdfDoc->mapper()->mapXObjectDictionary(obj))
725 { 677 {
726 case kImageDictionary_SkPdfObjectType: 678 case kImageDictionary_SkPdfObjectType:
(...skipping 13 matching lines...) Expand all
740 return kOK_PdfResult; 692 return kOK_PdfResult;
741 } 693 }
742 694
743 PdfResult PdfOp_Q(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 695 PdfResult PdfOp_Q(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) {
744 pdfContext->fGraphicsState = pdfContext->fStateStack.top(); 696 pdfContext->fGraphicsState = pdfContext->fStateStack.top();
745 pdfContext->fStateStack.pop(); 697 pdfContext->fStateStack.pop();
746 canvas->restore(); 698 canvas->restore();
747 return kOK_PdfResult; 699 return kOK_PdfResult;
748 } 700 }
749 701
750 PdfResult PdfOp_cm(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 702 static PdfResult PdfOp_cm(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
751 double array[6]; 703 double array[6];
752 for (int i = 0 ; i < 6 ; i++) { 704 for (int i = 0 ; i < 6 ; i++) {
753 array[5 - i] = pdfContext->fObjectStack.top()->numberValue(); 705 array[5 - i] = pdfContext->fObjectStack.top()->numberValue();
754 pdfContext->fObjectStack.pop(); 706 pdfContext->fObjectStack.pop();
755 } 707 }
756 708
757 // a b 709 // a b
758 // c d 710 // c d
759 // e f 711 // e f
760 712
(...skipping 16 matching lines...) Expand all
777 printf("\n"); 729 printf("\n");
778 SkTraceMatrix(pdfContext->fGraphicsState.fMatrix, "cm"); 730 SkTraceMatrix(pdfContext->fGraphicsState.fMatrix, "cm");
779 #endif 731 #endif
780 732
781 return kOK_PdfResult; 733 return kOK_PdfResult;
782 } 734 }
783 735
784 //leading TL Set the text leading, Tl 736 //leading TL Set the text leading, Tl
785 //, to leading, which is a number expressed in unscaled text 737 //, to leading, which is a number expressed in unscaled text
786 //space units. Text leading is used only by the T*, ', and " operators. Initial value: 0. 738 //space units. Text leading is used only by the T*, ', and " operators. Initial value: 0.
787 PdfResult PdfOp_TL(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 739 static PdfResult PdfOp_TL(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
788 double ty = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fOb jectStack.pop(); 740 double ty = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fOb jectStack.pop();
789 741
790 pdfContext->fGraphicsState.fTextLeading = ty; 742 pdfContext->fGraphicsState.fTextLeading = ty;
791 743
792 return kOK_PdfResult; 744 return kOK_PdfResult;
793 } 745 }
794 746
795 PdfResult PdfOp_Td(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 747 static PdfResult PdfOp_Td(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
796 double ty = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObje ctStack.pop(); 748 double ty = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObje ctStack.pop();
797 double tx = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObje ctStack.pop(); 749 double tx = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObje ctStack.pop();
798 750
799 double array[6] = {1, 0, 0, 1, tx, ty}; 751 double array[6] = {1, 0, 0, 1, tx, ty};
800 SkMatrix matrix = SkMatrixFromPdfMatrix(array); 752 SkMatrix matrix = SkMatrixFromPdfMatrix(array);
801 753
802 pdfContext->fGraphicsState.fMatrixTm.preConcat(matrix); 754 pdfContext->fGraphicsState.fMatrixTm.preConcat(matrix);
803 pdfContext->fGraphicsState.fMatrixTlm.preConcat(matrix); 755 pdfContext->fGraphicsState.fMatrixTlm.preConcat(matrix);
804 756
805 return kPartial_PdfResult; 757 return kPartial_PdfResult;
806 } 758 }
807 759
808 PdfResult PdfOp_TD(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 760 static PdfResult PdfOp_TD(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
809 double ty = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObje ctStack.pop(); 761 double ty = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObje ctStack.pop();
810 double tx = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObje ctStack.pop(); 762 double tx = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObje ctStack.pop();
811 763
812 // TODO(edisonn): Create factory methods or constructors so native is hidden 764 // TODO(edisonn): Create factory methods or constructors so native is hidden
813 SkPdfReal* _ty = pdfContext->fPdfDoc->createReal(-ty); 765 SkPdfReal* _ty = pdfContext->fPdfDoc->createReal(-ty);
814 pdfContext->fObjectStack.push(_ty); 766 pdfContext->fObjectStack.push(_ty);
815 767
816 PdfOp_TL(pdfContext, canvas, looper); 768 PdfOp_TL(pdfContext, canvas, looper);
817 769
818 SkPdfReal* vtx = pdfContext->fPdfDoc->createReal(tx); 770 SkPdfReal* vtx = pdfContext->fPdfDoc->createReal(tx);
819 pdfContext->fObjectStack.push(vtx); 771 pdfContext->fObjectStack.push(vtx);
820 772
821 SkPdfReal* vty = pdfContext->fPdfDoc->createReal(ty); 773 SkPdfReal* vty = pdfContext->fPdfDoc->createReal(ty);
822 pdfContext->fObjectStack.push(vty); 774 pdfContext->fObjectStack.push(vty);
823 775
824 PdfResult ret = PdfOp_Td(pdfContext, canvas, looper); 776 PdfResult ret = PdfOp_Td(pdfContext, canvas, looper);
825 777
826 // TODO(edisonn): delete all the objects after rendering was complete, in th is way pdf is rendered faster 778 // TODO(edisonn): delete all the objects after rendering was complete, in th is way pdf is rendered faster
827 // and the cleanup can happen while the user looks at the image 779 // and the cleanup can happen while the user looks at the image
828 delete _ty; 780 delete _ty;
829 delete vtx; 781 delete vtx;
830 delete vty; 782 delete vty;
831 783
832 return ret; 784 return ret;
833 } 785 }
834 786
835 PdfResult PdfOp_Tm(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 787 static PdfResult PdfOp_Tm(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
836 double f = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop(); 788 double f = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop();
837 double e = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop(); 789 double e = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop();
838 double d = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop(); 790 double d = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop();
839 double c = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop(); 791 double c = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop();
840 double b = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop(); 792 double b = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop();
841 double a = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop(); 793 double a = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fObjec tStack.pop();
842 794
843 double array[6]; 795 double array[6];
844 array[0] = a; 796 array[0] = a;
845 array[1] = b; 797 array[1] = b;
846 array[2] = c; 798 array[2] = c;
847 array[3] = d; 799 array[3] = d;
848 array[4] = e; 800 array[4] = e;
849 array[5] = f; 801 array[5] = f;
850 802
851 SkMatrix matrix = SkMatrixFromPdfMatrix(array); 803 SkMatrix matrix = SkMatrixFromPdfMatrix(array);
852 matrix.postConcat(pdfContext->fGraphicsState.fMatrix); 804 matrix.postConcat(pdfContext->fGraphicsState.fMatrix);
853 805
854 // TODO(edisonn): Text positioning. 806 // TODO(edisonn): Text positioning.
855 pdfContext->fGraphicsState.fMatrixTm = matrix; 807 pdfContext->fGraphicsState.fMatrixTm = matrix;
856 pdfContext->fGraphicsState.fMatrixTlm = matrix;; 808 pdfContext->fGraphicsState.fMatrixTlm = matrix;;
857 809
858 return kPartial_PdfResult; 810 return kPartial_PdfResult;
859 } 811 }
860 812
861 //— T* Move to the start of the next line. This operator has the same effect as the code 813 //— T* Move to the start of the next line. This operator has the same effect as the code
862 //0 Tl Td 814 //0 Tl Td
863 //where Tl is the current leading parameter in the text state 815 //where Tl is the current leading parameter in the text state
864 PdfResult PdfOp_T_star(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper* * looper) { 816 static PdfResult PdfOp_T_star(PdfContext* pdfContext, SkCanvas* canvas, PdfToken Looper** looper) {
865 SkPdfReal* zero = pdfContext->fPdfDoc->createReal(0.0); 817 SkPdfReal* zero = pdfContext->fPdfDoc->createReal(0.0);
866 SkPdfReal* tl = pdfContext->fPdfDoc->createReal(pdfContext->fGraphicsState.f TextLeading); 818 SkPdfReal* tl = pdfContext->fPdfDoc->createReal(pdfContext->fGraphicsState.f TextLeading);
867 819
868 pdfContext->fObjectStack.push(zero); 820 pdfContext->fObjectStack.push(zero);
869 pdfContext->fObjectStack.push(tl); 821 pdfContext->fObjectStack.push(tl);
870 822
871 PdfResult ret = PdfOp_Td(pdfContext, canvas, looper); 823 PdfResult ret = PdfOp_Td(pdfContext, canvas, looper);
872 824
873 delete zero; // TODO(edisonn): do not alocate and delete constants! 825 delete zero; // TODO(edisonn): do not alocate and delete constants!
874 delete tl; 826 delete tl;
875 827
876 return ret; 828 return ret;
877 } 829 }
878 830
879 PdfResult PdfOp_m(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 831 static PdfResult PdfOp_m(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
880 if (pdfContext->fGraphicsState.fPathClosed) { 832 if (pdfContext->fGraphicsState.fPathClosed) {
881 pdfContext->fGraphicsState.fPath.reset(); 833 pdfContext->fGraphicsState.fPath.reset();
882 pdfContext->fGraphicsState.fPathClosed = false; 834 pdfContext->fGraphicsState.fPathClosed = false;
883 } 835 }
884 836
885 pdfContext->fGraphicsState.fCurPosY = pdfContext->fObjectStack.top()->number Value(); pdfContext->fObjectStack.pop(); 837 pdfContext->fGraphicsState.fCurPosY = pdfContext->fObjectStack.top()->number Value(); pdfContext->fObjectStack.pop();
886 pdfContext->fGraphicsState.fCurPosX = pdfContext->fObjectStack.top()->number Value(); pdfContext->fObjectStack.pop(); 838 pdfContext->fGraphicsState.fCurPosX = pdfContext->fObjectStack.top()->number Value(); pdfContext->fObjectStack.pop();
887 839
888 pdfContext->fGraphicsState.fPath.moveTo(SkDoubleToScalar(pdfContext->fGraphi csState.fCurPosX), 840 pdfContext->fGraphicsState.fPath.moveTo(SkDoubleToScalar(pdfContext->fGraphi csState.fCurPosX),
889 SkDoubleToScalar(pdfContext->fGraphics State.fCurPosY)); 841 SkDoubleToScalar(pdfContext->fGraphics State.fCurPosY));
890 842
891 return kOK_PdfResult; 843 return kOK_PdfResult;
892 } 844 }
893 845
894 PdfResult PdfOp_l(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 846 static PdfResult PdfOp_l(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
895 if (pdfContext->fGraphicsState.fPathClosed) { 847 if (pdfContext->fGraphicsState.fPathClosed) {
896 pdfContext->fGraphicsState.fPath.reset(); 848 pdfContext->fGraphicsState.fPath.reset();
897 pdfContext->fGraphicsState.fPathClosed = false; 849 pdfContext->fGraphicsState.fPathClosed = false;
898 } 850 }
899 851
900 pdfContext->fGraphicsState.fCurPosY = pdfContext->fObjectStack.top()->number Value(); pdfContext->fObjectStack.pop(); 852 pdfContext->fGraphicsState.fCurPosY = pdfContext->fObjectStack.top()->number Value(); pdfContext->fObjectStack.pop();
901 pdfContext->fGraphicsState.fCurPosX = pdfContext->fObjectStack.top()->number Value(); pdfContext->fObjectStack.pop(); 853 pdfContext->fGraphicsState.fCurPosX = pdfContext->fObjectStack.top()->number Value(); pdfContext->fObjectStack.pop();
902 854
903 pdfContext->fGraphicsState.fPath.lineTo(SkDoubleToScalar(pdfContext->fGraphi csState.fCurPosX), 855 pdfContext->fGraphicsState.fPath.lineTo(SkDoubleToScalar(pdfContext->fGraphi csState.fCurPosX),
904 SkDoubleToScalar(pdfContext->fGraphics State.fCurPosY)); 856 SkDoubleToScalar(pdfContext->fGraphics State.fCurPosY));
905 857
906 return kOK_PdfResult; 858 return kOK_PdfResult;
907 } 859 }
908 860
909 PdfResult PdfOp_c(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 861 static PdfResult PdfOp_c(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
910 if (pdfContext->fGraphicsState.fPathClosed) { 862 if (pdfContext->fGraphicsState.fPathClosed) {
911 pdfContext->fGraphicsState.fPath.reset(); 863 pdfContext->fGraphicsState.fPath.reset();
912 pdfContext->fGraphicsState.fPathClosed = false; 864 pdfContext->fGraphicsState.fPathClosed = false;
913 } 865 }
914 866
915 double y3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 867 double y3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
916 double x3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 868 double x3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
917 double y2 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 869 double y2 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
918 double x2 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 870 double x2 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
919 double y1 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 871 double y1 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
920 double x1 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 872 double x1 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
921 873
922 pdfContext->fGraphicsState.fPath.cubicTo(SkDoubleToScalar(x1), SkDoubleToSca lar(y1), 874 pdfContext->fGraphicsState.fPath.cubicTo(SkDoubleToScalar(x1), SkDoubleToSca lar(y1),
923 SkDoubleToScalar(x2), SkDoubleToScal ar(y2), 875 SkDoubleToScalar(x2), SkDoubleToScal ar(y2),
924 SkDoubleToScalar(x3), SkDoubleToScal ar(y3)); 876 SkDoubleToScalar(x3), SkDoubleToScal ar(y3));
925 877
926 pdfContext->fGraphicsState.fCurPosX = x3; 878 pdfContext->fGraphicsState.fCurPosX = x3;
927 pdfContext->fGraphicsState.fCurPosY = y3; 879 pdfContext->fGraphicsState.fCurPosY = y3;
928 880
929 return kOK_PdfResult; 881 return kOK_PdfResult;
930 } 882 }
931 883
932 PdfResult PdfOp_v(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 884 static PdfResult PdfOp_v(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
933 if (pdfContext->fGraphicsState.fPathClosed) { 885 if (pdfContext->fGraphicsState.fPathClosed) {
934 pdfContext->fGraphicsState.fPath.reset(); 886 pdfContext->fGraphicsState.fPath.reset();
935 pdfContext->fGraphicsState.fPathClosed = false; 887 pdfContext->fGraphicsState.fPathClosed = false;
936 } 888 }
937 889
938 double y3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 890 double y3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
939 double x3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 891 double x3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
940 double y2 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 892 double y2 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
941 double x2 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 893 double x2 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
942 double y1 = pdfContext->fGraphicsState.fCurPosY; 894 double y1 = pdfContext->fGraphicsState.fCurPosY;
943 double x1 = pdfContext->fGraphicsState.fCurPosX; 895 double x1 = pdfContext->fGraphicsState.fCurPosX;
944 896
945 pdfContext->fGraphicsState.fPath.cubicTo(SkDoubleToScalar(x1), SkDoubleToSca lar(y1), 897 pdfContext->fGraphicsState.fPath.cubicTo(SkDoubleToScalar(x1), SkDoubleToSca lar(y1),
946 SkDoubleToScalar(x2), SkDoubleToScal ar(y2), 898 SkDoubleToScalar(x2), SkDoubleToScal ar(y2),
947 SkDoubleToScalar(x3), SkDoubleToScal ar(y3)); 899 SkDoubleToScalar(x3), SkDoubleToScal ar(y3));
948 900
949 pdfContext->fGraphicsState.fCurPosX = x3; 901 pdfContext->fGraphicsState.fCurPosX = x3;
950 pdfContext->fGraphicsState.fCurPosY = y3; 902 pdfContext->fGraphicsState.fCurPosY = y3;
951 903
952 return kOK_PdfResult; 904 return kOK_PdfResult;
953 } 905 }
954 906
955 PdfResult PdfOp_y(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 907 static PdfResult PdfOp_y(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
956 if (pdfContext->fGraphicsState.fPathClosed) { 908 if (pdfContext->fGraphicsState.fPathClosed) {
957 pdfContext->fGraphicsState.fPath.reset(); 909 pdfContext->fGraphicsState.fPath.reset();
958 pdfContext->fGraphicsState.fPathClosed = false; 910 pdfContext->fGraphicsState.fPathClosed = false;
959 } 911 }
960 912
961 double y3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 913 double y3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
962 double x3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 914 double x3 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
963 double y2 = pdfContext->fGraphicsState.fCurPosY; 915 double y2 = pdfContext->fGraphicsState.fCurPosY;
964 double x2 = pdfContext->fGraphicsState.fCurPosX; 916 double x2 = pdfContext->fGraphicsState.fCurPosX;
965 double y1 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 917 double y1 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
966 double x1 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 918 double x1 = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
967 919
968 pdfContext->fGraphicsState.fPath.cubicTo(SkDoubleToScalar(x1), SkDoubleToSca lar(y1), 920 pdfContext->fGraphicsState.fPath.cubicTo(SkDoubleToScalar(x1), SkDoubleToSca lar(y1),
969 SkDoubleToScalar(x2), SkDoubleToScal ar(y2), 921 SkDoubleToScalar(x2), SkDoubleToScal ar(y2),
970 SkDoubleToScalar(x3), SkDoubleToScal ar(y3)); 922 SkDoubleToScalar(x3), SkDoubleToScal ar(y3));
971 923
972 pdfContext->fGraphicsState.fCurPosX = x3; 924 pdfContext->fGraphicsState.fCurPosX = x3;
973 pdfContext->fGraphicsState.fCurPosY = y3; 925 pdfContext->fGraphicsState.fCurPosY = y3;
974 926
975 return kOK_PdfResult; 927 return kOK_PdfResult;
976 } 928 }
977 929
978 PdfResult PdfOp_re(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 930 static PdfResult PdfOp_re(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
979 if (pdfContext->fGraphicsState.fPathClosed) { 931 if (pdfContext->fGraphicsState.fPathClosed) {
980 pdfContext->fGraphicsState.fPath.reset(); 932 pdfContext->fGraphicsState.fPath.reset();
981 pdfContext->fGraphicsState.fPathClosed = false; 933 pdfContext->fGraphicsState.fPathClosed = false;
982 } 934 }
983 935
984 double height = pdfContext->fObjectStack.top()->numberValue(); pdfConte xt->fObjectStack.pop(); 936 double height = pdfContext->fObjectStack.top()->numberValue(); pdfConte xt->fObjectStack.pop();
985 double width = pdfContext->fObjectStack.top()->numberValue(); pdfConte xt->fObjectStack.pop(); 937 double width = pdfContext->fObjectStack.top()->numberValue(); pdfConte xt->fObjectStack.pop();
986 double y = pdfContext->fObjectStack.top()->numberValue(); pdfConte xt->fObjectStack.pop(); 938 double y = pdfContext->fObjectStack.top()->numberValue(); pdfConte xt->fObjectStack.pop();
987 double x = pdfContext->fObjectStack.top()->numberValue(); pdfConte xt->fObjectStack.pop(); 939 double x = pdfContext->fObjectStack.top()->numberValue(); pdfConte xt->fObjectStack.pop();
988 940
989 pdfContext->fGraphicsState.fPath.addRect(SkDoubleToScalar(x), SkDoubleToScal ar(y), 941 pdfContext->fGraphicsState.fPath.addRect(SkDoubleToScalar(x), SkDoubleToScal ar(y),
990 SkDoubleToScalar(x + width), SkDouble ToScalar(y + height)); 942 SkDoubleToScalar(x + width), SkDouble ToScalar(y + height));
991 943
992 pdfContext->fGraphicsState.fCurPosX = x; 944 pdfContext->fGraphicsState.fCurPosX = x;
993 pdfContext->fGraphicsState.fCurPosY = y + height; 945 pdfContext->fGraphicsState.fCurPosY = y + height;
994 946
995 return kOK_PdfResult; 947 return kOK_PdfResult;
996 } 948 }
997 949
998 PdfResult PdfOp_h(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 950 static PdfResult PdfOp_h(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
999 pdfContext->fGraphicsState.fPath.close(); 951 pdfContext->fGraphicsState.fPath.close();
1000 return kOK_PdfResult; 952 return kOK_PdfResult;
1001 } 953 }
1002 954
1003 PdfResult PdfOp_fillAndStroke(PdfContext* pdfContext, SkCanvas* canvas, bool fil l, bool stroke, bool close, bool evenOdd) { 955 static PdfResult PdfOp_fillAndStroke(PdfContext* pdfContext, SkCanvas* canvas, b ool fill, bool stroke, bool close, bool evenOdd) {
1004 SkPath path = pdfContext->fGraphicsState.fPath; 956 SkPath path = pdfContext->fGraphicsState.fPath;
1005 957
1006 if (close) { 958 if (close) {
1007 path.close(); 959 path.close();
1008 } 960 }
1009 961
1010 canvas->setMatrix(pdfContext->fGraphicsState.fMatrix); 962 canvas->setMatrix(pdfContext->fGraphicsState.fMatrix);
1011 963
1012 SkPaint paint; 964 SkPaint paint;
1013 965
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 #endif 1002 #endif
1051 } 1003 }
1052 1004
1053 //pdfContext->fGraphicsState.fClipPath.reset(); 1005 //pdfContext->fGraphicsState.fClipPath.reset();
1054 pdfContext->fGraphicsState.fHasClipPathToApply = false; 1006 pdfContext->fGraphicsState.fHasClipPathToApply = false;
1055 1007
1056 return kPartial_PdfResult; 1008 return kPartial_PdfResult;
1057 1009
1058 } 1010 }
1059 1011
1060 PdfResult PdfOp_S(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1012 static PdfResult PdfOp_S(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1061 return PdfOp_fillAndStroke(pdfContext, canvas, false, true, false, false); 1013 return PdfOp_fillAndStroke(pdfContext, canvas, false, true, false, false);
1062 } 1014 }
1063 1015
1064 PdfResult PdfOp_s(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1016 static PdfResult PdfOp_s(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1065 return PdfOp_fillAndStroke(pdfContext, canvas, false, true, true, false); 1017 return PdfOp_fillAndStroke(pdfContext, canvas, false, true, true, false);
1066 } 1018 }
1067 1019
1068 PdfResult PdfOp_F(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1020 static PdfResult PdfOp_F(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1069 return PdfOp_fillAndStroke(pdfContext, canvas, true, false, false, false); 1021 return PdfOp_fillAndStroke(pdfContext, canvas, true, false, false, false);
1070 } 1022 }
1071 1023
1072 PdfResult PdfOp_f(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1024 static PdfResult PdfOp_f(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1073 return PdfOp_fillAndStroke(pdfContext, canvas, true, false, false, false); 1025 return PdfOp_fillAndStroke(pdfContext, canvas, true, false, false, false);
1074 } 1026 }
1075 1027
1076 PdfResult PdfOp_f_star(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper* * looper) { 1028 static PdfResult PdfOp_f_star(PdfContext* pdfContext, SkCanvas* canvas, PdfToken Looper** looper) {
1077 return PdfOp_fillAndStroke(pdfContext, canvas, true, false, false, true); 1029 return PdfOp_fillAndStroke(pdfContext, canvas, true, false, false, true);
1078 } 1030 }
1079 1031
1080 PdfResult PdfOp_B(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1032 static PdfResult PdfOp_B(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1081 return PdfOp_fillAndStroke(pdfContext, canvas, true, true, false, false); 1033 return PdfOp_fillAndStroke(pdfContext, canvas, true, true, false, false);
1082 } 1034 }
1083 1035
1084 PdfResult PdfOp_B_star(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper* * looper) { 1036 static PdfResult PdfOp_B_star(PdfContext* pdfContext, SkCanvas* canvas, PdfToken Looper** looper) {
1085 return PdfOp_fillAndStroke(pdfContext, canvas, true, true, false, true); 1037 return PdfOp_fillAndStroke(pdfContext, canvas, true, true, false, true);
1086 } 1038 }
1087 1039
1088 PdfResult PdfOp_b(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1040 static PdfResult PdfOp_b(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1089 return PdfOp_fillAndStroke(pdfContext, canvas, true, true, true, false); 1041 return PdfOp_fillAndStroke(pdfContext, canvas, true, true, true, false);
1090 } 1042 }
1091 1043
1092 PdfResult PdfOp_b_star(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper* * looper) { 1044 static PdfResult PdfOp_b_star(PdfContext* pdfContext, SkCanvas* canvas, PdfToken Looper** looper) {
1093 return PdfOp_fillAndStroke(pdfContext, canvas, true, true, true, true); 1045 return PdfOp_fillAndStroke(pdfContext, canvas, true, true, true, true);
1094 } 1046 }
1095 1047
1096 PdfResult PdfOp_n(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1048 static PdfResult PdfOp_n(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1097 canvas->setMatrix(pdfContext->fGraphicsState.fMatrix); 1049 canvas->setMatrix(pdfContext->fGraphicsState.fMatrix);
1098 if (pdfContext->fGraphicsState.fHasClipPathToApply) { 1050 if (pdfContext->fGraphicsState.fHasClipPathToApply) {
1099 #ifndef PDF_DEBUG_NO_CLIPING 1051 #ifndef PDF_DEBUG_NO_CLIPING
1100 canvas->clipPath(pdfContext->fGraphicsState.fClipPath, SkRegion::kInters ect_Op, true); 1052 canvas->clipPath(pdfContext->fGraphicsState.fClipPath, SkRegion::kInters ect_Op, true);
1101 #endif 1053 #endif
1102 } 1054 }
1103 1055
1104 //pdfContext->fGraphicsState.fClipPath.reset(); 1056 //pdfContext->fGraphicsState.fClipPath.reset();
1105 pdfContext->fGraphicsState.fHasClipPathToApply = false; 1057 pdfContext->fGraphicsState.fHasClipPathToApply = false;
1106 1058
1107 pdfContext->fGraphicsState.fPathClosed = true; 1059 pdfContext->fGraphicsState.fPathClosed = true;
1108 1060
1109 return kOK_PdfResult; 1061 return kOK_PdfResult;
1110 } 1062 }
1111 1063
1112 PdfResult PdfOp_BT(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1064 static PdfResult PdfOp_BT(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1113 pdfContext->fGraphicsState.fTextBlock = true; 1065 pdfContext->fGraphicsState.fTextBlock = true;
1114 pdfContext->fGraphicsState.fMatrixTm = pdfContext->fGraphicsState.fMatrix; 1066 pdfContext->fGraphicsState.fMatrixTm = pdfContext->fGraphicsState.fMatrix;
1115 pdfContext->fGraphicsState.fMatrixTlm = pdfContext->fGraphicsState.fMatrix; 1067 pdfContext->fGraphicsState.fMatrixTlm = pdfContext->fGraphicsState.fMatrix;
1116 1068
1117 return kPartial_PdfResult; 1069 return kPartial_PdfResult;
1118 } 1070 }
1119 1071
1120 PdfResult PdfOp_ET(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1072 static PdfResult PdfOp_ET(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1121 if (!pdfContext->fGraphicsState.fTextBlock) { 1073 if (!pdfContext->fGraphicsState.fTextBlock) {
1122 return kIgnoreError_PdfResult; 1074 return kIgnoreError_PdfResult;
1123 } 1075 }
1124 // TODO(edisonn): anything else to be done once we are done with draw text? Like restore stack? 1076 // TODO(edisonn): anything else to be done once we are done with draw text? Like restore stack?
1125 return kPartial_PdfResult; 1077 return kPartial_PdfResult;
1126 } 1078 }
1127 1079
1128 //font size Tf Set the text font, Tf 1080 //font size Tf Set the text font, Tf
1129 //, to font and the text font size, Tfs, to size. font is the name of a 1081 //, to font and the text font size, Tfs, to size. font is the name of a
1130 //font resource in the Fontsubdictionary of the current resource dictionary; siz e is 1082 //font resource in the Fontsubdictionary of the current resource dictionary; siz e is
1131 //a number representing a scale factor. There is no initial value for either fon t or 1083 //a number representing a scale factor. There is no initial value for either fon t or
1132 //size; they must be specified explicitly using Tf before any text is shown. 1084 //size; they must be specified explicitly using Tf before any text is shown.
1133 PdfResult PdfOp_Tf(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1085 static PdfResult PdfOp_Tf(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1134 pdfContext->fGraphicsState.fCurFontSize = pdfContext->fObjectStack.top()->nu mberValue(); pdfContext->fObjectStack.pop(); 1086 pdfContext->fGraphicsState.fCurFontSize = pdfContext->fObjectStack.top()->nu mberValue(); pdfContext->fObjectStack.pop();
1135 const char* fontName = pdfContext->fObjectStack.top()->nameValue(); pdfContext->fObjectStack.pop(); 1087 const char* fontName = pdfContext->fObjectStack.top()->nameValue(); pdfContext->fObjectStack.pop();
1136 1088
1137 #ifdef PDF_TRACE 1089 #ifdef PDF_TRACE
1138 printf("font name: %s\n", fontName); 1090 printf("font name: %s\n", fontName);
1139 #endif 1091 #endif
1140 1092
1141 if (pdfContext->fGraphicsState.fResources->Font(pdfContext->fPdfDoc)) { 1093 if (pdfContext->fGraphicsState.fResources->Font(pdfContext->fPdfDoc)) {
1142 SkPdfObject* objFont = pdfContext->fGraphicsState.fResources->Font(pdfCo ntext->fPdfDoc)->get(fontName); 1094 SkPdfObject* objFont = pdfContext->fGraphicsState.fResources->Font(pdfCo ntext->fPdfDoc)->get(fontName);
1143 objFont = pdfContext->fPdfDoc->resolveReference(objFont); 1095 objFont = pdfContext->fPdfDoc->resolveReference(objFont);
1144 if (kNone_SkPdfObjectType == pdfContext->fPdfDoc->mapper()->mapFontDicti onary(objFont)) { 1096 if (kNone_SkPdfObjectType == pdfContext->fPdfDoc->mapper()->mapFontDicti onary(objFont)) {
1145 // TODO(edisonn): try to recover and draw it any way? 1097 // TODO(edisonn): try to recover and draw it any way?
1146 return kIgnoreError_PdfResult; 1098 return kIgnoreError_PdfResult;
1147 } 1099 }
1148 SkPdfFontDictionary* fd = (SkPdfFontDictionary*)objFont; 1100 SkPdfFontDictionary* fd = (SkPdfFontDictionary*)objFont;
1149 1101
1150 SkPdfFont* skfont = SkPdfFont::fontFromPdfDictionary(pdfContext->fPdfDoc , fd); 1102 SkPdfFont* skfont = SkPdfFont::fontFromPdfDictionary(pdfContext->fPdfDoc , fd);
1151 1103
1152 if (skfont) { 1104 if (skfont) {
1153 pdfContext->fGraphicsState.fSkFont = skfont; 1105 pdfContext->fGraphicsState.fSkFont = skfont;
1154 } 1106 }
1155 } 1107 }
1156 return kIgnoreError_PdfResult; 1108 return kIgnoreError_PdfResult;
1157 } 1109 }
1158 1110
1159 PdfResult PdfOp_Tj(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1111 static PdfResult PdfOp_Tj(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1160 if (!pdfContext->fGraphicsState.fTextBlock) { 1112 if (!pdfContext->fGraphicsState.fTextBlock) {
1161 // TODO(edisonn): try to recover and draw it any way? 1113 // TODO(edisonn): try to recover and draw it any way?
1162 return kIgnoreError_PdfResult; 1114 return kIgnoreError_PdfResult;
1163 } 1115 }
1164 1116
1165 PdfResult ret = DrawText(pdfContext, 1117 PdfResult ret = DrawText(pdfContext,
1166 pdfContext->fObjectStack.top(), 1118 pdfContext->fObjectStack.top(),
1167 canvas); 1119 canvas);
1168 pdfContext->fObjectStack.pop(); 1120 pdfContext->fObjectStack.pop();
1169 1121
1170 return ret; 1122 return ret;
1171 } 1123 }
1172 1124
1173 PdfResult PdfOp_quote(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** looper) { 1125 static PdfResult PdfOp_quote(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenL ooper** looper) {
1174 if (!pdfContext->fGraphicsState.fTextBlock) { 1126 if (!pdfContext->fGraphicsState.fTextBlock) {
1175 // TODO(edisonn): try to recover and draw it any way? 1127 // TODO(edisonn): try to recover and draw it any way?
1176 return kIgnoreError_PdfResult; 1128 return kIgnoreError_PdfResult;
1177 } 1129 }
1178 1130
1179 PdfOp_T_star(pdfContext, canvas, looper); 1131 PdfOp_T_star(pdfContext, canvas, looper);
1180 // Do not pop, and push, just transfer the param to Tj 1132 // Do not pop, and push, just transfer the param to Tj
1181 return PdfOp_Tj(pdfContext, canvas, looper); 1133 return PdfOp_Tj(pdfContext, canvas, looper);
1182 } 1134 }
1183 1135
1184 PdfResult PdfOp_doublequote(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLo oper** looper) { 1136 static PdfResult PdfOp_doublequote(PdfContext* pdfContext, SkCanvas* canvas, Pdf TokenLooper** looper) {
1185 if (!pdfContext->fGraphicsState.fTextBlock) { 1137 if (!pdfContext->fGraphicsState.fTextBlock) {
1186 // TODO(edisonn): try to recover and draw it any way? 1138 // TODO(edisonn): try to recover and draw it any way?
1187 return kIgnoreError_PdfResult; 1139 return kIgnoreError_PdfResult;
1188 } 1140 }
1189 1141
1190 SkPdfObject* str = pdfContext->fObjectStack.top(); pdfContext->fObject Stack.pop(); 1142 SkPdfObject* str = pdfContext->fObjectStack.top(); pdfContext->fObject Stack.pop();
1191 SkPdfObject* ac = pdfContext->fObjectStack.top(); pdfContext->fObject Stack.pop(); 1143 SkPdfObject* ac = pdfContext->fObjectStack.top(); pdfContext->fObject Stack.pop();
1192 SkPdfObject* aw = pdfContext->fObjectStack.top(); pdfContext->fObject Stack.pop(); 1144 SkPdfObject* aw = pdfContext->fObjectStack.top(); pdfContext->fObject Stack.pop();
1193 1145
1194 pdfContext->fObjectStack.push(aw); 1146 pdfContext->fObjectStack.push(aw);
1195 PdfOp_Tw(pdfContext, canvas, looper); 1147 PdfOp_Tw(pdfContext, canvas, looper);
1196 1148
1197 pdfContext->fObjectStack.push(ac); 1149 pdfContext->fObjectStack.push(ac);
1198 PdfOp_Tc(pdfContext, canvas, looper); 1150 PdfOp_Tc(pdfContext, canvas, looper);
1199 1151
1200 pdfContext->fObjectStack.push(str); 1152 pdfContext->fObjectStack.push(str);
1201 PdfOp_quote(pdfContext, canvas, looper); 1153 PdfOp_quote(pdfContext, canvas, looper);
1202 1154
1203 return kPartial_PdfResult; 1155 return kPartial_PdfResult;
1204 } 1156 }
1205 1157
1206 PdfResult PdfOp_TJ(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1158 static PdfResult PdfOp_TJ(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1207 if (!pdfContext->fGraphicsState.fTextBlock) { 1159 if (!pdfContext->fGraphicsState.fTextBlock) {
1208 // TODO(edisonn): try to recover and draw it any way? 1160 // TODO(edisonn): try to recover and draw it any way?
1209 return kIgnoreError_PdfResult; 1161 return kIgnoreError_PdfResult;
1210 } 1162 }
1211 1163
1212 SkPdfArray* array = (SkPdfArray*)pdfContext->fObjectStack.top(); 1164 SkPdfArray* array = (SkPdfArray*)pdfContext->fObjectStack.top();
1213 pdfContext->fObjectStack.pop(); 1165 pdfContext->fObjectStack.pop();
1214 1166
1215 if (!array->isArray()) { 1167 if (!array->isArray()) {
1216 return kIgnoreError_PdfResult; 1168 return kIgnoreError_PdfResult;
(...skipping 19 matching lines...) Expand all
1236 SkDoubleToScalar(0), 1188 SkDoubleToScalar(0),
1237 SkDoubleToScalar(0), 1189 SkDoubleToScalar(0),
1238 SkDoubleToScalar(1)); 1190 SkDoubleToScalar(1));
1239 1191
1240 pdfContext->fGraphicsState.fMatrixTm.preConcat(matrix); 1192 pdfContext->fGraphicsState.fMatrixTm.preConcat(matrix);
1241 } 1193 }
1242 } 1194 }
1243 return kPartial_PdfResult; // TODO(edisonn): Implement fully DrawText befor e returing OK. 1195 return kPartial_PdfResult; // TODO(edisonn): Implement fully DrawText befor e returing OK.
1244 } 1196 }
1245 1197
1246 PdfResult PdfOp_CS_cs(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColorOperat or* colorOperator) { 1198 static PdfResult PdfOp_CS_cs(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColo rOperator* colorOperator) {
1247 colorOperator->fColorSpace = pdfContext->fObjectStack.top()->nameValue(); pdfContext->fObjectStack.pop(); 1199 colorOperator->fColorSpace = pdfContext->fObjectStack.top()->nameValue(); pdfContext->fObjectStack.pop();
1248 return kOK_PdfResult; 1200 return kOK_PdfResult;
1249 } 1201 }
1250 1202
1251 PdfResult PdfOp_CS(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1203 static PdfResult PdfOp_CS(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1252 return PdfOp_CS_cs(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking ); 1204 return PdfOp_CS_cs(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking );
1253 } 1205 }
1254 1206
1255 PdfResult PdfOp_cs(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1207 static PdfResult PdfOp_cs(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1256 return PdfOp_CS_cs(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrok ing); 1208 return PdfOp_CS_cs(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrok ing);
1257 } 1209 }
1258 1210
1259 PdfResult PdfOp_SC_sc(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColorOperat or* colorOperator) { 1211 static PdfResult PdfOp_SC_sc(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColo rOperator* colorOperator) {
1260 double c[4]; 1212 double c[4];
1261 // int64_t v[4]; 1213 // int64_t v[4];
1262 1214
1263 int n = GetColorSpaceComponents(colorOperator->fColorSpace); 1215 int n = GetColorSpaceComponents(colorOperator->fColorSpace);
1264 1216
1265 bool doubles = true; 1217 bool doubles = true;
1266 if (strcmp(colorOperator->fColorSpace, "Indexed") == 0) { 1218 if (strcmp(colorOperator->fColorSpace, "Indexed") == 0) {
1267 doubles = false; 1219 doubles = false;
1268 } 1220 }
1269 1221
(...skipping 11 matching lines...) Expand all
1281 1233
1282 // TODO(edisonn): Now, set that color. Only DeviceRGB supported. 1234 // TODO(edisonn): Now, set that color. Only DeviceRGB supported.
1283 // TODO(edisonn): do possible field values to enum at parsing time! 1235 // TODO(edisonn): do possible field values to enum at parsing time!
1284 // TODO(edisonn): support also abreviations /DeviceRGB == /RGB 1236 // TODO(edisonn): support also abreviations /DeviceRGB == /RGB
1285 if (strcmp(colorOperator->fColorSpace, "DeviceRGB") == 0 || strcmp(colorOper ator->fColorSpace, "RGB") == 0) { 1237 if (strcmp(colorOperator->fColorSpace, "DeviceRGB") == 0 || strcmp(colorOper ator->fColorSpace, "RGB") == 0) {
1286 colorOperator->setRGBColor(SkColorSetRGB(255*c[0], 255*c[1], 255*c[2])); 1238 colorOperator->setRGBColor(SkColorSetRGB(255*c[0], 255*c[1], 255*c[2]));
1287 } 1239 }
1288 return kPartial_PdfResult; 1240 return kPartial_PdfResult;
1289 } 1241 }
1290 1242
1291 PdfResult PdfOp_SC(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1243 static PdfResult PdfOp_SC(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1292 return PdfOp_SC_sc(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking ); 1244 return PdfOp_SC_sc(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking );
1293 } 1245 }
1294 1246
1295 PdfResult PdfOp_sc(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1247 static PdfResult PdfOp_sc(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1296 return PdfOp_SC_sc(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrok ing); 1248 return PdfOp_SC_sc(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrok ing);
1297 } 1249 }
1298 1250
1299 PdfResult PdfOp_SCN_scn(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColorOper ator* colorOperator) { 1251 static PdfResult PdfOp_SCN_scn(PdfContext* pdfContext, SkCanvas* canvas, SkPdfCo lorOperator* colorOperator) {
1300 //SkPdfString* name; 1252 //SkPdfString* name;
1301 if (pdfContext->fObjectStack.top()->isName()) { 1253 if (pdfContext->fObjectStack.top()->isName()) {
1302 // TODO(edisonn): get name, pass it 1254 // TODO(edisonn): get name, pass it
1303 pdfContext->fObjectStack.pop(); 1255 pdfContext->fObjectStack.pop();
1304 } 1256 }
1305 1257
1306 // TODO(edisonn): SCN supports more color spaces than SCN. Read and implemen t spec. 1258 // TODO(edisonn): SCN supports more color spaces than SCN. Read and implemen t spec.
1307 PdfOp_SC_sc(pdfContext, canvas, colorOperator); 1259 PdfOp_SC_sc(pdfContext, canvas, colorOperator);
1308 1260
1309 return kPartial_PdfResult; 1261 return kPartial_PdfResult;
1310 } 1262 }
1311 1263
1312 PdfResult PdfOp_SCN(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** l ooper) { 1264 static PdfResult PdfOp_SCN(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoo per** looper) {
1313 return PdfOp_SCN_scn(pdfContext, canvas, &pdfContext->fGraphicsState.fStroki ng); 1265 return PdfOp_SCN_scn(pdfContext, canvas, &pdfContext->fGraphicsState.fStroki ng);
1314 } 1266 }
1315 1267
1316 PdfResult PdfOp_scn(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** l ooper) { 1268 static PdfResult PdfOp_scn(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoo per** looper) {
1317 return PdfOp_SCN_scn(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStr oking); 1269 return PdfOp_SCN_scn(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStr oking);
1318 } 1270 }
1319 1271
1320 PdfResult PdfOp_G_g(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColorOperator * colorOperator) { 1272 static PdfResult PdfOp_G_g(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColorO perator* colorOperator) {
1321 /*double gray = */pdfContext->fObjectStack.top()->numberValue(); pdfCont ext->fObjectStack.pop(); 1273 /*double gray = */pdfContext->fObjectStack.top()->numberValue(); pdfCont ext->fObjectStack.pop();
1322 return kNYI_PdfResult; 1274 return kNYI_PdfResult;
1323 } 1275 }
1324 1276
1325 PdfResult PdfOp_G(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1277 static PdfResult PdfOp_G(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1326 return PdfOp_G_g(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking); 1278 return PdfOp_G_g(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking);
1327 } 1279 }
1328 1280
1329 PdfResult PdfOp_g(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1281 static PdfResult PdfOp_g(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1330 return PdfOp_G_g(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrokin g); 1282 return PdfOp_G_g(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrokin g);
1331 } 1283 }
1332 1284
1333 PdfResult PdfOp_RG_rg(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColorOperat or* colorOperator) { 1285 static PdfResult PdfOp_RG_rg(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColo rOperator* colorOperator) {
1334 double b = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 1286 double b = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
1335 double g = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 1287 double g = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
1336 double r = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop(); 1288 double r = pdfContext->fObjectStack.top()->numberValue(); pdfContext->fO bjectStack.pop();
1337 1289
1338 colorOperator->fColorSpace = "DeviceRGB"; 1290 colorOperator->fColorSpace = "DeviceRGB";
1339 colorOperator->setRGBColor(SkColorSetRGB(255*r, 255*g, 255*b)); 1291 colorOperator->setRGBColor(SkColorSetRGB(255*r, 255*g, 255*b));
1340 return kOK_PdfResult; 1292 return kOK_PdfResult;
1341 } 1293 }
1342 1294
1343 PdfResult PdfOp_RG(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1295 static PdfResult PdfOp_RG(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1344 return PdfOp_RG_rg(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking ); 1296 return PdfOp_RG_rg(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking );
1345 } 1297 }
1346 1298
1347 PdfResult PdfOp_rg(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1299 static PdfResult PdfOp_rg(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1348 return PdfOp_RG_rg(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrok ing); 1300 return PdfOp_RG_rg(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrok ing);
1349 } 1301 }
1350 1302
1351 PdfResult PdfOp_K_k(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColorOperator * colorOperator) { 1303 static PdfResult PdfOp_K_k(PdfContext* pdfContext, SkCanvas* canvas, SkPdfColorO perator* colorOperator) {
1352 // TODO(edisonn): spec has some rules about overprint, implement them. 1304 // TODO(edisonn): spec has some rules about overprint, implement them.
1353 /*double k = */pdfContext->fObjectStack.top()->numberValue(); pdfContext ->fObjectStack.pop(); 1305 /*double k = */pdfContext->fObjectStack.top()->numberValue(); pdfContext ->fObjectStack.pop();
1354 /*double y = */pdfContext->fObjectStack.top()->numberValue(); pdfContext ->fObjectStack.pop(); 1306 /*double y = */pdfContext->fObjectStack.top()->numberValue(); pdfContext ->fObjectStack.pop();
1355 /*double m = */pdfContext->fObjectStack.top()->numberValue(); pdfContext ->fObjectStack.pop(); 1307 /*double m = */pdfContext->fObjectStack.top()->numberValue(); pdfContext ->fObjectStack.pop();
1356 /*double c = */pdfContext->fObjectStack.top()->numberValue(); pdfContext ->fObjectStack.pop(); 1308 /*double c = */pdfContext->fObjectStack.top()->numberValue(); pdfContext ->fObjectStack.pop();
1357 1309
1358 colorOperator->fColorSpace = "DeviceCMYK"; 1310 colorOperator->fColorSpace = "DeviceCMYK";
1359 // TODO(edisonn): Set color. 1311 // TODO(edisonn): Set color.
1360 return kNYI_PdfResult; 1312 return kNYI_PdfResult;
1361 } 1313 }
1362 1314
1363 PdfResult PdfOp_K(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1315 static PdfResult PdfOp_K(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1364 return PdfOp_K_k(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking); 1316 return PdfOp_K_k(pdfContext, canvas, &pdfContext->fGraphicsState.fStroking);
1365 } 1317 }
1366 1318
1367 PdfResult PdfOp_k(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1319 static PdfResult PdfOp_k(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1368 return PdfOp_K_k(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrokin g); 1320 return PdfOp_K_k(pdfContext, canvas, &pdfContext->fGraphicsState.fNonStrokin g);
1369 } 1321 }
1370 1322
1371 PdfResult PdfOp_W(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1323 static PdfResult PdfOp_W(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1372 pdfContext->fGraphicsState.fClipPath = pdfContext->fGraphicsState.fPath; 1324 pdfContext->fGraphicsState.fClipPath = pdfContext->fGraphicsState.fPath;
1373 pdfContext->fGraphicsState.fHasClipPathToApply = true; 1325 pdfContext->fGraphicsState.fHasClipPathToApply = true;
1374 1326
1375 return kOK_PdfResult; 1327 return kOK_PdfResult;
1376 } 1328 }
1377 1329
1378 PdfResult PdfOp_W_star(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper* * looper) { 1330 static PdfResult PdfOp_W_star(PdfContext* pdfContext, SkCanvas* canvas, PdfToken Looper** looper) {
1379 pdfContext->fGraphicsState.fClipPath = pdfContext->fGraphicsState.fPath; 1331 pdfContext->fGraphicsState.fClipPath = pdfContext->fGraphicsState.fPath;
1380 1332
1381 #ifdef PDF_TRACE 1333 #ifdef PDF_TRACE
1382 if (pdfContext->fGraphicsState.fClipPath.isRect(NULL)) { 1334 if (pdfContext->fGraphicsState.fClipPath.isRect(NULL)) {
1383 printf("CLIP IS RECT\n"); 1335 printf("CLIP IS RECT\n");
1384 } 1336 }
1385 #endif 1337 #endif
1386 1338
1387 // TODO(edisonn): there seem to be a bug with clipPath of a rect with even o dd. 1339 // TODO(edisonn): there seem to be a bug with clipPath of a rect with even o dd.
1388 pdfContext->fGraphicsState.fClipPath.setFillType(SkPath::kEvenOdd_FillType); 1340 pdfContext->fGraphicsState.fClipPath.setFillType(SkPath::kEvenOdd_FillType);
1389 pdfContext->fGraphicsState.fHasClipPathToApply = true; 1341 pdfContext->fGraphicsState.fHasClipPathToApply = true;
1390 1342
1391 return kPartial_PdfResult; 1343 return kPartial_PdfResult;
1392 } 1344 }
1393 1345
1394 PdfResult PdfOp_BX(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1346 static PdfResult PdfOp_BX(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1395 *looper = new PdfCompatibilitySectionLooper(); 1347 *looper = new PdfCompatibilitySectionLooper();
1396 return kOK_PdfResult; 1348 return kOK_PdfResult;
1397 } 1349 }
1398 1350
1399 PdfResult PdfOp_EX(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1351 static PdfResult PdfOp_EX(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1400 #ifdef ASSERT_BAD_PDF_OPS 1352 #ifdef ASSERT_BAD_PDF_OPS
1401 SkASSERT(false); // EX must be consumed by PdfCompatibilitySectionLooper, b ut let's 1353 SkASSERT(false); // EX must be consumed by PdfCompatibilitySectionLooper, b ut let's
1402 // have the assert when testing good pdfs. 1354 // have the assert when testing good pdfs.
1403 #endif 1355 #endif
1404 return kIgnoreError_PdfResult; 1356 return kIgnoreError_PdfResult;
1405 } 1357 }
1406 1358
1407 PdfResult PdfOp_BI(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1359 static PdfResult PdfOp_BI(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1408 *looper = new PdfInlineImageLooper(); 1360 *looper = new PdfInlineImageLooper();
1409 return kOK_PdfResult; 1361 return kOK_PdfResult;
1410 } 1362 }
1411 1363
1412 PdfResult PdfOp_ID(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1364 static PdfResult PdfOp_ID(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1413 #ifdef ASSERT_BAD_PDF_OPS 1365 #ifdef ASSERT_BAD_PDF_OPS
1414 SkASSERT(false); // must be processed in inline image looper, but let's 1366 SkASSERT(false); // must be processed in inline image looper, but let's
1415 // have the assert when testing good pdfs. 1367 // have the assert when testing good pdfs.
1416 #endif 1368 #endif
1417 return kIgnoreError_PdfResult; 1369 return kIgnoreError_PdfResult;
1418 } 1370 }
1419 1371
1420 PdfResult PdfOp_EI(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1372 static PdfResult PdfOp_EI(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1421 #ifdef ASSERT_BAD_PDF_OPS 1373 #ifdef ASSERT_BAD_PDF_OPS
1422 SkASSERT(false); // must be processed in inline image looper, but let's 1374 SkASSERT(false); // must be processed in inline image looper, but let's
1423 // have the assert when testing good pdfs. 1375 // have the assert when testing good pdfs.
1424 #endif 1376 #endif
1425 return kIgnoreError_PdfResult; 1377 return kIgnoreError_PdfResult;
1426 } 1378 }
1427 1379
1428 //lineWidth w Set the line width in the graphics state (see “Line Width” on page 152). 1380 //lineWidth w Set the line width in the graphics state (see “Line Width” on page 152).
1429 PdfResult PdfOp_w(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1381 static PdfResult PdfOp_w(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1430 double lineWidth = pdfContext->fObjectStack.top()->numberValue(); pdfCon text->fObjectStack.pop(); 1382 double lineWidth = pdfContext->fObjectStack.top()->numberValue(); pdfCon text->fObjectStack.pop();
1431 pdfContext->fGraphicsState.fLineWidth = lineWidth; 1383 pdfContext->fGraphicsState.fLineWidth = lineWidth;
1432 1384
1433 return kOK_PdfResult; 1385 return kOK_PdfResult;
1434 } 1386 }
1435 1387
1436 //lineCap J Set the line cap style in the graphics state (see “Line Cap Style” o n page 153). 1388 //lineCap J Set the line cap style in the graphics state (see “Line Cap Style” o n page 153).
1437 PdfResult PdfOp_J(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1389 static PdfResult PdfOp_J(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1438 pdfContext->fObjectStack.pop(); 1390 pdfContext->fObjectStack.pop();
1439 //double lineCap = pdfContext->fObjectStack.top()->numberValue(); pdfCon text->fObjectStack.pop(); 1391 //double lineCap = pdfContext->fObjectStack.top()->numberValue(); pdfCon text->fObjectStack.pop();
1440 1392
1441 return kNYI_PdfResult; 1393 return kNYI_PdfResult;
1442 } 1394 }
1443 1395
1444 //lineJoin j Set the line join style in the graphics state (see “Line Join Style ” on page 153). 1396 //lineJoin j Set the line join style in the graphics state (see “Line Join Style ” on page 153).
1445 PdfResult PdfOp_j(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1397 static PdfResult PdfOp_j(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1446 pdfContext->fObjectStack.pop(); 1398 pdfContext->fObjectStack.pop();
1447 //double lineJoin = pdfContext->fObjectStack.top()->numberValue(); pdfCo ntext->fObjectStack.pop(); 1399 //double lineJoin = pdfContext->fObjectStack.top()->numberValue(); pdfCo ntext->fObjectStack.pop();
1448 1400
1449 return kNYI_PdfResult; 1401 return kNYI_PdfResult;
1450 } 1402 }
1451 1403
1452 //miterLimit M Set the miter limit in the graphics state (see “Miter Limit” on p age 153). 1404 //miterLimit M Set the miter limit in the graphics state (see “Miter Limit” on p age 153).
1453 PdfResult PdfOp_M(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1405 static PdfResult PdfOp_M(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1454 pdfContext->fObjectStack.pop(); 1406 pdfContext->fObjectStack.pop();
1455 //double miterLimit = pdfContext->fObjectStack.top()->numberValue(); pdf Context->fObjectStack.pop(); 1407 //double miterLimit = pdfContext->fObjectStack.top()->numberValue(); pdf Context->fObjectStack.pop();
1456 1408
1457 return kNYI_PdfResult; 1409 return kNYI_PdfResult;
1458 } 1410 }
1459 1411
1460 //dashArray dashPhase d Set the line dash pattern in the graphics state (see “Li ne Dash Pattern” on 1412 //dashArray dashPhase d Set the line dash pattern in the graphics state (see “Li ne Dash Pattern” on
1461 //page 155). 1413 //page 155).
1462 PdfResult PdfOp_d(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1414 static PdfResult PdfOp_d(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1463 pdfContext->fObjectStack.pop(); 1415 pdfContext->fObjectStack.pop();
1464 pdfContext->fObjectStack.pop(); 1416 pdfContext->fObjectStack.pop();
1465 1417
1466 return kNYI_PdfResult; 1418 return kNYI_PdfResult;
1467 } 1419 }
1468 1420
1469 //intent ri (PDF 1.1) Set the color rendering intent in the graphics state (see “Rendering Intents” on page 197). 1421 //intent ri (PDF 1.1) Set the color rendering intent in the graphics state (see “Rendering Intents” on page 197).
1470 PdfResult PdfOp_ri(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1422 static PdfResult PdfOp_ri(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1471 pdfContext->fObjectStack.pop(); 1423 pdfContext->fObjectStack.pop();
1472 1424
1473 return kNYI_PdfResult; 1425 return kNYI_PdfResult;
1474 } 1426 }
1475 1427
1476 //flatness i Set the flatness tolerance in the graphics state (see Section 6.5.1, “Flatness 1428 //flatness i Set the flatness tolerance in the graphics state (see Section 6.5.1, “Flatness
1477 //Tolerance”). flatness is a number in the range 0 to 100; a value of 0 speci- 1429 //Tolerance”). flatness is a number in the range 0 to 100; a value of 0 speci-
1478 //fies the output device’s default flatness tolerance. 1430 //fies the output device’s default flatness tolerance.
1479 PdfResult PdfOp_i(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** loo per) { 1431 static PdfResult PdfOp_i(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoope r** looper) {
1480 pdfContext->fObjectStack.pop(); 1432 pdfContext->fObjectStack.pop();
1481 1433
1482 return kNYI_PdfResult; 1434 return kNYI_PdfResult;
1483 } 1435 }
1484 1436
1485 //dictName gs (PDF 1.2) Set the specified parameters in the graphics state. dictN ame is 1437 //dictName gs (PDF 1.2) Set the specified parameters in the graphics state. dictN ame is
1486 //the name of a graphics state parameter dictionary in the ExtGState subdictiona ry of the current resource dictionary (see the next section). 1438 //the name of a graphics state parameter dictionary in the ExtGState subdictiona ry of the current resource dictionary (see the next section).
1487 PdfResult PdfOp_gs(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1439 static PdfResult PdfOp_gs(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1488 const char* name = pdfContext->fObjectStack.top()->nameValue(); pdfContex t->fObjectStack.pop(); 1440 const char* name = pdfContext->fObjectStack.top()->nameValue(); pdfContex t->fObjectStack.pop();
1489 1441
1490 #ifdef PDF_TRACE 1442 #ifdef PDF_TRACE
1491 std::string str; 1443 std::string str;
1492 #endif 1444 #endif
1493 1445
1494 //Next, get the ExtGState Dictionary from the Resource Dictionary: 1446 //Next, get the ExtGState Dictionary from the Resource Dictionary:
1495 SkPdfDictionary* extGStateDictionary = pdfContext->fGraphicsState.fResources ->ExtGState(pdfContext->fPdfDoc); 1447 SkPdfDictionary* extGStateDictionary = pdfContext->fGraphicsState.fResources ->ExtGState(pdfContext->fPdfDoc);
1496 1448
1497 if (extGStateDictionary == NULL) { 1449 if (extGStateDictionary == NULL) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 PdfResult PdfOp_Tw(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1498 PdfResult PdfOp_Tw(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) {
1547 double wordSpace = pdfContext->fObjectStack.top()->numberValue(); pdfCon text->fObjectStack.pop(); 1499 double wordSpace = pdfContext->fObjectStack.top()->numberValue(); pdfCon text->fObjectStack.pop();
1548 pdfContext->fGraphicsState.fWordSpace = wordSpace; 1500 pdfContext->fGraphicsState.fWordSpace = wordSpace;
1549 1501
1550 return kOK_PdfResult; 1502 return kOK_PdfResult;
1551 } 1503 }
1552 1504
1553 //scale Tz Set the horizontal scaling, Th 1505 //scale Tz Set the horizontal scaling, Th
1554 //, to (scale ˜ 100). scale is a number specifying the 1506 //, to (scale ˜ 100). scale is a number specifying the
1555 //percentage of the normal width. Initial value: 100 (normal width). 1507 //percentage of the normal width. Initial value: 100 (normal width).
1556 PdfResult PdfOp_Tz(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1508 static PdfResult PdfOp_Tz(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1557 /*double scale = */pdfContext->fObjectStack.top()->numberValue(); pdfCon text->fObjectStack.pop(); 1509 /*double scale = */pdfContext->fObjectStack.top()->numberValue(); pdfCon text->fObjectStack.pop();
1558 1510
1559 return kNYI_PdfResult; 1511 return kNYI_PdfResult;
1560 } 1512 }
1561 1513
1562 //render Tr Set the text rendering mode, T 1514 //render Tr Set the text rendering mode, T
1563 //mode, to render, which is an integer. Initial value: 0. 1515 //mode, to render, which is an integer. Initial value: 0.
1564 PdfResult PdfOp_Tr(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1516 static PdfResult PdfOp_Tr(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1565 /*double render = */pdfContext->fObjectStack.top()->numberValue(); pdfCo ntext->fObjectStack.pop(); 1517 /*double render = */pdfContext->fObjectStack.top()->numberValue(); pdfCo ntext->fObjectStack.pop();
1566 1518
1567 return kNYI_PdfResult; 1519 return kNYI_PdfResult;
1568 } 1520 }
1569 //rise Ts Set the text rise, Trise, to rise, which is a number expressed in unsc aled text space 1521 //rise Ts Set the text rise, Trise, to rise, which is a number expressed in unsc aled text space
1570 //units. Initial value: 0. 1522 //units. Initial value: 0.
1571 PdfResult PdfOp_Ts(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1523 static PdfResult PdfOp_Ts(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1572 /*double rise = */pdfContext->fObjectStack.top()->numberValue(); pdfCont ext->fObjectStack.pop(); 1524 /*double rise = */pdfContext->fObjectStack.top()->numberValue(); pdfCont ext->fObjectStack.pop();
1573 1525
1574 return kNYI_PdfResult; 1526 return kNYI_PdfResult;
1575 } 1527 }
1576 1528
1577 //wx wy d0 1529 //wx wy d0
1578 PdfResult PdfOp_d0(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1530 static PdfResult PdfOp_d0(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1579 pdfContext->fObjectStack.pop(); 1531 pdfContext->fObjectStack.pop();
1580 pdfContext->fObjectStack.pop(); 1532 pdfContext->fObjectStack.pop();
1581 1533
1582 return kNYI_PdfResult; 1534 return kNYI_PdfResult;
1583 } 1535 }
1584 1536
1585 //wx wy llx lly urx ury d1 1537 //wx wy llx lly urx ury d1
1586 PdfResult PdfOp_d1(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1538 static PdfResult PdfOp_d1(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1587 pdfContext->fObjectStack.pop(); 1539 pdfContext->fObjectStack.pop();
1588 pdfContext->fObjectStack.pop(); 1540 pdfContext->fObjectStack.pop();
1589 pdfContext->fObjectStack.pop(); 1541 pdfContext->fObjectStack.pop();
1590 pdfContext->fObjectStack.pop(); 1542 pdfContext->fObjectStack.pop();
1591 pdfContext->fObjectStack.pop(); 1543 pdfContext->fObjectStack.pop();
1592 pdfContext->fObjectStack.pop(); 1544 pdfContext->fObjectStack.pop();
1593 1545
1594 return kNYI_PdfResult; 1546 return kNYI_PdfResult;
1595 } 1547 }
1596 1548
1597 //name sh 1549 //name sh
1598 PdfResult PdfOp_sh(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1550 static PdfResult PdfOp_sh(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1599 pdfContext->fObjectStack.pop(); 1551 pdfContext->fObjectStack.pop();
1600 1552
1601 return kNYI_PdfResult; 1553 return kNYI_PdfResult;
1602 } 1554 }
1603 1555
1604 //name Do 1556 //name Do
1605 PdfResult PdfOp_Do(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1557 static PdfResult PdfOp_Do(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1606 const char* name = pdfContext->fObjectStack.top()->nameValue(); pdfContex t->fObjectStack.pop(); 1558 const char* name = pdfContext->fObjectStack.top()->nameValue(); pdfContex t->fObjectStack.pop();
1607 1559
1608 SkPdfDictionary* xObject = pdfContext->fGraphicsState.fResources->XObject(p dfContext->fPdfDoc); 1560 SkPdfDictionary* xObject = pdfContext->fGraphicsState.fResources->XObject(p dfContext->fPdfDoc);
1609 1561
1610 if (xObject == NULL) { 1562 if (xObject == NULL) {
1611 #ifdef PDF_TRACE 1563 #ifdef PDF_TRACE
1612 printf("XObject is NULL!\n"); 1564 printf("XObject is NULL!\n");
1613 #endif 1565 #endif
1614 return kIgnoreError_PdfResult; 1566 return kIgnoreError_PdfResult;
1615 } 1567 }
1616 1568
1617 SkPdfObject* value = xObject->get(name); 1569 SkPdfObject* value = xObject->get(name);
1618 value = pdfContext->fPdfDoc->resolveReference(value); 1570 value = pdfContext->fPdfDoc->resolveReference(value);
1619 1571
1620 #ifdef PDF_TRACE 1572 #ifdef PDF_TRACE
1621 // value->ToString(str); 1573 // value->ToString(str);
1622 // printf("Do object value: %s\n", str); 1574 // printf("Do object value: %s\n", str);
1623 #endif 1575 #endif
1624 1576
1625 return doXObject(pdfContext, canvas, value); 1577 return doXObject(pdfContext, canvas, value);
1626 } 1578 }
1627 1579
1628 //tag MP Designate a marked-content point. tag is a name object indicating the r ole or 1580 //tag MP Designate a marked-content point. tag is a name object indicating the r ole or
1629 //significance of the point. 1581 //significance of the point.
1630 PdfResult PdfOp_MP(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1582 static PdfResult PdfOp_MP(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1631 pdfContext->fObjectStack.pop(); 1583 pdfContext->fObjectStack.pop();
1632 1584
1633 return kNYI_PdfResult; 1585 return kNYI_PdfResult;
1634 } 1586 }
1635 1587
1636 //tag properties DP Designate a marked-content point with an associated property list. tag is a 1588 //tag properties DP Designate a marked-content point with an associated property list. tag is a
1637 //name object indicating the role or significance of the point; properties is 1589 //name object indicating the role or significance of the point; properties is
1638 //either an inline dictionary containing the property list or a name object 1590 //either an inline dictionary containing the property list or a name object
1639 //associated with it in the Properties subdictionary of the current resource 1591 //associated with it in the Properties subdictionary of the current resource
1640 //dictionary (see Section 9.5.1, “Property Lists”). 1592 //dictionary (see Section 9.5.1, “Property Lists”).
1641 PdfResult PdfOp_DP(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** lo oper) { 1593 static PdfResult PdfOp_DP(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoop er** looper) {
1642 pdfContext->fObjectStack.pop(); 1594 pdfContext->fObjectStack.pop();
1643 pdfContext->fObjectStack.pop(); 1595 pdfContext->fObjectStack.pop();
1644 1596
1645 return kNYI_PdfResult; 1597 return kNYI_PdfResult;
1646 } 1598 }
1647 1599
1648 //tag BMC Begin a marked-content sequence terminated by a balancing EMC operator . 1600 //tag BMC Begin a marked-content sequence terminated by a balancing EMC operator .
1649 //tag is a name object indicating the role or significance of the sequence. 1601 //tag is a name object indicating the role or significance of the sequence.
1650 PdfResult PdfOp_BMC(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** l ooper) { 1602 static PdfResult PdfOp_BMC(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoo per** looper) {
1651 pdfContext->fObjectStack.pop(); 1603 pdfContext->fObjectStack.pop();
1652 1604
1653 return kNYI_PdfResult; 1605 return kNYI_PdfResult;
1654 } 1606 }
1655 1607
1656 //tag properties BDC Begin a marked-content sequence with an associated property list, terminated 1608 //tag properties BDC Begin a marked-content sequence with an associated property list, terminated
1657 //by a balancing EMCoperator. tag is a name object indicating the role or signif icance of the sequence; propertiesis either an inline dictionary containing the 1609 //by a balancing EMCoperator. tag is a name object indicating the role or signif icance of the sequence; propertiesis either an inline dictionary containing the
1658 //property list or a name object associated with it in the Properties subdiction ary of the current resource dictionary (see Section 9.5.1, “Property Lists”). 1610 //property list or a name object associated with it in the Properties subdiction ary of the current resource dictionary (see Section 9.5.1, “Property Lists”).
1659 PdfResult PdfOp_BDC(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** l ooper) { 1611 static PdfResult PdfOp_BDC(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoo per** looper) {
1660 pdfContext->fObjectStack.pop(); 1612 pdfContext->fObjectStack.pop();
1661 pdfContext->fObjectStack.pop(); 1613 pdfContext->fObjectStack.pop();
1662 1614
1663 return kNYI_PdfResult; 1615 return kNYI_PdfResult;
1664 } 1616 }
1665 1617
1666 //— EMC End a marked-content sequence begun by a BMC or BDC operator. 1618 //— EMC End a marked-content sequence begun by a BMC or BDC operator.
1667 PdfResult PdfOp_EMC(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** l ooper) { 1619 static PdfResult PdfOp_EMC(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLoo per** looper) {
1668 return kNYI_PdfResult; 1620 return kNYI_PdfResult;
1669 } 1621 }
1670 1622
1671 void initPdfOperatorRenderes() { 1623 static void initPdfOperatorRenderes() {
1672 static bool gInitialized = false; 1624 static bool gInitialized = false;
1673 if (gInitialized) { 1625 if (gInitialized) {
1674 return; 1626 return;
1675 } 1627 }
1676 1628
1677 gPdfOps["q"] = PdfOp_q; 1629 gPdfOps["q"] = PdfOp_q;
1678 gPdfOps["Q"] = PdfOp_Q; 1630 gPdfOps["Q"] = PdfOp_Q;
1679 gPdfOps["cm"] = PdfOp_cm; 1631 gPdfOps["cm"] = PdfOp_cm;
1680 1632
1681 gPdfOps["TD"] = PdfOp_TD; 1633 gPdfOps["TD"] = PdfOp_TD;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 out[out.size() - 2] = 'n'; 1900 out[out.size() - 2] = 'n';
1949 out[out.size() - 1] = 'g'; 1901 out[out.size() - 1] = 'g';
1950 } 1902 }
1951 SkImageEncoder::EncodeFile(out.c_str(), bitmap, SkImageEncoder::kPNG _Type, 100); 1903 SkImageEncoder::EncodeFile(out.c_str(), bitmap, SkImageEncoder::kPNG _Type, 100);
1952 } 1904 }
1953 return true; 1905 return true;
1954 } 1906 }
1955 1907
1956 return true; 1908 return true;
1957 } 1909 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkPdfParser.h ('k') | experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698