caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 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 | |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 8 | #include "SkTypes.h" |
| 9 | |
caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 10 | #include "SkBitmapProcShader.h" |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 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" |
reed | 8b57524 | 2014-12-17 01:47:32 -0800 | [diff] [blame] | 19 | #include "SkArcToPathEffect.h" |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 20 | #include "SkBitmapSource.h" |
| 21 | #include "SkBlurDrawLooper.h" |
caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 22 | #include "SkBlurImageFilter.h" |
| 23 | #include "SkBlurMaskFilter.h" |
sugoi | ce68627 | 2014-10-09 05:27:23 -0700 | [diff] [blame] | 24 | #include "SkColorCubeFilter.h" |
caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 25 | #include "SkColorFilter.h" |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 26 | #include "SkColorFilterImageFilter.h" |
| 27 | #include "SkColorMatrixFilter.h" |
| 28 | #include "SkColorShader.h" |
| 29 | #include "SkComposeImageFilter.h" |
| 30 | #include "SkComposeShader.h" |
caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 31 | #include "SkCornerPathEffect.h" |
| 32 | #include "SkDashPathEffect.h" |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 33 | #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.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 39 | #include "SkGradientShader.h" |
| 40 | #include "SkLayerDrawLooper.h" |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 41 | #include "SkLayerRasterizer.h" |
| 42 | #include "SkLerpXfermode.h" |
| 43 | #include "SkLightingImageFilter.h" |
commit-bot@chromium.org | 5970f62 | 2014-05-12 20:42:21 +0000 | [diff] [blame] | 44 | #include "SkLocalMatrixShader.h" |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 45 | #include "SkLumaColorFilter.h" |
tomhudson@google.com | b8bf9ce | 2012-08-13 15:48:18 +0000 | [diff] [blame] | 46 | #include "SkMagnifierImageFilter.h" |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 47 | #include "SkMatrixConvolutionImageFilter.h" |
| 48 | #include "SkMergeImageFilter.h" |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 49 | #include "SkModeColorFilter.h" |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 50 | #include "SkMorphologyImageFilter.h" |
| 51 | #include "SkOffsetImageFilter.h" |
| 52 | #include "SkOnce.h" |
| 53 | #include "SkPerlinNoiseShader.h" |
commit-bot@chromium.org | 9e5f85e | 2014-03-12 14:46:41 +0000 | [diff] [blame] | 54 | #include "SkPictureImageFilter.h" |
commit-bot@chromium.org | c5d9bb0 | 2014-04-08 15:19:34 +0000 | [diff] [blame] | 55 | #include "SkPictureShader.h" |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 56 | #include "SkPixelXorXfermode.h" |
| 57 | #include "SkRectShaderImageFilter.h" |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 58 | #include "SkTableColorFilter.h" |
| 59 | #include "SkTestImageFilters.h" |
| 60 | #include "SkTileImageFilter.h" |
senorblanco@chromium.org | fd0ec2c | 2014-03-25 17:35:10 +0000 | [diff] [blame] | 61 | #include "SkMatrixImageFilter.h" |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 62 | #include "SkXfermodeImageFilter.h" |
caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 63 | |
mtklein | 921827b | 2015-06-16 13:23:03 -0700 | [diff] [blame] | 64 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 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 | |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 81 | class SkPrivateEffectInitializer { |
| 82 | public: |
| 83 | static void Init() { |
reed | 8b57524 | 2014-12-17 01:47:32 -0800 | [diff] [blame] | 84 | SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArcToPathEffect) |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 85 | 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) |
sugoi | ce68627 | 2014-10-09 05:27:23 -0700 | [diff] [blame] | 89 | SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorCubeFilter) |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 90 | 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) |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 110 | SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkModeColorFilter) |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 111 | 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.com | a2ca41e | 2012-03-23 19:00:34 +0000 | [diff] [blame] | 123 | |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 124 | 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.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 129 | |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 130 | 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.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 139 | |
mtklein | 199ba8e | 2015-01-13 08:40:23 -0800 | [diff] [blame] | 140 | SK_DECLARE_STATIC_ONCE(once); |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 141 | void SkFlattenable::InitializeFlattenablesIfNeeded() { |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 142 | SkOnce(&once, SkPrivateEffectInitializer::Init); |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 143 | } |