1 /*
2  * Copyright (c) 2022-2023 Huawei Device Co., Ltd.. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "core_canvas.h"
17 
18 #include "impl_factory.h"
19 #include "utils/log.h"
20 
21 namespace OHOS {
22 namespace Rosen {
23 #define DRAW_API_WITH_PAINT(func, ...)                                                     \
24     do {                                                                                   \
25         bool brushValid = paintBrush_.IsValid();                                           \
26         bool penValid = paintPen_.IsValid();                                               \
27         if (!brushValid && !penValid) {                                                    \
28             impl_->func(__VA_ARGS__, defaultPaint_);                                       \
29             return;                                                                        \
30         }                                                                                  \
31         if (brushValid && penValid && Paint::CanCombinePaint(paintBrush_, paintPen_)) {    \
32             paintPen_.SetStyle(Paint::PaintStyle::PAINT_FILL_STROKE);                      \
33             impl_->func(__VA_ARGS__, paintPen_);                                           \
34             paintPen_.SetStyle(Paint::PaintStyle::PAINT_STROKE);                           \
35             return;                                                                        \
36         }                                                                                  \
37         if (brushValid) {                                                                  \
38             impl_->func(__VA_ARGS__, paintBrush_);                                         \
39         }                                                                                  \
40         if (penValid) {                                                                    \
41             impl_->func(__VA_ARGS__, paintPen_);                                           \
42         }                                                                                  \
43     } while (0)
44 
45 
46 #define DRAW_API_WITH_PAINT_LOOPER(func, ...)                                              \
47 do {                                                                                       \
48     bool brushValid = paintBrush_.IsValid();                                               \
49     bool penValid = paintPen_.IsValid();                                                   \
50     if (!brushValid && !penValid) {                                                        \
51         impl_->func(__VA_ARGS__, defaultPaint_);                                           \
52         return;                                                                            \
53     }                                                                                      \
54     if (brushValid && penValid && Paint::CanCombinePaint(paintBrush_, paintPen_)) {        \
55         paintPen_.SetStyle(Paint::PaintStyle::PAINT_FILL_STROKE);                          \
56         std::shared_ptr looper = paintPen_.GetLooper();                                    \
57         if (looper != nullptr) {                                                           \
58             Paint looperPaint;                                                             \
59             GetLooperPaint(paintPen_, looperPaint);                                        \
60             impl_->Save();                                                                 \
61             impl_->Translate(looper->GetXOffset(), looper->GetYOffset());                  \
62             impl_->func(__VA_ARGS__, looperPaint);                                         \
63             impl_->Restore();                                                              \
64         }                                                                                  \
65         impl_->func(__VA_ARGS__, paintPen_);                                               \
66         paintPen_.SetStyle(Paint::PaintStyle::PAINT_STROKE);                               \
67         return;                                                                            \
68     }                                                                                      \
69     if (brushValid) {                                                                      \
70         std::shared_ptr looper = paintBrush_.GetLooper();                                  \
71         if (looper != nullptr) {                                                           \
72             Paint looperPaint;                                                             \
73             GetLooperPaint(paintBrush_, looperPaint);                                      \
74             impl_->Save();                                                                 \
75             impl_->Translate(looper->GetXOffset(), looper->GetYOffset());                  \
76             impl_->func(__VA_ARGS__, looperPaint);                                         \
77             impl_->Restore();                                                              \
78         }                                                                                  \
79         impl_->func(__VA_ARGS__, paintBrush_);                                             \
80     }                                                                                      \
81     if (penValid) {                                                                        \
82         std::shared_ptr looper = paintPen_.GetLooper();                                    \
83         if (looper != nullptr) {                                                           \
84             Paint looperPaint;                                                             \
85             GetLooperPaint(paintPen_, looperPaint);                                        \
86             impl_->Save();                                                                 \
87             impl_->Translate(looper->GetXOffset(), looper->GetYOffset());                  \
88             impl_->func(__VA_ARGS__, looperPaint);                                         \
89             impl_->Restore();                                                              \
90         }                                                                                  \
91         impl_->func(__VA_ARGS__, paintPen_);                                               \
92     }                                                                                      \
93 } while (0)
94 
95 namespace Drawing {
GetLooperPaint(const Paint & paint,Paint & looperPaint)96 static void GetLooperPaint(const Paint& paint, Paint& looperPaint)
97 {
98     looperPaint = paint;
99     std::shared_ptr looper = paint.GetLooper();
100     looperPaint.SetColor(looper->GetColor());
101     Filter filter = looperPaint.GetFilter();
102     filter.SetMaskFilter(looper->GetMaskFilter());
103     looperPaint.SetFilter(filter);
104 }
105 
CoreCanvas()106 CoreCanvas::CoreCanvas() : impl_(ImplFactory::CreateCoreCanvasImpl())
107 {
108     defaultPaint_.SetAntiAlias(true);
109     defaultPaint_.SetStyle(Drawing::Paint::PaintStyle::PAINT_FILL);
110 }
111 
CoreCanvas(void * rawCanvas)112 CoreCanvas::CoreCanvas(void* rawCanvas) : impl_(ImplFactory::CreateCoreCanvasImpl(rawCanvas))
113 {
114     defaultPaint_.SetAntiAlias(true);
115     defaultPaint_.SetStyle(Drawing::Paint::PaintStyle::PAINT_FILL);
116 }
117 
CoreCanvas(int32_t width,int32_t height)118 CoreCanvas::CoreCanvas(int32_t width, int32_t height) : impl_(ImplFactory::CreateCoreCanvasImpl(width, height))
119 {
120     defaultPaint_.SetAntiAlias(true);
121     defaultPaint_.SetStyle(Drawing::Paint::PaintStyle::PAINT_FILL);
122 }
123 
Bind(const Bitmap & bitmap)124 void CoreCanvas::Bind(const Bitmap& bitmap)
125 {
126     impl_->Bind(bitmap);
127 }
128 
GetTotalMatrix() const129 Matrix CoreCanvas::GetTotalMatrix() const
130 {
131     return impl_->GetTotalMatrix();
132 }
133 
GetLocalClipBounds() const134 Rect CoreCanvas::GetLocalClipBounds() const
135 {
136     return impl_->GetLocalClipBounds();
137 }
138 
GetDeviceClipBounds() const139 RectI CoreCanvas::GetDeviceClipBounds() const
140 {
141     return impl_->GetDeviceClipBounds();
142 }
143 
GetRoundInDeviceClipBounds() const144 RectI CoreCanvas::GetRoundInDeviceClipBounds() const
145 {
146     return impl_->GetRoundInDeviceClipBounds();
147 }
148 
149 #ifdef RS_ENABLE_GPU
GetGPUContext()150 std::shared_ptr<GPUContext> CoreCanvas::GetGPUContext()
151 {
152     if (!gpuContext_) {
153         gpuContext_ = impl_->GetGPUContext();
154     }
155     return gpuContext_;
156 }
157 #endif
158 
GetWidth() const159 int32_t CoreCanvas::GetWidth() const
160 {
161     return impl_->GetWidth();
162 }
163 
GetHeight() const164 int32_t CoreCanvas::GetHeight() const
165 {
166     return impl_->GetHeight();
167 }
168 
GetImageInfo()169 ImageInfo CoreCanvas::GetImageInfo()
170 {
171     return impl_->GetImageInfo();
172 }
173 
ReadPixels(const ImageInfo & dstInfo,void * dstPixels,size_t dstRowBytes,int srcX,int srcY)174 bool CoreCanvas::ReadPixels(const ImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
175     int srcX, int srcY)
176 {
177     return impl_->ReadPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
178 }
179 
ReadPixels(const Bitmap & dstBitmap,int srcX,int srcY)180 bool CoreCanvas::ReadPixels(const Bitmap& dstBitmap, int srcX, int srcY)
181 {
182     return impl_->ReadPixels(dstBitmap, srcX, srcY);
183 }
184 
DrawPoint(const Point & point)185 void CoreCanvas::DrawPoint(const Point& point)
186 {
187     DRAW_API_WITH_PAINT(DrawPoint, point);
188 }
189 
DrawSdf(const SDFShapeBase & shape)190 void CoreCanvas::DrawSdf(const SDFShapeBase& shape)
191 {
192     impl_->DrawSdf(shape);
193 }
194 
DrawPoints(PointMode mode,size_t count,const Point pts[])195 void CoreCanvas::DrawPoints(PointMode mode, size_t count, const Point pts[])
196 {
197     DRAW_API_WITH_PAINT(DrawPoints, mode, count, pts);
198 }
199 
DrawLine(const Point & startPt,const Point & endPt)200 void CoreCanvas::DrawLine(const Point& startPt, const Point& endPt)
201 {
202     DRAW_API_WITH_PAINT(DrawLine, startPt, endPt);
203 }
204 
DrawRect(const Rect & rect)205 void CoreCanvas::DrawRect(const Rect& rect)
206 {
207     DRAW_API_WITH_PAINT(DrawRect, rect);
208 }
209 
DrawRoundRect(const RoundRect & roundRect)210 void CoreCanvas::DrawRoundRect(const RoundRect& roundRect)
211 {
212     DRAW_API_WITH_PAINT(DrawRoundRect, roundRect);
213 }
214 
DrawNestedRoundRect(const RoundRect & outer,const RoundRect & inner)215 void CoreCanvas::DrawNestedRoundRect(const RoundRect& outer, const RoundRect& inner)
216 {
217     DRAW_API_WITH_PAINT(DrawNestedRoundRect, outer, inner);
218 }
219 
DrawArc(const Rect & oval,scalar startAngle,scalar sweepAngle)220 void CoreCanvas::DrawArc(const Rect& oval, scalar startAngle, scalar sweepAngle)
221 {
222     DRAW_API_WITH_PAINT(DrawArc, oval, startAngle, sweepAngle);
223 }
224 
DrawPie(const Rect & oval,scalar startAngle,scalar sweepAngle)225 void CoreCanvas::DrawPie(const Rect& oval, scalar startAngle, scalar sweepAngle)
226 {
227     DRAW_API_WITH_PAINT(DrawPie, oval, startAngle, sweepAngle);
228 }
229 
DrawOval(const Rect & oval)230 void CoreCanvas::DrawOval(const Rect& oval)
231 {
232     DRAW_API_WITH_PAINT(DrawOval, oval);
233 }
234 
DrawCircle(const Point & centerPt,scalar radius)235 void CoreCanvas::DrawCircle(const Point& centerPt, scalar radius)
236 {
237     DRAW_API_WITH_PAINT(DrawCircle, centerPt, radius);
238 }
239 
DrawPath(const Path & path)240 void CoreCanvas::DrawPath(const Path& path)
241 {
242     DRAW_API_WITH_PAINT(DrawPath, path);
243 }
244 
DrawBackground(const Brush & brush)245 void CoreCanvas::DrawBackground(const Brush& brush)
246 {
247     impl_->DrawBackground(brush);
248 }
249 
DrawShadow(const Path & path,const Point3 & planeParams,const Point3 & devLightPos,scalar lightRadius,Color ambientColor,Color spotColor,ShadowFlags flag)250 void CoreCanvas::DrawShadow(const Path& path, const Point3& planeParams, const Point3& devLightPos, scalar lightRadius,
251     Color ambientColor, Color spotColor, ShadowFlags flag)
252 {
253     impl_->DrawShadow(path, planeParams, devLightPos, lightRadius, ambientColor, spotColor, flag);
254 }
255 
DrawShadowStyle(const Path & path,const Point3 & planeParams,const Point3 & devLightPos,scalar lightRadius,Color ambientColor,Color spotColor,ShadowFlags flag,bool isLimitElevation)256 void CoreCanvas::DrawShadowStyle(const Path& path, const Point3& planeParams, const Point3& devLightPos,
257     scalar lightRadius, Color ambientColor, Color spotColor, ShadowFlags flag, bool isLimitElevation)
258 {
259     impl_->DrawShadowStyle(
260         path, planeParams, devLightPos, lightRadius, ambientColor, spotColor, flag, isLimitElevation);
261 }
262 
DrawColor(ColorQuad color,BlendMode mode)263 void CoreCanvas::DrawColor(ColorQuad color, BlendMode mode)
264 {
265     impl_->DrawColor(color, mode);
266 }
267 
DrawRegion(const Region & region)268 void CoreCanvas::DrawRegion(const Region& region)
269 {
270     DRAW_API_WITH_PAINT(DrawRegion, region);
271 }
272 
DrawPatch(const Point cubics[12],const ColorQuad colors[4],const Point texCoords[4],BlendMode mode)273 void CoreCanvas::DrawPatch(const Point cubics[12], const ColorQuad colors[4], const Point texCoords[4], BlendMode mode)
274 {
275     DRAW_API_WITH_PAINT(DrawPatch, cubics, colors, texCoords, mode);
276 }
277 
DrawVertices(const Vertices & vertices,BlendMode mode)278 void CoreCanvas::DrawVertices(const Vertices& vertices, BlendMode mode)
279 {
280     DRAW_API_WITH_PAINT(DrawVertices, vertices, mode);
281 }
282 
OpCalculateBefore(const Matrix & matrix)283 bool CoreCanvas::OpCalculateBefore(const Matrix& matrix)
284 {
285     return impl_->OpCalculateBefore(matrix);
286 }
287 
OpCalculateAfter(const Rect & bound)288 std::shared_ptr<Drawing::OpListHandle> CoreCanvas::OpCalculateAfter(const Rect& bound)
289 {
290     return impl_->OpCalculateAfter(bound);
291 }
292 
DrawAtlas(const Image * atlas,const RSXform xform[],const Rect tex[],const ColorQuad colors[],int count,BlendMode mode,const SamplingOptions & sampling,const Rect * cullRect)293 void CoreCanvas::DrawAtlas(const Image* atlas, const RSXform xform[], const Rect tex[], const ColorQuad colors[],
294     int count, BlendMode mode, const SamplingOptions& sampling, const Rect* cullRect)
295 {
296     DRAW_API_WITH_PAINT(DrawAtlas, atlas, xform, tex, colors, count, mode, sampling, cullRect);
297 }
298 
DrawBitmap(const Bitmap & bitmap,const scalar px,const scalar py)299 void CoreCanvas::DrawBitmap(const Bitmap& bitmap, const scalar px, const scalar py)
300 {
301     DRAW_API_WITH_PAINT(DrawBitmap, bitmap, px, py);
302 }
303 
DrawImageNine(const Image * image,const RectI & center,const Rect & dst,FilterMode filter,const Brush * brush)304 void CoreCanvas::DrawImageNine(const Image* image, const RectI& center, const Rect& dst,
305     FilterMode filter, const Brush* brush)
306 {
307     impl_->DrawImageNine(image, center, dst, filter, brush);
308 }
309 
DrawImageLattice(const Image * image,const Lattice & lattice,const Rect & dst,FilterMode filter)310 void CoreCanvas::DrawImageLattice(const Image* image, const Lattice& lattice, const Rect& dst,
311     FilterMode filter)
312 {
313     DRAW_API_WITH_PAINT(DrawImageLattice, image, lattice, dst, filter);
314 }
315 
DrawImage(const Image & image,const scalar px,const scalar py,const SamplingOptions & sampling)316 void CoreCanvas::DrawImage(const Image& image, const scalar px, const scalar py, const SamplingOptions& sampling)
317 {
318     DRAW_API_WITH_PAINT(DrawImage, image, px, py, sampling);
319 }
320 
DrawImageRect(const Image & image,const Rect & src,const Rect & dst,const SamplingOptions & sampling,SrcRectConstraint constraint)321 void CoreCanvas::DrawImageRect(
322     const Image& image, const Rect& src, const Rect& dst, const SamplingOptions& sampling, SrcRectConstraint constraint)
323 {
324     DRAW_API_WITH_PAINT(DrawImageRect, image, src, dst, sampling, constraint);
325 }
326 
DrawImageRect(const Image & image,const Rect & dst,const SamplingOptions & sampling)327 void CoreCanvas::DrawImageRect(const Image& image, const Rect& dst, const SamplingOptions& sampling)
328 {
329     DRAW_API_WITH_PAINT(DrawImageRect, image, dst, sampling);
330 }
331 
DrawPicture(const Picture & picture)332 void CoreCanvas::DrawPicture(const Picture& picture)
333 {
334     impl_->DrawPicture(picture);
335 }
336 
DrawSVGDOM(const sk_sp<SkSVGDOM> & svgDom)337 void CoreCanvas::DrawSVGDOM(const sk_sp<SkSVGDOM>& svgDom)
338 {
339     impl_->DrawSVGDOM(svgDom);
340 }
341 
DrawTextBlob(const TextBlob * blob,const scalar x,const scalar y)342 void CoreCanvas::DrawTextBlob(const TextBlob* blob, const scalar x, const scalar y)
343 {
344     DRAW_API_WITH_PAINT_LOOPER(DrawTextBlob, blob, x, y);
345 }
346 
DrawSingleCharacter(int32_t unicode,const Font & font,scalar x,scalar y)347 void CoreCanvas::DrawSingleCharacter(int32_t unicode, const Font& font, scalar x, scalar y)
348 {
349     std::function<void(int, const Font&)> drawSingleCharacterProc = [&](int currentGlyph, const Font& currentFont) {
350         TextBlobBuilder textBlobBuilder;
351         const TextBlobBuilder::RunBuffer& runBuffer = textBlobBuilder.AllocRunPos(currentFont, 1);
352         runBuffer.glyphs[0] = currentGlyph;
353         runBuffer.pos[0] = 0;
354         runBuffer.pos[1] = 0;
355         std::shared_ptr<TextBlob> textBlob = textBlobBuilder.Make();
356         DrawTextBlob(textBlob.get(), x, y);
357     };
358     uint16_t glyph = font.UnicharToGlyph(unicode);
359     if (glyph != 0) {
360         drawSingleCharacterProc(glyph, font);
361     } else {
362         std::shared_ptr<Font> fallbackFont = font.GetFallbackFont(unicode);
363         if (fallbackFont) {
364             uint16_t fallbackGlyph = fallbackFont->UnicharToGlyph(unicode);
365             drawSingleCharacterProc(fallbackGlyph, *fallbackFont);
366         }
367     }
368 }
369 
DrawSymbol(const DrawingHMSymbolData & symbol,Point locate)370 void CoreCanvas::DrawSymbol(const DrawingHMSymbolData& symbol, Point locate)
371 {
372     DRAW_API_WITH_PAINT(DrawSymbol, symbol, locate);
373 }
374 
ClipRect(const Rect & rect,ClipOp op,bool doAntiAlias)375 void CoreCanvas::ClipRect(const Rect& rect, ClipOp op, bool doAntiAlias)
376 {
377     impl_->ClipRect(rect, op, doAntiAlias);
378 }
379 
ClipIRect(const RectI & rect,ClipOp op)380 void CoreCanvas::ClipIRect(const RectI& rect, ClipOp op)
381 {
382     impl_->ClipIRect(rect, op);
383 }
384 
ClipRoundRect(const RoundRect & roundRect,ClipOp op,bool doAntiAlias)385 void CoreCanvas::ClipRoundRect(const RoundRect& roundRect, ClipOp op, bool doAntiAlias)
386 {
387     impl_->ClipRoundRect(roundRect, op, doAntiAlias);
388 }
389 
ClipRoundRect(const Rect & rect,std::vector<Point> & pts,bool doAntiAlias)390 void CoreCanvas::ClipRoundRect(const Rect& rect, std::vector<Point>& pts, bool doAntiAlias)
391 {
392     impl_->ClipRoundRect(rect, pts, doAntiAlias);
393 }
394 
ClipPath(const Path & path,ClipOp op,bool doAntiAlias)395 void CoreCanvas::ClipPath(const Path& path, ClipOp op, bool doAntiAlias)
396 {
397     impl_->ClipPath(path, op, doAntiAlias);
398 }
399 
ClipRegion(const Region & region,ClipOp op)400 void CoreCanvas::ClipRegion(const Region& region, ClipOp op)
401 {
402     impl_->ClipRegion(region, op);
403 }
404 
IsClipEmpty()405 bool CoreCanvas::IsClipEmpty()
406 {
407     return impl_->IsClipEmpty();
408 }
409 
IsClipRect()410 bool CoreCanvas::IsClipRect()
411 {
412     return impl_->IsClipRect();
413 }
414 
QuickReject(const Rect & rect)415 bool CoreCanvas::QuickReject(const Rect& rect)
416 {
417     return impl_->QuickReject(rect);
418 }
419 
SetMatrix(const Matrix & matrix)420 void CoreCanvas::SetMatrix(const Matrix& matrix)
421 {
422     impl_->SetMatrix(matrix);
423 }
424 
ResetMatrix()425 void CoreCanvas::ResetMatrix()
426 {
427     impl_->ResetMatrix();
428 }
429 
ConcatMatrix(const Matrix & matrix)430 void CoreCanvas::ConcatMatrix(const Matrix& matrix)
431 {
432     impl_->ConcatMatrix(matrix);
433 }
434 
Translate(scalar dx,scalar dy)435 void CoreCanvas::Translate(scalar dx, scalar dy)
436 {
437     impl_->Translate(dx, dy);
438 }
439 
Scale(scalar sx,scalar sy)440 void CoreCanvas::Scale(scalar sx, scalar sy)
441 {
442     impl_->Scale(sx, sy);
443 }
444 
Rotate(scalar deg,scalar sx,scalar sy)445 void CoreCanvas::Rotate(scalar deg, scalar sx, scalar sy)
446 {
447     impl_->Rotate(deg, sx, sy);
448 }
449 
Shear(scalar sx,scalar sy)450 void CoreCanvas::Shear(scalar sx, scalar sy)
451 {
452     impl_->Shear(sx, sy);
453 }
454 
Flush()455 void CoreCanvas::Flush()
456 {
457     impl_->Flush();
458 }
459 
Clear(ColorQuad color)460 void CoreCanvas::Clear(ColorQuad color)
461 {
462     impl_->Clear(color);
463 }
464 
Save()465 uint32_t CoreCanvas::Save()
466 {
467     return impl_->Save();
468 }
469 
SaveLayer(const SaveLayerOps & saveLayerOps)470 void CoreCanvas::SaveLayer(const SaveLayerOps& saveLayerOps)
471 {
472     impl_->SaveLayer(saveLayerOps);
473 }
474 
Restore()475 void CoreCanvas::Restore()
476 {
477     impl_->Restore();
478 }
479 
GetSaveCount() const480 uint32_t CoreCanvas::GetSaveCount() const
481 {
482     return impl_->GetSaveCount();
483 }
484 
Discard()485 void CoreCanvas::Discard()
486 {
487     return impl_->Discard();
488 }
489 
AttachPen(const Pen & pen)490 CoreCanvas& CoreCanvas::AttachPen(const Pen& pen)
491 {
492     paintPen_.AttachPen(pen);
493     return *this;
494 }
495 
AttachBrush(const Brush & brush)496 CoreCanvas& CoreCanvas::AttachBrush(const Brush& brush)
497 {
498     paintBrush_.AttachBrush(brush);
499     return *this;
500 }
501 
AttachPaint(const Paint & paint)502 CoreCanvas& CoreCanvas::AttachPaint(const Paint& paint)
503 {
504     paintBrush_.Disable();
505     paintPen_ = paint;
506     return *this;
507 }
508 
DetachPen()509 CoreCanvas& CoreCanvas::DetachPen()
510 {
511     paintPen_.Disable();
512     return *this;
513 }
514 
DetachBrush()515 CoreCanvas& CoreCanvas::DetachBrush()
516 {
517     paintBrush_.Disable();
518     return *this;
519 }
520 
DetachPaint()521 CoreCanvas& CoreCanvas::DetachPaint()
522 {
523     paintPen_.Disable();
524     return *this;
525 }
526 
GetCanvasData() const527 std::shared_ptr<CoreCanvasImpl> CoreCanvas::GetCanvasData() const
528 {
529     return impl_;
530 }
531 
GetEnvForegroundColor() const532 ColorQuad CoreCanvas::GetEnvForegroundColor() const
533 {
534     return Color::COLOR_BLACK;
535 }
536 
isHighContrastEnabled() const537 bool CoreCanvas::isHighContrastEnabled() const
538 {
539     return false;
540 }
541 
GetCacheType() const542 Drawing::CacheType CoreCanvas::GetCacheType() const
543 {
544     return Drawing::CacheType::UNDEFINED;
545 }
546 
GetSurface() const547 Drawing::Surface* CoreCanvas::GetSurface() const
548 {
549     return nullptr;
550 }
551 
GetAlpha() const552 float CoreCanvas::GetAlpha() const
553 {
554     return 1.0f;
555 }
556 
GetAlphaSaveCount() const557 int CoreCanvas::GetAlphaSaveCount() const
558 {
559     return 0;
560 }
561 
BuildOverDraw(std::shared_ptr<Canvas> canvas)562 void CoreCanvas::BuildOverDraw(std::shared_ptr<Canvas> canvas)
563 {
564     if (impl_ && canvas) {
565         impl_->BuildOverDraw(canvas);
566     }
567 }
568 
BuildNoDraw(int32_t width,int32_t height)569 void CoreCanvas::BuildNoDraw(int32_t width, int32_t height)
570 {
571     impl_->BuildNoDraw(width, height);
572 }
573 
Reset(int32_t width,int32_t height)574 void CoreCanvas::Reset(int32_t width, int32_t height)
575 {
576     impl_->Reset(width, height);
577 }
578 
DrawBlurImage(const Image & image,const HpsBlurParameter & blurParams)579 bool CoreCanvas::DrawBlurImage(const Image& image, const HpsBlurParameter& blurParams)
580 {
581     return impl_->DrawBlurImage(image, blurParams);
582 }
583 
CalcHpsBluredImageDimension(const Drawing::HpsBlurParameter & blurParams)584 std::array<int, 2> CoreCanvas::CalcHpsBluredImageDimension(const Drawing::HpsBlurParameter& blurParams)
585 {
586     return impl_->CalcHpsBluredImageDimension(blurParams);
587 }
588 } // namespace Drawing
589 } // namespace Rosen
590 } // namespace OHOS
591