OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBitmapProcShader.h" | |
9 #include "SkPathEffect.h" | |
10 #include "SkXfermode.h" | |
11 | |
12 #include "Sk1DPathEffect.h" | 8 #include "Sk1DPathEffect.h" |
13 #include "Sk2DPathEffect.h" | 9 #include "Sk2DPathEffect.h" |
14 #include "SkAlphaThresholdFilter.h" | 10 #include "SkAlphaThresholdFilter.h" |
15 #include "SkArithmeticMode.h" | 11 #include "SkArithmeticMode.h" |
16 #include "SkArcToPathEffect.h" | 12 #include "SkArcToPathEffect.h" |
17 #include "SkBitmapSourceDeserializer.h" | 13 #include "SkBitmapSourceDeserializer.h" |
18 #include "SkBlurDrawLooper.h" | 14 #include "SkBlurDrawLooper.h" |
19 #include "SkBlurImageFilter.h" | 15 #include "SkBlurImageFilter.h" |
20 #include "SkBlurMaskFilter.h" | 16 #include "SkBlurMaskFilter.h" |
21 #include "SkColorCubeFilter.h" | 17 #include "SkColorCubeFilter.h" |
22 #include "SkColorFilter.h" | |
23 #include "SkColorFilterImageFilter.h" | 18 #include "SkColorFilterImageFilter.h" |
24 #include "SkColorFilterShader.h" | |
25 #include "SkColorMatrixFilter.h" | 19 #include "SkColorMatrixFilter.h" |
26 #include "SkColorShader.h" | |
27 #include "SkComposeImageFilter.h" | 20 #include "SkComposeImageFilter.h" |
28 #include "SkComposeShader.h" | |
29 #include "SkCornerPathEffect.h" | 21 #include "SkCornerPathEffect.h" |
30 #include "SkDashPathEffect.h" | 22 #include "SkDashPathEffect.h" |
31 #include "SkDiscretePathEffect.h" | 23 #include "SkDiscretePathEffect.h" |
32 #include "SkDisplacementMapEffect.h" | 24 #include "SkDisplacementMapEffect.h" |
33 #include "SkDropShadowImageFilter.h" | 25 #include "SkDropShadowImageFilter.h" |
34 #include "SkEmptyShader.h" | |
35 #include "SkEmbossMaskFilter.h" | 26 #include "SkEmbossMaskFilter.h" |
36 #include "SkFlattenable.h" | |
37 #include "SkGradientShader.h" | 27 #include "SkGradientShader.h" |
38 #include "SkImageShader.h" | |
39 #include "SkImageSource.h" | 28 #include "SkImageSource.h" |
40 #include "SkLayerDrawLooper.h" | 29 #include "SkLayerDrawLooper.h" |
41 #include "SkLayerRasterizer.h" | 30 #include "SkLayerRasterizer.h" |
42 #include "SkLerpXfermode.h" | 31 #include "SkLerpXfermode.h" |
43 #include "SkLightingImageFilter.h" | 32 #include "SkLightingImageFilter.h" |
44 #include "SkLightingShader.h" | 33 #include "SkLightingShader.h" |
45 #include "SkLocalMatrixShader.h" | |
46 #include "SkLumaColorFilter.h" | 34 #include "SkLumaColorFilter.h" |
47 #include "SkMagnifierImageFilter.h" | 35 #include "SkMagnifierImageFilter.h" |
48 #include "SkMatrixConvolutionImageFilter.h" | 36 #include "SkMatrixConvolutionImageFilter.h" |
49 #include "SkMergeImageFilter.h" | 37 #include "SkMergeImageFilter.h" |
50 #include "SkMorphologyImageFilter.h" | 38 #include "SkMorphologyImageFilter.h" |
51 #include "SkOffsetImageFilter.h" | 39 #include "SkOffsetImageFilter.h" |
52 #include "SkOnce.h" | |
53 #include "SkPaintImageFilter.h" | 40 #include "SkPaintImageFilter.h" |
54 #include "SkPerlinNoiseShader.h" | 41 #include "SkPerlinNoiseShader.h" |
55 #include "SkPictureImageFilter.h" | 42 #include "SkPictureImageFilter.h" |
56 #include "SkPictureShader.h" | |
57 #include "SkPixelXorXfermode.h" | 43 #include "SkPixelXorXfermode.h" |
58 #include "SkTableColorFilter.h" | 44 #include "SkTableColorFilter.h" |
59 #include "SkTestImageFilters.h" | 45 #include "SkTestImageFilters.h" |
60 #include "SkTileImageFilter.h" | 46 #include "SkTileImageFilter.h" |
61 #include "SkMatrixImageFilter.h" | |
62 #include "SkXfermodeImageFilter.h" | 47 #include "SkXfermodeImageFilter.h" |
63 | 48 |
64 class SkPrivateEffectInitializer { | 49 /* |
65 public: | 50 * None of these are strictly "required" for Skia to operate. |
66 static void Init() { | 51 * |
67 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArcToPathEffect) | 52 * These are the bulk of our "effects" -- subclasses of various effects on SkPa
int. |
68 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBitmapProcShader) | 53 * |
69 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBitmapSourceDeserializer) | 54 * Clients should feel free to dup this file and modify it as needed. This func
tion "InitEffects" |
70 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurDrawLooper) | 55 * will automatically be called before any of skia's effects are asked to be de
serialized. |
71 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurImageFilter) | 56 */ |
72 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorCubeFilter) | 57 void SkFlattenable::PrivateInitializer::InitEffects() { |
73 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorMatrixFilter) | 58 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBitmapSourceDeserializer) |
74 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorFilterShader) | |
75 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorShader) | |
76 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposePathEffect) | |
77 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeShader) | |
78 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkCornerPathEffect) | |
79 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDashPathEffect) | |
80 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDilateImageFilter) | |
81 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiscretePathEffect) | |
82 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDisplacementMapEffect) | |
83 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDropShadowImageFilter) | |
84 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmbossMaskFilter) | |
85 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmptyShader) | |
86 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkErodeImageFilter) | |
87 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkImageShader) | |
88 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkImageSource) | |
89 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerDrawLooper) | |
90 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerRasterizer) | |
91 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLerpXfermode) | |
92 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLocalMatrixShader) | |
93 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLumaColorFilter) | |
94 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath1DPathEffect) | |
95 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLine2DPathEffect) | |
96 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPaintImageFilter) | |
97 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath2DPathEffect) | |
98 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPerlinNoiseShader) | |
99 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureImageFilter) | |
100 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureShader) | |
101 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPixelXorXfermode) | |
102 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSumPathEffect) | |
103 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTileImageFilter) | |
104 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixImageFilter) | |
105 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkXfermodeImageFilter) | |
106 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMagnifierImageFilter) | |
107 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixConvolutionImageFilter) | |
108 | 59 |
109 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkOffsetImageFilter) | 60 // MaskFilter |
110 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeImageFilter) | 61 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmbossMaskFilter) |
111 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMergeImageFilter) | 62 SkBlurMaskFilter::InitializeFlattenables(); |
112 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorFilterImageFilter) | |
113 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDownSampleImageFilter) | |
114 | 63 |
115 SkAlphaThresholdFilter::InitializeFlattenables(); | 64 // DrawLooper |
116 SkArithmeticMode::InitializeFlattenables(); | 65 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurDrawLooper) |
117 SkBlurMaskFilter::InitializeFlattenables(); | 66 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerDrawLooper) |
118 SkColorFilter::InitializeFlattenables(); | |
119 SkGradientShader::InitializeFlattenables(); | |
120 SkLightingImageFilter::InitializeFlattenables(); | |
121 SkLightingShader::InitializeFlattenables(); | |
122 SkTableColorFilter::InitializeFlattenables(); | |
123 SkXfermode::InitializeFlattenables(); | |
124 } | |
125 }; | |
126 | 67 |
127 SK_DECLARE_STATIC_ONCE(once); | 68 // Rasterizer |
128 void SkFlattenable::InitializeFlattenablesIfNeeded() { | 69 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerRasterizer) |
129 SkOnce(&once, SkPrivateEffectInitializer::Init); | 70 |
| 71 // ColorFilter |
| 72 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorCubeFilter) |
| 73 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorMatrixFilter) |
| 74 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLumaColorFilter) |
| 75 SkAlphaThresholdFilter::InitializeFlattenables(); |
| 76 SkArithmeticMode::InitializeFlattenables(); |
| 77 SkTableColorFilter::InitializeFlattenables(); |
| 78 |
| 79 // Shader |
| 80 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPerlinNoiseShader) |
| 81 SkGradientShader::InitializeFlattenables(); |
| 82 SkLightingShader::InitializeFlattenables(); |
| 83 |
| 84 // Xfermode |
| 85 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLerpXfermode) |
| 86 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPixelXorXfermode) |
| 87 |
| 88 // PathEffect |
| 89 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArcToPathEffect) |
| 90 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkCornerPathEffect) |
| 91 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDashPathEffect) |
| 92 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiscretePathEffect) |
| 93 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath1DPathEffect) |
| 94 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLine2DPathEffect) |
| 95 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath2DPathEffect) |
| 96 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSumPathEffect) |
| 97 |
| 98 // ImageFilter |
| 99 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurImageFilter) |
| 100 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDilateImageFilter) |
| 101 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDisplacementMapEffect) |
| 102 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDropShadowImageFilter) |
| 103 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkErodeImageFilter) |
| 104 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkImageSource) |
| 105 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPaintImageFilter) |
| 106 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureImageFilter) |
| 107 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTileImageFilter) |
| 108 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkXfermodeImageFilter) |
| 109 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMagnifierImageFilter) |
| 110 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixConvolutionImageFilter) |
| 111 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkOffsetImageFilter) |
| 112 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeImageFilter) |
| 113 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMergeImageFilter) |
| 114 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorFilterImageFilter) |
| 115 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDownSampleImageFilter) |
| 116 SkLightingImageFilter::InitializeFlattenables(); |
130 } | 117 } |
OLD | NEW |