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