• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_DOCUMENT_H
17 #define SKIA_DOCUMENT_H
18 
19 #include "impl_interface/document_impl.h"
20 
21 #include "include/core/SkDocument.h"
22 
23 #include "utils/document.h"
24 #include "utils/file_w_stream.h"
25 #include "utils/sharing_serial_context.h"
26 #include "utils/serial_procs.h"
27 
28 namespace OHOS {
29 namespace Rosen {
30 namespace Drawing {
31 
32 class SkiaDocument : public DocumentImpl {
33 public:
34     static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER;
35     SkiaDocument(sk_sp<SkDocument> skDocument) noexcept;
~SkiaDocument()36     ~SkiaDocument() override {}
37 
GetType()38     AdapterType GetType() const override
39     {
40         return AdapterType::SKIA_ADAPTER;
41     }
42 
43     static std::shared_ptr<Document> MakeMultiPictureDocument(FileWStream* fileStream,
44         SerialProcs* procs, std::unique_ptr<SharingSerialContext>& serialContext);
45 
46     const sk_sp<SkDocument> GetSkiaDocument() const;
47     void SetSkDocument(const sk_sp<SkDocument>& skDocument);
48 
49     std::shared_ptr<Canvas> BeginPage(float width, float height) override;
50     void EndPage() override;
51     void Close() override;
52 
53 private:
54     sk_sp<SkDocument> skDocument_;
55 };
56 } // Drawing
57 } // Rosen
58 } // OHOS
59 #endif