OLD | NEW |
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 #ifndef SkPdfGraphicsState_DEFINED | 8 #ifndef SkPdfGraphicsState_DEFINED |
9 #define SkPdfGraphicsState_DEFINED | 9 #define SkPdfGraphicsState_DEFINED |
10 | 10 |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 #include "SkPdfConfig.h" | 13 #include "SkPdfConfig.h" |
14 #include "SkPdfUtils.h" | 14 #include "SkPdfUtils.h" |
15 | 15 |
16 //#include "SkTDStack.h" | |
17 | |
18 class SkPdfFont; | 16 class SkPdfFont; |
19 class SkPdfDoc; | 17 class SkPdfDoc; |
20 class SkPdfNativeObject; | 18 class SkPdfNativeObject; |
21 class SkPdfResourceDictionary; | 19 class SkPdfResourceDictionary; |
22 class SkPdfSoftMaskDictionary; | 20 class SkPdfSoftMaskDictionary; |
23 | 21 |
24 class SkPdfNativeDoc; | 22 class SkPdfNativeDoc; |
25 class SkPdfAllocator; | 23 class SkPdfAllocator; |
26 | 24 |
27 // TODO(edisonn): move this class in include/core? | 25 // TODO(edisonn): move this class in include/core? |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 dered on the output device (see Sectio
n 6.5.2, “Smoothness Toler- | 452 dered on the output device (see Sectio
n 6.5.2, “Smoothness Toler- |
455 ance”). The value of this parameter gi
ves the maximum error | 453 ance”). The value of this parameter gi
ves the maximum error |
456 tolerance, expressed as a fraction of
the range of each color compo- | 454 tolerance, expressed as a fraction of
the range of each color compo- |
457 nent; smaller numbers give smoother co
lor transitions at the | 455 nent; smaller numbers give smoother co
lor transitions at the |
458 expense of more computation and memory
use. Initial value: | 456 expense of more computation and memory
use. Initial value: |
459 installation-dependent. | 457 installation-dependent. |
460 */ | 458 */ |
461 | 459 |
462 | 460 |
463 | 461 |
464 | 462 // TODO(edisonn): some defaults are contextual, they could on colorspace, pd
f version, ... |
465 | |
466 | |
467 | 463 |
468 SkPdfGraphicsState() { | 464 SkPdfGraphicsState() { |
469 fCurPosX = 0.0; | 465 fCurPosX = 0.0; |
470 fCurPosY = 0.0; | 466 fCurPosY = 0.0; |
471 fCurFontSize = 0.0; | 467 fCurFontSize = 0.0; |
472 fTextBlock = false; | 468 fTextBlock = false; |
473 fCTM = SkMatrix::I(); | 469 fCTM = SkMatrix::I(); |
474 fMatrixTm = SkMatrix::I(); | 470 fMatrixTm = SkMatrix::I(); |
475 fMatrixTlm = SkMatrix::I(); | 471 fMatrixTlm = SkMatrix::I(); |
476 fPathClosed = true; | 472 fPathClosed = true; |
477 fLineWidth = 0; | 473 fLineWidth = 0; |
478 fTextLeading = 0; | 474 fTextLeading = 0; |
479 fWordSpace = 0; | 475 fWordSpace = 0; |
480 fCharSpace = 0; | 476 fCharSpace = 0; |
481 fHasClipPathToApply = false; | 477 fHasClipPathToApply = false; |
482 fResources = NULL; | 478 fResources = NULL; |
483 fSkFont = NULL; | 479 fSkFont = NULL; |
484 fLineCap = 0; | 480 fLineCap = 0; |
485 fLineJoin = 0; | 481 fLineJoin = 0; |
486 fMiterLimit = 10.0; | 482 fMiterLimit = 10.0; |
487 fAphaConstant = 1.0; | 483 fAphaConstant = 1.0; |
488 fAlphaSource = false; | 484 fAlphaSource = false; |
489 fDashArrayLength = 0; | 485 fDashArrayLength = 0; |
490 fDashPhase = 0; | 486 fDashPhase = 0; |
491 fBlendModesLength = 1; | 487 fBlendModesLength = 1; |
492 fBlendModes[0] = SkXfermode::kSrc_Mode; // PDF: Normal Blend mode | 488 fBlendModes[0] = SkXfermode::kSrc_Mode; // PDF: Normal Blend mode |
493 fSMask = NULL; | 489 fSMask = NULL; |
494 } | 490 } |
495 | 491 |
496 // TODO(edisonn): make two functons instead, stroking and non stoking, avoid
branching | 492 // TODO(edisonn): make two functions instead, stroking and non stoking, avoi
d branching |
497 void applyGraphicsState(SkPaint* paint, bool stroking); | 493 void applyGraphicsState(SkPaint* paint, bool stroking); |
498 }; | 494 }; |
499 | 495 |
500 // TODO(edisonn): better class design. | |
501 // TODO(edisonn): rename to SkPdfContext | |
502 class SkPdfContext { | 496 class SkPdfContext { |
503 public: | 497 public: |
504 SkTDStackNew<SkPdfNativeObject*> fObjectStack; | 498 SkTDStackNew<SkPdfNativeObject*> fObjectStack; |
505 SkTDStackNew<SkPdfGraphicsState> fStateStack; | 499 SkTDStackNew<SkPdfGraphicsState> fStateStack; |
506 SkPdfGraphicsState fGraphicsState; | 500 SkPdfGraphicsState fGraphicsState; |
507 SkPdfNativeDoc* fPdfDoc; | 501 SkPdfNativeDoc* fPdfDoc; |
508 // TODO(edisonn): the allocator, could be freed after the page is done drawi
ng. | 502 // TODO(edisonn): the allocator, could be freed after the page is done drawi
ng, so we have the |
| 503 // pixels on the screen asap. |
509 SkPdfAllocator* fTmpPageAllocator; | 504 SkPdfAllocator* fTmpPageAllocator; |
510 SkMatrix fOriginalMatrix; | 505 SkMatrix fOriginalMatrix; |
511 | 506 |
512 SkPdfContext(SkPdfNativeDoc* doc); | 507 SkPdfContext(SkPdfNativeDoc* doc); |
513 ~SkPdfContext(); | 508 ~SkPdfContext(); |
514 }; | 509 }; |
515 | 510 |
516 #endif // SkPdfGraphicsState_DEFINED | 511 #endif // SkPdfGraphicsState_DEFINED |
OLD | NEW |