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 INTERFACES_INNERKITS_INCLUDE_PIXEL_YUV_EXT_H
17 #define INTERFACES_INNERKITS_INCLUDE_PIXEL_YUV_EXT_H
18 
19 #include "image_type.h"
20 
21 #include "include/core/SkBitmap.h"
22 #include "include/core/SkCanvas.h"
23 #include "include/core/SkImage.h"
24 #include "memory_manager.h"
25 #include "pixel_yuv.h"
26 
27 namespace OHOS {
28 namespace Media {
29 
30 class PixelYuvExt : public PixelYuv {
31 public:
PixelYuvExt()32     PixelYuvExt() {}
33     virtual ~PixelYuvExt();
34     NATIVEEXPORT void rotate(float degrees) override;
35     NATIVEEXPORT void scale(float xAxis, float yAxis) override;
36     NATIVEEXPORT void scale(float xAxis, float yAxis, const AntiAliasingOption &option) override;
37     NATIVEEXPORT void scale(int32_t dstW, int32_t dstH);
38     NATIVEEXPORT void scale(int32_t dstW, int32_t dstH, const AntiAliasingOption &option);
39     NATIVEEXPORT bool resize(float xAxis, float yAxis) override;
40     NATIVEEXPORT bool resize(int32_t dstW, int32_t dstH);
41     NATIVEEXPORT void flip(bool xAxis, bool yAxis) override;
42     NATIVEEXPORT int32_t GetByteCount() override;
43     NATIVEEXPORT void SetPixelsAddr(void *addr, void *context, uint32_t size, AllocatorType type,
44                                     CustomFreePixelMap func) override;
45 #ifdef IMAGE_COLORSPACE_FLAG
46     bool CheckColorSpace(const OHOS::ColorManager::ColorSpace &grColorSpace);
47     int32_t ColorSpaceBGRAToYuv(uint8_t *bgraData, SkTransYuvInfo &dst, ImageInfo &imageInfo, PixelFormat &format,
48         const OHOS::ColorManager::ColorSpace &grColorSpace);
49     NATIVEEXPORT uint32_t ApplyColorSpace(const OHOS::ColorManager::ColorSpace &grColorSpace) override;
50 #endif
51 };
52 } // namespace Media
53 } // namespace OHOS
54 #endif // INTERFACES_INNERKITS_INCLUDE_PIXEL_YUV_EXT_H