blob: b3eb3aa74352be5366bb2919d5e3acaeeceaeecb [file] [log] [blame]
caryclark@google.comd26147a2011-12-15 14:16:43 +00001/*
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
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +00008#include "SkTypes.h"
9
caryclark@google.comd26147a2011-12-15 14:16:43 +000010#include "SkBitmapProcShader.h"
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +000011#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"
reed8b575242014-12-17 01:47:32 -080019#include "SkArcToPathEffect.h"
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +000020#include "SkBitmapSource.h"
21#include "SkBlurDrawLooper.h"
caryclark@google.comd26147a2011-12-15 14:16:43 +000022#include "SkBlurImageFilter.h"
23#include "SkBlurMaskFilter.h"
sugoice686272014-10-09 05:27:23 -070024#include "SkColorCubeFilter.h"
caryclark@google.comd26147a2011-12-15 14:16:43 +000025#include "SkColorFilter.h"
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +000026#include "SkColorFilterImageFilter.h"
27#include "SkColorMatrixFilter.h"
28#include "SkColorShader.h"
29#include "SkComposeImageFilter.h"
30#include "SkComposeShader.h"
caryclark@google.comd26147a2011-12-15 14:16:43 +000031#include "SkCornerPathEffect.h"
32#include "SkDashPathEffect.h"
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +000033#include "SkDiscretePathEffect.h"
34#include "SkDisplacementMapEffect.h"
35#include "SkDropShadowImageFilter.h"
36#include "SkEmptyShader.h"
37#include "SkEmbossMaskFilter.h"
38#include "SkFlattenable.h"
caryclark@google.comd26147a2011-12-15 14:16:43 +000039#include "SkGradientShader.h"
40#include "SkLayerDrawLooper.h"
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +000041#include "SkLayerRasterizer.h"
42#include "SkLerpXfermode.h"
43#include "SkLightingImageFilter.h"
commit-bot@chromium.org5970f622014-05-12 20:42:21 +000044#include "SkLocalMatrixShader.h"
commit-bot@chromium.org6c1ee2d2013-10-07 18:00:17 +000045#include "SkLumaColorFilter.h"
tomhudson@google.comb8bf9ce2012-08-13 15:48:18 +000046#include "SkMagnifierImageFilter.h"
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +000047#include "SkMatrixConvolutionImageFilter.h"
48#include "SkMergeImageFilter.h"
reeddb873d82015-03-01 19:53:47 -080049#include "SkModeColorFilter.h"
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +000050#include "SkMorphologyImageFilter.h"
51#include "SkOffsetImageFilter.h"
52#include "SkOnce.h"
53#include "SkPerlinNoiseShader.h"
commit-bot@chromium.org9e5f85e2014-03-12 14:46:41 +000054#include "SkPictureImageFilter.h"
commit-bot@chromium.orgc5d9bb02014-04-08 15:19:34 +000055#include "SkPictureShader.h"
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +000056#include "SkPixelXorXfermode.h"
57#include "SkRectShaderImageFilter.h"
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +000058#include "SkTableColorFilter.h"
59#include "SkTestImageFilters.h"
60#include "SkTileImageFilter.h"
senorblanco@chromium.orgfd0ec2c2014-03-25 17:35:10 +000061#include "SkMatrixImageFilter.h"
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +000062#include "SkXfermodeImageFilter.h"
caryclark@google.comd26147a2011-12-15 14:16:43 +000063
mtklein921827b2015-06-16 13:23:03 -070064// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
65//
66// Adding new classes to Init() below has security consequences in Chrome.
67//
68// In particular, it is important that we don't create code paths that
69// deserialize untrusted data as SkImageFilters; SkImageFilters are sent from
70// Chrome renderers (untrusted) to the main (trusted) process.
71//
72// If you add a new SkImageFilter here _or_ other effect that can be part of
73// an SkImageFilter, it's a good idea to have chrome-security@google.com sign
74// off on the CL, and at minimum extend SampleFilterFuzz.cpp to fuzz it.
75//
76// SkPictures are untrusted data. Please be extremely careful not to allow
77// SkPictures created in a Chrome renderer to be deserialized in the main process.
78//
79// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
80
reed9fa60da2014-08-21 07:59:51 -070081class SkPrivateEffectInitializer {
82public:
83 static void Init() {
reed8b575242014-12-17 01:47:32 -080084 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArcToPathEffect)
reed9fa60da2014-08-21 07:59:51 -070085 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBitmapProcShader)
86 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBitmapSource)
87 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurDrawLooper)
88 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurImageFilter)
sugoice686272014-10-09 05:27:23 -070089 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorCubeFilter)
reed9fa60da2014-08-21 07:59:51 -070090 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorMatrixFilter)
91 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorShader)
92 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposePathEffect)
93 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeShader)
94 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkCornerPathEffect)
95 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDashPathEffect)
96 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDilateImageFilter)
97 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiscretePathEffect)
98 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDisplacementMapEffect)
99 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDropShadowImageFilter)
100 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmbossMaskFilter)
101 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmptyShader)
102 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkErodeImageFilter)
103 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerDrawLooper)
104 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerRasterizer)
105 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLerpXfermode)
106 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLocalMatrixShader)
107 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLumaColorFilter)
108 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath1DPathEffect)
109 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLine2DPathEffect)
reeddb873d82015-03-01 19:53:47 -0800110 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkModeColorFilter)
reed9fa60da2014-08-21 07:59:51 -0700111 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath2DPathEffect)
112 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPerlinNoiseShader)
113 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureImageFilter)
114 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureShader)
115 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPixelXorXfermode)
116 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkRectShaderImageFilter)
117 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSumPathEffect)
118 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTileImageFilter)
119 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixImageFilter)
120 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkXfermodeImageFilter)
121 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMagnifierImageFilter)
122 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixConvolutionImageFilter)
djsollen@google.coma2ca41e2012-03-23 19:00:34 +0000123
reed9fa60da2014-08-21 07:59:51 -0700124 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkOffsetImageFilter)
125 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeImageFilter)
126 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMergeImageFilter)
127 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorFilterImageFilter)
128 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDownSampleImageFilter)
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +0000129
reed9fa60da2014-08-21 07:59:51 -0700130 SkArithmeticMode::InitializeFlattenables();
131 SkBlurMaskFilter::InitializeFlattenables();
132 SkColorFilter::InitializeFlattenables();
133 SkGradientShader::InitializeFlattenables();
134 SkLightingImageFilter::InitializeFlattenables();
135 SkTableColorFilter::InitializeFlattenables();
136 SkXfermode::InitializeFlattenables();
137 }
138};
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +0000139
mtklein199ba8e2015-01-13 08:40:23 -0800140SK_DECLARE_STATIC_ONCE(once);
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +0000141void SkFlattenable::InitializeFlattenablesIfNeeded() {
reed9fa60da2014-08-21 07:59:51 -0700142 SkOnce(&once, SkPrivateEffectInitializer::Init);
commit-bot@chromium.orgc0b7e102013-10-23 17:06:21 +0000143}