• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
AcquireCanvas(std::unique_ptr<SurfaceFrame> & frame)40 SkCanvas* DrawingProxy::AcquireCanvas(std::unique_ptr<SurfaceFrame>& frame)
41 {
42     return canvasContext_->AcquireCanvas(frame);
43 }
44 
CreateSurface(void * window)45 void* DrawingProxy::CreateSurface(void* window)
46 {
47     return canvasContext_->CreateSurface(window);
48 }
49 
MakeCurrent()50 void DrawingProxy::MakeCurrent()
51 {
52     canvasContext_->MakeCurrent();
53 }
54 
SwapBuffers()55 void DrawingProxy::SwapBuffers()
56 {
57     canvasContext_->SwapBuffers();
58 }
59 
RenderFrame()60 void DrawingProxy::RenderFrame()
61 {
62     canvasContext_->RenderFrame();
63 }
64 
Destroy()65 void DrawingProxy::Destroy()
66 {
67     if (canvasContext_) {
68         delete canvasContext_;
69         canvasContext_ = nullptr;
70     }
71 }
72 }
73 }