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

Side by Side Diff: experimental/PdfViewer/SkPdfBasics.h

Issue 21919003: pdfviewer: implementation of one type of pattern - simple tile patern, colored, with xstep and yste… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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 #ifndef __DEFINED__SkPdfBasics 1 #ifndef __DEFINED__SkPdfBasics
2 #define __DEFINED__SkPdfBasics 2 #define __DEFINED__SkPdfBasics
3 3
4 #include "SkCanvas.h" 4 #include "SkCanvas.h"
5 #include "SkPaint.h" 5 #include "SkPaint.h"
6 #include "SkPdfConfig.h" 6 #include "SkPdfConfig.h"
7 7
8 #include <iostream> 8 #include <iostream>
9 #include <cstdio> 9 #include <cstdio>
10 #include <map> 10 #include <map>
11 #include <stack> 11 #include <stack>
12 12
13 class SkPdfFont; 13 class SkPdfFont;
14 class SkPdfDoc; 14 class SkPdfDoc;
15 class SkPdfObject; 15 class SkPdfObject;
16 class SkPdfResourceDictionary; 16 class SkPdfResourceDictionary;
17 class SkPdfSoftMaskDictionary; 17 class SkPdfSoftMaskDictionary;
18 18
19 class SkNativeParsedPDF; 19 class SkNativeParsedPDF;
20 class SkPdfAllocator; 20 class SkPdfAllocator;
21 21
22 // TODO(edisonn): better class design. 22 // TODO(edisonn): better class design.
23 struct SkPdfColorOperator { 23 class SkPdfColorOperator {
24 24
25 /* 25 /*
26 color space name or array The current color space in which color value s are to be interpreted 26 color space name or array The current color space in which color value s are to be interpreted
27 (see Section 4.5, “Color Spaces”). There are two separate color space 27 (see Section 4.5, “Color Spaces”). There are two separate color space
28 parameters: one for stroking and one for all other painting opera- 28 parameters: one for stroking and one for all other painting opera-
29 tions. Initial value: DeviceGray. 29 tions. Initial value: DeviceGray.
30 */ 30 */
31 31
32 // TODO(edisonn): implement the array part too 32 // TODO(edisonn): implement the array part too
33 // does not own the char* 33 // does not own the char*
34 // TODO(edisonn): remove this public, let fields be private
35 // TODO(edisonn): make color space an enum!
36 public:
34 NotOwnedString fColorSpace; 37 NotOwnedString fColorSpace;
35 38 SkPdfObject* fPattern;
36 39
37 /* 40 /*
38 color (various) The current color to be used during painting operations (see Section 41 color (various) The current color to be used during painting operations (see Section
39 4.5, “Color Spaces”). The type and interpret ation of this parameter 42 4.5, “Color Spaces”). The type and interpret ation of this parameter
40 depend on the current color space; for most color spaces, a color 43 depend on the current color space; for most color spaces, a color
41 value consists of one to four numbers. There are two separate color 44 value consists of one to four numbers. There are two separate color
42 parameters: one for stroking and one for all other painting opera- 45 parameters: one for stroking and one for all other painting opera-
43 tions. Initial value: black. 46 tions. Initial value: black.
44 */ 47 */
45 48
46 SkColor fColor; 49 SkColor fColor;
47 double fOpacity; // ca or CA 50 double fOpacity; // ca or CA
51
48 // TODO(edisonn): add here other color space options. 52 // TODO(edisonn): add here other color space options.
49 53
54 public:
50 void setRGBColor(SkColor color) { 55 void setRGBColor(SkColor color) {
51 // TODO(edisonn): ASSERT DeviceRGB is the color space. 56 // TODO(edisonn): ASSERT DeviceRGB is the color space.
57 fPattern = NULL;
52 fColor = color; 58 fColor = color;
53 } 59 }
54 // TODO(edisonn): double check the default values for all fields. 60 // TODO(edisonn): double check the default values for all fields.
55 SkPdfColorOperator() : fColor(SK_ColorBLACK), fOpacity(1) { 61 SkPdfColorOperator() : fPattern(NULL), fColor(SK_ColorBLACK), fOpacity(1) {
56 NotOwnedString::init(&fColorSpace); 62 NotOwnedString::init(&fColorSpace, "DeviceRGB");
63 }
64
65 void setColorSpace(NotOwnedString* colorSpace) {
66 fColorSpace = *colorSpace;
67 fPattern = NULL;
68 }
69
70 void setPatternColorSpace(SkPdfObject* pattern) {
71 fColorSpace.fBuffer = (const unsigned char*)"Pattern";
72 fColorSpace.fBytes = 7; // strlen("Pattern")
73 fPattern = pattern;
57 } 74 }
58 75
59 void applyGraphicsState(SkPaint* paint) { 76 void applyGraphicsState(SkPaint* paint) {
60 paint->setColor(SkColorSetA(fColor, (U8CPU)(fOpacity * 255))); 77 paint->setColor(SkColorSetA(fColor, (U8CPU)(fOpacity * 255)));
61 } 78 }
62 }; 79 };
63 80
64 // TODO(edisonn): better class design. 81 // TODO(edisonn): better class design.
65 struct SkPdfGraphicsState { 82 struct SkPdfGraphicsState {
66 // TODO(edisonn): deprecate and remove these! 83 // TODO(edisonn): deprecate and remove these!
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 kPartial_PdfResult, 387 kPartial_PdfResult,
371 kNYI_PdfResult, 388 kNYI_PdfResult,
372 kIgnoreError_PdfResult, 389 kIgnoreError_PdfResult,
373 kError_PdfResult, 390 kError_PdfResult,
374 kUnsupported_PdfResult, 391 kUnsupported_PdfResult,
375 392
376 kCount_PdfResult 393 kCount_PdfResult
377 }; 394 };
378 395
379 #endif // __DEFINED__SkPdfBasics 396 #endif // __DEFINED__SkPdfBasics
OLDNEW
« no previous file with comments | « experimental/PdfViewer/PdfReference-okular-1.txt ('k') | experimental/PdfViewer/SkPdfRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698