forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Filters.h
446 lines (363 loc) · 13.5 KB
/
Filters.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_GFX_FILTERS_H_
#define MOZILLA_GFX_FILTERS_H_
#include "Types.h"
#include "mozilla/RefPtr.h"
#include "Point.h"
#include "Matrix.h"
#include <vector>
namespace mozilla {
namespace gfx {
class SourceSurface;
enum FilterBackend {
FILTER_BACKEND_SOFTWARE = 0,
FILTER_BACKEND_DIRECT2D1_1,
FILTER_BACKEND_RECORDING,
FILTER_BACKEND_CAPTURE
};
enum TransformFilterAtts {
ATT_TRANSFORM_MATRIX = 0, // Matrix
ATT_TRANSFORM_FILTER // Filter
};
enum TransformFilterInputs { IN_TRANSFORM_IN = 0 };
enum BlendFilterAtts {
ATT_BLEND_BLENDMODE = 0 // uint32_t
};
enum BlendMode {
BLEND_MODE_MULTIPLY = 0,
BLEND_MODE_SCREEN,
BLEND_MODE_DARKEN,
BLEND_MODE_LIGHTEN,
BLEND_MODE_OVERLAY,
BLEND_MODE_COLOR_DODGE,
BLEND_MODE_COLOR_BURN,
BLEND_MODE_HARD_LIGHT,
BLEND_MODE_SOFT_LIGHT,
BLEND_MODE_DIFFERENCE,
BLEND_MODE_EXCLUSION,
BLEND_MODE_HUE,
BLEND_MODE_SATURATION,
BLEND_MODE_COLOR,
BLEND_MODE_LUMINOSITY
};
enum BlendFilterInputs { IN_BLEND_IN = 0, IN_BLEND_IN2 };
enum MorphologyFilterAtts {
ATT_MORPHOLOGY_RADII = 0, // IntSize
ATT_MORPHOLOGY_OPERATOR // MorphologyOperator
};
enum MorphologyOperator {
MORPHOLOGY_OPERATOR_ERODE = 0,
MORPHOLOGY_OPERATOR_DILATE
};
enum MorphologyFilterInputs { IN_MORPHOLOGY_IN = 0 };
enum AlphaMode { ALPHA_MODE_PREMULTIPLIED = 0, ALPHA_MODE_STRAIGHT };
enum ColorMatrixFilterAtts {
ATT_COLOR_MATRIX_MATRIX = 0, // Matrix5x4
ATT_COLOR_MATRIX_ALPHA_MODE // AlphaMode
};
enum ColorMatrixFilterInputs { IN_COLOR_MATRIX_IN = 0 };
enum FloodFilterAtts {
ATT_FLOOD_COLOR = 0 // Color
};
enum FloodFilterInputs { IN_FLOOD_IN = 0 };
enum TileFilterAtts {
ATT_TILE_SOURCE_RECT = 0 // IntRect
};
enum TileFilterInputs { IN_TILE_IN = 0 };
enum TransferAtts {
ATT_TRANSFER_DISABLE_R = 0, // bool
ATT_TRANSFER_DISABLE_G, // bool
ATT_TRANSFER_DISABLE_B, // bool
ATT_TRANSFER_DISABLE_A // bool
};
enum TransferInputs { IN_TRANSFER_IN = 0 };
enum TableTransferAtts {
ATT_TABLE_TRANSFER_DISABLE_R = ATT_TRANSFER_DISABLE_R,
ATT_TABLE_TRANSFER_DISABLE_G = ATT_TRANSFER_DISABLE_G,
ATT_TABLE_TRANSFER_DISABLE_B = ATT_TRANSFER_DISABLE_B,
ATT_TABLE_TRANSFER_DISABLE_A = ATT_TRANSFER_DISABLE_A,
ATT_TABLE_TRANSFER_TABLE_R, // Float[]
ATT_TABLE_TRANSFER_TABLE_G, // Float[]
ATT_TABLE_TRANSFER_TABLE_B, // Float[]
ATT_TABLE_TRANSFER_TABLE_A // Float[]
};
enum TableTransferInputs { IN_TABLE_TRANSFER_IN = IN_TRANSFER_IN };
enum DiscreteTransferAtts {
ATT_DISCRETE_TRANSFER_DISABLE_R = ATT_TRANSFER_DISABLE_R,
ATT_DISCRETE_TRANSFER_DISABLE_G = ATT_TRANSFER_DISABLE_G,
ATT_DISCRETE_TRANSFER_DISABLE_B = ATT_TRANSFER_DISABLE_B,
ATT_DISCRETE_TRANSFER_DISABLE_A = ATT_TRANSFER_DISABLE_A,
ATT_DISCRETE_TRANSFER_TABLE_R, // Float[]
ATT_DISCRETE_TRANSFER_TABLE_G, // Float[]
ATT_DISCRETE_TRANSFER_TABLE_B, // Float[]
ATT_DISCRETE_TRANSFER_TABLE_A // Float[]
};
enum DiscreteTransferInputs { IN_DISCRETE_TRANSFER_IN = IN_TRANSFER_IN };
enum LinearTransferAtts {
ATT_LINEAR_TRANSFER_DISABLE_R = ATT_TRANSFER_DISABLE_R,
ATT_LINEAR_TRANSFER_DISABLE_G = ATT_TRANSFER_DISABLE_G,
ATT_LINEAR_TRANSFER_DISABLE_B = ATT_TRANSFER_DISABLE_B,
ATT_LINEAR_TRANSFER_DISABLE_A = ATT_TRANSFER_DISABLE_A,
ATT_LINEAR_TRANSFER_SLOPE_R, // Float
ATT_LINEAR_TRANSFER_SLOPE_G, // Float
ATT_LINEAR_TRANSFER_SLOPE_B, // Float
ATT_LINEAR_TRANSFER_SLOPE_A, // Float
ATT_LINEAR_TRANSFER_INTERCEPT_R, // Float
ATT_LINEAR_TRANSFER_INTERCEPT_G, // Float
ATT_LINEAR_TRANSFER_INTERCEPT_B, // Float
ATT_LINEAR_TRANSFER_INTERCEPT_A // Float
};
enum LinearTransferInputs { IN_LINEAR_TRANSFER_IN = IN_TRANSFER_IN };
enum GammaTransferAtts {
ATT_GAMMA_TRANSFER_DISABLE_R = ATT_TRANSFER_DISABLE_R,
ATT_GAMMA_TRANSFER_DISABLE_G = ATT_TRANSFER_DISABLE_G,
ATT_GAMMA_TRANSFER_DISABLE_B = ATT_TRANSFER_DISABLE_B,
ATT_GAMMA_TRANSFER_DISABLE_A = ATT_TRANSFER_DISABLE_A,
ATT_GAMMA_TRANSFER_AMPLITUDE_R, // Float
ATT_GAMMA_TRANSFER_AMPLITUDE_G, // Float
ATT_GAMMA_TRANSFER_AMPLITUDE_B, // Float
ATT_GAMMA_TRANSFER_AMPLITUDE_A, // Float
ATT_GAMMA_TRANSFER_EXPONENT_R, // Float
ATT_GAMMA_TRANSFER_EXPONENT_G, // Float
ATT_GAMMA_TRANSFER_EXPONENT_B, // Float
ATT_GAMMA_TRANSFER_EXPONENT_A, // Float
ATT_GAMMA_TRANSFER_OFFSET_R, // Float
ATT_GAMMA_TRANSFER_OFFSET_G, // Float
ATT_GAMMA_TRANSFER_OFFSET_B, // Float
ATT_GAMMA_TRANSFER_OFFSET_A // Float
};
enum GammaTransferInputs { IN_GAMMA_TRANSFER_IN = IN_TRANSFER_IN };
enum ConvolveMatrixAtts {
ATT_CONVOLVE_MATRIX_KERNEL_SIZE = 0, // IntSize
ATT_CONVOLVE_MATRIX_KERNEL_MATRIX, // Float[]
ATT_CONVOLVE_MATRIX_DIVISOR, // Float
ATT_CONVOLVE_MATRIX_BIAS, // Float
ATT_CONVOLVE_MATRIX_TARGET, // IntPoint
ATT_CONVOLVE_MATRIX_SOURCE_RECT, // IntRect
ATT_CONVOLVE_MATRIX_EDGE_MODE, // ConvolveMatrixEdgeMode
ATT_CONVOLVE_MATRIX_KERNEL_UNIT_LENGTH, // Size
ATT_CONVOLVE_MATRIX_PRESERVE_ALPHA, // bool
};
enum ConvolveMatrixEdgeMode {
EDGE_MODE_DUPLICATE = 0,
EDGE_MODE_WRAP,
EDGE_MODE_NONE
};
enum ConvolveMatrixInputs { IN_CONVOLVE_MATRIX_IN = 0 };
enum DisplacementMapAtts {
ATT_DISPLACEMENT_MAP_SCALE = 0, // Float
ATT_DISPLACEMENT_MAP_X_CHANNEL, // ColorChannel
ATT_DISPLACEMENT_MAP_Y_CHANNEL // ColorChannel
};
enum ColorChannel {
COLOR_CHANNEL_R = 0,
COLOR_CHANNEL_G,
COLOR_CHANNEL_B,
COLOR_CHANNEL_A
};
enum DisplacementMapInputs {
IN_DISPLACEMENT_MAP_IN = 0,
IN_DISPLACEMENT_MAP_IN2
};
enum TurbulenceAtts {
ATT_TURBULENCE_BASE_FREQUENCY = 0, // Size
ATT_TURBULENCE_NUM_OCTAVES, // uint32_t
ATT_TURBULENCE_SEED, // uint32_t
ATT_TURBULENCE_STITCHABLE, // bool
ATT_TURBULENCE_TYPE, // TurbulenceType
ATT_TURBULENCE_RECT // IntRect
};
enum TurbulenceType {
TURBULENCE_TYPE_TURBULENCE = 0,
TURBULENCE_TYPE_FRACTAL_NOISE
};
enum ArithmeticCombineAtts {
ATT_ARITHMETIC_COMBINE_COEFFICIENTS = 0 // Float[4]
};
enum ArithmeticCombineInputs {
IN_ARITHMETIC_COMBINE_IN = 0,
IN_ARITHMETIC_COMBINE_IN2
};
enum CompositeAtts {
ATT_COMPOSITE_OPERATOR = 0 // CompositeOperator
};
enum CompositeOperator {
COMPOSITE_OPERATOR_OVER = 0,
COMPOSITE_OPERATOR_IN,
COMPOSITE_OPERATOR_OUT,
COMPOSITE_OPERATOR_ATOP,
COMPOSITE_OPERATOR_XOR,
COMPOSITE_OPERATOR_LIGHTER
};
enum CompositeInputs {
// arbitrary number of inputs
IN_COMPOSITE_IN_START = 0
};
enum GaussianBlurAtts {
ATT_GAUSSIAN_BLUR_STD_DEVIATION = 0 // Float
};
enum GaussianBlurInputs { IN_GAUSSIAN_BLUR_IN = 0 };
enum DirectionalBlurAtts {
ATT_DIRECTIONAL_BLUR_STD_DEVIATION = 0, // Float
ATT_DIRECTIONAL_BLUR_DIRECTION // BlurDirection
};
enum BlurDirection { BLUR_DIRECTION_X = 0, BLUR_DIRECTION_Y };
enum DirectionalBlurInputs { IN_DIRECTIONAL_BLUR_IN = 0 };
enum LightingAtts {
ATT_POINT_LIGHT_POSITION = 0, // Point3D
ATT_SPOT_LIGHT_POSITION, // Point3D
ATT_SPOT_LIGHT_POINTS_AT, // Point3D
ATT_SPOT_LIGHT_FOCUS, // Float
ATT_SPOT_LIGHT_LIMITING_CONE_ANGLE, // Float
ATT_DISTANT_LIGHT_AZIMUTH, // Float
ATT_DISTANT_LIGHT_ELEVATION, // Float
ATT_LIGHTING_COLOR, // Color
ATT_LIGHTING_SURFACE_SCALE, // Float
ATT_LIGHTING_KERNEL_UNIT_LENGTH, // Size
ATT_DIFFUSE_LIGHTING_DIFFUSE_CONSTANT, // Float
ATT_SPECULAR_LIGHTING_SPECULAR_CONSTANT, // Float
ATT_SPECULAR_LIGHTING_SPECULAR_EXPONENT // Float
};
enum LightingInputs { IN_LIGHTING_IN = 0 };
enum PointDiffuseAtts {
ATT_POINT_DIFFUSE_POSITION = ATT_POINT_LIGHT_POSITION,
ATT_POINT_DIFFUSE_COLOR = ATT_LIGHTING_COLOR,
ATT_POINT_DIFFUSE_SURFACE_SCALE = ATT_LIGHTING_SURFACE_SCALE,
ATT_POINT_DIFFUSE_KERNEL_UNIT_LENGTH = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
ATT_POINT_DIFFUSE_DIFFUSE_CONSTANT = ATT_DIFFUSE_LIGHTING_DIFFUSE_CONSTANT
};
enum PointDiffuseInputs { IN_POINT_DIFFUSE_IN = IN_LIGHTING_IN };
enum SpotDiffuseAtts {
ATT_SPOT_DIFFUSE_POSITION = ATT_SPOT_LIGHT_POSITION,
ATT_SPOT_DIFFUSE_POINTS_AT = ATT_SPOT_LIGHT_POINTS_AT,
ATT_SPOT_DIFFUSE_FOCUS = ATT_SPOT_LIGHT_FOCUS,
ATT_SPOT_DIFFUSE_LIMITING_CONE_ANGLE = ATT_SPOT_LIGHT_LIMITING_CONE_ANGLE,
ATT_SPOT_DIFFUSE_COLOR = ATT_LIGHTING_COLOR,
ATT_SPOT_DIFFUSE_SURFACE_SCALE = ATT_LIGHTING_SURFACE_SCALE,
ATT_SPOT_DIFFUSE_KERNEL_UNIT_LENGTH = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
ATT_SPOT_DIFFUSE_DIFFUSE_CONSTANT = ATT_DIFFUSE_LIGHTING_DIFFUSE_CONSTANT
};
enum SpotDiffuseInputs { IN_SPOT_DIFFUSE_IN = IN_LIGHTING_IN };
enum DistantDiffuseAtts {
ATT_DISTANT_DIFFUSE_AZIMUTH = ATT_DISTANT_LIGHT_AZIMUTH,
ATT_DISTANT_DIFFUSE_ELEVATION = ATT_DISTANT_LIGHT_ELEVATION,
ATT_DISTANT_DIFFUSE_COLOR = ATT_LIGHTING_COLOR,
ATT_DISTANT_DIFFUSE_SURFACE_SCALE = ATT_LIGHTING_SURFACE_SCALE,
ATT_DISTANT_DIFFUSE_KERNEL_UNIT_LENGTH = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
ATT_DISTANT_DIFFUSE_DIFFUSE_CONSTANT = ATT_DIFFUSE_LIGHTING_DIFFUSE_CONSTANT
};
enum DistantDiffuseInputs { IN_DISTANT_DIFFUSE_IN = IN_LIGHTING_IN };
enum PointSpecularAtts {
ATT_POINT_SPECULAR_POSITION = ATT_POINT_LIGHT_POSITION,
ATT_POINT_SPECULAR_COLOR = ATT_LIGHTING_COLOR,
ATT_POINT_SPECULAR_SURFACE_SCALE = ATT_LIGHTING_SURFACE_SCALE,
ATT_POINT_SPECULAR_KERNEL_UNIT_LENGTH = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
ATT_POINT_SPECULAR_SPECULAR_CONSTANT =
ATT_SPECULAR_LIGHTING_SPECULAR_CONSTANT,
ATT_POINT_SPECULAR_SPECULAR_EXPONENT = ATT_SPECULAR_LIGHTING_SPECULAR_EXPONENT
};
enum PointSpecularInputs { IN_POINT_SPECULAR_IN = IN_LIGHTING_IN };
enum SpotSpecularAtts {
ATT_SPOT_SPECULAR_POSITION = ATT_SPOT_LIGHT_POSITION,
ATT_SPOT_SPECULAR_POINTS_AT = ATT_SPOT_LIGHT_POINTS_AT,
ATT_SPOT_SPECULAR_FOCUS = ATT_SPOT_LIGHT_FOCUS,
ATT_SPOT_SPECULAR_LIMITING_CONE_ANGLE = ATT_SPOT_LIGHT_LIMITING_CONE_ANGLE,
ATT_SPOT_SPECULAR_COLOR = ATT_LIGHTING_COLOR,
ATT_SPOT_SPECULAR_SURFACE_SCALE = ATT_LIGHTING_SURFACE_SCALE,
ATT_SPOT_SPECULAR_KERNEL_UNIT_LENGTH = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
ATT_SPOT_SPECULAR_SPECULAR_CONSTANT = ATT_SPECULAR_LIGHTING_SPECULAR_CONSTANT,
ATT_SPOT_SPECULAR_SPECULAR_EXPONENT = ATT_SPECULAR_LIGHTING_SPECULAR_EXPONENT
};
enum SpotSpecularInputs { IN_SPOT_SPECULAR_IN = IN_LIGHTING_IN };
enum DistantSpecularAtts {
ATT_DISTANT_SPECULAR_AZIMUTH = ATT_DISTANT_LIGHT_AZIMUTH,
ATT_DISTANT_SPECULAR_ELEVATION = ATT_DISTANT_LIGHT_ELEVATION,
ATT_DISTANT_SPECULAR_COLOR = ATT_LIGHTING_COLOR,
ATT_DISTANT_SPECULAR_SURFACE_SCALE = ATT_LIGHTING_SURFACE_SCALE,
ATT_DISTANT_SPECULAR_KERNEL_UNIT_LENGTH = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
ATT_DISTANT_SPECULAR_SPECULAR_CONSTANT =
ATT_SPECULAR_LIGHTING_SPECULAR_CONSTANT,
ATT_DISTANT_SPECULAR_SPECULAR_EXPONENT =
ATT_SPECULAR_LIGHTING_SPECULAR_EXPONENT
};
enum DistantSpecularInputs { IN_DISTANT_SPECULAR_IN = IN_LIGHTING_IN };
enum CropAtts {
ATT_CROP_RECT = 0 // Rect
};
enum CropInputs { IN_CROP_IN = 0 };
enum PremultiplyInputs { IN_PREMULTIPLY_IN = 0 };
enum UnpremultiplyInputs { IN_UNPREMULTIPLY_IN = 0 };
enum OpacityAtts { ATT_OPACITY_VALUE = 0 };
enum OpacityInputs { IN_OPACITY_IN = 0 };
class FilterNode : public external::AtomicRefCounted<FilterNode> {
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNode)
virtual ~FilterNode() = default;
virtual FilterBackend GetBackendType() = 0;
virtual void SetInput(uint32_t aIndex, SourceSurface* aSurface) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetInput(uint32_t aIndex, FilterNode* aFilter) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, bool) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, uint32_t) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, Float) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, const Size&) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, const IntSize&) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, const IntPoint&) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, const Rect&) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, const IntRect&) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, const Point&) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, const Matrix&) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, const Matrix5x4&) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, const Point3D&) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, const DeviceColor&) {
MOZ_CRASH("GFX: FilterNode");
}
virtual void SetAttribute(uint32_t aIndex, const Float* aFloat,
uint32_t aSize) {
MOZ_CRASH("GFX: FilterNode");
}
/** Maps a rectangle in filter space back to a rectangle in the space of
* aSourceNode's first input. aSourceNode should not have an input
* assigned when calling this function. */
virtual IntRect MapRectToSource(const IntRect& aRect, const IntRect& aMax,
FilterNode* aSourceNode) {
return aMax;
}
protected:
friend class Factory;
FilterNode() = default;
};
} // namespace gfx
} // namespace mozilla
#endif