• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_H
17 #define ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_TEXT_BLOB_H
18 
19 #include <memory>
20 
21 #ifndef USE_ROSEN_DRAWING
22 #include <include/core/SkTextBlob.h>
23 #include <include/core/SkPath.h>
24 #else
25 #include "drawing.h"
26 #endif
27 
28 namespace OHOS {
29 namespace Rosen {
30 namespace TextEngine {
31 class TexgineTextBlob {
32 public:
33     /*
34      * @brief Return the pointer of SkTextBlob to prepare the paint info
35      */
36 #ifndef USE_ROSEN_DRAWING
37     sk_sp<SkTextBlob> GetTextBlob() const;
38 #else
39     std::shared_ptr<RSTextBlob> GetTextBlob() const;
40 #endif
41 
42     /*
43      * @brief Sets SkTextBlob to TexgineTextBlob
44      */
45 #ifndef USE_ROSEN_DRAWING
46     void SetTextBlob(const sk_sp<SkTextBlob> textBlob);
47 #else
48     void SetTextBlob(const std::shared_ptr<RSTextBlob> textBlob);
49 #endif
50 
51 #ifndef USE_ROSEN_DRAWING
52     void GetGlyphIDs(std::vector<SkGlyphID>& glyphIds);
53 
54     SkPath GetPathbyGlyphID(const SkGlyphID& glyphId);
55 #else
56     void GetGlyphIDs(std::vector<uint16_t>& glyphIds);
57 
58     RSPath GetPathbyGlyphID(const uint16_t& glyphId);
59 #endif
60 
61 private:
62 #ifndef USE_ROSEN_DRAWING
63     sk_sp<SkTextBlob> textBlob_ = nullptr;
64 #else
65     std::shared_ptr<RSTextBlob> textBlob_ = nullptr;
66 #endif
67 };
68 } // namespace TextEngine
69 } // namespace Rosen
70 } // namespace OHOS
71 
72 #endif // ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_TEXT_BLOB_H
73