• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-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 #include <unistd.h>
17 
18 #include "common/graphic_startup.h"
19 #include "common/screen.h"
20 #include "common/task_manager.h"
21 #if ENABLE_VECTOR_FONT
22 #include "font/ui_font_vector.h"
23 #else
24 #include "common/ui_text_language.h"
25 #include "font/ui_font_bitmap.h"
26 #endif
27 #include "gfx_utils/graphic_log.h"
28 #include "graphic_config.h"
29 #include "window/window.h"
30 
31 extern void RunApp();
32 
33 namespace OHOS {
34 uint32_t g_animaterBuffer[HORIZONTAL_RESOLUTION * VERTICAL_RESOLUTION];
TestAPP()35 void TestAPP()
36 {
37     WindowConfig config = {};
38     config.rect.SetRect(0, 0, Screen::GetInstance().GetWidth() - 1, Screen::GetInstance().GetHeight() - 1);
39     Window* window = Window::CreateWindow(config);
40     if (window == nullptr) {
41         GRAPHIC_LOGE("Create window false!");
42         return;
43     }
44     window->BindRootView(RootView::GetInstance());
45     RunApp();
46     window->Show();
47 }
48 
49 static uint32_t g_fontMemBaseAddr[MIN_FONT_PSRAM_LENGTH / 4];
50 #if ENABLE_ICU
51 static uint8_t g_icuMemBaseAddr[OHOS::SHAPING_WORD_DICT_LENGTH];
52 #endif
53 
InitFontEngine()54 static void InitFontEngine()
55 {
56 #if ENABLE_VECTOR_FONT
57     GraphicStartUp::InitFontEngine(reinterpret_cast<uintptr_t>(g_fontMemBaseAddr), MIN_FONT_PSRAM_LENGTH,
58                                    VECTOR_FONT_DIR, DEFAULT_VECTOR_FONT_FILENAME);
59 #else
60     BitmapFontInit();
61     const char* dPath = "/user/data/font.bin";
62     GraphicStartUp::InitFontEngine(reinterpret_cast<uintptr_t>(g_fontMemBaseAddr), MIN_FONT_PSRAM_LENGTH,
63                                    dPath, nullptr);
64 #endif
65 
66 #if ENABLE_ICU
67     GraphicStartUp::InitLineBreakEngine(reinterpret_cast<uintptr_t>(g_icuMemBaseAddr), SHAPING_WORD_DICT_LENGTH,
68                                         VECTOR_FONT_DIR, DEFAULT_LINE_BREAK_RULE_FILENAME);
69 #endif
70 }
71 } // namespace OHOS
72 
main(int argc,char * argv[])73 int main(int argc, char* argv[])
74 {
75     OHOS::GraphicStartUp::Init();
76     OHOS::InitFontEngine();
77     OHOS::TestAPP();
78     while (1) {
79         /* Periodically call TaskHandler(). It could be done in a timer interrupt or an OS task too. */
80         OHOS::TaskManager::GetInstance()->TaskHandler();
81         usleep(1000 * 10); /* 1000 * 10: Just to let the system breathe */
82     }
83     return 0;
84 }
85