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