• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in comliance with the License.
5  * You may obtian 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 
16 #include "../../dtk_constants.h"
17 #include "../../dtk_test_ext.h"
18 #include "../../utils.h"
19 
20 namespace OHOS {
21 namespace Rosen {
22 // 测试类:Pixmap
23 // 测试接口:Pixmap构造接口、Pixmap操作接口、clip接口、transform接口、抗锯齿、透明度、视效接口
24 // 测试内容:对Pixmap和图元操作接口、视效接口等进行组合
25 
26 using namespace Drawing;
27 
28 // Pixmap_Scene_0091
29 // Pixmap构造接口:Pixmap_ImageInfo_07
30 // Pixmap操作接口:ScalePixels
31 // cilp:ClipRoundRect(G2)
32 // transform:ConcatMatrix
33 // 抗锯齿:AA
34 // 透明度:不透明
35 // 视效:CreateBlendModeColorFilter
36 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 1)
37 {
38     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
39     Drawing::Brush brush;
40     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
41     // 2.Pixmap构造接口
42     auto colorspace = Drawing::ColorSpace::CreateSRGB();
43     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_PREMUL,
44         colorspace); // 512 width * 512 height
45     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
46 
47     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
48     ImageInfo imageinfo2 = ImageInfo::MakeN32Premul(4, 4); // pixel row and col(4, 4)
49     uint32_t data[16];
50     Pixmap dst(imageinfo2, data, sizeof(uint32_t) * imageinfo2.GetWidth());
51 
52     Drawing::Bitmap bitmap1;
53     bitmap1.Build(imageinfo2);
54     bitmap1.ClearWithColor(0xFF789645); // 不透明效果,灰绿色
55 
56     // 4.组合transform函数
57     Drawing::Matrix matrix;
58     matrix.Rotate(15, 10, 10); // 15 angle 10 position
59     playbackCanvas_->ConcatMatrix(matrix);
60 
61     // 5.设置视效效果,将效果添加到笔刷
62     int rectPos = 0;
63     brush.SetColor(0xFFFF0000);
64     for (auto blendMode : blendModes) {
65         std::shared_ptr<Drawing::ColorFilter> colorFilter =
66             Drawing::ColorFilter::CreateBlendModeColorFilter(0xFFFF0000, blendMode);
67         auto filter = Drawing::Filter();
68         filter.SetColorFilter(colorFilter);
69         brush.SetFilter(filter);
70 
71         // 6.绘制结果
72         const void* pixel1 = pixmap.GetAddr();
73         bitmap1.SetPixels(const_cast<void*>(pixel1));
74         playbackCanvas_->AttachBrush(brush);
75         if (pixmap.ScalePixels(dst, SamplingOptions())) {
76             playbackCanvas_->DrawRect(Drawing::Rect(800 + (rectPos % VARIATION) * LEFT,
77                 800 + (rectPos / VARIATION) * LEFT, 1000 + (rectPos % VARIATION) * LEFT,
78                 1000 + (rectPos / VARIATION) * LEFT)); // rect region(800, 800, 1000, 1000)
79         } else {
80             playbackCanvas_->DrawRect(Drawing::Rect(1000 + (rectPos % VARIATION) * LEFT,
81                 1000 + (rectPos / VARIATION) * LEFT, 1200 + (rectPos % VARIATION) * LEFT,
82                 1200 + (rectPos / VARIATION) * LEFT)); // rect region(1000, 1000, 1200, 1200)
83         }
84         playbackCanvas_->DrawBitmap(bitmap1, 250 + (rectPos % VARIATION) * LEFT,
85             300 + (rectPos / VARIATION) * RIGHT); // 250,300 is bitmap position
86         rectPos += 1;
87     }
88     playbackCanvas_->DetachBrush();
89 
90     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
91     TestBase::ClipRoundRectG2(true);
92 }
93 
94 // Pixmap_Scene_0092
95 // Pixmap构造接口:Pixmap_ImageInfo_07
96 // Pixmap操作接口:ScalePixels
97 // cilp:ClipRoundRect(G2)
98 // transform:Scale(正常值)
99 // 抗锯齿:AA
100 // 透明度:不透明
101 // 视效:CreateMatrixColorFilter
102 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 2)
103 {
104     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
105     Drawing::Brush brush;
106     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
107     // 2.Pixmap构造接口
108     auto colorspace = Drawing::ColorSpace::CreateSRGB();
109     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_PREMUL,
110         colorspace); // 512 width * 512 height
111     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
112 
113     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
114     ImageInfo imageinfo2 = ImageInfo::MakeN32Premul(4, 4); // pixel row and col(4, 4)
115     uint32_t data[16];
116     Pixmap dst(imageinfo2, data, sizeof(uint32_t) * imageinfo2.GetWidth());
117 
118     Drawing::Bitmap bitmap1;
119     bitmap1.Build(imageinfo2);
120     bitmap1.ClearWithColor(0xFF789645); // 不透明效果,灰绿色
121 
122     // 4.组合transform函数
123     playbackCanvas_->Scale(2.0f, 2.0f); // ratio
124 
125     // 5.设置视效效果,将效果添加到笔刷
126     Drawing::ColorMatrix matrix;
127     matrix.SetArray(ARR);
128     auto cf = Drawing::ColorFilter::CreateMatrixColorFilter(matrix);
129     auto filter = Drawing::Filter();
130     filter.SetImageFilter(Drawing::ImageFilter::CreateColorFilterImageFilter(*cf, nullptr));
131     brush.SetFilter(filter);
132 
133     // 6.绘制结果
134     const void* pixel1 = pixmap.GetAddr();
135     bitmap1.SetPixels(const_cast<void*>(pixel1));
136     playbackCanvas_->AttachBrush(brush);
137     if (pixmap.ScalePixels(dst, SamplingOptions())) {
138         playbackCanvas_->DrawRect(Drawing::Rect(800, 800, 1000, 1000)); // rect region(800, 800, 1000, 1000)
139     } else {
140         playbackCanvas_->DrawRect(Drawing::Rect(1000, 1000, 1200, 1200)); // rect region(1000, 1000, 1200, 1200)
141     }
142     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
143     playbackCanvas_->DetachBrush();
144 
145     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
146     TestBase::ClipRoundRectG2(true);
147 }
148 
149 // Pixmap_Scene_0093
150 // Pixmap构造接口:Pixmap_ImageInfo_08
151 // Pixmap操作接口:GetWidth
152 // cilp:ClipRoundRect(G2_capsule)
153 // transform:Scale(极大值)
154 // 抗锯齿:非AA
155 // 透明度:透明
156 // 视效:CreateLinearGradient
157 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 3)
158 {
159     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
160     Drawing::Brush brush;
161     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
162     // 2.Pixmap构造接口
163     auto colorspace = Drawing::ColorSpace::CreateSRGB();
164     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
165         colorspace); // 512 width * 512 height
166     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
167 
168     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
169     auto width = pixmap.GetWidth();
170 
171     Drawing::Bitmap bitmap1;
172     bitmap1.Build(imageInfo);
173     bitmap1.ClearWithColor(0x00789645); // 透明效果,灰绿色
174 
175     // 4.组合transform函数
176     playbackCanvas_->Scale(1.0f, 10100.0f); // ratio
177 
178     // 5.设置视效效果,将效果添加到笔刷
179     std::vector<Drawing::ColorQuad> colors = { Drawing::Color::COLOR_RED, Drawing::Color::COLOR_GREEN,
180         Drawing::Color::COLOR_BLUE };
181     std::vector<Drawing::scalar> pos = { 0.00f, 0.50f, 1.00f };
182     auto linearGradient = Drawing::ShaderEffect::CreateLinearGradient(
183         { 0, 0 }, { 1000, 1000 }, colors, pos, Drawing::TileMode::CLAMP); // 0 start pos & 1000 end pos
184     brush.SetShaderEffect(linearGradient);
185 
186     // 6.绘制结果
187     const void* pixel1 = pixmap.GetAddr();
188     bitmap1.SetPixels(const_cast<void*>(pixel1));
189     playbackCanvas_->AttachBrush(brush);
190     playbackCanvas_->DrawRect(Rect(0, 0, width, 500)); // width * 500 height
191     playbackCanvas_->DrawBitmap(bitmap1, 250, 300);    // 250,300 is bitmap position
192     playbackCanvas_->DetachBrush();
193 
194     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
195     TestBase::ClipRoundRectG2capsule(false);
196 }
197 
198 // Pixmap_Scene_0094
199 // Pixmap构造接口:Pixmap_ImageInfo_08
200 // Pixmap操作接口:GetWidth
201 // cilp:null
202 // transform:Scale(正常值)
203 // 抗锯齿:非AA
204 // 透明度:不透明
205 // 视效:CreateComposeColorFilter
206 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 4)
207 {
208     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
209     Drawing::Brush brush;
210     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
211     // 2.Pixmap构造接口
212     auto colorspace = Drawing::ColorSpace::CreateSRGB();
213     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
214         colorspace); // 512 width * 512 height
215     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
216 
217     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
218     auto width = pixmap.GetWidth();
219 
220     Drawing::Bitmap bitmap1;
221     bitmap1.Build(imageInfo);
222     bitmap1.ClearWithColor(0xFF789645); // 不透明效果,灰绿色
223 
224     // 4.组合transform函数
225     playbackCanvas_->Scale(2.0f, 2.0f); // ratio
226 
227     // 5.设置视效效果,将效果添加到笔刷
228     brush.SetColor(0xFFFF0000);
229     std::shared_ptr<Drawing::ColorFilter> colorFilter1 =
230         Drawing::ColorFilter::CreateBlendModeColorFilter(0xFFFF0000, Drawing::BlendMode::SRC_IN);
231     std::shared_ptr<Drawing::ColorFilter> colorFilter2 =
232         Drawing::ColorFilter::CreateBlendModeColorFilter(0xFFFF00FF, Drawing::BlendMode::MODULATE);
233     std::shared_ptr<Drawing::ColorFilter> colorFilter3 =
234         Drawing::ColorFilter::CreateComposeColorFilter(*colorFilter1, *colorFilter2);
235     auto filter = Drawing::Filter();
236     filter.SetColorFilter(colorFilter3);
237     brush.SetFilter(filter);
238 
239     // 6.绘制结果
240     const void* pixel1 = pixmap.GetAddr();
241     bitmap1.SetPixels(const_cast<void*>(pixel1));
242     playbackCanvas_->AttachBrush(brush);
243     playbackCanvas_->DrawRect(Rect(0, 0, width, 500)); // width * 500 height
244     playbackCanvas_->DrawBitmap(bitmap1, 250, 300);    // 250,300 is bitmap position
245     playbackCanvas_->DetachBrush();
246 
247     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
248     // null
249 }
250 
251 // Pixmap_Scene_0095
252 // Pixmap构造接口:Pixmap_ImageInfo_08
253 // Pixmap操作接口:GetHeight
254 // cilp:ClipPath
255 // transform:Scale(极大值)
256 // 抗锯齿:AA
257 // 透明度:透明
258 // 视效:CreateMatrixColorFilter
259 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 5)
260 {
261     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
262     Drawing::Brush brush;
263     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
264     // 2.Pixmap构造接口
265     auto colorspace = Drawing::ColorSpace::CreateSRGB();
266     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
267         colorspace); // 512 width * 512 height
268     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
269 
270     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
271     auto height = pixmap.GetHeight();
272 
273     Drawing::Bitmap bitmap1;
274     bitmap1.Build(imageInfo);
275     bitmap1.ClearWithColor(0x00789645); // 透明效果,灰绿色
276 
277     // 4.组合transform函数
278     playbackCanvas_->Scale(1.0f, 10100.0f); // ratio
279 
280     // 5.设置视效效果,将效果添加到笔刷
281     Drawing::ColorMatrix matrix;
282     matrix.SetArray(ARR);
283     auto cf = Drawing::ColorFilter::CreateMatrixColorFilter(matrix);
284     auto filter = Drawing::Filter();
285     filter.SetImageFilter(Drawing::ImageFilter::CreateColorFilterImageFilter(*cf, nullptr));
286     brush.SetFilter(filter);
287 
288     // 6.绘制结果
289     const void* pixel1 = pixmap.GetAddr();
290     bitmap1.SetPixels(const_cast<void*>(pixel1));
291     playbackCanvas_->AttachBrush(brush);
292     playbackCanvas_->DrawRect(Rect(0, 0, 500, height)); // 500 width * height
293     playbackCanvas_->DrawBitmap(bitmap1, 250, 300);     // 250,300 is bitmap position
294     playbackCanvas_->DetachBrush();
295 
296     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
297     TestBase::ClipPath(true);
298 }
299 
300 // Pixmap_Scene_0096
301 // Pixmap构造接口:Pixmap_ImageInfo_08
302 // Pixmap操作接口:GetHeight
303 // cilp:ClipRoundRect(非G2)
304 // transform:Scale(极小值)
305 // 抗锯齿:AA
306 // 透明度:半透明
307 // 视效:CreateLumaColorFilter
308 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 6)
309 {
310     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
311     Drawing::Brush brush;
312     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
313     // 2.Pixmap构造接口
314     auto colorspace = Drawing::ColorSpace::CreateSRGB();
315     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
316         colorspace); // 512 width * 512 height
317     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
318 
319     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
320     auto height = pixmap.GetHeight();
321 
322     Drawing::Bitmap bitmap1;
323     bitmap1.Build(imageInfo);
324     bitmap1.ClearWithColor(0x89789645); // 半透明效果,灰绿色
325 
326     // 4.组合transform函数
327     playbackCanvas_->Scale(10100.0f, 1.0f); // ratio
328 
329     // 5.设置视效效果,将效果添加到笔刷
330     brush.SetColor(0xFF0000FF);
331     auto filter = Drawing::Filter();
332     filter.SetColorFilter(Drawing::ColorFilter::CreateLumaColorFilter());
333     brush.SetFilter(filter);
334 
335     // 6.绘制结果
336     const void* pixel1 = pixmap.GetAddr();
337     bitmap1.SetPixels(const_cast<void*>(pixel1));
338     playbackCanvas_->AttachBrush(brush);
339     playbackCanvas_->DrawRect(Rect(0, 0, 500, height)); // 500 width * height
340     playbackCanvas_->DrawBitmap(bitmap1, 250, 300);     // 250,300 is bitmap position
341     playbackCanvas_->DetachBrush();
342 
343     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
344     TestBase::ClipRoundRectnotG2(true);
345 }
346 
347 // Pixmap_Scene_0097
348 // Pixmap构造接口:Pixmap_ImageInfo_08
349 // Pixmap操作接口:GetColorType
350 // cilp:ClipRect
351 // transform:Scale(极小值)
352 // 抗锯齿:非AA
353 // 透明度:半透明
354 // 视效:CreateColorShader
355 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 7)
356 {
357     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
358     Drawing::Brush brush;
359     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
360     // 2.Pixmap构造接口
361     auto colorspace = Drawing::ColorSpace::CreateSRGB();
362     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
363         colorspace); // 512 width * 512 height
364     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
365 
366     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
367     // GetColorType只有绘制部分,放在绘制结果里
368 
369     Drawing::Bitmap bitmap1;
370     bitmap1.Build(imageInfo);
371     bitmap1.ClearWithColor(0x89789645); // 半透明效果,灰绿色
372 
373     // 4.组合transform函数
374     playbackCanvas_->Scale(10100.0f, 1.0f); // ratio
375 
376     // 5.设置视效效果,将效果添加到笔刷
377     brush.SetColor(0xFFFF0000);
378     auto colorShader = Drawing::ShaderEffect::CreateColorShader(Drawing::Color::COLOR_RED);
379     brush.SetShaderEffect(colorShader);
380 
381     // 6.绘制结果
382     const void* pixel1 = pixmap.GetAddr();
383     bitmap1.SetPixels(const_cast<void*>(pixel1));
384     playbackCanvas_->AttachBrush(brush);
385     if (pixmap.GetColorType() == COLORTYPE_UNKNOWN) {
386         playbackCanvas_->DrawRect(Drawing::Rect(800, 800, 1000, 1000)); // rect region(800, 800, 1000, 1000)
387     } else {
388         playbackCanvas_->DrawRect(Drawing::Rect(1000, 1000, 1200, 1200)); // rect region(1000, 1000, 1200, 1200)
389     }
390     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
391     playbackCanvas_->DetachBrush();
392 
393     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
394     TestBase::ClipRect(false);
395 }
396 
397 // Pixmap_Scene_0098
398 // Pixmap构造接口:Pixmap_ImageInfo_08
399 // Pixmap操作接口:GetColorType
400 // cilp:null
401 // transform:Translate
402 // 抗锯齿:非AA
403 // 透明度:不透明
404 // 视效:CreateBlendImageFilter
405 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 8)
406 {
407     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
408     Drawing::Brush brush;
409     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
410     // 2.Pixmap构造接口
411     auto colorspace = Drawing::ColorSpace::CreateSRGB();
412     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
413         colorspace); // 512 width * 512 height
414     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
415 
416     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
417     // GetColorType只有绘制部分,放在绘制结果里
418 
419     Drawing::Bitmap bitmap1;
420     bitmap1.Build(imageInfo);
421     bitmap1.ClearWithColor(0xFF789645); // 不透明效果,灰绿色
422 
423     // 4.组合transform函数
424     playbackCanvas_->Translate(200, 200); // 200 distance
425 
426     // 5.设置视效效果,将效果添加到笔刷
427     int rectPos = 0;
428     brush.SetColor(0x4CB21933);
429     for (auto blendMode : blendModes) {
430         auto background = Drawing::ImageFilter::CreateBlurImageFilter(
431             1.0f, 1.0f, Drawing::TileMode::REPEAT, nullptr, Drawing::ImageBlurType::GAUSS);
432         auto foreground = Drawing::ImageFilter::CreateBlurImageFilter(
433             1.0f, 1.0f, Drawing::TileMode::REPEAT, nullptr, Drawing::ImageBlurType::GAUSS);
434         auto filter = Drawing::Filter();
435         filter.SetImageFilter(Drawing::ImageFilter::CreateBlendImageFilter(blendMode, background, foreground));
436         brush.SetFilter(filter);
437 
438         // 6.绘制结果
439         const void* pixel1 = pixmap.GetAddr();
440         bitmap1.SetPixels(const_cast<void*>(pixel1));
441         playbackCanvas_->Save();
442         playbackCanvas_->AttachBrush(brush);
443         if (pixmap.GetColorType() == COLORTYPE_UNKNOWN) {
444             playbackCanvas_->DrawRect(Drawing::Rect(800 + (rectPos % VARIATION) * LEFT,
445                 800 + (rectPos / VARIATION) * LEFT, 1000 + (rectPos % VARIATION) * LEFT,
446                 1000 + (rectPos / VARIATION) * LEFT)); // rect region(800, 800, 1000, 1000)
447         } else {
448             playbackCanvas_->DrawRect(Drawing::Rect(1000 + (rectPos % VARIATION) * LEFT,
449                 1000 + (rectPos / VARIATION) * LEFT, 1200 + (rectPos % VARIATION) * LEFT,
450                 1200 + (rectPos / VARIATION) * LEFT)); // rect region(1000, 1000, 1200, 1200)
451         }
452         playbackCanvas_->DrawBitmap(bitmap1, 250 + (rectPos % VARIATION) * LEFT,
453             300 + (rectPos / VARIATION) * RIGHT); // 250,300 is bitmap position
454         playbackCanvas_->Restore();
455         rectPos += 1;
456     }
457     playbackCanvas_->DetachBrush();
458 
459     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
460     // null
461 }
462 
463 // Pixmap_Scene_0099
464 // Pixmap构造接口:Pixmap_ImageInfo_08
465 // Pixmap操作接口:GetAlphaType
466 // cilp:ClipPath
467 // transform:Shear
468 // 抗锯齿:AA
469 // 透明度:透明
470 // 视效:null
471 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 9)
472 {
473     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
474     Drawing::Brush brush;
475     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
476     // 2.Pixmap构造接口
477     auto colorspace = Drawing::ColorSpace::CreateSRGB();
478     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
479         colorspace); // 512 width * 512 height
480     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
481 
482     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
483     // GetAlphaType只有绘制部分,放在绘制结果里
484 
485     Drawing::Bitmap bitmap1;
486     bitmap1.Build(imageInfo);
487     bitmap1.ClearWithColor(0x00789645); // 透明效果,灰绿色
488 
489     // 4.组合transform函数
490     playbackCanvas_->Shear(10.0f, 10.0f); // slope
491 
492     // 5.设置视效效果,将效果添加到笔刷
493     // null
494 
495     // 6.绘制结果
496     const void* pixel1 = pixmap.GetAddr();
497     bitmap1.SetPixels(const_cast<void*>(pixel1));
498     playbackCanvas_->AttachBrush(brush);
499     if (pixmap.GetAlphaType() == ALPHATYPE_UNPREMUL) {
500         playbackCanvas_->DrawRect(Drawing::Rect(800, 800, 1000, 1000)); // rect region(800, 800, 1000, 1000)
501     } else {
502         playbackCanvas_->DrawRect(Drawing::Rect(1000, 1000, 1200, 1200)); // rect region(1000, 1000, 1200, 1200)
503     }
504     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
505     playbackCanvas_->DetachBrush();
506 
507     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
508     TestBase::ClipPath(true);
509 }
510 
511 // Pixmap_Scene_0100
512 // Pixmap构造接口:Pixmap_ImageInfo_08
513 // Pixmap操作接口:GetAlphaType
514 // cilp:ClipRoundRect(G2)
515 // transform:Rotate
516 // 抗锯齿:AA
517 // 透明度:透明
518 // 视效:CreateSrgbGammaToLinear
519 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 10)
520 {
521     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
522     Drawing::Brush brush;
523     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
524     // 2.Pixmap构造接口
525     auto colorspace = Drawing::ColorSpace::CreateSRGB();
526     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
527         colorspace); // 512 width * 512 height
528     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
529 
530     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
531     // GetAlphaType只有绘制部分,放在绘制结果里
532 
533     Drawing::Bitmap bitmap1;
534     bitmap1.Build(imageInfo);
535     bitmap1.ClearWithColor(0x00789645); // 透明效果,灰绿色
536 
537     // 4.组合transform函数
538     playbackCanvas_->Rotate(30, 10, 10); // 30 angle 10 position
539 
540     // 5.设置视效效果,将效果添加到笔刷
541     brush.SetColor(0xFF4F7091);
542     auto filter = Drawing::Filter();
543     filter.SetColorFilter(Drawing::ColorFilter::CreateSrgbGammaToLinear());
544     brush.SetFilter(filter);
545 
546     // 6.绘制结果
547     const void* pixel1 = pixmap.GetAddr();
548     bitmap1.SetPixels(const_cast<void*>(pixel1));
549     playbackCanvas_->AttachBrush(brush);
550     if (pixmap.GetAlphaType() == ALPHATYPE_UNPREMUL) {
551         playbackCanvas_->DrawRect(Drawing::Rect(800, 800, 1000, 1000)); // rect region(800, 800, 1000, 1000)
552     } else {
553         playbackCanvas_->DrawRect(Drawing::Rect(1000, 1000, 1200, 1200)); // rect region(1000, 1000, 1200, 1200)
554     }
555     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
556     playbackCanvas_->DetachBrush();
557 
558     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
559     TestBase::ClipRoundRectG2(true);
560 }
561 
562 // Pixmap_Scene_0101
563 // Pixmap构造接口:Pixmap_ImageInfo_08
564 // Pixmap操作接口:GetColorSpace
565 // cilp:ClipRoundRect(G2_capsule)
566 // transform:null
567 // 抗锯齿:非AA
568 // 透明度:半透明
569 // 视效:CreateBlendShader
570 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 11)
571 {
572     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
573     Drawing::Brush brush;
574     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
575     // 2.Pixmap构造接口
576     auto colorspace = Drawing::ColorSpace::CreateSRGB();
577     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
578         colorspace); // 512 width * 512 height
579     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
580 
581     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
582     // GetColorSpace只有绘制部分,放在绘制结果里
583 
584     Drawing::Bitmap bitmap1;
585     bitmap1.Build(imageInfo);
586     bitmap1.ClearWithColor(0x89789645); // 半透明效果,灰绿色
587 
588     // 4.组合transform函数
589     // null
590 
591     // 5.设置视效效果,将效果添加到笔刷
592     int rectPos = 0;
593     brush.SetColor(0xFFFF0000);
594     auto dst = Drawing::ShaderEffect::CreateColorShader(Drawing::Color::COLOR_RED);
595     auto src = Drawing::ShaderEffect::CreateColorShader(Drawing::Color::COLOR_GREEN);
596     for (auto BlendMode : blendModes) {
597         auto blendShader = Drawing::ShaderEffect::CreateBlendShader(*dst, *src, BlendMode);
598         brush.SetShaderEffect(blendShader);
599 
600         // 6.绘制结果
601         const void* pixel1 = pixmap.GetAddr();
602         bitmap1.SetPixels(const_cast<void*>(pixel1));
603         playbackCanvas_->AttachBrush(brush);
604         if (pixmap.GetColorSpace() == colorspace) {
605             playbackCanvas_->DrawRect(Drawing::Rect(800 + (rectPos % VARIATION) * LEFT,
606                 800 + (rectPos / VARIATION) * LEFT, 1000 + (rectPos % VARIATION) * LEFT,
607                 1000 + (rectPos / VARIATION) * LEFT)); // rect region(800, 800, 1000, 1000)
608         } else {
609             playbackCanvas_->DrawRect(Drawing::Rect(1000 + (rectPos % VARIATION) * LEFT,
610                 1000 + (rectPos / VARIATION) * LEFT, 1200 + (rectPos % VARIATION) * LEFT,
611                 1200 + (rectPos / VARIATION) * LEFT)); // rect region(1000, 1000, 1200, 1200)
612         }
613         playbackCanvas_->DrawBitmap(bitmap1, 250 + (rectPos % VARIATION) * LEFT,
614             300 + (rectPos / VARIATION) * RIGHT); // 250,300 is bitmap position
615         rectPos += 1;
616     }
617     playbackCanvas_->DetachBrush();
618 
619     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
620     TestBase::ClipRoundRectG2capsule(false);
621 }
622 
623 // Pixmap_Scene_0102
624 // Pixmap构造接口:Pixmap_ImageInfo_08
625 // Pixmap操作接口:GetRowBytes
626 // cilp:ClipRoundRect(非G2)
627 // transform:Shear
628 // 抗锯齿:AA
629 // 透明度:不透明
630 // 视效:CreateLinearToSrgbGamma
631 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 12)
632 {
633     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
634     Drawing::Brush brush;
635     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
636     // 2.Pixmap构造接口
637     auto colorspace = Drawing::ColorSpace::CreateSRGB();
638     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
639         colorspace); // 512 width * 512 height
640     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
641 
642     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
643     ImageInfo imageInfo1(1, 1, COLORTYPE_RGBA_8888, ALPHATYPE_PREMUL);
644     uint32_t pixel[] = { 0xFF123456 };
645     Pixmap pixmap1(imageInfo1, pixel, sizeof(pixel));
646     std::shared_ptr<Data> data = std::make_shared<Data>();
647     data->BuildWithCopy(pixmap1.GetAddr(), pixmap1.GetRowBytes() * pixmap1.GetHeight());
648     auto image = Image::MakeRasterData(imageInfo1, data, pixmap1.GetRowBytes());
649 
650     Drawing::Bitmap bitmap1;
651     bitmap1.Build(imageInfo1);
652     bitmap1.ClearWithColor(0xFF789645); // 不透明效果,灰绿色
653 
654     // 4.组合transform函数
655     playbackCanvas_->Shear(10.0f, 10.0f); // slope
656 
657     // 5.设置视效效果,将效果添加到笔刷
658     brush.SetColor(0xFF4F7091);
659     auto filter = Drawing::Filter();
660     filter.SetColorFilter(Drawing::ColorFilter::CreateLinearToSrgbGamma());
661     brush.SetFilter(filter);
662 
663     // 6.绘制结果
664     const void* pixel1 = pixmap1.GetAddr();
665     bitmap1.SetPixels(const_cast<void*>(pixel1));
666     playbackCanvas_->AttachBrush(brush);
667     playbackCanvas_->DrawImageNine(image.get(), Drawing::RectI(0, 0, 1, 1), Rect(100, 100, 500, 500),
668         FilterMode::NEAREST);                       // Rect(100, 100, 500, 500) & RectI(0, 0, 1, 1)
669     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
670     playbackCanvas_->DetachBrush();
671 
672     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
673     TestBase::ClipRoundRectnotG2(true);
674 }
675 
676 // Pixmap_Scene_0103
677 // Pixmap构造接口:Pixmap_ImageInfo_08
678 // Pixmap操作接口:GetAddr
679 // cilp:ClipRoundRect(G2_capsule)
680 // transform:ConcatMatrix
681 // 抗锯齿:非AA
682 // 透明度:透明
683 // 视效:CreateBlurMaskFilter
684 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 13)
685 {
686     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
687     Drawing::Brush brush;
688     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
689     // 2.Pixmap构造接口
690     auto colorspace = Drawing::ColorSpace::CreateSRGB();
691     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
692         colorspace); // 512 width * 512 height
693     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
694 
695     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
696     Drawing::Bitmap bitmap1;
697     const void* pixel = pixmap.GetAddr();
698     bitmap1.SetPixels(const_cast<void*>(pixel));
699 
700     bitmap1.Build(imageInfo);
701     bitmap1.ClearWithColor(0x00789645); // 透明效果,灰绿色
702 
703     // 4.组合transform函数
704     Drawing::Matrix matrix;
705     matrix.Rotate(15, 10, 10); // 15 angle 10 position
706     playbackCanvas_->ConcatMatrix(matrix);
707 
708     // 5.设置视效效果,将效果添加到笔刷
709     int rectPos = 0;
710     brush.SetColor(0xFFFF0000);
711     for (auto& blurType : blurTypes) {
712         auto filter = Drawing::Filter();
713         // 5.设置视效效果,将效果添加到笔刷
714         filter.SetMaskFilter(Drawing::MaskFilter::CreateBlurMaskFilter(blurType, 10.0f, true));
715         brush.SetFilter(filter);
716 
717         // 6.绘制结果
718         playbackCanvas_->AttachBrush(brush);
719         playbackCanvas_->DrawBitmap(bitmap1, 300 + (rectPos % VARIATION) * LEFT,
720             300 + (rectPos / VARIATION) * RIGHT); // 250,300 is bitmap position
721         rectPos += 200;
722     }
723     playbackCanvas_->DetachBrush();
724 
725     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
726     TestBase::ClipRoundRectG2capsule(false);
727 }
728 
729 // Pixmap_Scene_0104
730 // Pixmap构造接口:Pixmap_ImageInfo_08
731 // Pixmap操作接口:GetColor
732 // cilp:ClipRoundRect(非G2)
733 // transform:Scale(极小值)
734 // 抗锯齿:AA
735 // 透明度:半透明
736 // 视效:CreateBlurImageFilter
737 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 14)
738 {
739     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
740     Drawing::Brush brush;
741     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
742     // 2.Pixmap构造接口
743     auto colorspace = Drawing::ColorSpace::CreateSRGB();
744     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
745         colorspace); // 512 width * 512 height
746     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
747 
748     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
749     Drawing::Pen pen;
750     pen.SetWidth(8.5f);
751     pen.SetColor(pixmap.GetColor(imageInfo.GetWidth() / 2, imageInfo.GetHeight() / 2));
752 
753     Drawing::Bitmap bitmap1;
754     bitmap1.Build(imageInfo);
755     bitmap1.ClearWithColor(0x89789645); // 半透明效果,灰绿色
756 
757     // 4.组合transform函数
758     playbackCanvas_->Scale(10100.0f, 1.0f); // ratio
759 
760     // 5.设置视效效果,将效果添加到笔刷
761     brush.SetColor(0xFFFF0000);
762     auto filter = Drawing::Filter();
763     filter.SetImageFilter(Drawing::ImageFilter::CreateBlurImageFilter(
764         10.0f, 10.0f, Drawing::TileMode::CLAMP, nullptr, Drawing::ImageBlurType::GAUSS));
765     brush.SetFilter(filter);
766 
767     // 6.绘制结果
768     const void* pixel1 = pixmap.GetAddr();
769     bitmap1.SetPixels(const_cast<void*>(pixel1));
770     playbackCanvas_->AttachBrush(brush);
771     playbackCanvas_->AttachPen(pen);
772     auto p1 = Drawing::Point(800, 800);   // point position(800, 800)
773     auto p2 = Drawing::Point(1000, 1000); // point position(1000, 1000)
774     playbackCanvas_->DrawLine(p1, p2);
775     playbackCanvas_->DetachPen();
776     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
777     playbackCanvas_->DetachBrush();
778 
779     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
780     TestBase::ClipRoundRectnotG2(true);
781 }
782 
783 // Pixmap_Scene_0105
784 // Pixmap构造接口:Pixmap_ImageInfo_08
785 // Pixmap操作接口:ScalePixels
786 // cilp:null
787 // transform:Translate
788 // 抗锯齿:非AA
789 // 透明度:不透明
790 // 视效:CreateBlendModeColorFilter
791 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 15)
792 {
793     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
794     Drawing::Brush brush;
795     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
796     // 2.Pixmap构造接口
797     auto colorspace = Drawing::ColorSpace::CreateSRGB();
798     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_UNKNOWN, Drawing::AlphaType::ALPHATYPE_UNPREMUL,
799         colorspace); // 512 width * 512 height
800     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
801 
802     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
803     ImageInfo imageinfo2 = ImageInfo::MakeN32Premul(4, 4); // pixel row and col(4, 4)
804     uint32_t data[16];
805     Pixmap dst(imageinfo2, data, sizeof(uint32_t) * imageinfo2.GetWidth());
806 
807     Drawing::Bitmap bitmap1;
808     bitmap1.Build(imageinfo2);
809     bitmap1.ClearWithColor(0xFF789645); // 不透明效果,灰绿色
810 
811     // 4.组合transform函数
812     playbackCanvas_->Translate(200, 200); // 200 distance
813 
814     // 5.设置视效效果,将效果添加到笔刷
815     int rectPos = 0;
816     brush.SetColor(0xFFFF0000);
817     for (auto blendMode : blendModes) {
818         std::shared_ptr<Drawing::ColorFilter> colorFilter =
819             Drawing::ColorFilter::CreateBlendModeColorFilter(0xFFFF0000, blendMode);
820         auto filter = Drawing::Filter();
821         filter.SetColorFilter(colorFilter);
822         brush.SetFilter(filter);
823 
824         // 6.绘制结果
825         const void* pixel1 = pixmap.GetAddr();
826         bitmap1.SetPixels(const_cast<void*>(pixel1));
827         playbackCanvas_->AttachBrush(brush);
828         if (pixmap.ScalePixels(dst, SamplingOptions())) {
829             playbackCanvas_->DrawRect(Drawing::Rect(800 + (rectPos % VARIATION) * LEFT,
830                 800 + (rectPos / VARIATION) * LEFT, 1000 + (rectPos % VARIATION) * LEFT,
831                 1000 + (rectPos / VARIATION) * LEFT)); // rect region(800, 800, 1000, 1000)
832         } else {
833             playbackCanvas_->DrawRect(Drawing::Rect(1000 + (rectPos % VARIATION) * LEFT,
834                 1000 + (rectPos / VARIATION) * LEFT, 1200 + (rectPos % VARIATION) * LEFT,
835                 1200 + (rectPos / VARIATION) * LEFT)); // rect region(1000, 1000, 1200, 1200)
836         }
837         playbackCanvas_->DrawBitmap(bitmap1, 250 + (rectPos % VARIATION) * LEFT,
838             300 + (rectPos / VARIATION) * RIGHT); // 250,300 is bitmap position
839         rectPos += 1;
840     }
841     playbackCanvas_->DetachBrush();
842 
843     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
844     // null
845 }
846 
847 // Pixmap_Scene_0106
848 // Pixmap构造接口:Pixmap_ImageInfo_09
849 // Pixmap操作接口:GetWidth
850 // cilp:ClipRoundRect(G2)
851 // transform:Scale(正常值)
852 // 抗锯齿:AA
853 // 透明度:不透明
854 // 视效:CreateColorShader
855 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 16)
856 {
857     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
858     Drawing::Brush brush;
859     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
860     // 2.Pixmap构造接口
861     auto colorspace = Drawing::ColorSpace::CreateSRGB();
862     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
863         colorspace); // 512 width * 512 height
864     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
865 
866     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
867     auto width = pixmap.GetWidth();
868 
869     Drawing::Bitmap bitmap1;
870     bitmap1.Build(imageInfo);
871     bitmap1.ClearWithColor(0xFF789645); // 不透明效果,灰绿色
872 
873     // 4.组合transform函数
874     playbackCanvas_->Scale(2.0f, 2.0f); // ratio
875 
876     // 5.设置视效效果,将效果添加到笔刷
877     brush.SetColor(0xFFFF0000);
878     auto colorShader = Drawing::ShaderEffect::CreateColorShader(Drawing::Color::COLOR_RED);
879     brush.SetShaderEffect(colorShader);
880 
881     // 6.绘制结果
882     const void* pixel1 = pixmap.GetAddr();
883     bitmap1.SetPixels(const_cast<void*>(pixel1));
884     playbackCanvas_->AttachBrush(brush);
885     playbackCanvas_->DrawRect(Rect(0, 0, width, 500)); // width * 500 height
886     playbackCanvas_->DrawBitmap(bitmap1, 250, 300);    // 250,300 is bitmap position
887     playbackCanvas_->DetachBrush();
888 
889     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
890     TestBase::ClipRoundRectG2(true);
891 }
892 
893 // Pixmap_Scene_0107
894 // Pixmap构造接口:Pixmap_ImageInfo_09
895 // Pixmap操作接口:GetHeight
896 // cilp:ClipRoundRect(G2_capsule)
897 // transform:Scale(极大值)
898 // 抗锯齿:非AA
899 // 透明度:透明
900 // 视效:CreateBlurMaskFilter
901 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 17)
902 {
903     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
904     Drawing::Brush brush;
905     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
906     // 2.Pixmap构造接口
907     auto colorspace = Drawing::ColorSpace::CreateSRGB();
908     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
909         colorspace); // 512 width * 512 height
910     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
911 
912     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
913     auto height = pixmap.GetHeight();
914 
915     Drawing::Bitmap bitmap1;
916     bitmap1.Build(imageInfo);
917     bitmap1.ClearWithColor(0x00789645); // 透明效果,灰绿色
918 
919     // 4.组合transform函数
920     playbackCanvas_->Scale(1.0f, 10100.0f); // ratio
921 
922     // 5.设置视效效果,将效果添加到笔刷
923     int rectPos = 0;
924     brush.SetColor(0xFFFF0000);
925     for (auto& blurType : blurTypes) {
926         auto filter = Drawing::Filter();
927         filter.SetMaskFilter(Drawing::MaskFilter::CreateBlurMaskFilter(blurType, 10.0f, true));
928         brush.SetFilter(filter);
929 
930         // 6.绘制结果
931         const void* pixel1 = pixmap.GetAddr();
932         bitmap1.SetPixels(const_cast<void*>(pixel1));
933         playbackCanvas_->AttachBrush(brush);
934         playbackCanvas_->DrawRect(Rect(0 + (rectPos % VARIATION) * LEFT, 0 + (rectPos / VARIATION) * LEFT,
935             500 + (rectPos % VARIATION) * LEFT, height + (rectPos / VARIATION) * LEFT)); // 500 width * height
936         playbackCanvas_->DrawBitmap(bitmap1, 250 + (rectPos % VARIATION) * LEFT,
937             300 + (rectPos / VARIATION) * RIGHT); // 250,300 is bitmap position
938         rectPos += 200;
939     }
940     playbackCanvas_->DetachBrush();
941 
942     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
943     TestBase::ClipRoundRectG2capsule(false);
944 }
945 
946 // Pixmap_Scene_0108
947 // Pixmap构造接口:Pixmap_ImageInfo_09
948 // Pixmap操作接口:GetColorType
949 // cilp:ClipRoundRect(非G2)
950 // transform:Scale(极小值)
951 // 抗锯齿:AA
952 // 透明度:半透明
953 // 视效:CreateMatrixColorFilter
954 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 18)
955 {
956     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
957     Drawing::Brush brush;
958     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
959     // 2.Pixmap构造接口
960     auto colorspace = Drawing::ColorSpace::CreateSRGB();
961     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
962         colorspace); // 512 width * 512 height
963     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
964 
965     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
966     // GetColorType只有绘制部分,放在绘制结果里
967 
968     Drawing::Bitmap bitmap1;
969     bitmap1.Build(imageInfo);
970     bitmap1.ClearWithColor(0x89789645); // 半透明效果,灰绿色
971 
972     // 4.组合transform函数
973     playbackCanvas_->Scale(10100.0f, 1.0f); // ratio
974 
975     // 5.设置视效效果,将效果添加到笔刷
976     Drawing::ColorMatrix matrix;
977     matrix.SetArray(ARR);
978     auto cf = Drawing::ColorFilter::CreateMatrixColorFilter(matrix);
979     auto filter = Drawing::Filter();
980     filter.SetImageFilter(Drawing::ImageFilter::CreateColorFilterImageFilter(*cf, nullptr));
981     brush.SetFilter(filter);
982 
983     // 6.绘制结果
984     const void* pixel1 = pixmap.GetAddr();
985     bitmap1.SetPixels(const_cast<void*>(pixel1));
986     playbackCanvas_->AttachBrush(brush);
987     if (pixmap.GetColorType() == COLORTYPE_ALPHA_8) {
988         playbackCanvas_->DrawRect(Drawing::Rect(800, 800, 1000, 1000)); // rect region(800, 800, 1000, 1000)
989     } else {
990         playbackCanvas_->DrawRect(Drawing::Rect(1000, 1000, 1200, 1200)); // rect region(1000, 1000, 1200, 1200)
991     }
992     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
993     playbackCanvas_->DetachBrush();
994 
995     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
996     TestBase::ClipRoundRectnotG2(true);
997 }
998 
999 // Pixmap_Scene_0109
1000 // Pixmap构造接口:Pixmap_ImageInfo_09
1001 // Pixmap操作接口:GetAlphaType
1002 // cilp:null
1003 // transform:Translate
1004 // 抗锯齿:非AA
1005 // 透明度:透明
1006 // 视效:CreateBlurImageFilter
1007 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 19)
1008 {
1009     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1010     Drawing::Brush brush;
1011     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1012     // 2.Pixmap构造接口
1013     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1014     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1015         colorspace); // 512 width * 512 height
1016     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1017 
1018     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1019     // GetAlphaType只有绘制部分,放在绘制结果里
1020 
1021     Drawing::Bitmap bitmap1;
1022     bitmap1.Build(imageInfo);
1023     bitmap1.ClearWithColor(0x00789645); // 透明效果,灰绿色
1024 
1025     // 4.组合transform函数
1026     playbackCanvas_->Translate(200, 200); // 200 distance
1027 
1028     // 5.设置视效效果,将效果添加到笔刷
1029     brush.SetColor(0xFFFF0000);
1030     auto filter = Drawing::Filter();
1031     filter.SetImageFilter(Drawing::ImageFilter::CreateBlurImageFilter(
1032         10.0f, 10.0f, Drawing::TileMode::CLAMP, nullptr, Drawing::ImageBlurType::GAUSS));
1033     brush.SetFilter(filter);
1034 
1035     // 6.绘制结果
1036     const void* pixel1 = pixmap.GetAddr();
1037     bitmap1.SetPixels(const_cast<void*>(pixel1));
1038     playbackCanvas_->AttachBrush(brush);
1039     if (pixmap.GetAlphaType() == ALPHATYPE_UNKNOWN) {
1040         playbackCanvas_->DrawRect(Drawing::Rect(800, 800, 1000, 1000)); // rect region(800, 800, 1000, 1000)
1041     } else {
1042         playbackCanvas_->DrawRect(Drawing::Rect(1000, 1000, 1200, 1200)); // rect region(1000, 1000, 1200, 1200)
1043     }
1044     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
1045     playbackCanvas_->DetachBrush();
1046 
1047     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1048     // null
1049 }
1050 
1051 // Pixmap_Scene_0110
1052 // Pixmap构造接口:Pixmap_ImageInfo_09
1053 // Pixmap操作接口:GetColorSpace
1054 // cilp:ClipPath
1055 // transform:Scale(正常值)
1056 // 抗锯齿:AA
1057 // 透明度:半透明
1058 // 视效:CreateLinearGradient
1059 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 20)
1060 {
1061     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1062     Drawing::Brush brush;
1063     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1064     // 2.Pixmap构造接口
1065     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1066     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1067         colorspace); // 512 width * 512 height
1068     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1069 
1070     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1071     // GetColorSpace只有绘制部分,放在绘制结果里
1072 
1073     Drawing::Bitmap bitmap1;
1074     bitmap1.Build(imageInfo);
1075     bitmap1.ClearWithColor(0x89789645); // 半透明效果,灰绿色
1076 
1077     // 4.组合transform函数
1078     playbackCanvas_->Scale(2.0f, 2.0f); // ratio
1079 
1080     // 5.设置视效效果,将效果添加到笔刷
1081     std::vector<Drawing::ColorQuad> colors = { Drawing::Color::COLOR_RED, Drawing::Color::COLOR_GREEN,
1082         Drawing::Color::COLOR_BLUE };
1083     std::vector<Drawing::scalar> pos = { 0.00f, 0.50f, 1.00f };
1084     auto linearGradient = Drawing::ShaderEffect::CreateLinearGradient(
1085         { 0, 0 }, { 1000, 1000 }, colors, pos, Drawing::TileMode::CLAMP); // 0 start pos & 1000 end pos
1086     brush.SetShaderEffect(linearGradient);
1087 
1088     // 6.绘制结果
1089     const void* pixel1 = pixmap.GetAddr();
1090     bitmap1.SetPixels(const_cast<void*>(pixel1));
1091     playbackCanvas_->AttachBrush(brush);
1092     if (pixmap.GetColorSpace() == colorspace) {
1093         playbackCanvas_->DrawRect(Drawing::Rect(800, 800, 1000, 1000)); // rect region(800, 800, 1000, 1000)
1094     } else {
1095         playbackCanvas_->DrawRect(Drawing::Rect(1000, 1000, 1200, 1200)); // rect region(1000, 1000, 1200, 1200)
1096     }
1097     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
1098     playbackCanvas_->DetachBrush();
1099 
1100     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1101     TestBase::ClipPath(true);
1102 }
1103 
1104 // Pixmap_Scene_0111
1105 // Pixmap构造接口:Pixmap_ImageInfo_09
1106 // Pixmap操作接口:GetColorSpace
1107 // cilp:ClipRect
1108 // transform:null
1109 // 抗锯齿:非AA
1110 // 透明度:半透明
1111 // 视效:CreateLinearToSrgbGamma
1112 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 21)
1113 {
1114     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1115     Drawing::Brush brush;
1116     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1117     // 2.Pixmap构造接口
1118     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1119     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1120         colorspace); // 512 width * 512 height
1121     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1122 
1123     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1124     // GetColorSpace只有绘制部分,放在绘制结果里
1125 
1126     Drawing::Bitmap bitmap1;
1127     bitmap1.Build(imageInfo);
1128     bitmap1.ClearWithColor(0x89789645); // 半透明效果,灰绿色
1129 
1130     // 4.组合transform函数
1131     // null
1132 
1133     // 5.设置视效效果,将效果添加到笔刷
1134     brush.SetColor(0xFF4F7091);
1135     auto filter = Drawing::Filter();
1136     filter.SetColorFilter(Drawing::ColorFilter::CreateLinearToSrgbGamma());
1137     brush.SetFilter(filter);
1138 
1139     // 6.绘制结果
1140     const void* pixel1 = pixmap.GetAddr();
1141     bitmap1.SetPixels(const_cast<void*>(pixel1));
1142     playbackCanvas_->AttachBrush(brush);
1143     if (pixmap.GetColorSpace() == colorspace) {
1144         playbackCanvas_->DrawRect(Drawing::Rect(800, 800, 1000, 1000)); // rect region(800, 800, 1000, 1000)
1145     } else {
1146         playbackCanvas_->DrawRect(Drawing::Rect(1000, 1000, 1200, 1200)); // rect region(1000, 1000, 1200, 1200)
1147     }
1148     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
1149     playbackCanvas_->DetachBrush();
1150 
1151     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1152     TestBase::ClipRect(false);
1153 }
1154 
1155 // Pixmap_Scene_0112
1156 // Pixmap构造接口:Pixmap_ImageInfo_09
1157 // Pixmap操作接口:GetRowBytes
1158 // cilp:ClipRect
1159 // transform:ConcatMatrix
1160 // 抗锯齿:非AA
1161 // 透明度:不透明
1162 // 视效:null
1163 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 22)
1164 {
1165     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1166     Drawing::Brush brush;
1167     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1168     // 2.Pixmap构造接口
1169     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1170     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1171         colorspace); // 512 width * 512 height
1172     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1173 
1174     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1175     ImageInfo imageInfo1(1, 1, COLORTYPE_RGBA_8888, ALPHATYPE_PREMUL);
1176     uint32_t pixel[] = { 0xFF123456 };
1177     Pixmap pixmap1(imageInfo1, pixel, sizeof(pixel));
1178     std::shared_ptr<Data> data = std::make_shared<Data>();
1179     data->BuildWithCopy(pixmap1.GetAddr(), pixmap1.GetRowBytes() * pixmap1.GetHeight());
1180     auto image = Image::MakeRasterData(imageInfo1, data, pixmap1.GetRowBytes());
1181 
1182     Drawing::Bitmap bitmap1;
1183     bitmap1.Build(imageInfo1);
1184     bitmap1.ClearWithColor(0xFF789645); // 不透明效果,灰绿色
1185 
1186     // 4.组合transform函数
1187     Drawing::Matrix matrix;
1188     matrix.Rotate(15, 10, 10); // 15 angle 10 position
1189     playbackCanvas_->ConcatMatrix(matrix);
1190 
1191     // 5.设置视效效果,将效果添加到笔刷
1192     // null
1193 
1194     // 6.绘制结果
1195     const void* pixel1 = pixmap.GetAddr();
1196     bitmap1.SetPixels(const_cast<void*>(pixel1));
1197     playbackCanvas_->AttachBrush(brush);
1198     playbackCanvas_->DrawImageNine(image.get(), Drawing::RectI(0, 0, 1, 1), Rect(100, 100, 500, 500),
1199         FilterMode::NEAREST);                       // Rect(100, 100, 500, 500) & RectI(0, 0, 1, 1)
1200     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
1201     playbackCanvas_->DetachBrush();
1202 
1203     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1204     TestBase::ClipRect(false);
1205 }
1206 
1207 // Pixmap_Scene_0113
1208 // Pixmap构造接口:Pixmap_ImageInfo_09
1209 // Pixmap操作接口:GetRowBytes
1210 // cilp:ClipRoundRect(G2)
1211 // transform:ConcatMatrix
1212 // 抗锯齿:AA
1213 // 透明度:不透明
1214 // 视效:CreateSrgbGammaToLinear
1215 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 23)
1216 {
1217     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1218     Drawing::Brush brush;
1219     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1220     // 2.Pixmap构造接口
1221     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1222     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1223         colorspace); // 512 width * 512 height
1224     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1225 
1226     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1227     ImageInfo imageInfo1(1, 1, COLORTYPE_RGBA_8888, ALPHATYPE_PREMUL);
1228     uint32_t pixel[] = { 0xFF123456 };
1229     Pixmap pixmap1(imageInfo1, pixel, sizeof(pixel));
1230     std::shared_ptr<Data> data = std::make_shared<Data>();
1231     data->BuildWithCopy(pixmap1.GetAddr(), pixmap1.GetRowBytes() * pixmap1.GetHeight());
1232     auto image = Image::MakeRasterData(imageInfo1, data, pixmap1.GetRowBytes());
1233 
1234     Drawing::Bitmap bitmap1;
1235     bitmap1.Build(imageInfo1);
1236     bitmap1.ClearWithColor(0xFF789645); // 不透明效果,灰绿色
1237 
1238     // 4.组合transform函数
1239     Drawing::Matrix matrix;
1240     matrix.Rotate(15, 10, 10); // 15 angle 10 position
1241     playbackCanvas_->ConcatMatrix(matrix);
1242 
1243     // 5.设置视效效果,将效果添加到笔刷
1244     brush.SetColor(0xFF4F7091);
1245     auto filter = Drawing::Filter();
1246     filter.SetColorFilter(Drawing::ColorFilter::CreateSrgbGammaToLinear());
1247     brush.SetFilter(filter);
1248 
1249     // 6.绘制结果
1250     const void* pixel1 = pixmap.GetAddr();
1251     bitmap1.SetPixels(const_cast<void*>(pixel1));
1252     playbackCanvas_->AttachBrush(brush);
1253     playbackCanvas_->DrawImageNine(image.get(), Drawing::RectI(0, 0, 1, 1), Rect(100, 100, 500, 500),
1254         FilterMode::NEAREST);                       // Rect(100, 100, 500, 500) & RectI(0, 0, 1, 1)
1255     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
1256     playbackCanvas_->DetachBrush();
1257 
1258     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1259     TestBase::ClipRoundRectG2(true);
1260 }
1261 
1262 // Pixmap_Scene_0114
1263 // Pixmap构造接口:Pixmap_ImageInfo_09
1264 // Pixmap操作接口:GetAddr
1265 // cilp:ClipPath
1266 // transform:Rotate
1267 // 抗锯齿:AA
1268 // 透明度:透明
1269 // 视效:CreateBlendShader
1270 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 24)
1271 {
1272     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1273     Drawing::Brush brush;
1274     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1275     // 2.Pixmap构造接口
1276     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1277     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1278         colorspace); // 512 width * 512 height
1279     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1280 
1281     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1282     Drawing::Bitmap bitmap1;
1283     const void* pixel = pixmap.GetAddr();
1284     bitmap1.SetPixels(const_cast<void*>(pixel));
1285 
1286     bitmap1.Build(imageInfo);
1287     bitmap1.ClearWithColor(0x00789645); // 透明效果,灰绿色
1288 
1289     // 4.组合transform函数
1290     playbackCanvas_->Rotate(30, 10, 10); // 30 angle 10 position
1291 
1292     // 5.设置视效效果,将效果添加到笔刷
1293     int rectPos = 0;
1294     brush.SetColor(0xFFFF0000);
1295     auto dst = Drawing::ShaderEffect::CreateColorShader(Drawing::Color::COLOR_RED);
1296     auto src = Drawing::ShaderEffect::CreateColorShader(Drawing::Color::COLOR_GREEN);
1297     for (auto BlendMode : blendModes) {
1298         auto blendShader = Drawing::ShaderEffect::CreateBlendShader(*dst, *src, BlendMode);
1299         brush.SetShaderEffect(blendShader);
1300 
1301         // 6.绘制结果
1302         playbackCanvas_->AttachBrush(brush);
1303         playbackCanvas_->DrawBitmap(bitmap1, 300 + (rectPos % VARIATION) * LEFT,
1304             300 + (rectPos / VARIATION) * RIGHT); // 300,300 is bitmap position
1305         rectPos += 1;
1306     }
1307     playbackCanvas_->DetachBrush();
1308 
1309     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1310     TestBase::ClipPath(true);
1311 }
1312 
1313 // Pixmap_Scene_0115
1314 // Pixmap构造接口:Pixmap_ImageInfo_09
1315 // Pixmap操作接口:GetAddr
1316 // cilp:ClipRoundRect(G2_capsule)
1317 // transform:Rotate
1318 // 抗锯齿:非AA
1319 // 透明度:透明
1320 // 视效:CreateLumaColorFilter
1321 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 25)
1322 {
1323     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1324     Drawing::Brush brush;
1325     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1326     // 2.Pixmap构造接口
1327     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1328     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1329         colorspace); // 512 width * 512 height
1330     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1331 
1332     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1333     Drawing::Bitmap bitmap1;
1334     const void* pixel = pixmap.GetAddr();
1335     bitmap1.SetPixels(const_cast<void*>(pixel));
1336 
1337     bitmap1.Build(imageInfo);
1338     bitmap1.ClearWithColor(0x00789645); // 透明效果,灰绿色
1339 
1340     // 4.组合transform函数
1341     playbackCanvas_->Rotate(30, 10, 10); // 30 angle 10 position
1342 
1343     // 5.设置视效效果,将效果添加到笔刷
1344     brush.SetColor(0xFF0000FF);
1345     auto filter = Drawing::Filter();
1346     filter.SetColorFilter(Drawing::ColorFilter::CreateLumaColorFilter());
1347     brush.SetFilter(filter);
1348 
1349     // 6.绘制结果
1350     playbackCanvas_->AttachBrush(brush);
1351     playbackCanvas_->DrawBitmap(bitmap1, 300, 300); // 300,300 is bitmap position
1352     playbackCanvas_->DetachBrush();
1353 
1354     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1355     TestBase::ClipRoundRectG2capsule(false);
1356 }
1357 
1358 // Pixmap_Scene_0116
1359 // Pixmap构造接口:Pixmap_ImageInfo_09
1360 // Pixmap操作接口:GetColor
1361 // cilp:ClipRect
1362 // transform:Shear
1363 // 抗锯齿:非AA
1364 // 透明度:半透明
1365 // 视效:CreateBlendModeColorFilter
1366 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 26)
1367 {
1368     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1369     Drawing::Brush brush;
1370     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1371     // 2.Pixmap构造接口
1372     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1373     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1374         colorspace); // 512 width * 512 height
1375     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1376 
1377     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1378     Drawing::Pen pen;
1379     pen.SetWidth(8.5f);
1380     pen.SetColor(pixmap.GetColor(imageInfo.GetWidth() / 2, imageInfo.GetHeight() / 2));
1381 
1382     Drawing::Bitmap bitmap1;
1383     bitmap1.Build(imageInfo);
1384     bitmap1.ClearWithColor(0x89789645); // 半透明效果,灰绿色
1385 
1386     // 4.组合transform函数
1387     playbackCanvas_->Shear(10.0f, 10.0f); // slope
1388 
1389     // 5.设置视效效果,将效果添加到笔刷
1390     int rectPos = 0;
1391     brush.SetColor(0xFFFF0000);
1392     for (auto blendMode : blendModes) {
1393         std::shared_ptr<Drawing::ColorFilter> colorFilter =
1394             Drawing::ColorFilter::CreateBlendModeColorFilter(0xFFFF0000, blendMode);
1395         auto filter = Drawing::Filter();
1396         filter.SetColorFilter(colorFilter);
1397         brush.SetFilter(filter);
1398 
1399         // 6.绘制结果
1400         const void* pixel1 = pixmap.GetAddr();
1401         bitmap1.SetPixels(const_cast<void*>(pixel1));
1402         playbackCanvas_->AttachBrush(brush);
1403         playbackCanvas_->AttachPen(pen);
1404         auto p1 = Drawing::Point(
1405             800 + (rectPos % VARIATION) * LEFT, 800 + (rectPos / VARIATION) * RIGHT); // point position(800, 800)
1406         auto p2 = Drawing::Point(
1407             1000 + (rectPos % VARIATION) * LEFT, 1000 + (rectPos / VARIATION) * RIGHT); // point position(1000, 1000)
1408         playbackCanvas_->DrawLine(p1, p2);
1409         playbackCanvas_->DetachPen();
1410         playbackCanvas_->DrawBitmap(bitmap1, 250 + (rectPos % VARIATION) * LEFT,
1411             300 + (rectPos / VARIATION) * RIGHT); // 250,300 is bitmap position
1412         rectPos += 1;
1413     }
1414     playbackCanvas_->DetachBrush();
1415 
1416     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1417     TestBase::ClipRect(false);
1418 }
1419 
1420 // Pixmap_Scene_0117
1421 // Pixmap构造接口:Pixmap_ImageInfo_09
1422 // Pixmap操作接口:GetColor
1423 // cilp:ClipRoundRect(非G2)
1424 // transform:Scale(正常值)
1425 // 抗锯齿:AA
1426 // 透明度:半透明
1427 // 视效:CreateBlendImageFilter
1428 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 27)
1429 {
1430     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1431     Drawing::Brush brush;
1432     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1433     // 2.Pixmap构造接口
1434     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1435     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1436         colorspace); // 512 width * 512 height
1437     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1438 
1439     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1440     Drawing::Pen pen;
1441     pen.SetWidth(8.5f);
1442     pen.SetColor(pixmap.GetColor(imageInfo.GetWidth() / 2, imageInfo.GetHeight() / 2));
1443 
1444     Drawing::Bitmap bitmap1;
1445     bitmap1.Build(imageInfo);
1446     bitmap1.ClearWithColor(0x89789645); // 半透明效果,灰绿色
1447 
1448     // 4.组合transform函数
1449     playbackCanvas_->Scale(2.0f, 2.0f); // ratio
1450 
1451     // 5.设置视效效果,将效果添加到笔刷
1452     int rectPos = 0;
1453     brush.SetColor(0x4CB21933);
1454     for (auto blendMode : blendModes) {
1455         auto background = Drawing::ImageFilter::CreateBlurImageFilter(
1456             1.0f, 1.0f, Drawing::TileMode::REPEAT, nullptr, Drawing::ImageBlurType::GAUSS);
1457         auto foreground = Drawing::ImageFilter::CreateBlurImageFilter(
1458             1.0f, 1.0f, Drawing::TileMode::REPEAT, nullptr, Drawing::ImageBlurType::GAUSS);
1459         auto filter = Drawing::Filter();
1460         filter.SetImageFilter(Drawing::ImageFilter::CreateBlendImageFilter(blendMode, background, foreground));
1461         brush.SetFilter(filter);
1462 
1463         // 6.绘制结果
1464         const void* pixel1 = pixmap.GetAddr();
1465         bitmap1.SetPixels(const_cast<void*>(pixel1));
1466         playbackCanvas_->Save();
1467         playbackCanvas_->AttachBrush(brush);
1468         playbackCanvas_->AttachPen(pen);
1469         auto p1 = Drawing::Point(
1470             800 + (rectPos % VARIATION) * LEFT, 800 + (rectPos / VARIATION) * RIGHT); // point position(800, 800)
1471         auto p2 = Drawing::Point(
1472             1000 + (rectPos % VARIATION) * LEFT, 1000 + (rectPos / VARIATION) * RIGHT); // point position(1000, 1000)
1473         playbackCanvas_->DrawLine(p1, p2);
1474         playbackCanvas_->DetachPen();
1475         playbackCanvas_->DrawBitmap(bitmap1, 250 + (rectPos % VARIATION) * LEFT,
1476             300 + (rectPos / VARIATION) * RIGHT); // 250,300 is bitmap position
1477         playbackCanvas_->Restore();
1478         rectPos += 1;
1479     }
1480     playbackCanvas_->DetachBrush();
1481 
1482     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1483     TestBase::ClipRoundRectnotG2(true);
1484 }
1485 
1486 // Pixmap_Scene_0118
1487 // Pixmap构造接口:Pixmap_ImageInfo_09
1488 // Pixmap操作接口:ScalePixels
1489 // cilp:ClipRoundRect(G2)
1490 // transform:null
1491 // 抗锯齿:AA
1492 // 透明度:不透明
1493 // 视效:CreateComposeColorFilter
1494 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 28)
1495 {
1496     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1497     Drawing::Brush brush;
1498     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1499     // 2.Pixmap构造接口
1500     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1501     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_ALPHA_8, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1502         colorspace); // 512 width * 512 height
1503     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1504 
1505     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1506     ImageInfo imageinfo2 = ImageInfo::MakeN32Premul(4, 4); // pixel row and col(4, 4)
1507     uint32_t data[16];
1508     Pixmap dst(imageinfo2, data, sizeof(uint32_t) * imageinfo2.GetWidth());
1509 
1510     Drawing::Bitmap bitmap1;
1511     bitmap1.Build(imageinfo2);
1512     bitmap1.ClearWithColor(0xFF789645); // 不透明效果,灰绿色
1513 
1514     // 4.组合transform函数
1515     // null
1516 
1517     // 5.设置视效效果,将效果添加到笔刷
1518     brush.SetColor(0xFFFF0000);
1519     std::shared_ptr<Drawing::ColorFilter> colorFilter1 =
1520         Drawing::ColorFilter::CreateBlendModeColorFilter(0xFFFF0000, Drawing::BlendMode::SRC_IN);
1521     std::shared_ptr<Drawing::ColorFilter> colorFilter2 =
1522         Drawing::ColorFilter::CreateBlendModeColorFilter(0xFFFF00FF, Drawing::BlendMode::MODULATE);
1523     std::shared_ptr<Drawing::ColorFilter> colorFilter3 =
1524         Drawing::ColorFilter::CreateComposeColorFilter(*colorFilter1, *colorFilter2);
1525     auto filter = Drawing::Filter();
1526     filter.SetColorFilter(colorFilter3);
1527     brush.SetFilter(filter);
1528 
1529     // 6.绘制结果
1530     const void* pixel1 = pixmap.GetAddr();
1531     bitmap1.SetPixels(const_cast<void*>(pixel1));
1532     playbackCanvas_->AttachBrush(brush);
1533     if (pixmap.ScalePixels(dst, SamplingOptions())) {
1534         playbackCanvas_->DrawRect(Drawing::Rect(800, 800, 1000, 1000)); // rect region(800, 800, 1000, 1000)
1535     } else {
1536         playbackCanvas_->DrawRect(Drawing::Rect(1000, 1000, 1200, 1200)); // rect region(1000, 1000, 1200, 1200)
1537     }
1538     playbackCanvas_->DrawBitmap(bitmap1, 250, 300); // 250,300 is bitmap position
1539     playbackCanvas_->DetachBrush();
1540 
1541     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1542     TestBase::ClipRoundRectG2(true);
1543 }
1544 
1545 // Pixmap_Scene_0119
1546 // Pixmap构造接口:Pixmap_ImageInfo_10
1547 // Pixmap操作接口:GetWidth
1548 // cilp:ClipPath
1549 // transform:Scale(极小值)
1550 // 抗锯齿:AA
1551 // 透明度:透明
1552 // 视效:CreateMatrixColorFilter
1553 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 29)
1554 {
1555     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1556     Drawing::Brush brush;
1557     brush.SetAntiAlias(true); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1558     // 2.Pixmap构造接口
1559     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1560     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_RGB_565, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1561         colorspace); // 512 width * 512 height
1562     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1563 
1564     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1565     auto width = pixmap.GetWidth();
1566 
1567     Drawing::Bitmap bitmap1;
1568     bitmap1.Build(imageInfo);
1569     bitmap1.ClearWithColor(0x00789645); // 透明效果,灰绿色
1570 
1571     // 4.组合transform函数
1572     playbackCanvas_->Scale(10100.0f, 1.0f); // ratio
1573 
1574     // 5.设置视效效果,将效果添加到笔刷
1575     Drawing::ColorMatrix matrix;
1576     matrix.SetArray(ARR);
1577     auto cf = Drawing::ColorFilter::CreateMatrixColorFilter(matrix);
1578     auto filter = Drawing::Filter();
1579     filter.SetImageFilter(Drawing::ImageFilter::CreateColorFilterImageFilter(*cf, nullptr));
1580     brush.SetFilter(filter);
1581 
1582     // 6.绘制结果
1583     const void* pixel1 = pixmap.GetAddr();
1584     bitmap1.SetPixels(const_cast<void*>(pixel1));
1585     playbackCanvas_->AttachBrush(brush);
1586     playbackCanvas_->DrawRect(Rect(0, 0, width, 500)); // width * 500 height
1587     playbackCanvas_->DrawBitmap(bitmap1, 250, 300);    // 250,300 is bitmap position
1588     playbackCanvas_->DetachBrush();
1589 
1590     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1591     TestBase::ClipPath(true);
1592 }
1593 
1594 // Pixmap_Scene_0120
1595 // Pixmap构造接口:Pixmap_ImageInfo_10
1596 // Pixmap操作接口:GetWidth
1597 // cilp:null
1598 // transform:Scale(极大值)
1599 // 抗锯齿:非AA
1600 // 透明度:不透明
1601 // 视效:CreateSrgbGammaToLinear
1602 DEF_DTK(Pixmap_Scene4, TestLevel::L2, 30)
1603 {
1604     // 1.创建笔刷,设置笔刷是否为抗锯齿效果
1605     Drawing::Brush brush;
1606     brush.SetAntiAlias(false); // 设置笔刷抗锯齿,true为AA(抗锯齿),false为非AA(不抗锯齿)
1607     // 2.Pixmap构造接口
1608     auto colorspace = Drawing::ColorSpace::CreateSRGB();
1609     ImageInfo imageInfo(512, 512, Drawing::ColorType::COLORTYPE_RGB_565, Drawing::AlphaType::ALPHATYPE_UNKNOWN,
1610         colorspace); // 512 width * 512 height
1611     Pixmap pixmap(imageInfo, nullptr, imageInfo.GetBytesPerPixel() * imageInfo.GetWidth());
1612 
1613     // 3.Pixmap操作接口,设置透明度, 由最后一步填充的颜色值的前两位控制,00为透明效果,89为半透明,FF为不透明
1614     auto width = pixmap.GetWidth();
1615 
1616     Drawing::Bitmap bitmap1;
1617     bitmap1.Build(imageInfo);
1618     bitmap1.ClearWithColor(0xFF789645); // 不透明效果,灰绿色
1619 
1620     // 4.组合transform函数
1621     playbackCanvas_->Scale(1.0f, 10100.0f); // ratio
1622 
1623     // 5.设置视效效果,将效果添加到笔刷
1624     brush.SetColor(0xFF4F7091);
1625     auto filter = Drawing::Filter();
1626     filter.SetColorFilter(Drawing::ColorFilter::CreateSrgbGammaToLinear());
1627     brush.SetFilter(filter);
1628 
1629     // 6.绘制结果
1630     const void* pixel1 = pixmap.GetAddr();
1631     bitmap1.SetPixels(const_cast<void*>(pixel1));
1632     playbackCanvas_->AttachBrush(brush);
1633     playbackCanvas_->DrawRect(Rect(0, 0, width, 500)); // width * 500 height
1634     playbackCanvas_->DrawBitmap(bitmap1, 250, 300);    // 250,300 is bitmap position
1635     playbackCanvas_->DetachBrush();
1636 
1637     // 7.组合Clip函数,cilp也有抗锯齿效果,默认和笔刷效果保持一致
1638     // null
1639 }
1640 
1641 } // namespace Rosen
1642 } // namespace OHOS