| 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 #include "SkTDStackNester.h" | |
| 16 | 15 |
| 17 class SkPdfAllocator; | |
| 18 class SkPdfFont; | 16 class SkPdfFont; |
| 19 class SkPdfDoc; | |
| 20 class SkPdfNativeDoc; | |
| 21 class SkPdfNativeObject; | 17 class SkPdfNativeObject; |
| 22 class SkPdfResourceDictionary; | 18 class SkPdfResourceDictionary; |
| 23 class SkPdfSoftMaskDictionary; | 19 class SkPdfSoftMaskDictionary; |
| 24 | 20 |
| 25 /** \class SkPdfColorOperator | 21 /** \class SkPdfColorOperator |
| 26 * Operates on stroking or non-stroking properties. | 22 * Operates on stroking or non-stroking properties. |
| 27 */ | 23 */ |
| 28 class SkPdfColorOperator { | 24 class SkPdfColorOperator { |
| 29 | 25 |
| 30 /* | 26 /* |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 fColorSpace.fBuffer = (const unsigned char*)"Pattern"; | 69 fColorSpace.fBuffer = (const unsigned char*)"Pattern"; |
| 74 fColorSpace.fBytes = 7; // strlen("Pattern") | 70 fColorSpace.fBytes = 7; // strlen("Pattern") |
| 75 fPattern = pattern; | 71 fPattern = pattern; |
| 76 } | 72 } |
| 77 | 73 |
| 78 void applyGraphicsState(SkPaint* paint) { | 74 void applyGraphicsState(SkPaint* paint) { |
| 79 paint->setColor(SkColorSetA(fColor, (U8CPU)(fOpacity * 255))); | 75 paint->setColor(SkColorSetA(fColor, (U8CPU)(fOpacity * 255))); |
| 80 } | 76 } |
| 81 }; | 77 }; |
| 82 | 78 |
| 83 /** \class SkTDStackNester | 79 /** |
| 84 * Operates on stroking or non-stroking properties. | 80 * Operates on stroking or non-stroking properties. |
| 85 */ | 81 */ |
| 86 struct SkPdfGraphicsState { | 82 struct SkPdfGraphicsState { |
| 87 // TODO(edisonn): deprecate and remove these! | 83 // TODO(edisonn): deprecate and remove these! |
| 88 double fCurPosX; | 84 double fCurPosX; |
| 89 double fCurPosY; | 85 double fCurPosY; |
| 90 | 86 |
| 91 double fCurFontSize; | 87 double fCurFontSize; |
| 92 bool fTextBlock; | 88 bool fTextBlock; |
| 93 SkPdfFont* fSkFont; | 89 SkPdfFont* fSkFont; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 fDashPhase = 0; | 344 fDashPhase = 0; |
| 349 fBlendModesLength = 1; | 345 fBlendModesLength = 1; |
| 350 fBlendModes[0] = SkXfermode::kSrc_Mode; // PDF: Normal Blend mode | 346 fBlendModes[0] = SkXfermode::kSrc_Mode; // PDF: Normal Blend mode |
| 351 fSMask = NULL; | 347 fSMask = NULL; |
| 352 } | 348 } |
| 353 | 349 |
| 354 // TODO(edisonn): make two functions instead, stroking and non stoking, avoi
d branching | 350 // TODO(edisonn): make two functions instead, stroking and non stoking, avoi
d branching |
| 355 void applyGraphicsState(SkPaint* paint, bool stroking); | 351 void applyGraphicsState(SkPaint* paint, bool stroking); |
| 356 }; | 352 }; |
| 357 | 353 |
| 358 /** \class SkPdfContext | |
| 359 * The context of the drawing. The document we draw from, the current stack of
objects, ... | |
| 360 */ | |
| 361 class SkPdfContext { | |
| 362 public: | |
| 363 SkTDStackNester<SkPdfNativeObject*> fObjectStack; | |
| 364 SkTDStackNester<SkPdfGraphicsState> fStateStack; | |
| 365 SkPdfGraphicsState fGraphicsState; | |
| 366 SkPdfNativeDoc* fPdfDoc; | |
| 367 SkPdfAllocator* fTmpPageAllocator; | |
| 368 SkMatrix fOriginalMatrix; | |
| 369 | |
| 370 SkPdfContext(SkPdfNativeDoc* doc); | |
| 371 ~SkPdfContext(); | |
| 372 }; | |
| 373 | |
| 374 #endif // SkPdfGraphicsState_DEFINED | 354 #endif // SkPdfGraphicsState_DEFINED |
| OLD | NEW |