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()22DrawingProxy::DrawingProxy() 23 { 24 canvasContext_ = CanvasContext::Create(); 25 } 26 ~DrawingProxy()27DrawingProxy::~DrawingProxy() 28 { 29 if (canvasContext_) { 30 delete canvasContext_; 31 canvasContext_ = nullptr; 32 } 33 } 34 InitDrawContext()35void DrawingProxy::InitDrawContext() 36 { 37 canvasContext_->InitDrawContext(); 38 } 39 AcquireSkCanvas(std::unique_ptr<SurfaceFrame> & frame)40SkCanvas* DrawingProxy::AcquireSkCanvas(std::unique_ptr<SurfaceFrame>& frame) 41 { 42 return canvasContext_->AcquireSkCanvas(frame); 43 } 44 AcquireDrCanvas(std::unique_ptr<SurfaceFrame> & frame)45Drawing::Canvas* DrawingProxy::AcquireDrCanvas(std::unique_ptr<SurfaceFrame>& frame) 46 { 47 return canvasContext_->AcquireDrCanvas(frame); 48 } 49 CreateSurface(void * window)50void* DrawingProxy::CreateSurface(void* window) 51 { 52 return canvasContext_->CreateSurface(window); 53 } 54 MakeCurrent()55void DrawingProxy::MakeCurrent() 56 { 57 canvasContext_->MakeCurrent(); 58 } 59 SwapBuffers()60void DrawingProxy::SwapBuffers() 61 { 62 canvasContext_->SwapBuffers(); 63 } 64 RenderFrame()65void DrawingProxy::RenderFrame() 66 { 67 canvasContext_->RenderFrame(); 68 } 69 Destroy()70void DrawingProxy::Destroy() 71 { 72 if (canvasContext_) { 73 delete canvasContext_; 74 canvasContext_ = nullptr; 75 } 76 } 77 } 78 }