1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include <map>
16
17 #include "ge_shader_filter_params.h"
18 #include "ge_visual_effect_impl.h"
19 #include "ge_log.h"
20 #include "ge_external_dynamic_loader.h"
21 #include "common/rs_vector4.h"
22 #include "common/rs_vector3.h"
23
24 namespace OHOS {
25 namespace Rosen {
26 namespace Drawing {
27
28 std::map<const std::string, std::function<void(GEVisualEffectImpl*)>> GEVisualEffectImpl::g_initialMap = {
29 { GE_FILTER_KAWASE_BLUR,
__anoncf3aad2e0102() 30 [](GEVisualEffectImpl* impl) {
31 impl->SetFilterType(GEVisualEffectImpl::FilterType::KAWASE_BLUR);
32 impl->MakeKawaseParams();
33 }
34 },
35 { GE_FILTER_MESA_BLUR,
__anoncf3aad2e0202() 36 [](GEVisualEffectImpl* impl) {
37 impl->SetFilterType(GEVisualEffectImpl::FilterType::MESA_BLUR);
38 impl->MakeMESAParams();
39 }
40 },
41 { GE_FILTER_GREY,
__anoncf3aad2e0302() 42 [](GEVisualEffectImpl* impl) {
43 impl->SetFilterType(GEVisualEffectImpl::FilterType::GREY);
44 impl->MakeGreyParams();
45 }
46 },
47 { GE_FILTER_AI_BAR,
__anoncf3aad2e0402() 48 [](GEVisualEffectImpl* impl) {
49 impl->SetFilterType(GEVisualEffectImpl::FilterType::AIBAR);
50 impl->MakeAIBarParams();
51 }
52 },
53 { GE_FILTER_LINEAR_GRADIENT_BLUR,
__anoncf3aad2e0502() 54 [](GEVisualEffectImpl* impl) {
55 impl->SetFilterType(GEVisualEffectImpl::FilterType::LINEAR_GRADIENT_BLUR);
56 impl->MakeLinearGradientBlurParams();
57 }
58 },
59 { GE_FILTER_MAGNIFIER,
__anoncf3aad2e0602() 60 [](GEVisualEffectImpl* impl) {
61 impl->SetFilterType(GEVisualEffectImpl::FilterType::MAGNIFIER);
62 impl->MakeMagnifierParams();
63 }
64 },
65 { GE_FILTER_WATER_RIPPLE,
__anoncf3aad2e0702() 66 [](GEVisualEffectImpl* impl) {
67 impl->SetFilterType(GEVisualEffectImpl::FilterType::WATER_RIPPLE);
68 impl->MakeWaterRippleParams();
69 }
70 },
71 { GE_FILTER_COLOR_GRADIENT,
__anoncf3aad2e0802() 72 [](GEVisualEffectImpl* impl) {
73 impl->SetFilterType(GEVisualEffectImpl::FilterType::COLOR_GRADIENT);
74 impl->MakeColorGradientParams();
75 }
76 },
77 { GE_FILTER_DISPLACEMENT_DISTORT,
__anoncf3aad2e0902() 78 [](GEVisualEffectImpl* impl) {
79 impl->SetFilterType(GEVisualEffectImpl::FilterType::DISPLACEMENT_DISTORT_FILTER);
80 impl->MakeDisplacementDistortParams();
81 }
82 },
83 { GE_FILTER_SOUND_WAVE,
__anoncf3aad2e0a02() 84 [](GEVisualEffectImpl* impl) {
85 impl->SetFilterType(GEVisualEffectImpl::FilterType::SOUND_WAVE);
86 impl->MakeSoundWaveParams();
87 }
88 },
89 { GE_FILTER_EDGE_LIGHT,
__anoncf3aad2e0b02() 90 [](GEVisualEffectImpl* impl) {
91 impl->SetFilterType(GEVisualEffectImpl::FilterType::EDGE_LIGHT);
92 impl->MakeEdgeLightParams();
93 }
94 },
95 { GE_FILTER_BEZIER_WARP,
__anoncf3aad2e0c02() 96 [](GEVisualEffectImpl* impl) {
97 impl->SetFilterType(GEVisualEffectImpl::FilterType::BEZIER_WARP);
98 impl->MakeBezierWarpParams();
99 }
100 },
101 { GE_FILTER_DISPERSION,
__anoncf3aad2e0d02() 102 [](GEVisualEffectImpl* impl) {
103 impl->SetFilterType(GEVisualEffectImpl::FilterType::DISPERSION);
104 impl->MakeDispersionParams();
105 }
106 },
107 { GE_FILTER_CONTENT_LIGHT,
__anoncf3aad2e0e02() 108 [](GEVisualEffectImpl* impl) {
109 impl->SetFilterType(GEVisualEffectImpl::FilterType::CONTENT_LIGHT);
110 impl->MakeContentLightParams();
111 }
112 },
113 { GE_FILTER_DIRECTION_LIGHT,
__anoncf3aad2e0f02() 114 [](GEVisualEffectImpl* impl) {
115 impl->SetFilterType(GEVisualEffectImpl::FilterType::DIRECTION_LIGHT);
116 impl->MakeDirectionLightParams();
117 }
118 },
119 { GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT,
__anoncf3aad2e1002() 120 [](GEVisualEffectImpl* impl) {
121 impl->SetFilterType(GEVisualEffectImpl::FilterType::CONTOUR_DIAGONAL_FLOW_LIGHT);
122 impl->MakeContentDiagonalParams();
123 }
124 },
125 { GE_SHADER_WAVY_RIPPLE_LIGHT,
__anoncf3aad2e1102() 126 [](GEVisualEffectImpl* impl) {
127 impl->SetFilterType(GEVisualEffectImpl::FilterType::WAVY_RIPPLE_LIGHT);
128 impl->MakeWavyRippleLightParams();
129 }
130 },
131 { GE_SHADER_AURORA_NOISE,
__anoncf3aad2e1202() 132 [](GEVisualEffectImpl* impl) {
133 impl->SetFilterType(GEVisualEffectImpl::FilterType::AURORA_NOISE);
134 impl->MakeAuroraNoiseParams();
135 }
136 },
137 { GE_MASK_RIPPLE,
__anoncf3aad2e1302() 138 [](GEVisualEffectImpl* impl) {
139 impl->SetFilterType(GEVisualEffectImpl::FilterType::RIPPLE_MASK);
140 impl->MakeRippleMaskParams();
141 }
142 },
143 { GE_MASK_DOUBLE_RIPPLE,
__anoncf3aad2e1402() 144 [](GEVisualEffectImpl* impl) {
145 impl->SetFilterType(GEVisualEffectImpl::FilterType::DOUBLE_RIPPLE_MASK);
146 impl->MakeDoubleRippleMaskParams();
147 }
148 },
149 { GE_MASK_RADIAL_GRADIENT,
__anoncf3aad2e1502() 150 [](GEVisualEffectImpl* impl) {
151 impl->SetFilterType(GEVisualEffectImpl::FilterType::RADIAL_GRADIENT_MASK);
152 impl->MakeRadialGradientMaskParams();
153 }
154 },
155 { GE_MASK_PIXEL_MAP,
__anoncf3aad2e1602() 156 [](GEVisualEffectImpl* impl) {
157 impl->SetFilterType(GEVisualEffectImpl::FilterType::PIXEL_MAP_MASK);
158 impl->MakePixelMapMaskParams();
159 }
160 },
161 { GE_MASK_WAVE_GRADIENT,
__anoncf3aad2e1702() 162 [](GEVisualEffectImpl* impl) {
163 impl->SetFilterType(GEVisualEffectImpl::FilterType::WAVE_GRADIENT_MASK);
164 impl->MakeWaveGradientMaskParams();
165 }
166 },
167 { GE_SHADER_PARTICLE_CIRCULAR_HALO,
__anoncf3aad2e1802() 168 [](GEVisualEffectImpl* impl) {
169 impl->SetFilterType(GEVisualEffectImpl::FilterType::PARTICLE_CIRCULAR_HALO);
170 impl->MakeParticleCircularHaloParams();
171 }
172 },
173 { GE_FILTER_MASK_TRANSITION,
__anoncf3aad2e1902() 174 [](GEVisualEffectImpl* impl) {
175 impl->SetFilterType(GEVisualEffectImpl::FilterType::MASK_TRANSITION);
176 impl->MakeMaskTransitionParams();
177 }
178 },
179 { GE_FILTER_VARIABLE_RADIUS_BLUR,
__anoncf3aad2e1a02() 180 [](GEVisualEffectImpl* impl) {
181 impl->SetFilterType(GEVisualEffectImpl::FilterType::VARIABLE_RADIUS_BLUR);
182 impl->MakeVariableRadiusBlurParams();
183 }
184 },
185 { GEX_SHADER_COLOR_GRADIENT_EFFECT,
__anoncf3aad2e1b02() 186 [](GEVisualEffectImpl* impl) {
187 impl->SetFilterType(GEVisualEffectImpl::FilterType::COLOR_GRADIENT_EFFECT);
188 impl->MakeColorGradientEffectParams();
189 }
190 },
191 { GEX_SHADER_LIGHT_CAVE,
__anoncf3aad2e1c02() 192 [](GEVisualEffectImpl* impl) {
193 impl->SetFilterType(GEVisualEffectImpl::FilterType::LIGHT_CAVE);
194 impl->MakeLightCaveParams();
195 }
196 },
197 { GE_SHADER_BORDER_LIGHT,
__anoncf3aad2e1d02() 198 [](GEVisualEffectImpl* impl) {
199 impl->SetFilterType(GEVisualEffectImpl::FilterType::BORDER_LIGHT);
200 impl->MakeBorderLightParams();
201 }
202 }
203 };
204
GEVisualEffectImpl(const std::string & name)205 GEVisualEffectImpl::GEVisualEffectImpl(const std::string& name)
206 {
207 auto iter = g_initialMap.find(name);
208 if (iter != g_initialMap.end()) {
209 iter->second(this);
210 }
211 }
212
~GEVisualEffectImpl()213 GEVisualEffectImpl::~GEVisualEffectImpl() {}
214
SetParam(const std::string & tag,int32_t param)215 void GEVisualEffectImpl::SetParam(const std::string& tag, int32_t param)
216 {
217 switch (filterType_) {
218 case FilterType::KAWASE_BLUR: {
219 if (kawaseParams_ == nullptr) {
220 return;
221 }
222
223 if (tag == GE_FILTER_KAWASE_BLUR_RADIUS) {
224 kawaseParams_->radius = param;
225 }
226 break;
227 }
228 case FilterType::MESA_BLUR: {
229 if (mesaParams_ == nullptr) {
230 return;
231 }
232
233 if (tag == GE_FILTER_MESA_BLUR_RADIUS) {
234 mesaParams_->radius = param;
235 }
236 if (tag == GE_FILTER_MESA_BLUR_STRETCH_TILE_MODE) {
237 mesaParams_->tileMode = param;
238 }
239 break;
240 }
241 case FilterType::LINEAR_GRADIENT_BLUR: {
242 if (linearGradientBlurParams_ == nullptr) {
243 return;
244 }
245
246 if (tag == GE_FILTER_LINEAR_GRADIENT_BLUR_DIRECTION) {
247 linearGradientBlurParams_->direction = param;
248 }
249 break;
250 }
251 case FilterType::MAGNIFIER: {
252 if (magnifierParams_ == nullptr) {
253 return;
254 }
255
256 if (tag == GE_FILTER_MAGNIFIER_ROTATE_DEGREE) {
257 magnifierParams_->rotateDegree = param;
258 }
259 break;
260 }
261 default:
262 break;
263 }
264 }
265
SetParam(const std::string & tag,bool param)266 void GEVisualEffectImpl::SetParam(const std::string& tag, bool param)
267 {
268 switch (filterType_) {
269 case FilterType::LINEAR_GRADIENT_BLUR: {
270 if (linearGradientBlurParams_ == nullptr) {
271 return;
272 }
273
274 if (tag == GE_FILTER_LINEAR_GRADIENT_BLUR_IS_OFF_SCREEN) {
275 linearGradientBlurParams_->isOffscreenCanvas = param;
276 }
277 if (tag == GE_FILTER_LINEAR_GRADIENT_BLUR_IS_RADIUS_GRADIENT) {
278 linearGradientBlurParams_->isRadiusGradient = param;
279 }
280
281 break;
282 }
283 case FilterType::EDGE_LIGHT: {
284 if (edgeLightParams_ == nullptr) {
285 return;
286 }
287 if (tag == GE_FILTER_EDGE_LIGHT_USE_RAW_COLOR) {
288 edgeLightParams_->useRawColor = param;
289 }
290 if (tag == GE_FILTER_EDGE_LIGHT_BLOOM) {
291 edgeLightParams_->bloom = param;
292 }
293 break;
294 }
295 case FilterType::MASK_TRANSITION: {
296 if (maskTransitionParams_ == nullptr) {
297 GE_LOGE("GEVisualEffectImpl set inverse failed, maskTransitionParams is nullptr");
298 return;
299 }
300 if (tag == GE_FILTER_MASK_TRANSITION_INVERSE) {
301 maskTransitionParams_->inverse = param;
302 }
303 break;
304 }
305 default:
306 break;
307 }
308 }
309
SetParam(const std::string & tag,int64_t param)310 void GEVisualEffectImpl::SetParam(const std::string& tag, int64_t param) {}
311
SetParam(const std::string & tag,float param)312 void GEVisualEffectImpl::SetParam(const std::string& tag, float param)
313 {
314 switch (filterType_) {
315 case FilterType::MESA_BLUR: {
316 SetMESABlurParams(tag, param);
317 break;
318 }
319 case FilterType::AIBAR: {
320 SetAIBarParams(tag, param);
321 break;
322 }
323 case FilterType::GREY: {
324 SetGreyParams(tag, param);
325 break;
326 }
327
328 case FilterType::LINEAR_GRADIENT_BLUR: {
329 SetLinearGradientBlurParams(tag, param);
330 break;
331 }
332 case FilterType::MAGNIFIER: {
333 SetMagnifierParamsFloat(tag, param);
334 break;
335 }
336 case FilterType::WATER_RIPPLE: {
337 SetWaterRippleParams(tag, param);
338 break;
339 }
340 case FilterType::RIPPLE_MASK : {
341 SetRippleMaskParamsFloat(tag, param);
342 break;
343 }
344 case FilterType::DOUBLE_RIPPLE_MASK : {
345 SetDoubleRippleMaskParamsFloat(tag, param);
346 break;
347 }
348 case FilterType::RADIAL_GRADIENT_MASK: {
349 SetRadialGradientMaskParamsFloat(tag, param);
350 break;
351 }
352 case FilterType::WAVE_GRADIENT_MASK : {
353 SetWaveGradientMaskParamsFloat(tag, param);
354 break;
355 }
356 case FilterType::SOUND_WAVE: {
357 SetSoundWaveParams(tag, param);
358 break;
359 }
360 case FilterType::EDGE_LIGHT: {
361 SetEdgeLightParams(tag, param);
362 break;
363 }
364 case FilterType::DISPERSION: {
365 SetDispersionParams(tag, param);
366 break;
367 }
368 case FilterType::CONTENT_LIGHT: {
369 SetContentLightParams(tag, param);
370 break;
371 }
372 case FilterType::DIRECTION_LIGHT: {
373 SetDirectionLightParamsFloat(tag, param);
374 break;
375 }
376 case FilterType::CONTOUR_DIAGONAL_FLOW_LIGHT: {
377 SetContentDiagonalFlowParams(tag, param);
378 break;
379 }
380 case FilterType::WAVY_RIPPLE_LIGHT: {
381 SetWavyRippleLightParams(tag, param);
382 break;
383 }
384 case FilterType::AURORA_NOISE: {
385 SetAuroraNoiseParams(tag, param);
386 break;
387 }
388 case FilterType::PARTICLE_CIRCULAR_HALO: {
389 SetParticleCircularHaloParams(tag, param);
390 break;
391 }
392 case FilterType::MASK_TRANSITION: {
393 SetMaskTransitionParamsFloat(tag, param);
394 break;
395 }
396 case FilterType::VARIABLE_RADIUS_BLUR: {
397 SetVariableRadiusBlurParams(tag, param);
398 break;
399 }
400 case FilterType::COLOR_GRADIENT_EFFECT: {
401 SetColorGradientEffectParams(tag, param);
402 break;
403 }
404 case FilterType::LIGHT_CAVE: {
405 SetLightCaveParams(tag, param);
406 break;
407 }
408 case FilterType::BORDER_LIGHT: {
409 SetBorderLightParams(tag, param);
410 break;
411 }
412 default:
413 break;
414 }
415 }
416
SetParam(const std::string & tag,double param)417 void GEVisualEffectImpl::SetParam(const std::string& tag, double param) {}
418
SetParam(const std::string & tag,const char * const param)419 void GEVisualEffectImpl::SetParam(const std::string& tag, const char* const param) {}
420
SetParam(const std::string & tag,const std::shared_ptr<Drawing::Image> param)421 void GEVisualEffectImpl::SetParam(const std::string& tag, const std::shared_ptr<Drawing::Image> param)
422 {
423 switch (filterType_) {
424 case FilterType::PIXEL_MAP_MASK: {
425 if (pixelMapMaskParams_ == nullptr) {
426 return;
427 }
428 if (tag == GE_MASK_PIXEL_MAP_PIXEL_MAP) {
429 pixelMapMaskParams_->image = param;
430 }
431 break;
432 }
433 default:
434 break;
435 }
436 }
437
SetParam(const std::string & tag,const std::shared_ptr<Drawing::ColorFilter> param)438 void GEVisualEffectImpl::SetParam(const std::string& tag, const std::shared_ptr<Drawing::ColorFilter> param) {}
439
SetParam(const std::string & tag,const Drawing::Matrix param)440 void GEVisualEffectImpl::SetParam(const std::string& tag, const Drawing::Matrix param)
441 {
442 switch (filterType_) {
443 case FilterType::LINEAR_GRADIENT_BLUR: {
444 if (linearGradientBlurParams_ == nullptr) {
445 return;
446 }
447
448 if (tag == GE_FILTER_LINEAR_GRADIENT_BLUR_CANVAS_MAT) {
449 linearGradientBlurParams_->mat = param;
450 }
451 break;
452 }
453 default:
454 break;
455 }
456 }
457
SetParam(const std::string & tag,const std::pair<float,float> & param)458 void GEVisualEffectImpl::SetParam(const std::string& tag, const std::pair<float, float>& param)
459 {
460 switch (filterType_) {
461 case FilterType::RIPPLE_MASK: {
462 if (rippleMaskParams_ == nullptr) {
463 return;
464 }
465 if (tag == GE_MASK_RIPPLE_CENTER) {
466 rippleMaskParams_->center_ = param;
467 }
468 break;
469 }
470 case FilterType::DOUBLE_RIPPLE_MASK: {
471 if (doubleRippleMaskParams_ == nullptr) {
472 return;
473 }
474 if (tag == GE_MASK_DOUBLE_RIPPLE_CENTER1) {
475 doubleRippleMaskParams_->center1_ = param;
476 }
477 if (tag == GE_MASK_DOUBLE_RIPPLE_CENTER2) {
478 doubleRippleMaskParams_->center2_ = param;
479 }
480 break;
481 }
482 case FilterType::DISPLACEMENT_DISTORT_FILTER: {
483 if (displacementDistortParams_ == nullptr) {
484 return;
485 }
486 if (tag == GE_FILTER_DISPLACEMENT_DISTORT_FACTOR) {
487 displacementDistortParams_->factor_ = param;
488 }
489 break;
490 }
491 case FilterType::RADIAL_GRADIENT_MASK: {
492 if (radialGradientMaskParams_ == nullptr) {
493 return;
494 }
495 if (tag == GE_MASK_RADIAL_GRADIENT_CENTER) {
496 radialGradientMaskParams_->center_ = param;
497 }
498 break;
499 }
500 case FilterType::WAVY_RIPPLE_LIGHT: {
501 SetWavyRippleLightParams(tag, param);
502 break;
503 }
504 case FilterType::WAVE_GRADIENT_MASK: {
505 if (waveGradientMaskParams_ == nullptr) {
506 return;
507 }
508 if (tag == GE_MASK_WAVE_GRADIENT_CENTER) {
509 waveGradientMaskParams_->center_ = param;
510 }
511 break;
512 }
513 case FilterType::PARTICLE_CIRCULAR_HALO: {
514 SetParticleCircularHaloParams(tag, param);
515 break;
516 }
517 case FilterType::DISPERSION: {
518 SetDispersionParams(tag, param);
519 break;
520 }
521 case FilterType::BEZIER_WARP: {
522 SetBezierWarpParams(tag, param);
523 break;
524 }
525 case FilterType::COLOR_GRADIENT_EFFECT: {
526 SetColorGradientEffectParams(tag, param);
527 break;
528 }
529 case FilterType::LIGHT_CAVE: {
530 SetLightCaveParams(tag, param);
531 break;
532 }
533 default:
534 break;
535 }
536 }
537
SetParam(const std::string & tag,const std::vector<std::pair<float,float>> & param)538 void GEVisualEffectImpl::SetParam(const std::string& tag, const std::vector<std::pair<float, float>>& param)
539 {
540 switch (filterType_) {
541 case FilterType::LINEAR_GRADIENT_BLUR: {
542 if (linearGradientBlurParams_ == nullptr) {
543 return;
544 }
545 if (tag == GE_FILTER_LINEAR_GRADIENT_BLUR_FRACTION_STOPS) {
546 linearGradientBlurParams_->fractionStops = param;
547 }
548 break;
549 }
550 default:
551 break;
552 }
553 }
554
SetParam(const std::string & tag,const std::vector<Vector2f> & param)555 void GEVisualEffectImpl::SetParam(const std::string& tag, const std::vector<Vector2f>& param)
556 {
557 switch (filterType_) {
558 case FilterType::CONTOUR_DIAGONAL_FLOW_LIGHT: {
559 if (contentDiagonalParams_ == nullptr) {
560 return;
561 }
562 if (tag == GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT_CONTOUR) {
563 contentDiagonalParams_->contour_ = param;
564 }
565 break;
566 }
567 default:
568 break;
569 }
570 }
571
SetParam(const std::string & tag,const std::array<Drawing::Point,POINT_NUM> & param)572 void GEVisualEffectImpl::SetParam(const std::string& tag, const std::array<Drawing::Point, POINT_NUM>& param)
573 {
574 switch (filterType_) {
575 case FilterType::BEZIER_WARP: {
576 if (bezierWarpParams_ == nullptr) {
577 return;
578 }
579 if (tag == GE_FILTER_BEZIER_WARP_DESTINATION_PATCH) {
580 bezierWarpParams_->destinationPatch = param;
581 }
582 break;
583 }
584 default:
585 break;
586 }
587 }
588
SetParam(const std::string & tag,const std::vector<float> & param)589 void GEVisualEffectImpl::SetParam(const std::string& tag, const std::vector<float>& param)
590 {
591 switch (filterType_) {
592 case FilterType::COLOR_GRADIENT: {
593 if (colorGradientParams_ == nullptr) {
594 return;
595 }
596 if (tag == GE_FILTER_COLOR_GRADIENT_COLOR) {
597 colorGradientParams_->colors = param;
598 }
599 if (tag == GE_FILTER_COLOR_GRADIENT_POSITION) {
600 colorGradientParams_->positions = param;
601 }
602 if (tag == GE_FILTER_COLOR_GRADIENT_STRENGTH) {
603 colorGradientParams_->strengths = param;
604 }
605 break;
606 }
607 case FilterType::RADIAL_GRADIENT_MASK: {
608 if (radialGradientMaskParams_ == nullptr) {
609 return;
610 }
611 if (tag == GE_MASK_RADIAL_GRADIENT_COLORS) {
612 radialGradientMaskParams_->colors_ = param;
613 }
614 if (tag == GE_MASK_RADIAL_GRADIENT_POSITIONS) {
615 radialGradientMaskParams_->positions_ = param;
616 }
617 break;
618 }
619 default:
620 break;
621 }
622 }
623
SetParam(const std::string & tag,const uint32_t param)624 void GEVisualEffectImpl::SetParam(const std::string& tag, const uint32_t param)
625 {
626 switch (filterType_) {
627 case FilterType::MAGNIFIER: {
628 SetMagnifierParamsUint32(tag, param);
629 break;
630 }
631 case FilterType::WATER_RIPPLE: {
632 if (waterRippleParams_ == nullptr) {
633 return;
634 }
635 if (tag == GE_FILTER_WATER_RIPPLE_RIPPLE_MODE) {
636 waterRippleParams_->rippleMode = param;
637 } else if (tag == GE_FILTER_WATER_RIPPLE_WAVE_NUM) {
638 waterRippleParams_->waveCount = param;
639 }
640 break;
641 }
642 default:
643 break;
644 }
645 }
646
SetParam(const std::string & tag,const std::shared_ptr<Drawing::GEShaderMask> param)647 void GEVisualEffectImpl::SetParam(const std::string& tag, const std::shared_ptr<Drawing::GEShaderMask> param)
648 {
649 switch (filterType_) {
650 case FilterType::DISPLACEMENT_DISTORT_FILTER: {
651 if (displacementDistortParams_ == nullptr) {
652 return;
653 }
654 if (tag == GE_FILTER_DISPLACEMENT_DISTORT_MASK) {
655 displacementDistortParams_->mask_ = param;
656 }
657 break;
658 }
659 case FilterType::COLOR_GRADIENT: {
660 if (colorGradientParams_ == nullptr) {
661 return;
662 }
663 if (tag == GE_FILTER_COLOR_GRADIENT_MASK) {
664 colorGradientParams_->mask = param;
665 }
666 break;
667 }
668 case FilterType::EDGE_LIGHT: {
669 if (edgeLightParams_ == nullptr) {
670 return;
671 }
672 if (tag == GE_FILTER_EDGE_LIGHT_MASK) {
673 edgeLightParams_->mask = param;
674 }
675 break;
676 }
677 case FilterType::DISPERSION: {
678 if (dispersionParams_ == nullptr) {
679 return;
680 }
681
682 if (tag == GE_FILTER_DISPERSION_MASK) {
683 dispersionParams_->mask = param;
684 }
685 break;
686 }
687 case FilterType::DIRECTION_LIGHT: {
688 if (directionLightParams_ == nullptr) {
689 return;
690 }
691
692 if (tag == GE_FILTER_DIRECTION_LIGHT_MASK) {
693 directionLightParams_->mask = param;
694 }
695 break;
696 }
697 case FilterType::MASK_TRANSITION: {
698 if (maskTransitionParams_ == nullptr) {
699 GE_LOGE("GEVisualEffectImpl set mask failed, maskTransitionParams is nullptr");
700 return;
701 }
702
703 if (tag == GE_FILTER_MASK_TRANSITION_MASK) {
704 maskTransitionParams_->mask = param;
705 }
706 break;
707 }
708 case FilterType::VARIABLE_RADIUS_BLUR: {
709 if (variableRadiusBlurParams_ == nullptr) {
710 return;
711 }
712
713 if (tag == GE_FILTER_VARIABLE_RADIUS_BLUR_MASK) {
714 variableRadiusBlurParams_->mask = param;
715 }
716 break;
717 }
718 case FilterType::COLOR_GRADIENT_EFFECT: {
719 if (colorGradientEffectParams_ == nullptr) {
720 return;
721 }
722
723 if (tag == GEX_SHADER_COLOR_GRADIENT_EFFECT_MASK) {
724 colorGradientEffectParams_->mask_ = param;
725 }
726 break;
727 }
728 default:
729 break;
730 }
731 }
732
SetParam(const std::string & tag,const Vector3f & param)733 void GEVisualEffectImpl::SetParam(const std::string& tag, const Vector3f& param)
734 {
735 switch (filterType_) {
736 case FilterType::CONTENT_LIGHT: {
737 if (contentLightParams_ == nullptr) {
738 return;
739 }
740 if (tag == GE_FILTER_CONTENT_LIGHT_POSITION) {
741 contentLightParams_->position = param;
742 }
743 if (tag == GE_FILTER_CONTENT_LIGHT_ROTATION_ANGLE) {
744 contentLightParams_->rotationAngle = param;
745 }
746 break;
747 }
748 case FilterType::DIRECTION_LIGHT: {
749 if (directionLightParams_ == nullptr) {
750 return;
751 }
752 if (tag == GE_FILTER_DIRECTION_LIGHT_DIRECTION) {
753 directionLightParams_->lightDirection = param;
754 }
755 break;
756 }
757 case FilterType::BORDER_LIGHT: {
758 SetBorderLightParams(tag, param);
759 break;
760 }
761 default:
762 break;
763 }
764 }
765
SetParam(const std::string & tag,const Vector4f & param)766 void GEVisualEffectImpl::SetParam(const std::string& tag, const Vector4f& param)
767 {
768 switch (filterType_) {
769 case FilterType::CONTENT_LIGHT: {
770 if (contentLightParams_ != nullptr && tag == GE_FILTER_CONTENT_LIGHT_COLOR) {
771 contentLightParams_->color = param;
772 }
773 break;
774 }
775 case FilterType::CONTOUR_DIAGONAL_FLOW_LIGHT: {
776 SetContentDiagonalFlowParams(tag, param);
777 break;
778 }
779 case FilterType::PIXEL_MAP_MASK: {
780 if (pixelMapMaskParams_ == nullptr) {
781 return;
782 }
783 SetPixelMapMaskParams(tag, param);
784 break;
785 }
786 case FilterType::DIRECTION_LIGHT: {
787 if (directionLightParams_ != nullptr && tag == GE_FILTER_DIRECTION_LIGHT_COLOR) {
788 directionLightParams_->lightColor = param;
789 }
790 break;
791 }
792 case FilterType::EDGE_LIGHT: {
793 if (edgeLightParams_ != nullptr && tag == GE_FILTER_EDGE_LIGHT_COLOR) {
794 edgeLightParams_->color = param;
795 }
796 break;
797 }
798 case FilterType::COLOR_GRADIENT_EFFECT: {
799 SetColorGradientEffectParams(tag, param);
800 break;
801 }
802 case FilterType::SOUND_WAVE: {
803 Drawing::Color4f color {param.x_, param.y_, param.z_, param.w_};
804 SetSoundWaveParams(tag, color);
805 break;
806 }
807 case FilterType::BORDER_LIGHT: {
808 SetBorderLightParams(tag, param);
809 break;
810 }
811 case FilterType::LIGHT_CAVE: {
812 SetLightCaveParams(tag, param);
813 break;
814 }
815 default:
816 break;
817 }
818 }
819
SetParam(const std::string & tag,const RectF & param)820 void GEVisualEffectImpl::SetParam(const std::string& tag, const RectF& param)
821 {
822 switch (filterType_) {
823 case FilterType::PIXEL_MAP_MASK: {
824 SetPixelMapMaskParams(tag, param);
825 break;
826 }
827 default:
828 break;
829 }
830 }
831
SetPixelMapMaskParams(const std::string & tag,const RectF & param)832 void GEVisualEffectImpl::SetPixelMapMaskParams(const std::string& tag, const RectF& param)
833 {
834 if (pixelMapMaskParams_ == nullptr) {
835 return;
836 }
837 if (tag == GE_MASK_PIXEL_MAP_SRC) {
838 pixelMapMaskParams_->src = param;
839 }
840 if (tag == GE_MASK_PIXEL_MAP_DST) {
841 pixelMapMaskParams_->dst = param;
842 }
843 }
844
SetPixelMapMaskParams(const std::string & tag,const Vector4f & param)845 void GEVisualEffectImpl::SetPixelMapMaskParams(const std::string& tag, const Vector4f& param)
846 {
847 if (pixelMapMaskParams_ == nullptr) {
848 return;
849 }
850 if (tag == GE_MASK_PIXEL_MAP_SRC) {
851 Drawing::RectF rect(param.x_, param.y_, param.z_, param.w_);
852 pixelMapMaskParams_->src = rect;
853 }
854 if (tag == GE_MASK_PIXEL_MAP_DST) {
855 Drawing::RectF rect(param.x_, param.y_, param.z_, param.w_);
856 pixelMapMaskParams_->dst = rect;
857 }
858 if (tag == GE_MASK_PIXEL_MAP_FILL_COLOR) {
859 pixelMapMaskParams_->fillColor = param;
860 }
861 }
862
SetParam(const std::string & tag,const Drawing::Color4f & param)863 void GEVisualEffectImpl::SetParam(const std::string& tag, const Drawing::Color4f& param)
864 {
865 switch (filterType_) {
866 case FilterType::SOUND_WAVE: {
867 SetSoundWaveParams(tag, param);
868 break;
869 }
870 default:
871 break;
872 }
873 }
874
SetMESABlurParams(const std::string & tag,float param)875 void GEVisualEffectImpl::SetMESABlurParams(const std::string& tag, float param)
876 {
877 if (mesaParams_ == nullptr) {
878 return;
879 }
880
881 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
882 { GE_FILTER_MESA_BLUR_GREY_COEF_1,
883 [](GEVisualEffectImpl* obj, float p) { obj->mesaParams_->greyCoef1 = p; } },
884 { GE_FILTER_MESA_BLUR_GREY_COEF_2,
885 [](GEVisualEffectImpl* obj, float p) { obj->mesaParams_->greyCoef2 = p; } },
886 { GE_FILTER_MESA_BLUR_STRETCH_OFFSET_X,
887 [](GEVisualEffectImpl* obj, float p) { obj->mesaParams_->offsetX = p; } },
888 { GE_FILTER_MESA_BLUR_STRETCH_OFFSET_Y,
889 [](GEVisualEffectImpl* obj, float p) { obj->mesaParams_->offsetY = p; } },
890 { GE_FILTER_MESA_BLUR_STRETCH_OFFSET_Z,
891 [](GEVisualEffectImpl* obj, float p) { obj->mesaParams_->offsetZ = p; } },
892 { GE_FILTER_MESA_BLUR_STRETCH_OFFSET_W,
893 [](GEVisualEffectImpl* obj, float p) { obj->mesaParams_->offsetW = p; } },
894 { GE_FILTER_MESA_BLUR_STRETCH_WIDTH,
895 [](GEVisualEffectImpl* obj, float p) { obj->mesaParams_->width = p; } },
896 { GE_FILTER_MESA_BLUR_STRETCH_HEIGHT,
897 [](GEVisualEffectImpl* obj, float p) { obj->mesaParams_->height = p; } }
898 };
899
900 auto it = actions.find(tag);
901 if (it != actions.end()) {
902 it->second(this, param);
903 }
904 }
905
SetAIBarParams(const std::string & tag,float param)906 void GEVisualEffectImpl::SetAIBarParams(const std::string& tag, float param)
907 {
908 if (aiBarParams_ == nullptr) {
909 return;
910 }
911
912 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
913 { GE_FILTER_AI_BAR_LOW,
914 [](GEVisualEffectImpl* obj, float p) { obj->aiBarParams_->aiBarLow = p; } },
915 { GE_FILTER_AI_BAR_HIGH,
916 [](GEVisualEffectImpl* obj, float p) { obj->aiBarParams_->aiBarHigh = p; } },
917 { GE_FILTER_AI_BAR_THRESHOLD,
918 [](GEVisualEffectImpl* obj, float p) { obj->aiBarParams_->aiBarThreshold = p; } },
919 { GE_FILTER_AI_BAR_OPACITY,
920 [](GEVisualEffectImpl* obj, float p) { obj->aiBarParams_->aiBarOpacity = p; } },
921 { GE_FILTER_AI_BAR_SATURATION,
922 [](GEVisualEffectImpl* obj, float p) { obj->aiBarParams_->aiBarSaturation = p; } }
923 };
924
925 auto it = actions.find(tag);
926 if (it != actions.end()) {
927 it->second(this, param);
928 }
929 }
930
SetGreyParams(const std::string & tag,float param)931 void GEVisualEffectImpl::SetGreyParams(const std::string& tag, float param)
932 {
933 if (greyParams_ == nullptr) {
934 return;
935 }
936
937 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
938 { GE_FILTER_GREY_COEF_1, [](GEVisualEffectImpl* obj, float p) { obj->greyParams_->greyCoef1 = p; } },
939 { GE_FILTER_GREY_COEF_2, [](GEVisualEffectImpl* obj, float p) { obj->greyParams_->greyCoef2 = p; } }
940 };
941
942 auto it = actions.find(tag);
943 if (it != actions.end()) {
944 it->second(this, param);
945 }
946 }
947
SetLinearGradientBlurParams(const std::string & tag,float param)948 void GEVisualEffectImpl::SetLinearGradientBlurParams(const std::string& tag, float param)
949 {
950 if (linearGradientBlurParams_ == nullptr) {
951 return;
952 }
953
954 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
955 { GE_FILTER_LINEAR_GRADIENT_BLUR_RADIUS,
956 [](GEVisualEffectImpl* obj, float p) { obj->linearGradientBlurParams_->blurRadius = p; } },
957 { GE_FILTER_LINEAR_GRADIENT_BLUR_GEO_WIDTH,
958 [](GEVisualEffectImpl* obj, float p) { obj->linearGradientBlurParams_->geoWidth = p; } },
959 { GE_FILTER_LINEAR_GRADIENT_BLUR_GEO_HEIGHT,
960 [](GEVisualEffectImpl* obj, float p) { obj->linearGradientBlurParams_->geoHeight = p; } },
961 { GE_FILTER_LINEAR_GRADIENT_BLUR_TRAN_X,
962 [](GEVisualEffectImpl* obj, float p) { obj->linearGradientBlurParams_->tranX = p; } },
963 { GE_FILTER_LINEAR_GRADIENT_BLUR_TRAN_Y,
964 [](GEVisualEffectImpl* obj, float p) { obj->linearGradientBlurParams_->tranY = p; } }
965 };
966
967 auto it = actions.find(tag);
968 if (it != actions.end()) {
969 it->second(this, param);
970 }
971 }
972
SetMagnifierParamsFloat(const std::string & tag,float param)973 void GEVisualEffectImpl::SetMagnifierParamsFloat(const std::string& tag, float param)
974 {
975 if (magnifierParams_ == nullptr) {
976 return;
977 }
978
979 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
980 { GE_FILTER_MAGNIFIER_FACTOR,
981 [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->factor = p; } },
982 { GE_FILTER_MAGNIFIER_WIDTH,
983 [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->width = p; } },
984 { GE_FILTER_MAGNIFIER_HEIGHT,
985 [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->height = p; } },
986 { GE_FILTER_MAGNIFIER_CORNER_RADIUS,
987 [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->cornerRadius = p; } },
988 { GE_FILTER_MAGNIFIER_BORDER_WIDTH,
989 [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->borderWidth = p; } },
990 { GE_FILTER_MAGNIFIER_SHADOW_OFFSET_X,
991 [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->shadowOffsetX = p; } },
992 { GE_FILTER_MAGNIFIER_SHADOW_OFFSET_Y,
993 [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->shadowOffsetY = p; } },
994 { GE_FILTER_MAGNIFIER_SHADOW_SIZE,
995 [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->shadowSize = p; } },
996 { GE_FILTER_MAGNIFIER_SHADOW_STRENGTH,
997 [](GEVisualEffectImpl* obj, float p) { obj->magnifierParams_->shadowStrength = p; } }
998 };
999
1000 auto it = actions.find(tag);
1001 if (it != actions.end()) {
1002 it->second(this, param);
1003 }
1004 }
1005
SetWaveGradientMaskParamsFloat(const std::string & tag,float param)1006 void GEVisualEffectImpl::SetWaveGradientMaskParamsFloat(const std::string& tag, float param)
1007 {
1008 if (waveGradientMaskParams_ == nullptr) {
1009 return;
1010 }
1011
1012 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1013 { GE_MASK_WAVE_GRADIENT_WIDTH,
1014 [](GEVisualEffectImpl* obj, float p) { obj->waveGradientMaskParams_->width_ = p; } },
1015 { GE_MASK_WAVE_GRADIENT_PROPAGATION_RADIUS,
1016 [](GEVisualEffectImpl* obj, float p) { obj->waveGradientMaskParams_->propagationRadius_ = p; } },
1017 { GE_MASK_WAVE_GRADIENT_BLUR_RADIUS,
1018 [](GEVisualEffectImpl* obj, float p) { obj->waveGradientMaskParams_->blurRadius_ = p; } },
1019 { GE_MASK_WAVE_GRADIENT_TURBULENCE_STRENGTH,
1020 [](GEVisualEffectImpl* obj, float p) { obj->waveGradientMaskParams_->turbulenceStrength_ = p; } },
1021 };
1022
1023 auto it = actions.find(tag);
1024 if (it != actions.end()) {
1025 it->second(this, param);
1026 }
1027 }
1028
SetDoubleRippleMaskParamsFloat(const std::string & tag,float param)1029 void GEVisualEffectImpl::SetDoubleRippleMaskParamsFloat(const std::string& tag, float param)
1030 {
1031 if (doubleRippleMaskParams_ == nullptr) {
1032 return;
1033 }
1034
1035 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1036 { GE_MASK_DOUBLE_RIPPLE_RADIUS,
1037 [](GEVisualEffectImpl* obj, float p) { obj->doubleRippleMaskParams_->radius_ = p; } },
1038 { GE_MASK_DOUBLE_RIPPLE_WIDTH,
1039 [](GEVisualEffectImpl* obj, float p) { obj->doubleRippleMaskParams_->width_ = p; } },
1040 { GE_MASK_DOUBLE_RIPPLE_TURBULENCE,
1041 [](GEVisualEffectImpl* obj, float p) { obj->doubleRippleMaskParams_->turbulence_ = p; } },
1042 { GE_MASK_DOUBLE_RIPPLE_HALOTHICKNESS,
1043 [](GEVisualEffectImpl* obj, float p) { obj->doubleRippleMaskParams_->haloThickness_ = p; } }
1044 };
1045
1046 auto it = actions.find(tag);
1047 if (it != actions.end()) {
1048 it->second(this, param);
1049 }
1050 }
1051
SetRippleMaskParamsFloat(const std::string & tag,float param)1052 void GEVisualEffectImpl::SetRippleMaskParamsFloat(const std::string& tag, float param)
1053 {
1054 if (rippleMaskParams_ == nullptr) {
1055 return;
1056 }
1057
1058 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1059 { GE_MASK_RIPPLE_RADIUS,
1060 [](GEVisualEffectImpl* obj, float p) { obj->rippleMaskParams_->radius_ = p; } },
1061 { GE_MASK_RIPPLE_WIDTH,
1062 [](GEVisualEffectImpl* obj, float p) { obj->rippleMaskParams_->width_ = p; } },
1063 { GE_MASK_RIPPLE_WIDTH_CENTER_OFFSET,
1064 [](GEVisualEffectImpl* obj, float p) { obj->rippleMaskParams_->widthCenterOffset_ = p; } },
1065 };
1066
1067 auto it = actions.find(tag);
1068 if (it != actions.end()) {
1069 it->second(this, param);
1070 }
1071 }
1072
SetRadialGradientMaskParamsFloat(const std::string & tag,float param)1073 void GEVisualEffectImpl::SetRadialGradientMaskParamsFloat(const std::string& tag, float param)
1074 {
1075 if (radialGradientMaskParams_ == nullptr) {
1076 return;
1077 }
1078
1079 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1080 { GE_MASK_RADIAL_GRADIENT_RADIUSX,
1081 [](GEVisualEffectImpl* obj, float p) { obj->radialGradientMaskParams_->radiusX_ = p; } },
1082 { GE_MASK_RADIAL_GRADIENT_RADIUSY,
1083 [](GEVisualEffectImpl* obj, float p) { obj->radialGradientMaskParams_->radiusY_ = p; } },
1084 };
1085
1086 auto it = actions.find(tag);
1087 if (it != actions.end()) {
1088 it->second(this, param);
1089 }
1090 }
1091
SetMagnifierParamsUint32(const std::string & tag,uint32_t param)1092 void GEVisualEffectImpl::SetMagnifierParamsUint32(const std::string& tag, uint32_t param)
1093 {
1094 if (magnifierParams_ == nullptr) {
1095 return;
1096 }
1097
1098 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, uint32_t)>> actions = {
1099 { GE_FILTER_MAGNIFIER_GRADIENT_MASK_COLOR_1,
1100 [](GEVisualEffectImpl* obj, uint32_t p) { obj->magnifierParams_->gradientMaskColor1 = p; } },
1101 { GE_FILTER_MAGNIFIER_GRADIENT_MASK_COLOR_2,
1102 [](GEVisualEffectImpl* obj, uint32_t p) { obj->magnifierParams_->gradientMaskColor2 = p; } },
1103 { GE_FILTER_MAGNIFIER_OUTER_CONTOUR_COLOR_1,
1104 [](GEVisualEffectImpl* obj, uint32_t p) { obj->magnifierParams_->outerContourColor1 = p; } },
1105 { GE_FILTER_MAGNIFIER_OUTER_CONTOUR_COLOR_2,
1106 [](GEVisualEffectImpl* obj, uint32_t p) { obj->magnifierParams_->outerContourColor2 = p; } }
1107 };
1108
1109 auto it = actions.find(tag);
1110 if (it != actions.end()) {
1111 it->second(this, param);
1112 }
1113 }
1114
SetWaterRippleParams(const std::string & tag,float param)1115 void GEVisualEffectImpl::SetWaterRippleParams(const std::string& tag, float param)
1116 {
1117 if (waterRippleParams_ == nullptr) {
1118 return;
1119 }
1120
1121 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1122
1123 { GE_FILTER_WATER_RIPPLE_PROGRESS,
1124 [](GEVisualEffectImpl* obj, float p) { obj->waterRippleParams_->progress = p; } },
1125 { GE_FILTER_WATER_RIPPLE_RIPPLE_CENTER_X,
1126 [](GEVisualEffectImpl* obj, float p) { obj->waterRippleParams_->rippleCenterX = p; } },
1127 { GE_FILTER_WATER_RIPPLE_RIPPLE_CENTER_Y,
1128 [](GEVisualEffectImpl* obj, float p) { obj->waterRippleParams_->rippleCenterY = p; } },
1129 };
1130
1131 auto it = actions.find(tag);
1132 if (it != actions.end()) {
1133 it->second(this, param);
1134 }
1135 }
1136
SetSoundWaveParams(const std::string & tag,float param)1137 void GEVisualEffectImpl::SetSoundWaveParams(const std::string& tag, float param)
1138 {
1139 if (soundWaveParams_ == nullptr) {
1140 return;
1141 }
1142
1143 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1144
1145 { GE_FILTER_SOUND_WAVE_COLORPROGRESS,
1146 [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->colorProgress = p; } },
1147 { GE_FILTER_SOUND_WAVE_SOUNDINTENSITY,
1148 [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->soundIntensity = p; } },
1149 { GE_FILTER_SOUND_WAVE_SHOCKWAVEALPHA_A,
1150 [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->shockWaveAlphaA = p; } },
1151 { GE_FILTER_SOUND_WAVE_SHOCKWAVEALPHA_B,
1152 [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->shockWaveAlphaB = p; } },
1153 { GE_FILTER_SOUND_WAVE_SHOCKWAVEPROGRESS_A,
1154 [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->shockWaveProgressA = p; } },
1155 { GE_FILTER_SOUND_WAVE_SHOCKWAVEPROGRESS_B,
1156 [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->shockWaveProgressB = p; } },
1157 { GE_FILTER_SOUND_WAVE_TOTAL_ALPHA,
1158 [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->shockWaveTotalAlpha = p; } },
1159 };
1160
1161 auto it = actions.find(tag);
1162 if (it != actions.end()) {
1163 it->second(this, param);
1164 }
1165 }
1166
SetSoundWaveParams(const std::string & tag,const Drawing::Color4f & param)1167 void GEVisualEffectImpl::SetSoundWaveParams(const std::string& tag, const Drawing::Color4f& param)
1168 {
1169 if (soundWaveParams_ == nullptr) {
1170 return;
1171 }
1172
1173 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, const Drawing::Color4f&)>>
1174 actions = {
1175 { GE_FILTER_SOUND_WAVE_COLOR_A,
1176 [](GEVisualEffectImpl* obj, const Drawing::Color4f& p) { obj->soundWaveParams_->colorA = p; } },
1177 { GE_FILTER_SOUND_WAVE_COLOR_B,
1178 [](GEVisualEffectImpl* obj, const Drawing::Color4f& p) { obj->soundWaveParams_->colorB = p; } },
1179 { GE_FILTER_SOUND_WAVE_COLOR_C,
1180 [](GEVisualEffectImpl* obj, const Drawing::Color4f& p) { obj->soundWaveParams_->colorC = p; } },
1181 };
1182
1183 auto it = actions.find(tag);
1184 if (it != actions.end()) {
1185 it->second(this, param);
1186 }
1187 }
1188
SetEdgeLightParams(const std::string & tag,float param)1189 void GEVisualEffectImpl::SetEdgeLightParams(const std::string& tag, float param)
1190 {
1191 if (edgeLightParams_ == nullptr) {
1192 return;
1193 }
1194
1195 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1196 { GE_FILTER_EDGE_LIGHT_ALPHA,
1197 [](GEVisualEffectImpl* obj, float p) { obj->edgeLightParams_->alpha = p; } },
1198 };
1199
1200 auto it = actions.find(tag);
1201 if (it != actions.end()) {
1202 it->second(this, param);
1203 }
1204 }
1205
SetDispersionParams(const std::string & tag,float param)1206 void GEVisualEffectImpl::SetDispersionParams(const std::string& tag, float param)
1207 {
1208 if (dispersionParams_ == nullptr) {
1209 return;
1210 }
1211
1212 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1213 { GE_FILTER_DISPERSION_OPACITY,
1214 [](GEVisualEffectImpl* obj, float p) { obj->dispersionParams_->opacity = p; } },
1215 };
1216
1217 auto it = actions.find(tag);
1218 if (it != actions.end()) {
1219 it->second(this, param);
1220 }
1221 }
1222
SetDispersionParams(const std::string & tag,const std::pair<float,float> & param)1223 void GEVisualEffectImpl::SetDispersionParams(const std::string& tag, const std::pair<float, float>& param)
1224 {
1225 if (dispersionParams_ == nullptr) {
1226 return;
1227 }
1228
1229 if (tag == GE_FILTER_DISPERSION_RED_OFFSET) {
1230 dispersionParams_->redOffset = param;
1231 } else if (tag == GE_FILTER_DISPERSION_GREEN_OFFSET) {
1232 dispersionParams_->greenOffset = param;
1233 } else if (tag == GE_FILTER_DISPERSION_BLUE_OFFSET) {
1234 dispersionParams_->blueOffset = param;
1235 }
1236 }
1237
SetBezierWarpParams(const std::string & tag,const std::pair<float,float> & param)1238 void GEVisualEffectImpl::SetBezierWarpParams(const std::string& tag, const std::pair<float, float>& param)
1239 {
1240 if (bezierWarpParams_ == nullptr) {
1241 return;
1242 }
1243
1244 std::array<const char*, GE_FILTER_BEZIER_WARP_POINT_NUM> ctrlPointsName = {
1245 GE_FILTER_BEZIER_WARP_CONTROL_POINT0,
1246 GE_FILTER_BEZIER_WARP_CONTROL_POINT1,
1247 GE_FILTER_BEZIER_WARP_CONTROL_POINT2,
1248 GE_FILTER_BEZIER_WARP_CONTROL_POINT3,
1249 GE_FILTER_BEZIER_WARP_CONTROL_POINT4,
1250 GE_FILTER_BEZIER_WARP_CONTROL_POINT5,
1251 GE_FILTER_BEZIER_WARP_CONTROL_POINT6,
1252 GE_FILTER_BEZIER_WARP_CONTROL_POINT7,
1253 GE_FILTER_BEZIER_WARP_CONTROL_POINT8,
1254 GE_FILTER_BEZIER_WARP_CONTROL_POINT9,
1255 GE_FILTER_BEZIER_WARP_CONTROL_POINT10,
1256 GE_FILTER_BEZIER_WARP_CONTROL_POINT11,
1257 };
1258
1259 auto it = std::find(ctrlPointsName.begin(), ctrlPointsName.end(), tag);
1260 if (it != ctrlPointsName.end()) {
1261 size_t index = std::distance(ctrlPointsName.begin(), it);
1262 bezierWarpParams_->destinationPatch[index].Set(param.first, param.second);
1263 }
1264 }
1265
SetContentLightParams(const std::string & tag,float param)1266 void GEVisualEffectImpl::SetContentLightParams(const std::string& tag, float param)
1267 {
1268 if (contentLightParams_ == nullptr) {
1269 return;
1270 }
1271
1272 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1273 { GE_FILTER_CONTENT_LIGHT_INTENSITY,
1274 [](GEVisualEffectImpl* obj, float p) { obj->contentLightParams_->intensity = p; } },
1275 };
1276
1277 auto it = actions.find(tag);
1278 if (it != actions.end()) {
1279 it->second(this, param);
1280 }
1281 }
1282
SetDirectionLightParamsFloat(const std::string & tag,float param)1283 void GEVisualEffectImpl::SetDirectionLightParamsFloat(const std::string& tag, float param)
1284 {
1285 if (directionLightParams_ == nullptr) {
1286 return;
1287 }
1288
1289 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1290 { GE_FILTER_DIRECTION_LIGHT_INTENSITY,
1291 [](GEVisualEffectImpl* obj, float p) { obj->directionLightParams_->lightIntensity = p; } },
1292 { GE_FILTER_DIRECTION_LIGHT_FACTOR,
1293 [](GEVisualEffectImpl* obj, float p) { obj->directionLightParams_->maskFactor = p; } },
1294 };
1295
1296 auto it = actions.find(tag);
1297 if (it != actions.end()) {
1298 it->second(this, param);
1299 }
1300 }
1301
SetContentDiagonalFlowParams(const std::string & tag,const Vector4f & param)1302 void GEVisualEffectImpl::SetContentDiagonalFlowParams(const std::string& tag, const Vector4f& param)
1303 {
1304 if (contentDiagonalParams_ == nullptr) {
1305 return;
1306 }
1307 if (tag == GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT_LINE1_COLOR) {
1308 contentDiagonalParams_->line1Color_ = param;
1309 }
1310 if (tag == GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT_LINE2_COLOR) {
1311 contentDiagonalParams_->line2Color_ = param;
1312 }
1313 }
1314
SetContentDiagonalFlowParams(const std::string & tag,float param)1315 void GEVisualEffectImpl::SetContentDiagonalFlowParams(const std::string& tag, float param)
1316 {
1317 if (contentDiagonalParams_ == nullptr) {
1318 return;
1319 }
1320
1321 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1322 { GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT_LINE1_START,
1323 [](GEVisualEffectImpl* obj, float p) { obj->contentDiagonalParams_->line1Start_ = p; } },
1324 { GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT_LINE1_LENGTH,
1325 [](GEVisualEffectImpl* obj, float p) { obj->contentDiagonalParams_->line1Length_ = p; } },
1326 { GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT_LINE2_START,
1327 [](GEVisualEffectImpl* obj, float p) { obj->contentDiagonalParams_->line2Start_ = p; } },
1328 { GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT_LINE2_LENGTH,
1329 [](GEVisualEffectImpl* obj, float p) { obj->contentDiagonalParams_->line2Length_ = p; } },
1330 { GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT_THICKNESS,
1331 [](GEVisualEffectImpl* obj, float p) { obj->contentDiagonalParams_->thickness_ = p; } },
1332 { GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT_RADIUS,
1333 [](GEVisualEffectImpl* obj, float p) { obj->contentDiagonalParams_->radius_ = p; } },
1334 { GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT_WEIGHT1,
1335 [](GEVisualEffectImpl* obj, float p) { obj->contentDiagonalParams_->weight1 = p; } },
1336 { GE_SHADER_CONTOUR_DIAGONAL_FLOW_LIGHT_WEIGHT2,
1337 [](GEVisualEffectImpl* obj, float p) { obj->contentDiagonalParams_->weight2 = p; } }
1338 };
1339
1340 auto it = actions.find(tag);
1341 if (it != actions.end()) {
1342 it->second(this, param);
1343 }
1344 }
1345
SetWavyRippleLightParams(const std::string & tag,float param)1346 void GEVisualEffectImpl::SetWavyRippleLightParams(const std::string& tag, float param)
1347 {
1348 if (wavyRippleLightParams_ == nullptr) {
1349 return;
1350 }
1351 if (tag == GE_SHADER_WAVY_RIPPLE_LIGHT_RIADIUS) {
1352 wavyRippleLightParams_->radius_ = param;
1353 }
1354 if (tag == GE_SHADER_WAVY_RIPPLE_LIGHT_THICKNESS) {
1355 wavyRippleLightParams_->thickness_ = param;
1356 }
1357 }
1358
SetWavyRippleLightParams(const std::string & tag,const std::pair<float,float> & param)1359 void GEVisualEffectImpl::SetWavyRippleLightParams(const std::string& tag, const std::pair<float, float>& param)
1360 {
1361 if (wavyRippleLightParams_ == nullptr) {
1362 return;
1363 }
1364 if (tag == GE_SHADER_WAVY_RIPPLE_LIGHT_CENTER) {
1365 wavyRippleLightParams_->center_ = param;
1366 }
1367 }
SetAuroraNoiseParams(const std::string & tag,float param)1368 void GEVisualEffectImpl::SetAuroraNoiseParams(const std::string& tag, float param)
1369 {
1370 if (auroNoiseParams_ == nullptr) {
1371 return;
1372 }
1373 if (tag == GE_SHADER_AURORA_NOISE_VALUE) {
1374 auroNoiseParams_->noise_ = param;
1375 }
1376 }
1377
SetParticleCircularHaloParams(const std::string & tag,const std::pair<float,float> & param)1378 void GEVisualEffectImpl::SetParticleCircularHaloParams(const std::string& tag, const std::pair<float, float>& param)
1379 {
1380 if (particleCircularHaloParams_ == nullptr) {
1381 return;
1382 }
1383 if (tag == GE_SHADER_PARTICLE_CIRCULAR_HALO_CENTER) {
1384 particleCircularHaloParams_->center_.first = std::clamp(param.first, 0.0f, 1.0f);
1385 particleCircularHaloParams_->center_.second = std::clamp(param.second, 0.0f, 1.0f);
1386 }
1387 }
1388
SetParticleCircularHaloParams(const std::string & tag,float param)1389 void GEVisualEffectImpl::SetParticleCircularHaloParams(const std::string& tag, float param)
1390 {
1391 if (particleCircularHaloParams_ == nullptr) {
1392 return;
1393 }
1394 if (tag == GE_SHADER_PARTICLE_CIRCULAR_HALO_RADIUS) {
1395 particleCircularHaloParams_->radius_ = std::clamp(param, 0.001f, 10.0f);
1396 }
1397 if (tag == GE_SHADER_PARTICLE_CIRCULAR_HALO_NOISE) {
1398 particleCircularHaloParams_->noise_ = std::max(param, 0.0f);
1399 }
1400 }
1401
SetBorderLightParams(const std::string & tag,float param)1402 void GEVisualEffectImpl::SetBorderLightParams(const std::string& tag, float param)
1403 {
1404 if (borderLightParams_ == nullptr) {
1405 return;
1406 }
1407 if (tag == GE_SHADER_BORDER_LIGHT_INTENSITY) {
1408 borderLightParams_->intensity = param;
1409 }
1410 if (tag == GE_SHADER_BORDER_LIGHT_WIDTH) {
1411 borderLightParams_->width = param;
1412 }
1413 if (tag == GE_SHADER_BORDER_LIGHT_CORNER_RADIUS) {
1414 borderLightParams_->cornerRadius = param;
1415 }
1416 }
1417
SetBorderLightParams(const std::string & tag,const Vector3f & param)1418 void GEVisualEffectImpl::SetBorderLightParams(const std::string& tag, const Vector3f& param)
1419 {
1420 if (borderLightParams_ == nullptr) {
1421 return;
1422 }
1423 if (tag == GE_SHADER_BORDER_LIGHT_POSITION) {
1424 borderLightParams_->position = param;
1425 }
1426 if (tag == GE_SHADER_BORDER_LIGHT_ROTATION_ANGLE) {
1427 borderLightParams_->rotationAngle = param;
1428 }
1429 }
1430
SetBorderLightParams(const std::string & tag,const Vector4f & param)1431 void GEVisualEffectImpl::SetBorderLightParams(const std::string& tag, const Vector4f& param)
1432 {
1433 if (borderLightParams_ == nullptr) {
1434 return;
1435 }
1436 if (tag == GE_SHADER_BORDER_LIGHT_COLOR) {
1437 borderLightParams_->color = param;
1438 }
1439 }
1440
SetMaskTransitionParamsFloat(const std::string & tag,float param)1441 void GEVisualEffectImpl::SetMaskTransitionParamsFloat(const std::string& tag, float param)
1442 {
1443 if (maskTransitionParams_ == nullptr) {
1444 GE_LOGE("GEVisualEffectImpl set factor failed, maskTransitionParams is nullptr");
1445 return;
1446 }
1447
1448 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1449 { GE_FILTER_MASK_TRANSITION_FACTOR,
1450 [](GEVisualEffectImpl* obj, float p) { obj->maskTransitionParams_->factor = p; } },
1451 };
1452
1453 auto it = actions.find(tag);
1454 if (it != actions.end()) {
1455 it->second(this, param);
1456 }
1457 }
1458
SetVariableRadiusBlurParams(const std::string & tag,float param)1459 void GEVisualEffectImpl::SetVariableRadiusBlurParams(const std::string& tag, float param)
1460 {
1461 if (variableRadiusBlurParams_ == nullptr) {
1462 return;
1463 }
1464 if (tag == GE_FILTER_VARIABLE_RADIUS_BLUR_RADIUS) {
1465 variableRadiusBlurParams_->blurRadius = param;
1466 }
1467 }
1468
SetColorGradientEffectParams(const std::string & tag,float param)1469 void GEVisualEffectImpl::SetColorGradientEffectParams(const std::string& tag, float param)
1470 {
1471 if (colorGradientEffectParams_ == nullptr) {
1472 return;
1473 }
1474 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, float)>> actions = {
1475 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR_NUMBER,
1476 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->colorNum_ = p;}},
1477 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH0,
1478 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[0] = p;}},
1479 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH1,
1480 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[1] = p;}},
1481 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH2,
1482 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[2] = p;}},
1483 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH3,
1484 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[3] = p;}},
1485 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH4,
1486 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[4] = p;}},
1487 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH5,
1488 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[5] = p;}},
1489 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH6,
1490 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[6] = p;}},
1491 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH7,
1492 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[7] = p;}},
1493 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH8,
1494 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[8] = p;}},
1495 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH9,
1496 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[9] = p;}},
1497 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH10,
1498 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[10] = p;}},
1499 {GEX_SHADER_COLOR_GRADIENT_EFFECT_STRENGTH11,
1500 [](GEVisualEffectImpl* obj, float p) {obj->colorGradientEffectParams_->strengths_[11] = p;}},
1501 };
1502 auto it = actions.find(tag);
1503 if (it != actions.end()) {
1504 it->second(this, param);
1505 }
1506 }
1507
SetColorGradientEffectParams(const std::string & tag,const Vector4f & param)1508 void GEVisualEffectImpl::SetColorGradientEffectParams(const std::string& tag, const Vector4f& param)
1509 {
1510 if (colorGradientEffectParams_ == nullptr) {
1511 return;
1512 }
1513 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, Vector4f)>> actions = {
1514 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR0, [](GEVisualEffectImpl* obj, Vector4f param) {
1515 obj->colorGradientEffectParams_->colors_[0] = Drawing::Color4f{param[0], param[1], param[2], param[3]};}
1516 },
1517 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR1, [](GEVisualEffectImpl* obj, Vector4f param) {
1518 obj->colorGradientEffectParams_->colors_[1] = Drawing::Color4f{param[0], param[1], param[2], param[3]};}
1519 },
1520 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR2, [](GEVisualEffectImpl* obj, Vector4f param) {
1521 obj->colorGradientEffectParams_->colors_[2] = Drawing::Color4f{param[0], param[1], param[2], param[3]};}
1522 },
1523 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR3, [](GEVisualEffectImpl* obj, Vector4f param) {
1524 obj->colorGradientEffectParams_->colors_[3] = Drawing::Color4f{param[0], param[1], param[2], param[3]};}
1525 },
1526 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR4, [](GEVisualEffectImpl* obj, Vector4f param) {
1527 obj->colorGradientEffectParams_->colors_[4] = Drawing::Color4f{param[0], param[1], param[2], param[3]};}
1528 },
1529 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR5, [](GEVisualEffectImpl* obj, Vector4f param) {
1530 obj->colorGradientEffectParams_->colors_[5] = Drawing::Color4f{param[0], param[1], param[2], param[3]};}
1531 },
1532 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR6, [](GEVisualEffectImpl* obj, Vector4f param) {
1533 obj->colorGradientEffectParams_->colors_[6] = Drawing::Color4f{param[0], param[1], param[2], param[3]};}
1534 },
1535 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR7, [](GEVisualEffectImpl* obj, Vector4f param) {
1536 obj->colorGradientEffectParams_->colors_[7] = Drawing::Color4f{param[0], param[1], param[2], param[3]};}
1537 },
1538 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR8, [](GEVisualEffectImpl* obj, Vector4f param) {
1539 obj->colorGradientEffectParams_->colors_[8] = Drawing::Color4f{param[0], param[1], param[2], param[3]};}
1540 },
1541 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR9, [](GEVisualEffectImpl* obj, Vector4f param) {
1542 obj->colorGradientEffectParams_->colors_[9] = Drawing::Color4f{param[0], param[1], param[2], param[3]};}
1543 },
1544 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR10, [](GEVisualEffectImpl* obj, Vector4f param) {
1545 obj->colorGradientEffectParams_->colors_[10] = Drawing::Color4f{param[0], param[1], param[2], param[3]};
1546 }
1547 },
1548 {GEX_SHADER_COLOR_GRADIENT_EFFECT_COLOR11, [](GEVisualEffectImpl* obj, Vector4f param) {
1549 obj->colorGradientEffectParams_->colors_[11] = Drawing::Color4f{param[0], param[1], param[2], param[3]};
1550 }
1551 },
1552
1553 };
1554 auto it = actions.find(tag);
1555 if (it != actions.end()) {
1556 it->second(this, param);
1557 }
1558 }
1559
SetColorGradientEffectParams(const std::string & tag,const std::pair<float,float> & param)1560 void GEVisualEffectImpl::SetColorGradientEffectParams(const std::string& tag, const std::pair<float, float>& param)
1561 {
1562 if (colorGradientEffectParams_ == nullptr) {
1563 return;
1564 }
1565 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, std::pair<float, float> params)>>
1566 actions = {
1567 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS0, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1568 obj->colorGradientEffectParams_->positions_[0] = Drawing::Point{param.first, param.second};}},
1569 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS1, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1570 obj->colorGradientEffectParams_->positions_[1] = Drawing::Point{param.first, param.second};}},
1571 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS2, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1572 obj->colorGradientEffectParams_->positions_[2] = Drawing::Point{param.first, param.second};}},
1573 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS3, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1574 obj->colorGradientEffectParams_->positions_[3] = Drawing::Point{param.first, param.second};} },
1575 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS4, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1576 obj->colorGradientEffectParams_->positions_[4] = Drawing::Point{param.first, param.second};}},
1577 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS5, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1578 obj->colorGradientEffectParams_->positions_[5] = Drawing::Point{param.first, param.second};}},
1579 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS6, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1580 obj->colorGradientEffectParams_->positions_[6] = Drawing::Point{param.first, param.second};}},
1581 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS7, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1582 obj->colorGradientEffectParams_->positions_[7] = Drawing::Point{param.first, param.second};}},
1583 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS8, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1584 obj->colorGradientEffectParams_->positions_[8] = Drawing::Point{param.first, param.second};}},
1585 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS9, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1586 obj->colorGradientEffectParams_->positions_[9] = Drawing::Point{param.first, param.second};}},
1587 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS10, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1588 obj->colorGradientEffectParams_->positions_[10] = Drawing::Point{param.first, param.second};}},
1589 {GEX_SHADER_COLOR_GRADIENT_EFFECT_POS11, [](GEVisualEffectImpl* obj, std::pair<float, float> param) {
1590 obj->colorGradientEffectParams_->positions_[11] = Drawing::Point{param.first, param.second};}}
1591 };
1592 auto it = actions.find(tag);
1593 if (it != actions.end()) {
1594 it->second(this, param);
1595 }
1596 }
1597
1598
SetLightCaveParams(const std::string & tag,const Vector4f & param)1599 void GEVisualEffectImpl::SetLightCaveParams(const std::string& tag, const Vector4f& param)
1600 {
1601 if (lightCaveShaderParams_ == nullptr) {
1602 return;
1603 }
1604
1605 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*, const Vector4f&)>> actions = {
1606 { GEX_SHADER_LIGHT_CAVE_COLORA,
1607 [](GEVisualEffectImpl* obj, const Vector4f& p) { obj->lightCaveShaderParams_->colorA = p; }
1608 },
1609 { GEX_SHADER_LIGHT_CAVE_COLORB,
1610 [](GEVisualEffectImpl* obj, const Vector4f& p) { obj->lightCaveShaderParams_->colorB = p; }
1611 },
1612 { GEX_SHADER_LIGHT_CAVE_COLORC,
1613 [](GEVisualEffectImpl* obj, const Vector4f& p) { obj->lightCaveShaderParams_->colorC = p; }
1614 }
1615 };
1616
1617 auto it = actions.find(tag);
1618 if (it != actions.end()) {
1619 it->second(this, param);
1620 }
1621 }
1622
SetLightCaveParams(const std::string & tag,const std::pair<float,float> & param)1623 void GEVisualEffectImpl::SetLightCaveParams(const std::string& tag, const std::pair<float, float>& param)
1624 {
1625 if (lightCaveShaderParams_ == nullptr) {
1626 return;
1627 }
1628
1629 static std::unordered_map<std::string, std::function<void(GEVisualEffectImpl*,
1630 const std::pair<float, float>&)>> actions = {
1631 { GEX_SHADER_LIGHT_CAVE_POSITION,
1632 [](GEVisualEffectImpl* obj, const std::pair<float, float>& p) {
1633 obj->lightCaveShaderParams_->position = Vector2f(p.first, p.second);
1634 }
1635 },
1636 { GEX_SHADER_LIGHT_CAVE_RADIUSXY,
1637 [](GEVisualEffectImpl* obj, const std::pair<float, float>& p) {
1638 obj->lightCaveShaderParams_->radiusXY = Vector2f(p.first, p.second);
1639 }
1640 }
1641 };
1642
1643 auto it = actions.find(tag);
1644 if (it != actions.end()) {
1645 it->second(this, param);
1646 }
1647 }
1648
SetLightCaveParams(const std::string & tag,float param)1649 void GEVisualEffectImpl::SetLightCaveParams(const std::string& tag, float param)
1650 {
1651 if (lightCaveShaderParams_ == nullptr) {
1652 return;
1653 }
1654
1655 if (tag == GEX_SHADER_LIGHT_CAVE_PROGRESS) {
1656 lightCaveShaderParams_->progress = param;
1657 }
1658 }
1659 } // namespace Drawing
1660 } // namespace Rosen
1661 } // namespace OHOS
1662