1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "Sk1DPathEffect.h"
9 #include "Sk2DPathEffect.h"
10 #include "SkAlphaThresholdFilter.h"
11 #include "SkArithmeticMode.h"
12 #include "SkArcToPathEffect.h"
13 #include "SkAvoidXfermode.h"
14 #include "SkBitmapSourceDeserializer.h"
15 #include "SkBlurDrawLooper.h"
16 #include "SkBlurImageFilter.h"
17 #include "SkBlurMaskFilter.h"
18 #include "SkColorCubeFilter.h"
19 #include "SkColorFilterImageFilter.h"
20 #include "SkColorMatrixFilterRowMajor255.h"
21 #include "SkComposeImageFilter.h"
22 #include "SkCornerPathEffect.h"
23 #include "SkDashPathEffect.h"
24 #include "SkDiscretePathEffect.h"
25 #include "SkDisplacementMapEffect.h"
26 #include "SkDropShadowImageFilter.h"
27 #include "SkEmbossMaskFilter.h"
28 #include "SkGradientShader.h"
29 #include "SkImageSource.h"
30 #include "SkLayerDrawLooper.h"
31 #include "SkLayerRasterizer.h"
32 #include "SkLightingImageFilter.h"
33 #include "SkLightingShader.h"
34 #include "SkLumaColorFilter.h"
35 #include "SkMagnifierImageFilter.h"
36 #include "SkMatrixConvolutionImageFilter.h"
37 #include "SkMergeImageFilter.h"
38 #include "SkMorphologyImageFilter.h"
39 #include "SkOffsetImageFilter.h"
40 #include "SkPaintImageFilter.h"
41 #include "SkPerlinNoiseShader.h"
42 #include "SkPictureImageFilter.h"
43 #include "SkPixelXorXfermode.h"
44 #include "SkTableColorFilter.h"
45 #include "SkTestImageFilters.h"
46 #include "SkTileImageFilter.h"
47 #include "SkXfermodeImageFilter.h"
48 
49 // Security note:
50 //
51 // As new subclasses are added here, they should be reviewed by chrome security before they
52 // support deserializing cross-process: chrome-security@google.com. SampleFilterFuzz.cpp should
53 // also be amended to exercise the new subclass.
54 //
55 // See SkReadBuffer::isCrossProcess() and SkPicture::PictureIOSecurityPrecautionsEnabled()
56 //
57 
58 /*
59  *  None of these are strictly "required" for Skia to operate.
60  *
61  *  These are the bulk of our "effects" -- subclasses of various effects on SkPaint.
62  *
63  *  Clients should feel free to dup this file and modify it as needed. This function "InitEffects"
64  *  will automatically be called before any of skia's effects are asked to be deserialized.
65  */
InitEffects()66 void SkFlattenable::PrivateInitializer::InitEffects() {
67     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBitmapSourceDeserializer)
68 
69     // MaskFilter
70     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmbossMaskFilter)
71     SkBlurMaskFilter::InitializeFlattenables();
72 
73     // DrawLooper
74     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurDrawLooper)
75     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerDrawLooper)
76 
77     // Rasterizer
78     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerRasterizer)
79 
80     // ColorFilter
81     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorCubeFilter)
82     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorMatrixFilterRowMajor255)
83     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLumaColorFilter)
84     SkAlphaThresholdFilter::InitializeFlattenables();
85     SkArithmeticMode::InitializeFlattenables();
86     SkTableColorFilter::InitializeFlattenables();
87 
88     // Shader
89     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPerlinNoiseShader)
90     SkGradientShader::InitializeFlattenables();
91     SkLightingShader::InitializeFlattenables();
92 
93     // Xfermode
94     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPixelXorXfermode)
95     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkAvoidXfermode)
96 
97     // PathEffect
98     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArcToPathEffect)
99     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkCornerPathEffect)
100     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDashPathEffect)
101     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiscretePathEffect)
102     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath1DPathEffect)
103     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLine2DPathEffect)
104     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath2DPathEffect)
105     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSumPathEffect)
106 
107     // ImageFilter
108     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurImageFilter)
109     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDilateImageFilter)
110     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDisplacementMapEffect)
111     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDropShadowImageFilter)
112     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkErodeImageFilter)
113     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkImageSource)
114     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPaintImageFilter)
115     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureImageFilter)
116     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTileImageFilter)
117     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkXfermodeImageFilter)
118     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMagnifierImageFilter)
119     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixConvolutionImageFilter)
120     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkOffsetImageFilter)
121     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeImageFilter)
122     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMergeImageFilter)
123     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorFilterImageFilter)
124     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDownSampleImageFilter)
125     SkLightingImageFilter::InitializeFlattenables();
126 }
127