1 /*
2  * Copyright 2016 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 "SkBitmapProcShader.h"
9 #include "SkColorFilter.h"
10 #include "SkColorFilterShader.h"
11 #include "SkColorShader.h"
12 #include "SkComposeShader.h"
13 #include "SkEmptyShader.h"
14 #include "SkFlattenable.h"
15 #include "SkImageShader.h"
16 #include "SkLocalMatrixShader.h"
17 #include "SkOnce.h"
18 #include "SkPathEffect.h"
19 #include "SkPictureShader.h"
20 #include "SkMatrixImageFilter.h"
21 #include "SkXfermode.h"
22 
23 /*
24  *  Registers all of the required effects subclasses for picture deserialization.
25  *
26  *  Optional subclasses (e.g. Blur) should be registered in the ports/ version of this file,
27  *  inside the InitEffects() method.
28  */
InitCore()29 void SkFlattenable::PrivateInitializer::InitCore() {
30     // Shader
31     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBitmapProcShader)
32     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorFilterShader)
33     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorShader)
34     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeShader)
35     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmptyShader)
36     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkImageShader)
37     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLocalMatrixShader)
38     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureShader)
39 
40     // PathEffect
41     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposePathEffect)
42 
43     // ImageFilter
44     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixImageFilter)
45 
46     // ColorFilter
47     SkColorFilter::InitializeFlattenables();
48 
49     // Xfermode
50     SkXfermode::InitializeFlattenables();
51 
52     // Now initialize any optional/additional effects (implemented in src/ports)
53     InitEffects();
54 };
55 
56 SK_DECLARE_STATIC_ONCE(once);
InitializeFlattenablesIfNeeded()57 void SkFlattenable::InitializeFlattenablesIfNeeded() {
58     SkOnce(&once, SkFlattenable::PrivateInitializer::InitCore);
59 }
60