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 SKIA_TEXTURE_INFO_H 17 #define SKIA_TEXTURE_INFO_H 18 #ifdef RS_ENABLE_GPU 19 #ifdef USE_M133_SKIA 20 #include "include/gpu/ganesh/GrBackendSurface.h" 21 #include "include/gpu/ganesh/gl/GrGLBackendSurface.h" 22 #ifdef RS_ENABLE_VK 23 #include "include/gpu/ganesh/vk/GrVkTypes.h" 24 #include "include/gpu/ganesh/vk/GrVkBackendSurface.h" 25 #endif 26 #else 27 #include "include/gpu/GrBackendSurface.h" 28 #endif 29 #endif 30 31 #include "image/image.h" 32 33 namespace OHOS { 34 namespace Rosen { 35 namespace Drawing { 36 class SkiaTextureInfo { 37 public: ConvertToGrSurfaceOrigin(const TextureOrigin & origin)38 static GrSurfaceOrigin ConvertToGrSurfaceOrigin(const TextureOrigin& origin) 39 { 40 switch (origin) { 41 case TextureOrigin::TOP_LEFT: 42 return GrSurfaceOrigin::kTopLeft_GrSurfaceOrigin; 43 case TextureOrigin::BOTTOM_LEFT: 44 return GrSurfaceOrigin::kBottomLeft_GrSurfaceOrigin; 45 default: 46 return GrSurfaceOrigin::kTopLeft_GrSurfaceOrigin; 47 } 48 } 49 #ifdef RS_ENABLE_VK 50 static GrBackendTexture ConvertToGrBackendVKTexture(const TextureInfo& info); 51 52 static void ConvertToVKTexture(const GrBackendTexture& backendTexture, TextureInfo& info); 53 #endif 54 #ifdef RS_ENABLE_GPU 55 static TextureInfo ConvertToTextureInfo(const GrBackendTexture& grBackendTexture); 56 57 static GrBackendTexture ConvertToGrBackendTexture(const TextureInfo& info); 58 #endif 59 }; 60 } // namespace Drawing 61 } // namespace Rosen 62 } // namespace OHOS 63 #endif // SKIA_TEXTURE_INFO_H