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 #ifndef USE_ROSEN_DRAWING 27 template <typename T> 28 class sk_sp; 29 class SkImage; 30 #else 31 #include "draw/canvas.h" 32 #include "image/image.h" 33 #endif 34 35 namespace OHOS { 36 namespace Rosen { 37 class RSB_EXPORT RSPixelMapUtil { 38 public: 39 // The generated SkImage already holds the shared_ptr of the source PixelMap, 40 // and the PixelMap should not hold SkImage to avoid circular references. 41 #ifndef USE_ROSEN_DRAWING 42 static sk_sp<SkImage> ExtractSkImage(std::shared_ptr<Media::PixelMap> pixelMap); 43 static void TransformDataSetForAstc(std::shared_ptr<Media::PixelMap> pixelMap, 44 SkRect& src, SkRect& dst, RSPaintFilterCanvas& canvas); 45 #else 46 static std::shared_ptr<Drawing::Image> ExtractDrawingImage(std::shared_ptr<Media::PixelMap> pixelMap); 47 static void TransformDataSetForAstc(std::shared_ptr<Media::PixelMap> pixelMap, 48 Drawing::Rect& src, Drawing::Rect& dst, Drawing::Canvas& canvas); 49 #endif 50 }; 51 } // namespace Rosen 52 } // namespace OHOS 53 #endif // RENDER_SERVICE_BASE_RENDER_RS_PIXEL_MAP_UTIL_H 54