forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_list_testing.cc
851 lines (801 loc) · 33.2 KB
/
display_list_testing.cc
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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/testing/display_list_testing.h"
#include <iomanip>
#include "flutter/display_list/display_list.h"
namespace flutter {
namespace testing {
// clang-format off
bool DisplayListsEQ_Verbose(const DisplayList* a, const DisplayList* b) {
if (a->Equals(b)) {
return true;
}
FML_LOG(ERROR) << std::endl
<< std::endl
<< *a << std::endl
<< "not identical to ..." << std::endl
<< std::endl
<< *b;
return false;
}
bool DisplayListsNE_Verbose(const DisplayList* a, const DisplayList* b) {
if (a->Equals(b)) {
FML_LOG(ERROR) << std::endl
<< "DisplayLists are both the same:" << std::endl
<< *a;
return false;
}
return true;
}
std::ostream& operator<<(std::ostream& os,
const DisplayList& display_list) {
DisplayListStreamDispatcher dispatcher(os);
os << std::boolalpha;
os << std::setprecision(std::numeric_limits<long double>::digits10 + 1);
os << "DisplayList {" << std::endl;
display_list.Dispatch(dispatcher);
os << "}" << std::endl;
return os;
}
std::ostream& operator<<(std::ostream& os, const DlBlendMode& mode) {
switch (mode) {
case DlBlendMode::kClear: return os << "BlendMode::kClear";
case DlBlendMode::kSrc: return os << "BlendMode::kSrc";
case DlBlendMode::kDst: return os << "BlendMode::kDst";
case DlBlendMode::kSrcOver: return os << "BlendMode::kSrcOver";
case DlBlendMode::kDstOver: return os << "BlendMode::kDstOver";
case DlBlendMode::kSrcIn: return os << "BlendMode::kSrcIn";
case DlBlendMode::kDstIn: return os << "BlendMode::kDstIn";
case DlBlendMode::kSrcOut: return os << "BlendMode::kSrcOut";
case DlBlendMode::kDstOut: return os << "BlendMode::kDstOut";
case DlBlendMode::kSrcATop: return os << "BlendMode::kSrcATop";
case DlBlendMode::kDstATop: return os << "BlendMode::kDstATop";
case DlBlendMode::kXor: return os << "BlendMode::kXor";
case DlBlendMode::kPlus: return os << "BlendMode::kPlus";
case DlBlendMode::kModulate: return os << "BlendMode::kModulate";
case DlBlendMode::kScreen: return os << "BlendMode::kScreen";
case DlBlendMode::kOverlay: return os << "BlendMode::kOverlay";
case DlBlendMode::kDarken: return os << "BlendMode::kDarken";
case DlBlendMode::kLighten: return os << "BlendMode::kLighten";
case DlBlendMode::kColorDodge: return os << "BlendMode::kColorDodge";
case DlBlendMode::kColorBurn: return os << "BlendMode::kColorBurn";
case DlBlendMode::kHardLight: return os << "BlendMode::kHardLight";
case DlBlendMode::kSoftLight: return os << "BlendMode::kSoftLight";
case DlBlendMode::kDifference: return os << "BlendMode::kDifference";
case DlBlendMode::kExclusion: return os << "BlendMode::kExclusion";
case DlBlendMode::kMultiply: return os << "BlendMode::kMultiply";
case DlBlendMode::kHue: return os << "BlendMode::kHue";
case DlBlendMode::kSaturation: return os << "BlendMode::kSaturation";
case DlBlendMode::kColor: return os << "BlendMode::kColor";
case DlBlendMode::kLuminosity: return os << "BlendMode::kLuminosity";
default: return os << "BlendMode::????";
}
}
std::ostream& operator<<(std::ostream& os, const SaveLayerOptions& options) {
return os << "SaveLayerOptions("
<< "can_distribute_opacity: " << options.can_distribute_opacity()
<< ", "
<< "renders_with_attributes: " << options.renders_with_attributes()
<< ")";
}
static std::ostream& operator<<(std::ostream& os, const SkPoint& point) {
return os << "SkPoint(" << point.fX << ", " << point.fY << ")";
}
static std::ostream& operator<<(std::ostream& os, const SkIRect& rect) {
return os << "SkIRect("
<< "left: " << rect.fLeft << ", "
<< "top: " << rect.fTop << ", "
<< "right: " << rect.fRight << ", "
<< "bottom: " << rect.fBottom
<< ")";
}
static std::ostream& operator<<(std::ostream& os, const SkRect& rect) {
return os << "SkRect("
<< "left: " << rect.fLeft << ", "
<< "top: " << rect.fTop << ", "
<< "right: " << rect.fRight << ", "
<< "bottom: " << rect.fBottom
<< ")";
}
static std::ostream& operator<<(std::ostream& os, const SkRect* rect) {
return rect ? (os << "&" << *rect) : os << "no rect";
}
static std::ostream& operator<<(std::ostream& os, const SkRRect& rrect) {
return os << "SkRRect("
<< rrect.rect() << ", "
<< "ul: (" << rrect.radii(SkRRect::kUpperLeft_Corner).fX << ", "
<< rrect.radii(SkRRect::kUpperLeft_Corner).fY << "), "
<< "ur: (" << rrect.radii(SkRRect::kUpperRight_Corner).fX << ", "
<< rrect.radii(SkRRect::kUpperRight_Corner).fY << "), "
<< "lr: (" << rrect.radii(SkRRect::kLowerRight_Corner).fX << ", "
<< rrect.radii(SkRRect::kLowerRight_Corner).fY << "), "
<< "ll: (" << rrect.radii(SkRRect::kLowerLeft_Corner).fX << ", "
<< rrect.radii(SkRRect::kLowerLeft_Corner).fY << ")"
<< ")";
}
static std::ostream& operator<<(std::ostream& os, const SkPath& path) {
return os << "SkPath("
<< "bounds: " << path.getBounds()
// should iterate over verbs and coordinates...
<< ")";
}
static std::ostream& operator<<(std::ostream& os, const SkMatrix& matrix) {
return os << "SkMatrix("
<< "[" << matrix[0] << ", " << matrix[1] << ", " << matrix[2] << "], "
<< "[" << matrix[3] << ", " << matrix[4] << ", " << matrix[5] << "], "
<< "[" << matrix[6] << ", " << matrix[7] << ", " << matrix[8] << "]"
<< ")";
}
static std::ostream& operator<<(std::ostream& os, const SkMatrix* matrix) {
if (matrix) return os << "&" << *matrix;
return os << "no matrix";
}
static std::ostream& operator<<(std::ostream& os, const SkRSXform& xform) {
return os << "SkRSXform("
<< "scos: " << xform.fSCos << ", "
<< "ssin: " << xform.fSSin << ", "
<< "tx: " << xform.fTx << ", "
<< "ty: " << xform.fTy << ")";
}
static std::ostream& operator<<(std::ostream& os, const SkClipOp& op) {
switch (op) {
case SkClipOp::kDifference: return os << "ClipOp::kDifference";
case SkClipOp::kIntersect: return os << "ClipOp::kIntersect";
default: return os << "ClipOp::????";
}
}
static std::ostream& operator<<(std::ostream& os, const DlStrokeCap& cap) {
switch (cap) {
case DlStrokeCap::kButt: return os << "Cap::kButt";
case DlStrokeCap::kRound: return os << "Cap::kRound";
case DlStrokeCap::kSquare: return os << "Cap::kSquare";
default: return os << "Cap::????";
}
}
static std::ostream& operator<<(std::ostream& os, const DlStrokeJoin& join) {
switch (join) {
case DlStrokeJoin::kMiter: return os << "Join::kMiter";
case DlStrokeJoin::kRound: return os << "Join::kRound";
case DlStrokeJoin::kBevel: return os << "Join::kBevel";
default: return os << "Join::????";
}
}
static std::ostream& operator<<(std::ostream& os, const DlDrawStyle& style) {
switch (style) {
case DlDrawStyle::kFill: return os << "Style::kFill";
case DlDrawStyle::kStroke: return os << "Style::kStroke";
case DlDrawStyle::kStrokeAndFill: return os << "Style::kStrokeAnFill";
default: return os << "Style::????";
}
}
static std::ostream& operator<<(std::ostream& os, const SkBlurStyle& style) {
switch (style) {
case kNormal_SkBlurStyle: return os << "BlurStyle::kNormal";
case kSolid_SkBlurStyle: return os << "BlurStyle::kSolid";
case kOuter_SkBlurStyle: return os << "BlurStyle::kOuter";
case kInner_SkBlurStyle: return os << "BlurStyle::kInner";
default: return os << "Style::????";
}
}
static std::ostream& operator<<(std::ostream& os,
const SkCanvas::PointMode& mode) {
switch (mode) {
case SkCanvas::kPoints_PointMode: return os << "PointMode::kPoints";
case SkCanvas::kLines_PointMode: return os << "PointMode::kLines";
case SkCanvas::kPolygon_PointMode: return os << "PointMode::kPolygon";
default: return os << "PointMode::????";
}
}
static std::ostream& operator<<(std::ostream& os, const DlFilterMode& mode) {
switch (mode) {
case DlFilterMode::kNearest: return os << "FilterMode::kNearest";
case DlFilterMode::kLinear: return os << "FilterMode::kLinear";
default: return os << "FilterMode::????";
}
}
static std::ostream& operator<<(std::ostream& os, const DlColor& color) {
return os << "DlColor(" << std::hex << color.argb << std::dec << ")";
}
static std::ostream& operator<<(std::ostream& os,
DlImageSampling sampling) {
switch (sampling) {
case DlImageSampling::kNearestNeighbor: {
return os << "NearestSampling";
}
case DlImageSampling::kLinear: {
return os << "LinearSampling";
}
case DlImageSampling::kMipmapLinear: {
return os << "MipmapSampling";
}
case DlImageSampling::kCubic: {
return os << "CubicSampling";
}
}
}
static std::ostream& operator<<(std::ostream& os, const SkTextBlob* blob) {
if (blob == nullptr) {
return os << "no text";
}
return os << "&SkTextBlob(ID: " << blob->uniqueID() << ", " << blob->bounds() << ")";
}
static std::ostream& operator<<(std::ostream& os, const DlVertexMode& mode) {
switch (mode) {
case DlVertexMode::kTriangles: return os << "VertexMode::kTriangles";
case DlVertexMode::kTriangleStrip: return os << "VertexMode::kTriangleStrip";
case DlVertexMode::kTriangleFan: return os << "VertexMode::kTriangleFan";
default: return os << "VertexMode::????";
}
}
static std::ostream& operator<<(std::ostream& os, const DlTileMode& mode) {
switch (mode) {
case DlTileMode::kClamp: return os << "TileMode::kClamp";
case DlTileMode::kRepeat: return os << "TileMode::kRepeat";
case DlTileMode::kMirror: return os << "TileMode::kMirror";
case DlTileMode::kDecal: return os << "TileMode::kDecal";
default: return os << "TileMode::????";
}
}
static std::ostream& operator<<(std::ostream& os, const DlImage* image) {
if (image == nullptr) {
return os << "null image";
}
os << "&DlImage(" << image->width() << " x " << image->height() << ", ";
if (image->skia_image()) {
os << "skia(" << image->skia_image().get() << "), ";
}
if (image->impeller_texture()) {
os << "impeller(" << image->impeller_texture().get() << "), ";
}
return os << "isTextureBacked: " << image->isTextureBacked() << ")";
}
std::ostream& DisplayListStreamDispatcher::startl() {
for (int i = 0; i < cur_indent_; i++) {
os_ << " ";
}
return os_;
}
template <class T>
std::ostream& DisplayListStreamDispatcher::out_array(std::string name,
int count,
const T array[]) {
if (array == nullptr || count < 0) {
return os_ << "no " << name;
}
os_ << name << "[" << count << "] = [" << std::endl;
indent();
indent();
for (int i = 0; i < count; i++) {
startl() << array[i] << "," << std::endl;
}
outdent();
startl() << "]";
outdent();
return os_;
}
void DisplayListStreamDispatcher::setAntiAlias(bool aa) {
startl() << "setAntiAlias(" << aa << ");" << std::endl;
}
void DisplayListStreamDispatcher::setDither(bool dither) {
startl() << "setDither(" << dither << ");" << std::endl;
}
void DisplayListStreamDispatcher::setStyle(DlDrawStyle style) {
startl() << "setStyle(" << style << ");" << std::endl;
}
void DisplayListStreamDispatcher::setColor(DlColor color) {
startl() << "setColor(" << color << ");" << std::endl;
}
void DisplayListStreamDispatcher::setStrokeWidth(SkScalar width) {
startl() << "setStrokeWidth(" << width << ");" << std::endl;
}
void DisplayListStreamDispatcher::setStrokeMiter(SkScalar limit) {
startl() << "setStrokeMiter(" << limit << ");" << std::endl;
}
void DisplayListStreamDispatcher::setStrokeCap(DlStrokeCap cap) {
startl() << "setStrokeCap(" << cap << ");" << std::endl;
}
void DisplayListStreamDispatcher::setStrokeJoin(DlStrokeJoin join) {
startl() << "setStrokeJoin(" << join << ");" << std::endl;
}
void DisplayListStreamDispatcher::setColorSource(const DlColorSource* source) {
if (source == nullptr) {
startl() << "setColorSource(no ColorSource);" << std::endl;
return;
}
startl() << "setColorSource(";
switch (source->type()) {
case DlColorSourceType::kColor: {
const DlColorColorSource* color_src = source->asColor();
FML_DCHECK(color_src);
os_ << "DlColorColorSource(" << color_src->color() << ")";
break;
}
case DlColorSourceType::kImage: {
const DlImageColorSource* image_src = source->asImage();
FML_DCHECK(image_src);
os_ << "DlImageColorSource(image: " << image_src->image()
<< ", hMode: " << image_src->horizontal_tile_mode()
<< ", vMode: " << image_src->vertical_tile_mode()
<< ", " << image_src->sampling()
<< ", " << image_src->matrix_ptr()
<< ")";
break;
}
case DlColorSourceType::kLinearGradient: {
const DlLinearGradientColorSource* linear_src = source->asLinearGradient();
FML_DCHECK(linear_src);
os_ << "DlLinearGradientSource("
<< "start: " << linear_src->start_point()
<< ", end: " << linear_src->end_point() << ", ";
out_array("colors", linear_src->stop_count(), linear_src->colors()) << ", ";
out_array("stops", linear_src->stop_count(), linear_src->stops()) << ", "
<< linear_src->tile_mode() << ", " << linear_src->matrix_ptr() << ")";
break;
}
case DlColorSourceType::kRadialGradient: {
const DlRadialGradientColorSource* radial_src = source->asRadialGradient();
FML_DCHECK(radial_src);
os_ << "DlRadialGradientSource("
<< "center: " << radial_src->center()
<< ", radius: " << radial_src->radius() << ", ";
out_array("colors", radial_src->stop_count(), radial_src->colors()) << ", ";
out_array("stops", radial_src->stop_count(), radial_src->stops()) << ", "
<< radial_src->tile_mode() << ", " << radial_src->matrix_ptr() << ")";
break;
}
case DlColorSourceType::kConicalGradient: {
const DlConicalGradientColorSource* conical_src = source->asConicalGradient();
FML_DCHECK(conical_src);
os_ << "DlConicalGradientColorSource("
<< "start center: " << conical_src->start_center()
<< ", start radius: " << conical_src->start_radius()
<< ", end center: " << conical_src->end_center()
<< ", end radius: " << conical_src->end_radius() << ", ";
out_array("colors", conical_src->stop_count(), conical_src->colors()) << ", ";
out_array("stops", conical_src->stop_count(), conical_src->stops()) << ", "
<< conical_src->tile_mode() << ", " << conical_src->matrix_ptr() << ")";
break;
}
case DlColorSourceType::kSweepGradient: {
const DlSweepGradientColorSource* sweep_src = source->asSweepGradient();
FML_DCHECK(sweep_src);
os_ << "DlSweepGradientColorSource("
<< "center: " << sweep_src->center()
<< ", start: " << sweep_src->start() << ", "
<< ", end: " << sweep_src->end() << ", ";
out_array("colors", sweep_src->stop_count(), sweep_src->colors()) << ", ";
out_array("stops", sweep_src->stop_count(), sweep_src->stops()) << ", "
<< sweep_src->tile_mode() << ", " << sweep_src->matrix_ptr() << ")";
break;
}
default:
os_ << "DlUnknownColorSource(" << source->skia_object().get() << ")";
break;
}
os_ << ");" << std::endl;
}
void DisplayListStreamDispatcher::out(const DlColorFilter& filter) {
switch (filter.type()) {
case DlColorFilterType::kBlend: {
const DlBlendColorFilter* blend = filter.asBlend();
FML_DCHECK(blend);
os_ << "DlBlendColorFilter(" << blend->color() << ", "
<< static_cast<int>(blend->mode()) << ")";
break;
}
case DlColorFilterType::kMatrix: {
const DlMatrixColorFilter* matrix = filter.asMatrix();
FML_DCHECK(matrix);
float values[20];
matrix->get_matrix(values);
os_ << "DlMatrixColorFilter(matrix[20] = [" << std::endl;
indent();
for (int i = 0; i < 20; i += 5) {
startl() << values[i] << ", "
<< values[i+1] << ", "
<< values[i+2] << ", "
<< values[i+3] << ", "
<< values[i+4] << ","
<< std::endl;
}
outdent();
startl() << "]";
break;
}
case DlColorFilterType::kSrgbToLinearGamma: {
os_ << "DlSrgbToLinearGammaColorFilter()";
break;
}
case DlColorFilterType::kLinearToSrgbGamma: {
os_ << "DlLinearToSrgbGammaColorFilter()";
break;
}
default:
os_ << "DlUnknownColorFilter(" << filter.skia_object().get() << ")";
break;
}
}
void DisplayListStreamDispatcher::out(const DlColorFilter* filter) {
if (filter == nullptr) {
os_ << "no ColorFilter";
} else {
os_ << "&";
out(*filter);
}
}
void DisplayListStreamDispatcher::setColorFilter(const DlColorFilter* filter) {
startl() << "setColorFilter(";
out(filter);
os_ << ");" << std::endl;
}
void DisplayListStreamDispatcher::setInvertColors(bool invert) {
startl() << "setInvertColors(" << invert << ");" << std::endl;
}
void DisplayListStreamDispatcher::setBlendMode(DlBlendMode mode) {
startl() << "setBlendMode(" << mode << ");" << std::endl;
}
void DisplayListStreamDispatcher::setBlender(sk_sp<SkBlender> blender) {
startl() << "setBlender(" << blender << ");" << std::endl;
}
void DisplayListStreamDispatcher::setPathEffect(const DlPathEffect* effect) {
startl() << "setPathEffect(" << effect << ");" << std::endl;
}
void DisplayListStreamDispatcher::setMaskFilter(const DlMaskFilter* filter) {
if (filter == nullptr) {
startl() << "setMaskFilter(no MaskFilter);" << std::endl;
return;
}
startl() << "setMaskFilter(";
switch (filter->type()) {
case DlMaskFilterType::kBlur: {
const DlBlurMaskFilter* blur = filter->asBlur();
FML_DCHECK(blur);
os_ << "DlMaskFilter(" << blur->style() << ", " << blur->sigma() << ")";
break;
}
default:
os_ << "DlUnknownMaskFilter(" << filter->skia_object().get() << ")";
break;
}
os_ << ");" << std::endl;
}
void DisplayListStreamDispatcher::out(const DlImageFilter& filter) {
switch (filter.type()) {
case DlImageFilterType::kBlur: {
const DlBlurImageFilter* blur = filter.asBlur();
FML_DCHECK(blur);
os_ << "DlBlurImageFilter(" << blur->sigma_x() << ", "
<< blur->sigma_y() << ", "
<< blur->tile_mode() << ")";
break;
}
case DlImageFilterType::kDilate: {
const DlDilateImageFilter* dilate = filter.asDilate();
FML_DCHECK(dilate);
os_ << "DlDilateImageFilter(" << dilate->radius_x() << ", " << dilate->radius_y() << ")";
break;
}
case DlImageFilterType::kErode: {
const DlErodeImageFilter* erode = filter.asErode();
FML_DCHECK(erode);
os_ << "DlDilateImageFilter(" << erode->radius_x() << ", " << erode->radius_y() << ")";
break;
}
case DlImageFilterType::kMatrix: {
const DlMatrixImageFilter* matrix = filter.asMatrix();
FML_DCHECK(matrix);
os_ << "DlMatrixImageFilter(" << matrix->matrix() << ", " << matrix->sampling() << ")";
break;
}
case DlImageFilterType::kComposeFilter: {
const DlComposeImageFilter* compose = filter.asCompose();
FML_DCHECK(compose);
os_ << "DlComposeImageFilter(" << std::endl;
indent();
startl() << "outer: ";
out(compose->outer().get());
os_ << "," << std::endl;
startl() << "inner: ";
out(compose->inner().get());
os_ << "," << std::endl;
outdent();
startl() << ")";
break;
}
case DlImageFilterType::kColorFilter: {
const DlColorFilterImageFilter* color_filter = filter.asColorFilter();
FML_DCHECK(color_filter);
os_ << "DlColorFilterImageFilter(";
out(*color_filter->color_filter());
os_ << ")";
break;
}
default:
os_ << "DlUnknownImageFilter(" << filter.skia_object().get() << ")";
break;
}
}
void DisplayListStreamDispatcher::out(const DlImageFilter* filter) {
if (filter == nullptr) {
os_ << "no ImageFilter";
} else {
os_ << "&";
out(*filter);
}
}
void DisplayListStreamDispatcher::setImageFilter(const DlImageFilter* filter) {
startl() << "setImageFilter(";
out(filter);
os_ << ");" << std::endl;
}
void DisplayListStreamDispatcher::save() {
startl() << "save();" << std::endl;
startl() << "{" << std::endl;
indent();
}
void DisplayListStreamDispatcher::saveLayer(const SkRect* bounds,
const SaveLayerOptions options,
const DlImageFilter* backdrop) {
startl() << "saveLayer(" << bounds << ", " << options;
if (backdrop) {
os_ << "," << std::endl;
indent(10);
startl() << "backdrop: ";
out(backdrop);
outdent(10);
} else {
os_ << ", no backdrop";
}
os_ << ");" << std::endl;
startl() << "{" << std::endl;
indent();
}
void DisplayListStreamDispatcher::restore() {
outdent();
startl() << "}" << std::endl;
startl() << "restore();" << std::endl;
}
void DisplayListStreamDispatcher::translate(SkScalar tx, SkScalar ty) {
startl() << "translate(" << tx << ", " << ty << ");" << std::endl;
}
void DisplayListStreamDispatcher::scale(SkScalar sx, SkScalar sy) {
startl() << "scale(" << sx << ", " << sy << ");" << std::endl;
}
void DisplayListStreamDispatcher::rotate(SkScalar degrees) {
startl() << "rotate(" << degrees << ");" << std::endl;
}
void DisplayListStreamDispatcher::skew(SkScalar sx, SkScalar sy) {
startl() << "skew(" << sx << ", " << sy << ");" << std::endl;
}
void DisplayListStreamDispatcher::transform2DAffine(
SkScalar mxx, SkScalar mxy, SkScalar mxt,
SkScalar myx, SkScalar myy, SkScalar myt) {
startl() << "transform2DAffine(" << std::endl;
indent();
{
startl()
<< "[" << mxx << ", " << mxy << ", " << mxt << "], "
<< std::endl;
startl()
<< "[" << myx << ", " << myy << ", " << myt << "], "
<< std::endl;
}
outdent();
startl() << ");" << std::endl;
}
void DisplayListStreamDispatcher::transformFullPerspective(
SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt,
SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt,
SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt,
SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) {
startl() << "transformFullPerspective(" << std::endl;
indent();
{
startl()
<< "[" << mxx << ", " << mxy << ", " << mxz << ", " << mxt << "], "
<< std::endl;
startl()
<< "[" << myx << ", " << myy << ", " << myz << ", " << myt << "], "
<< std::endl;
startl()
<< "[" << mzx << ", " << mzy << ", " << mzz << ", " << mzt << "], "
<< std::endl;
startl()
<< "[" << mwx << ", " << mwy << ", " << mwz << ", " << mwt << "]"
<< std::endl;
}
outdent();
startl() << ");" << std::endl;
}
void DisplayListStreamDispatcher::transformReset() {
startl() << "transformReset();" << std::endl;
}
void DisplayListStreamDispatcher::clipRect(const SkRect& rect, SkClipOp clip_op,
bool is_aa) {
startl() << "clipRect("
<< rect << ", "
<< clip_op << ", "
<< "isaa: " << is_aa
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::clipRRect(const SkRRect& rrect,
SkClipOp clip_op,
bool is_aa) {
startl() << "clipRRect("
<< rrect << ", "
<< clip_op << ", "
<< "isaa: " << is_aa
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::clipPath(const SkPath& path, SkClipOp clip_op,
bool is_aa) {
startl() << "clipPath("
<< path << ", "
<< clip_op << ", "
<< "isaa: " << is_aa
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawColor(DlColor color, DlBlendMode mode) {
startl() << "drawColor("
<< color << ", "
<< mode
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawPaint() {
startl() << "drawPaint();" << std::endl;
}
void DisplayListStreamDispatcher::drawLine(const SkPoint& p0,
const SkPoint& p1) {
startl() << "drawLine(" << p0 << ", " << p1 << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawRect(const SkRect& rect) {
startl() << "drawRect(" << rect << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawOval(const SkRect& bounds) {
startl() << "drawOval(" << bounds << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawCircle(const SkPoint& center,
SkScalar radius) {
startl() << "drawCircle(" << center << ", " << radius << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawRRect(const SkRRect& rrect) {
startl() << "drawRRect(" << rrect << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawDRRect(const SkRRect& outer,
const SkRRect& inner) {
startl() << "drawDRRect(outer: " << outer << ", " << std::endl;
startl() << " inner: " << inner << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawPath(const SkPath& path) {
startl() << "drawPath(" << path << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawArc(const SkRect& oval_bounds,
SkScalar start_degrees,
SkScalar sweep_degrees,
bool use_center) {
startl() << "drawArc("
<< oval_bounds << ", "
<< start_degrees << ", "
<< sweep_degrees << ", "
<< "use_center: " << use_center
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawPoints(SkCanvas::PointMode mode,
uint32_t count,
const SkPoint points[]) {
startl() << "drawPoints(" << mode << ", ";
out_array("points", count, points)
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawSkVertices(const sk_sp<SkVertices> vertices,
SkBlendMode mode) {
startl() << "drawSkVertices(" << vertices << ", " << static_cast<int>(mode) << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawVertices(const DlVertices* vertices,
DlBlendMode mode) {
startl() << "drawVertices("
<< "DlVertices("
<< vertices->mode() << ", ";
out_array("vertices", vertices->vertex_count(), vertices->vertices()) << ", ";
out_array("texture_coords", vertices->vertex_count(), vertices->texture_coordinates()) << ", ";
out_array("colors", vertices->vertex_count(), vertices->colors()) << ", ";
out_array("indices", vertices->index_count(), vertices->indices())
<< "), " << mode << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawImage(const sk_sp<DlImage> image,
const SkPoint point,
DlImageSampling sampling,
bool render_with_attributes) {
startl() << "drawImage(" << image.get() << "," << std::endl;
startl() << " " << point << ", "
<< sampling << ", "
<< "with attributes: " << render_with_attributes
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawImageRect(const sk_sp<DlImage> image,
const SkRect& src,
const SkRect& dst,
DlImageSampling sampling,
bool render_with_attributes,
SkCanvas::SrcRectConstraint constraint) {
startl() << "drawImageRect(" << image.get() << "," << std::endl;
startl() << " src: " << src << "," << std::endl;
startl() << " dst: " << dst << "," << std::endl;
startl() << " " << sampling << ", "
<< "with attributes: " << render_with_attributes << ", "
<< constraint
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawImageNine(const sk_sp<DlImage> image,
const SkIRect& center,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) {
startl() << "drawImageNine(" << image.get() << "," << std::endl;
startl() << " center: " << center << "," << std::endl;
startl() << " dst: " << dst << "," << std::endl;
startl() << " " << filter << ", "
<< "with attributes: " << render_with_attributes
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawImageLattice(const sk_sp<DlImage> image,
const SkCanvas::Lattice& lattice,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) {
startl() << "drawImageLattice(blah blah);" << std::endl;
}
void DisplayListStreamDispatcher::drawAtlas(const sk_sp<DlImage> atlas,
const SkRSXform xform[],
const SkRect tex[],
const DlColor colors[],
int count,
DlBlendMode mode,
DlImageSampling sampling,
const SkRect* cull_rect,
bool render_with_attributes) {
startl() << "drawAtlas(" << atlas.get() << ", ";
out_array("xforms", count, xform) << ", ";
out_array("tex_coords", count, tex) << ", ";
out_array("colors", count, colors) << ", "
<< mode << ", " << sampling << ", cull: " << cull_rect << ", "
<< "with attributes: " << render_with_attributes
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawPicture(const sk_sp<SkPicture> picture,
const SkMatrix* matrix,
bool render_with_attributes) {
startl() << "drawPicture("
<< "SkPicture(ID: " << picture->uniqueID() << ", bounds: " << picture->cullRect() << ", @" << picture << "), "
<< matrix << ", "
<< render_with_attributes
<< ");" << std::endl;
}
void DisplayListStreamDispatcher::drawDisplayList(
const sk_sp<DisplayList> display_list) {
startl() << "drawDisplayList(ID: " << display_list->unique_id() << ", bounds: " << display_list->bounds() << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawTextBlob(const sk_sp<SkTextBlob> blob,
SkScalar x,
SkScalar y) {
startl() << "drawTextBlob("
<< blob.get() << ", "
<< x << ", " << y << ");" << std::endl;
}
void DisplayListStreamDispatcher::drawShadow(const SkPath& path,
const DlColor color,
const SkScalar elevation,
bool transparent_occluder,
SkScalar dpr) {
startl() << "drawShadow("
<< path << ", "
<< color << ", "
<< elevation << ", "
<< transparent_occluder << ", "
<< dpr
<< ");" << std::endl;
}
// clang-format on
} // namespace testing
} // namespace flutter