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