• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #ifndef NEW_SKIA
17 #include "flutter_render_custom_paint.h"
18 #endif
19 #include "rosen_render_custom_paint.h"
20 
21 #include "base/utils/measure_util.h"
22 
23 namespace OHOS::Ace {
Create()24 RefPtr<RenderNode> RenderCustomPaint::Create()
25 {
26     if (SystemProperties::GetRosenBackendEnabled()) {
27 #ifdef ENABLE_ROSEN_BACKEND
28         return AceType::MakeRefPtr<RosenRenderCustomPaint>();
29 #else
30         return nullptr;
31 #endif
32     } else {
33 #ifndef NEW_SKIA
34         return AceType::MakeRefPtr<FlutterRenderCustomPaint>();
35 #else
36         return nullptr;
37 #endif
38     }
39 }
40 
PaintMeasureText(const MeasureContext & context)41 double RenderCustomPaint::PaintMeasureText(const MeasureContext& context)
42 {
43     if (SystemProperties::GetRosenBackendEnabled()) {
44 #ifdef ENABLE_ROSEN_BACKEND
45         return RosenRenderCustomPaint::MeasureTextInner(context);
46 #else
47         return 0.0;
48 #endif
49     } else {
50         return 0.0;
51     }
52 }
53 
MeasureTextSize(const MeasureContext & context)54 Size RenderCustomPaint::MeasureTextSize(const MeasureContext& context)
55 {
56     if (SystemProperties::GetRosenBackendEnabled()) {
57 #ifdef ENABLE_ROSEN_BACKEND
58         return RosenRenderCustomPaint::MeasureTextSizeInner(context);
59 #else
60         return Size(0.0, 0.0);
61 #endif
62     } else {
63         return Size(0.0, 0.0);
64     }
65 }
66 } // namespace OHOS::Ace
67