1 /* 2 * Copyright (c) 2024 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_YUV_INFO_H 17 #define SKIA_YUV_INFO_H 18 19 #include "include/core/SkYUVAInfo.h" 20 21 #include "image/yuv_info.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 namespace Drawing { 26 27 class SkiaYUVInfo { 28 public: ConvertToSkPlaneConfig(const YUVInfo::PlaneConfig & config)29 static SkYUVAInfo::PlaneConfig ConvertToSkPlaneConfig(const YUVInfo::PlaneConfig& config) 30 { 31 switch (config) { 32 case YUVInfo::PlaneConfig::Y_UV: 33 return SkYUVAInfo::PlaneConfig::kY_UV; 34 case YUVInfo::PlaneConfig::Y_VU: 35 return SkYUVAInfo::PlaneConfig::kY_VU; 36 case YUVInfo::PlaneConfig::UNKNOWN: 37 return SkYUVAInfo::PlaneConfig::kUnknown; 38 default: 39 return SkYUVAInfo::PlaneConfig::kUnknown; 40 } 41 } 42 ConvertToSkSubSampling(const YUVInfo::SubSampling & sampling)43 static SkYUVAInfo::Subsampling ConvertToSkSubSampling(const YUVInfo::SubSampling& sampling) 44 { 45 switch (sampling) { 46 case YUVInfo::SubSampling::K420: 47 return SkYUVAInfo::Subsampling::k420; 48 case YUVInfo::SubSampling::UNKNOWN: 49 return SkYUVAInfo::Subsampling::kUnknown; 50 default: 51 return SkYUVAInfo::Subsampling::kUnknown; 52 } 53 } 54 ConvertToSkYUVColorSpace(const YUVInfo::YUVColorSpace & colorspace)55 static SkYUVColorSpace ConvertToSkYUVColorSpace(const YUVInfo::YUVColorSpace& colorspace) 56 { 57 switch (colorspace) { 58 case YUVInfo::YUVColorSpace::JPEG_FULL_YUVCOLORSPACE: 59 return SkYUVColorSpace::kJPEG_Full_SkYUVColorSpace; 60 case YUVInfo::YUVColorSpace::IDENTITY_YUVCOLORSPACE: 61 return SkYUVColorSpace::kIdentity_SkYUVColorSpace; 62 default: 63 return SkYUVColorSpace::kIdentity_SkYUVColorSpace; 64 } 65 } 66 }; 67 } // namespace Drawing 68 } // namespace Rosen 69 } // namespace OHOS 70 #endif