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 "SkTypes.h"
9
10#include "SkBitmapProcShader.h"
11#include "SkMallocPixelRef.h"
12#include "SkPathEffect.h"
13#include "SkPixelRef.h"
14#include "SkXfermode.h"
15
16#include "Sk1DPathEffect.h"
17#include "Sk2DPathEffect.h"
18#include "SkArithmeticMode.h"
19#include "SkAvoidXfermode.h"
20#include "SkBicubicImageFilter.h"
21#include "SkBitmapSource.h"
22#include "SkBlurDrawLooper.h"
23#include "SkBlurImageFilter.h"
24#include "SkBlurMaskFilter.h"
25#include "SkColorFilter.h"
26#include "SkColorFilterImageFilter.h"
27#include "SkColorMatrixFilter.h"
28#include "SkColorShader.h"
29#include "SkComposeImageFilter.h"
30#include "SkComposeShader.h"
31#include "SkCornerPathEffect.h"
32#include "SkDashPathEffect.h"
33#include "SkDiscretePathEffect.h"
34#include "SkDisplacementMapEffect.h"
35#include "SkDropShadowImageFilter.h"
36#include "SkEmptyShader.h"
37#include "SkEmbossMaskFilter.h"
38#include "SkFlattenable.h"
39#include "SkGradientShader.h"
40#include "SkImages.h"
41#include "SkLayerDrawLooper.h"
42#include "SkLayerRasterizer.h"
43#include "SkLerpXfermode.h"
44#include "SkLightingImageFilter.h"
45#include "SkLumaColorFilter.h"
46#include "SkMagnifierImageFilter.h"
47#include "SkMatrixConvolutionImageFilter.h"
48#include "SkMergeImageFilter.h"
49#include "SkMorphologyImageFilter.h"
50#include "SkOffsetImageFilter.h"
51#include "SkOnce.h"
52#include "SkPerlinNoiseShader.h"
53#include "SkPixelXorXfermode.h"
54#include "SkRectShaderImageFilter.h"
55#include "SkStippleMaskFilter.h"
56#include "SkTableColorFilter.h"
57#include "SkTestImageFilters.h"
58#include "SkTileImageFilter.h"
59#include "SkXfermodeImageFilter.h"
60
61static void InitializeFlattenables(int*) {
62    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkAvoidXfermode)
63    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBicubicImageFilter)
64    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBitmapProcShader)
65    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBitmapSource)
66    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurDrawLooper)
67    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurImageFilter)
68    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorMatrixFilter)
69    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorShader)
70    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposePathEffect)
71    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeShader)
72    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkCornerPathEffect)
73    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDashPathEffect)
74    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDilateImageFilter)
75    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiscretePathEffect)
76    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDisplacementMapEffect)
77    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDropShadowImageFilter)
78    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmbossMaskFilter)
79    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmptyShader)
80    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkErodeImageFilter)
81    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerDrawLooper)
82    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerRasterizer)
83    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLerpXfermode)
84    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLumaColorFilter)
85    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath1DPathEffect)
86    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(Sk2DPathEffect)
87    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLine2DPathEffect)
88    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath2DPathEffect)
89    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPerlinNoiseShader)
90    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPixelXorXfermode)
91    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkRectShaderImageFilter)
92    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkStippleMaskFilter)
93    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSumPathEffect)
94    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTileImageFilter)
95    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkXfermodeImageFilter)
96    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMagnifierImageFilter)
97    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixConvolutionImageFilter)
98
99    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkOffsetImageFilter)
100    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeImageFilter)
101    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMergeImageFilter)
102    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorFilterImageFilter)
103    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDownSampleImageFilter)
104    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMallocPixelRef)
105
106    SkArithmeticMode::InitializeFlattenables();
107    SkBlurMaskFilter::InitializeFlattenables();
108    SkColorFilter::InitializeFlattenables();
109    SkGradientShader::InitializeFlattenables();
110    SkImages::InitializeFlattenables();
111    SkLightingImageFilter::InitializeFlattenables();
112    SkTableColorFilter::InitializeFlattenables();
113    SkXfermode::InitializeFlattenables();
114}
115
116void SkFlattenable::InitializeFlattenablesIfNeeded() {
117    int dummy;
118    SK_DECLARE_STATIC_ONCE(once);
119    SkOnce(&once, InitializeFlattenables, &dummy);
120}
121