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 ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_TEXT_BLOB_BUILDER_H 17 #define ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_TEXT_BLOB_BUILDER_H 18 19 #include <memory> 20 21 #ifndef USE_ROSEN_DRAWING 22 #include <include/core/SkTextBlob.h> 23 #else 24 #include "drawing.h" 25 #endif 26 27 #include "texgine_font.h" 28 #include "texgine_text_blob.h" 29 30 namespace OHOS { 31 namespace Rosen { 32 namespace TextEngine { 33 class TexgineTextBlobBuilder { 34 public: 35 #ifndef USE_ROSEN_DRAWING 36 /* 37 * @brief Get the SkTextBlobBuilder. 38 * SkTextBlobBuilder is helper class for constructing SkTextBlob 39 */ 40 std::shared_ptr<SkTextBlobBuilder> GetTextBlobBuilder() const; 41 #else 42 std::shared_ptr<RSTextBlobBuilder> GetTextBlobBuilder() const; 43 #endif 44 /* 45 * @brief Returns run with storage for glyphs and SkPoint positions 46 * @param font SkFont used for this run 47 * @param The count The number of glyphs 48 * @return Writable glyph buffer and SkPoint buffer 49 */ 50 #ifndef USE_ROSEN_DRAWING 51 const SkTextBlobBuilder::RunBuffer& AllocRunPos(const TexgineFont &font, int count); 52 #else 53 const RSTextBlobBuilder::RunBuffer& AllocRunPos(const TexgineFont &font, int count); 54 #endif 55 56 /* 57 * @brief Create TexgineTextBlob 58 */ 59 std::shared_ptr<TexgineTextBlob> Make(); 60 61 private: 62 #ifndef USE_ROSEN_DRAWING 63 std::shared_ptr<SkTextBlobBuilder> textBlobBuilder_ = std::make_shared<SkTextBlobBuilder>(); 64 #else 65 std::shared_ptr<RSTextBlobBuilder> textBlobBuilder_ = std::make_shared<RSTextBlobBuilder>(); 66 #endif 67 }; 68 } // namespace TextEngine 69 } // namespace Rosen 70 } // namespace OHOS 71 72 #endif // ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_TEXT_BLOB_BUILDER_H 73