OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkBitmapHeap.h" | 10 #include "SkBitmapHeap.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "SkImageFilter.h" | 21 #include "SkImageFilter.h" |
22 #include "SkMaskFilter.h" | 22 #include "SkMaskFilter.h" |
23 #include "SkOrderedReadBuffer.h" | 23 #include "SkOrderedReadBuffer.h" |
24 #include "SkPathEffect.h" | 24 #include "SkPathEffect.h" |
25 #include "SkRasterizer.h" | 25 #include "SkRasterizer.h" |
26 #include "SkRRect.h" | 26 #include "SkRRect.h" |
27 #include "SkShader.h" | 27 #include "SkShader.h" |
28 #include "SkTypeface.h" | 28 #include "SkTypeface.h" |
29 #include "SkXfermode.h" | 29 #include "SkXfermode.h" |
30 | 30 |
31 static SkEffectType paintflat_to_effecttype(PaintFlats pf) { | |
32 static const uint8_t gEffectTypesInPaintFlatsOrder[] = { | |
33 kColorFilter_SkEffectType, | |
34 kDrawLooper_SkEffectType, | |
35 kImageFilter_SkEffectType, | |
36 kMaskFilter_SkEffectType, | |
37 kPathEffect_SkEffectType, | |
38 kRasterizer_SkEffectType, | |
39 kShader_SkEffectType, | |
40 kXfermode_SkEffectType, | |
41 }; | |
42 | |
43 SkASSERT((size_t)pf < SK_ARRAY_COUNT(gEffectTypesInPaintFlatsOrder)); | |
44 return (SkEffectType)gEffectTypesInPaintFlatsOrder[pf]; | |
45 } | |
46 | |
47 static void set_paintflat(SkPaint* paint, SkFlattenable* obj, unsigned paintFlat
) { | 31 static void set_paintflat(SkPaint* paint, SkFlattenable* obj, unsigned paintFlat
) { |
48 SkASSERT(paintFlat < kCount_PaintFlats); | 32 SkASSERT(paintFlat < kCount_PaintFlats); |
49 switch (paintFlat) { | 33 switch (paintFlat) { |
50 case kColorFilter_PaintFlat: | 34 case kColorFilter_PaintFlat: |
51 paint->setColorFilter((SkColorFilter*)obj); | 35 paint->setColorFilter((SkColorFilter*)obj); |
52 break; | 36 break; |
53 case kDrawLooper_PaintFlat: | 37 case kDrawLooper_PaintFlat: |
54 paint->setLooper((SkDrawLooper*)obj); | 38 paint->setLooper((SkDrawLooper*)obj); |
55 break; | 39 break; |
| 40 case kImageFilter_PaintFlat: |
| 41 paint->setImageFilter((SkImageFilter*)obj); |
| 42 break; |
56 case kMaskFilter_PaintFlat: | 43 case kMaskFilter_PaintFlat: |
57 paint->setMaskFilter((SkMaskFilter*)obj); | 44 paint->setMaskFilter((SkMaskFilter*)obj); |
58 break; | 45 break; |
59 case kPathEffect_PaintFlat: | 46 case kPathEffect_PaintFlat: |
60 paint->setPathEffect((SkPathEffect*)obj); | 47 paint->setPathEffect((SkPathEffect*)obj); |
61 break; | 48 break; |
62 case kRasterizer_PaintFlat: | 49 case kRasterizer_PaintFlat: |
63 paint->setRasterizer((SkRasterizer*)obj); | 50 paint->setRasterizer((SkRasterizer*)obj); |
64 break; | 51 break; |
65 case kShader_PaintFlat: | 52 case kShader_PaintFlat: |
66 paint->setShader((SkShader*)obj); | 53 paint->setShader((SkShader*)obj); |
67 break; | 54 break; |
68 case kImageFilter_PaintFlat: | |
69 paint->setImageFilter((SkImageFilter*)obj); | |
70 break; | |
71 case kXfermode_PaintFlat: | 55 case kXfermode_PaintFlat: |
72 paint->setXfermode((SkXfermode*)obj); | 56 paint->setXfermode((SkXfermode*)obj); |
73 break; | 57 break; |
74 default: | 58 default: |
75 SkDEBUGFAIL("never gets here"); | 59 SkDEBUGFAIL("never gets here"); |
76 } | 60 } |
77 } | 61 } |
78 | 62 |
| 63 static SkFlattenable* read_paintflat(SkFlattenableReadBuffer* reader, unsigned p
aintFlat) { |
| 64 SkASSERT(paintFlat < kCount_PaintFlats); |
| 65 switch (paintFlat) { |
| 66 case kColorFilter_PaintFlat: |
| 67 return reader->readColorFilter(); |
| 68 case kDrawLooper_PaintFlat: |
| 69 return reader->readDrawLooper(); |
| 70 case kImageFilter_PaintFlat: |
| 71 return reader->readImageFilter(); |
| 72 case kMaskFilter_PaintFlat: |
| 73 return reader->readMaskFilter(); |
| 74 case kPathEffect_PaintFlat: |
| 75 return reader->readPathEffect(); |
| 76 case kRasterizer_PaintFlat: |
| 77 return reader->readRasterizer(); |
| 78 case kShader_PaintFlat: |
| 79 return reader->readShader(); |
| 80 case kXfermode_PaintFlat: |
| 81 return reader->readXfermode(); |
| 82 default: |
| 83 SkDEBUGFAIL("never gets here"); |
| 84 } |
| 85 return NULL; |
| 86 } |
| 87 |
79 template <typename T> class SkRefCntTDArray : public SkTDArray<T> { | 88 template <typename T> class SkRefCntTDArray : public SkTDArray<T> { |
80 public: | 89 public: |
81 ~SkRefCntTDArray() { this->unrefAll(); } | 90 ~SkRefCntTDArray() { this->unrefAll(); } |
82 }; | 91 }; |
83 | 92 |
84 class SkGPipeState : public SkBitmapHeapReader { | 93 class SkGPipeState : public SkBitmapHeapReader { |
85 public: | 94 public: |
86 SkGPipeState(); | 95 SkGPipeState(); |
87 ~SkGPipeState(); | 96 ~SkGPipeState(); |
88 | 97 |
(...skipping 26 matching lines...) Expand all Loading... |
115 | 124 |
116 SkFlattenable* getFlat(unsigned index) const { | 125 SkFlattenable* getFlat(unsigned index) const { |
117 if (0 == index) { | 126 if (0 == index) { |
118 return NULL; | 127 return NULL; |
119 } | 128 } |
120 return fFlatArray[index - 1]; | 129 return fFlatArray[index - 1]; |
121 } | 130 } |
122 | 131 |
123 void defFlattenable(PaintFlats pf, int index) { | 132 void defFlattenable(PaintFlats pf, int index) { |
124 index--; | 133 index--; |
125 SkFlattenable* obj = fReader->readFlattenable(paintflat_to_effecttype(pf
)); | 134 SkFlattenable* obj = read_paintflat(fReader, pf); |
126 if (fFlatArray.count() == index) { | 135 if (fFlatArray.count() == index) { |
127 *fFlatArray.append() = obj; | 136 *fFlatArray.append() = obj; |
128 } else { | 137 } else { |
129 SkSafeUnref(fFlatArray[index]); | 138 SkSafeUnref(fFlatArray[index]); |
130 fFlatArray[index] = obj; | 139 fFlatArray[index] = obj; |
131 } | 140 } |
132 } | 141 } |
133 | 142 |
134 void defFactory(const char* name) { | 143 void defFactory(const char* name) { |
135 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(name); | 144 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(name); |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 status = kReadAtom_Status; | 895 status = kReadAtom_Status; |
887 break; | 896 break; |
888 } | 897 } |
889 } | 898 } |
890 | 899 |
891 if (bytesRead) { | 900 if (bytesRead) { |
892 *bytesRead = reader.offset(); | 901 *bytesRead = reader.offset(); |
893 } | 902 } |
894 return status; | 903 return status; |
895 } | 904 } |
OLD | NEW |