1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
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 "drawing_proxy.h"
17 
18 #include "drawing_utils.h"
19 
20 namespace OHOS {
21 namespace Rosen {
DrawingProxy()22 DrawingProxy::DrawingProxy()
23 {
24     canvasContext_ = CanvasContext::Create();
25 }
26 
~DrawingProxy()27 DrawingProxy::~DrawingProxy()
28 {
29     if (canvasContext_) {
30         delete canvasContext_;
31         canvasContext_ = nullptr;
32     }
33 }
34 
InitDrawContext()35 void DrawingProxy::InitDrawContext()
36 {
37     canvasContext_->InitDrawContext();
38 }
39 
AcquireSkCanvas(std::unique_ptr<SurfaceFrame> & frame)40 SkCanvas* DrawingProxy::AcquireSkCanvas(std::unique_ptr<SurfaceFrame>& frame)
41 {
42     return canvasContext_->AcquireSkCanvas(frame);
43 }
44 
AcquireDrCanvas(std::unique_ptr<SurfaceFrame> & frame)45 Drawing::Canvas* DrawingProxy::AcquireDrCanvas(std::unique_ptr<SurfaceFrame>& frame)
46 {
47     return canvasContext_->AcquireDrCanvas(frame);
48 }
49 
CreateSurface(void * window)50 void* DrawingProxy::CreateSurface(void* window)
51 {
52     return canvasContext_->CreateSurface(window);
53 }
54 
MakeCurrent()55 void DrawingProxy::MakeCurrent()
56 {
57     canvasContext_->MakeCurrent();
58 }
59 
SwapBuffers()60 void DrawingProxy::SwapBuffers()
61 {
62     canvasContext_->SwapBuffers();
63 }
64 
RenderFrame()65 void DrawingProxy::RenderFrame()
66 {
67     canvasContext_->RenderFrame();
68 }
69 
Destroy()70 void DrawingProxy::Destroy()
71 {
72     if (canvasContext_) {
73         delete canvasContext_;
74         canvasContext_ = nullptr;
75     }
76 }
77 }
78 }