• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 namespace OHOS {
21 namespace Rosen {
22 namespace Drawing {
CoreCanvas()23 CoreCanvas::CoreCanvas() : impl_(ImplFactory::CreateCoreCanvasImpl()) {}
24 
CoreCanvas(void * rawCanvas)25 CoreCanvas::CoreCanvas(void* rawCanvas) : impl_(ImplFactory::CreateCoreCanvasImpl(rawCanvas)) {}
26 
CoreCanvas(int32_t width,int32_t height)27 CoreCanvas::CoreCanvas(int32_t width, int32_t height) : impl_(ImplFactory::CreateCoreCanvasImpl(width, height)) {}
28 
Bind(const Bitmap & bitmap)29 void CoreCanvas::Bind(const Bitmap& bitmap)
30 {
31     impl_->Bind(bitmap);
32 }
33 
GetTotalMatrix() const34 Matrix CoreCanvas::GetTotalMatrix() const
35 {
36     return impl_->GetTotalMatrix();
37 }
38 
GetLocalClipBounds() const39 Rect CoreCanvas::GetLocalClipBounds() const
40 {
41     return impl_->GetLocalClipBounds();
42 }
43 
GetDeviceClipBounds() const44 RectI CoreCanvas::GetDeviceClipBounds() const
45 {
46     return impl_->GetDeviceClipBounds();
47 }
48 
49 #ifdef ACE_ENABLE_GPU
GetGPUContext() const50 std::shared_ptr<GPUContext> CoreCanvas::GetGPUContext() const
51 {
52     return impl_->GetGPUContext();
53 }
54 #endif
55 
GetWidth() const56 int32_t CoreCanvas::GetWidth() const
57 {
58     return impl_->GetWidth();
59 }
60 
GetHeight() const61 int32_t CoreCanvas::GetHeight() const
62 {
63     return impl_->GetHeight();
64 }
65 
DrawPoint(const Point & point)66 void CoreCanvas::DrawPoint(const Point& point)
67 {
68     impl_->DrawPoint(point);
69 }
70 
DrawLine(const Point & startPt,const Point & endPt)71 void CoreCanvas::DrawLine(const Point& startPt, const Point& endPt)
72 {
73     impl_->DrawLine(startPt, endPt);
74 }
75 
DrawRect(const Rect & rect)76 void CoreCanvas::DrawRect(const Rect& rect)
77 {
78     impl_->DrawRect(rect);
79 }
80 
DrawRoundRect(const RoundRect & roundRect)81 void CoreCanvas::DrawRoundRect(const RoundRect& roundRect)
82 {
83     impl_->DrawRoundRect(roundRect);
84 }
85 
DrawNestedRoundRect(const RoundRect & outer,const RoundRect & inner)86 void CoreCanvas::DrawNestedRoundRect(const RoundRect& outer, const RoundRect& inner)
87 {
88     impl_->DrawNestedRoundRect(outer, inner);
89 }
90 
DrawArc(const Rect & oval,scalar startAngle,scalar sweepAngle)91 void CoreCanvas::DrawArc(const Rect& oval, scalar startAngle, scalar sweepAngle)
92 {
93     impl_->DrawArc(oval, startAngle, sweepAngle);
94 }
95 
DrawPie(const Rect & oval,scalar startAngle,scalar sweepAngle)96 void CoreCanvas::DrawPie(const Rect& oval, scalar startAngle, scalar sweepAngle)
97 {
98     impl_->DrawPie(oval, startAngle, sweepAngle);
99 }
100 
DrawOval(const Rect & oval)101 void CoreCanvas::DrawOval(const Rect& oval)
102 {
103     impl_->DrawOval(oval);
104 }
105 
DrawCircle(const Point & centerPt,scalar radius)106 void CoreCanvas::DrawCircle(const Point& centerPt, scalar radius)
107 {
108     impl_->DrawCircle(centerPt, radius);
109 }
110 
DrawPath(const Path & path)111 void CoreCanvas::DrawPath(const Path& path)
112 {
113     impl_->DrawPath(path);
114 }
115 
DrawBackground(const Brush & brush)116 void CoreCanvas::DrawBackground(const Brush& brush)
117 {
118     impl_->DrawBackground(brush);
119 }
120 
DrawShadow(const Path & path,const Point3 & planeParams,const Point3 & devLightPos,scalar lightRadius,Color ambientColor,Color spotColor,ShadowFlags flag)121 void CoreCanvas::DrawShadow(const Path& path, const Point3& planeParams, const Point3& devLightPos, scalar lightRadius,
122     Color ambientColor, Color spotColor, ShadowFlags flag)
123 {
124     impl_->DrawShadow(path, planeParams, devLightPos, lightRadius, ambientColor, spotColor, flag);
125 }
126 
DrawRegion(const Region & region)127 void CoreCanvas::DrawRegion(const Region& region)
128 {
129     impl_->DrawRegion(region);
130 }
131 
DrawBitmap(const Bitmap & bitmap,const scalar px,const scalar py)132 void CoreCanvas::DrawBitmap(const Bitmap& bitmap, const scalar px, const scalar py)
133 {
134     impl_->DrawBitmap(bitmap, px, py);
135 }
136 
DrawBitmap(Media::PixelMap & pixelMap,const scalar px,const scalar py)137 void CoreCanvas::DrawBitmap(Media::PixelMap& pixelMap, const scalar px, const scalar py)
138 {
139     impl_->DrawBitmap(pixelMap, px, py);
140 }
141 
DrawImage(const Image & image,const scalar px,const scalar py,const SamplingOptions & sampling)142 void CoreCanvas::DrawImage(const Image& image, const scalar px, const scalar py, const SamplingOptions& sampling)
143 {
144     impl_->DrawImage(image, px, py, sampling);
145 }
146 
DrawImageRect(const Image & image,const Rect & src,const Rect & dst,const SamplingOptions & sampling,SrcRectConstraint constraint)147 void CoreCanvas::DrawImageRect(
148     const Image& image, const Rect& src, const Rect& dst, const SamplingOptions& sampling, SrcRectConstraint constraint)
149 {
150     impl_->DrawImageRect(image, src, dst, sampling, constraint);
151 }
152 
DrawImageRect(const Image & image,const Rect & dst,const SamplingOptions & sampling)153 void CoreCanvas::DrawImageRect(const Image& image, const Rect& dst, const SamplingOptions& sampling)
154 {
155     impl_->DrawImageRect(image, dst, sampling);
156 }
157 
DrawPicture(const Picture & picture)158 void CoreCanvas::DrawPicture(const Picture& picture)
159 {
160     impl_->DrawPicture(picture);
161 }
162 
DrawSVGDOM(const sk_sp<SkSVGDOM> & svgDom)163 void CoreCanvas::DrawSVGDOM(const sk_sp<SkSVGDOM>& svgDom)
164 {
165     impl_->DrawSVGDOM(svgDom);
166 }
167 
ClipRect(const Rect & rect,ClipOp op,bool doAntiAlias)168 void CoreCanvas::ClipRect(const Rect& rect, ClipOp op, bool doAntiAlias)
169 {
170     impl_->ClipRect(rect, op, doAntiAlias);
171 }
172 
ClipRoundRect(const RoundRect & roundRect,ClipOp op,bool doAntiAlias)173 void CoreCanvas::ClipRoundRect(const RoundRect& roundRect, ClipOp op, bool doAntiAlias)
174 {
175     impl_->ClipRoundRect(roundRect, op, doAntiAlias);
176 }
177 
ClipPath(const Path & path,ClipOp op,bool doAntiAlias)178 void CoreCanvas::ClipPath(const Path& path, ClipOp op, bool doAntiAlias)
179 {
180     impl_->ClipPath(path, op, doAntiAlias);
181 }
182 
SetMatrix(const Matrix & matrix)183 void CoreCanvas::SetMatrix(const Matrix& matrix)
184 {
185     impl_->SetMatrix(matrix);
186 }
187 
ResetMatrix()188 void CoreCanvas::ResetMatrix()
189 {
190     impl_->ResetMatrix();
191 }
192 
ConcatMatrix(const Matrix & matrix)193 void CoreCanvas::ConcatMatrix(const Matrix& matrix)
194 {
195     impl_->ConcatMatrix(matrix);
196 }
197 
Translate(scalar dx,scalar dy)198 void CoreCanvas::Translate(scalar dx, scalar dy)
199 {
200     impl_->Translate(dx, dy);
201 }
202 
Scale(scalar sx,scalar sy)203 void CoreCanvas::Scale(scalar sx, scalar sy)
204 {
205     impl_->Scale(sx, sy);
206 }
207 
Rotate(scalar deg,scalar sx,scalar sy)208 void CoreCanvas::Rotate(scalar deg, scalar sx, scalar sy)
209 {
210     impl_->Rotate(deg, sx, sy);
211 }
212 
Shear(scalar sx,scalar sy)213 void CoreCanvas::Shear(scalar sx, scalar sy)
214 {
215     impl_->Shear(sx, sy);
216 }
217 
Flush()218 void CoreCanvas::Flush()
219 {
220     impl_->Flush();
221 }
222 
Clear(ColorQuad color)223 void CoreCanvas::Clear(ColorQuad color)
224 {
225     impl_->Clear(color);
226 }
227 
Save()228 void CoreCanvas::Save()
229 {
230     impl_->Save();
231 }
232 
SaveLayer(const SaveLayerOps & saveLayerOps)233 void CoreCanvas::SaveLayer(const SaveLayerOps& saveLayerOps)
234 {
235     impl_->SaveLayer(saveLayerOps);
236 }
237 
Restore()238 void CoreCanvas::Restore()
239 {
240     impl_->Restore();
241 }
242 
GetSaveCount() const243 uint32_t CoreCanvas::GetSaveCount() const
244 {
245     return impl_->GetSaveCount();
246 }
247 
AttachPen(const Pen & pen)248 CoreCanvas& CoreCanvas::AttachPen(const Pen& pen)
249 {
250     impl_->AttachPen(pen);
251     return *this;
252 }
253 
AttachBrush(const Brush & brush)254 CoreCanvas& CoreCanvas::AttachBrush(const Brush& brush)
255 {
256     impl_->AttachBrush(brush);
257     return *this;
258 }
259 
DetachPen()260 CoreCanvas& CoreCanvas::DetachPen()
261 {
262     impl_->DetachPen();
263     return *this;
264 }
265 
DetachBrush()266 CoreCanvas& CoreCanvas::DetachBrush()
267 {
268     impl_->DetachBrush();
269     return *this;
270 }
271 
GetCanvasData() const272 std::shared_ptr<CoreCanvasImpl> CoreCanvas::GetCanvasData() const
273 {
274     return impl_;
275 }
276 } // namespace Drawing
277 } // namespace Rosen
278 } // namespace OHOS
279