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 RENDER_SERVICE_BASE_RENDER_RS_PIXEL_MAP_UTIL_H 17 #define RENDER_SERVICE_BASE_RENDER_RS_PIXEL_MAP_UTIL_H 18 19 #include <memory> 20 21 #include "common/rs_common_def.h" 22 #include "pixel_map.h" 23 #include "pipeline/rs_paint_filter_canvas.h" 24 #include "include/core/SkRRect.h" 25 26 #include "draw/canvas.h" 27 #include "image/image.h" 28 #include "image/gpu_context.h" 29 30 namespace OHOS { 31 namespace Rosen { 32 enum class ImageFit; 33 class RSB_EXPORT RSPixelMapUtil { 34 public: 35 // The generated SkImage already holds the shared_ptr of the source PixelMap, 36 // and the PixelMap should not hold SkImage to avoid circular references. 37 static std::shared_ptr<Drawing::ColorSpace> GetPixelmapColorSpace( 38 const std::shared_ptr<Media::PixelMap>& pixelMap); 39 static std::shared_ptr<Drawing::Image> ExtractDrawingImage(std::shared_ptr<Media::PixelMap> pixelMap); 40 static void TransformDataSetForAstc(std::shared_ptr<Media::PixelMap> pixelMap, 41 Drawing::Rect& src, Drawing::Rect& dst, Drawing::Canvas& canvas, ImageFit imageFit); 42 static void DrawPixelMap(Drawing::Canvas& canvas, Media::PixelMap& pixelMap, 43 const Drawing::scalar px, const Drawing::scalar py); 44 static bool IsYUVFormat(std::shared_ptr<Media::PixelMap> pixelMap); 45 static bool IsSupportZeroCopy(std::shared_ptr<Media::PixelMap> pixelMap, const Drawing::SamplingOptions& sampling); 46 static std::shared_ptr<Drawing::Image> ConvertYUVPixelMapToDrawingImage( 47 std::shared_ptr<Drawing::GPUContext> gpuContext, std::shared_ptr<Media::PixelMap> pixelMap); 48 static bool CheckFormatConsistency(std::shared_ptr<Media::PixelMap> pixelMap); 49 }; 50 } // namespace Rosen 51 } // namespace OHOS 52 #endif // RENDER_SERVICE_BASE_RENDER_RS_PIXEL_MAP_UTIL_H 53