• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 SKIAIMAGE_H
17 #define SKIAIMAGE_H
18 
19 #include "include/core/SkBitmap.h"
20 #include "include/core/SkImage.h"
21 #include "include/core/SkPaint.h"
22 #include "include/core/SkPicture.h"
23 #include "skia_bitmap.h"
24 #include "skia_color_space.h"
25 #include "skia_matrix.h"
26 #include "skia_paint.h"
27 #include "skia_picture.h"
28 
29 #include "impl_interface/image_impl.h"
30 
31 namespace OHOS {
32 namespace Rosen {
33 namespace Drawing {
34 class SkiaImage : public ImageImpl {
35 public:
36     static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER;
37     SkiaImage() noexcept;
38     explicit SkiaImage(sk_sp<SkImage> skImg) noexcept;
~SkiaImage()39     ~SkiaImage() override {}
GetType()40     AdapterType GetType() const override
41     {
42         return AdapterType::SKIA_ADAPTER;
43     }
44     void* BuildFromBitmap(const Bitmap& bitmap) override;
45     void* BuildFromPicture(const Picture& picture, const SizeI& dimensions, const Matrix& matrix, const Brush& brush,
46         BitDepth bitDepth, std::shared_ptr<ColorSpace> colorSpace) override;
47     int GetWidth() override;
48     int GetHeight() override;
49     const sk_sp<SkImage> GetImage() const;
50 
51 private:
52     sk_sp<SkImage> skiaImage_;
53     SkiaPaint skiaPaint_;
54 };
55 } // namespace Drawing
56 } // namespace Rosen
57 } // namespace OHOS
58 #endif
59