Flutter Engine
The Flutter Engine
third_party
skia
modules
skottie
utils
PreshapeTool.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2024 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#include "
include/core/SkData.h
"
9
#include "
include/core/SkFontMgr.h
"
// IWYU pragma: keep
10
#include "
include/core/SkGraphics.h
"
11
#include "
include/core/SkRefCnt.h
"
12
#include "
include/core/SkStream.h
"
13
#include "
include/private/base/SkDebug.h
"
14
#include "
include/private/base/SkFeatures.h
"
15
#include "
modules/skottie/utils/TextPreshape.h
"
16
#include "
modules/skresources/include/SkResources.h
"
17
#include "
modules/skshaper/utils/FactoryHelpers.h
"
18
#include "
tools/flags/CommandLineFlags.h
"
19
20
#if defined(SK_BUILD_FOR_MAC) && defined(SK_FONTMGR_CORETEXT_AVAILABLE)
21
#include "
include/ports/SkFontMgr_mac_ct.h
"
22
#elif defined(SK_BUILD_FOR_ANDROID) && defined(SK_FONTMGR_ANDROID_AVAILABLE)
23
#include "
include/ports/SkFontMgr_android.h
"
24
#include "
src/ports/SkTypeface_FreeType.h
"
25
#elif defined(SK_BUILD_FOR_UNIX) && defined(SK_FONTMGR_FONTCONFIG_AVAILABLE)
26
#include "
include/ports/SkFontMgr_fontconfig.h
"
27
#else
28
#include "
include/ports/SkFontMgr_empty.h
"
29
#endif
30
31
static
DEFINE_string2
(input ,
i
,
nullptr
,
"Input .json file."
);
32
static
DEFINE_string2
(
output
, o,
nullptr
,
"Output .json file."
);
33
34
int
main
(
int
argc,
char
**
argv
) {
35
CommandLineFlags::Parse
(argc,
argv
);
36
SkGraphics::Init
();
37
38
if
(FLAGS_input.isEmpty() || FLAGS_output.isEmpty()) {
39
SkDebugf
(
"Missing required 'input' and 'output' args.\n"
);
40
return
1;
41
}
42
43
const
auto
data
=
SkData::MakeFromFileName
(FLAGS_input[0]);
44
if
(!
data
) {
45
SkDebugf
(
"Could not read file: %s\n"
, FLAGS_input[0]);
46
return
1;
47
}
48
49
SkFILEWStream
out
(FLAGS_output[0]);
50
if
(!
out
.isValid()) {
51
SkDebugf
(
"Could not write file: %s\n"
, FLAGS_output[0]);
52
return
1;
53
}
54
55
#if defined(SK_BUILD_FOR_MAC) && defined(SK_FONTMGR_CORETEXT_AVAILABLE)
56
sk_sp<SkFontMgr>
fontMgr
=
SkFontMgr_New_CoreText
(
nullptr
);
57
#elif defined(SK_BUILD_FOR_ANDROID) && defined(SK_FONTMGR_ANDROID_AVAILABLE)
58
sk_sp<SkFontMgr>
fontMgr
=
SkFontMgr_New_Android
(
nullptr
, std::make_unique<SkFontScanner_FreeType>());
59
#elif defined(SK_BUILD_FOR_UNIX) && defined(SK_FONTMGR_FONTCONFIG_AVAILABLE)
60
sk_sp<SkFontMgr>
fontMgr
=
SkFontMgr_New_FontConfig
(
nullptr
);
61
#else
62
sk_sp<SkFontMgr>
fontMgr
=
SkFontMgr_New_Custom_Empty
();
63
#endif
64
65
if
(!
skottie_utils::Preshape
(
data
, &
out
,
fontMgr
,
SkShapers::BestAvailable
(),
nullptr
)) {
66
SkDebugf
(
"Could not preshape: %s\n"
, FLAGS_input[0]);
67
return
-1;
68
}
69
70
return
0;
71
}
CommandLineFlags.h
FactoryHelpers.h
DEFINE_string2
static DEFINE_string2(input, i, nullptr, "Input .json file.")
main
int main(int argc, char **argv)
Definition:
PreshapeTool.cpp:34
SkData.h
SkDebug.h
SkDebugf
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SkFeatures.h
SkFontMgr.h
SkFontMgr_android.h
SkFontMgr_New_Android
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts *custom)
Definition:
SkFontMgr_android.cpp:510
SkFontMgr_empty.h
SkFontMgr_New_Custom_Empty
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Custom_Empty()
Definition:
SkFontMgr_custom_empty.cpp:27
SkFontMgr_fontconfig.h
SkFontMgr_New_FontConfig
SK_API sk_sp< SkFontMgr > SkFontMgr_New_FontConfig(FcConfig *fc)
Definition:
SkFontMgr_fontconfig.cpp:970
SkFontMgr_mac_ct.h
SkFontMgr_New_CoreText
SK_API sk_sp< SkFontMgr > SkFontMgr_New_CoreText(CTFontCollectionRef)
SkGraphics.h
SkRefCnt.h
SkResources.h
SkStream.h
SkTypeface_FreeType.h
TextPreshape.h
CommandLineFlags::Parse
static void Parse(int argc, const char *const *argv)
Definition:
CommandLineFlags.cpp:215
SkData::MakeFromFileName
static sk_sp< SkData > MakeFromFileName(const char path[])
Definition:
SkData.cpp:148
SkFILEWStream
Definition:
SkStream.h:435
SkGraphics::Init
static void Init()
Definition:
SkGraphics.cpp:22
sk_sp< SkFontMgr >
fontMgr
sk_sp< SkFontMgr > fontMgr
Definition:
examples.cpp:32
i
int i
Definition:
fl_socket_accessible.cc:18
argv
char ** argv
Definition:
library.h:9
SkShapers::BestAvailable
sk_sp< Factory > BestAvailable()
Definition:
FactoryHelpers.h:104
dart_profiler_symbols.output
output
Definition:
dart_profiler_symbols.py:51
dump_adb_log.out
out
Definition:
dump_adb_log.py:10
skottie_utils::Preshape
bool Preshape(const char *json, size_t size, SkWStream *stream, const sk_sp< SkFontMgr > &fmgr, const sk_sp< SkShapers::Factory > &sfact, const sk_sp< skresources::ResourceProvider > &rp)
Definition:
TextPreshape.cpp:442
data
std::shared_ptr< const fml::Mapping > data
Definition:
texture_gles.cc:63
Generated on Sun Jun 23 2024 21:56:05 for Flutter Engine by
1.9.4