blob: bc3e254bd0923ee06a5e1cfeb6e539f0c97e0dad [file] [log] [blame]
reed6054d682016-01-13 08:47:54 -08001/*
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"
msarett95416f42016-04-27 13:51:20 -070017#include "SkMatrixImageFilter.h"
reed6054d682016-01-13 08:47:54 -080018#include "SkOnce.h"
19#include "SkPathEffect.h"
20#include "SkPictureShader.h"
msarett95416f42016-04-27 13:51:20 -070021#include "SkRecordedDrawable.h"
Florin Malita4aed1382017-05-25 10:38:07 -040022#include "SkShaderBase.h"
reed6054d682016-01-13 08:47:54 -080023
24/*
25 * Registers all of the required effects subclasses for picture deserialization.
26 *
27 * Optional subclasses (e.g. Blur) should be registered in the ports/ version of this file,
28 * inside the InitEffects() method.
29 */
30void SkFlattenable::PrivateInitializer::InitCore() {
31 // Shader
reed6054d682016-01-13 08:47:54 -080032 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorFilterShader)
33 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorShader)
reed0ccc62d2016-05-04 13:09:39 -070034 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColor4Shader)
reed6054d682016-01-13 08:47:54 -080035 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeShader)
36 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmptyShader)
reed6054d682016-01-13 08:47:54 -080037 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLocalMatrixShader)
38 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureShader)
39
reed6054d682016-01-13 08:47:54 -080040
41 // ImageFilter
42 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixImageFilter)
43
reed6054d682016-01-13 08:47:54 -080044 SkColorFilter::InitializeFlattenables();
Mike Reeda07741a2017-02-25 22:34:32 -050045 SkPathEffect::InitializeFlattenables();
Florin Malita4aed1382017-05-25 10:38:07 -040046 SkShaderBase::InitializeFlattenables();
reed6054d682016-01-13 08:47:54 -080047
msarett95416f42016-04-27 13:51:20 -070048 // Drawable
49 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkRecordedDrawable)
50
reed6054d682016-01-13 08:47:54 -080051 // Now initialize any optional/additional effects (implemented in src/ports)
52 InitEffects();
53};
54
reed6054d682016-01-13 08:47:54 -080055void SkFlattenable::InitializeFlattenablesIfNeeded() {
mtkleind9dd4282016-04-18 08:09:11 -070056 static SkOnce once;
57 once(SkFlattenable::PrivateInitializer::InitCore);
reed6054d682016-01-13 08:47:54 -080058}