1 /* 2 * Copyright (c) 2023 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 #ifndef DRAWING_CONTEXT_H 17 #define DRAWING_CONTEXT_H 18 19 #if defined(NEW_SKIA) 20 #include <include/gpu/GrDirectContext.h> 21 #else 22 #include <include/gpu/GrContext.h> 23 #endif 24 25 #include "rs_render_surface_frame.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 class DrawingContext { 30 public: DrawingContext(RenderType renderType)31 explicit DrawingContext(RenderType renderType) : renderType_(renderType) {} 32 ~DrawingContext() = default; 33 sk_sp<SkSurface> AcquireSurface(const std::shared_ptr<RSRenderSurfaceFrame>& frame); 34 bool SetUpDrawingContext(); 35 GPUContext* GetDrawingContext() const; 36 private: 37 sk_sp<SkSurface> AcquireSurfaceInGLES(const std::shared_ptr<RSRenderSurfaceFrame>& frame); 38 sk_sp<SkSurface> AcquireSurfaceInRaster(const std::shared_ptr<RSRenderSurfaceFrame>& frame); 39 sk_sp<SkSurface> AcquireSurfaceInVulkan(const std::shared_ptr<RSRenderSurfaceFrame>& frame); 40 sk_sp<SkColorSpace> GetSkColorSpace(const std::shared_ptr<RSRenderSurfaceFrame>& frame); 41 std::shared_ptr<GPUContext> gpuContext_ = nullptr; 42 RenderType renderType_; 43 }; 44 } 45 } 46 #endif