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 DOCUMENT_H 17 #define DOCUMENT_H 18 19 #include "draw/canvas.h" 20 #include "impl_interface/document_impl.h" 21 #include "utils/file_w_stream.h" 22 #include "utils/sharing_serial_context.h" 23 #include "utils/serial_procs.h" 24 25 namespace OHOS { 26 namespace Rosen { 27 namespace Drawing { 28 class Document { 29 public: 30 Document() noexcept; 31 explicit Document(std::shared_ptr<DocumentImpl> documentImpl) noexcept; ~Document()32 virtual ~Document() {} 33 template <typename T> GetImpl()34 T* GetImpl() const 35 { 36 return documentImplPtr_->DowncastingTo<T>(); 37 } 38 39 /* 40 * @brief Writes into a file format that is similar to Picture::Serialize 41 */ 42 static std::shared_ptr<Document> MakeMultiPictureDocument(FileWStream* fileStream, 43 SerialProcs* procs, std::unique_ptr<SharingSerialContext>& serialContext); 44 45 /* 46 * @brief begin a new page for the document, returning the canvas that will draw 47 * into the page. 48 */ 49 std::shared_ptr<Canvas> BeginPage(float width, float height); 50 void EndPage(); 51 void Close(); 52 53 private: 54 std::shared_ptr<DocumentImpl> documentImplPtr_; 55 }; 56 } // namespace Drawing 57 } // namespace Rosen 58 } // namespace OHOS 59 #endif