Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
05458826
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
05458826
编写于
12月 18, 2017
作者:
S
Sarah Zakarias
提交者:
GitHub
12月 18, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Select fonts from asset directory instead of FLX (#4464)
上级
0182ed98
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
37 addition
and
29 deletion
+37
-29
assets/directory_asset_bundle.h
assets/directory_asset_bundle.h
+3
-1
lib/ui/text/font_collection.cc
lib/ui/text/font_collection.cc
+7
-5
lib/ui/text/font_collection.h
lib/ui/text/font_collection.h
+3
-3
runtime/asset_font_selector.cc
runtime/asset_font_selector.cc
+11
-7
runtime/asset_font_selector.h
runtime/asset_font_selector.h
+6
-5
shell/common/engine.cc
shell/common/engine.cc
+6
-7
shell/common/engine.h
shell/common/engine.h
+1
-1
未找到文件。
assets/directory_asset_bundle.h
浏览文件 @
05458826
...
...
@@ -9,10 +9,12 @@
#include <vector>
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/ref_counted.h"
namespace
blink
{
class
DirectoryAssetBundle
{
class
DirectoryAssetBundle
:
public
fxl
::
RefCountedThreadSafe
<
DirectoryAssetBundle
>
{
public:
explicit
DirectoryAssetBundle
(
std
::
string
directory
);
~
DirectoryAssetBundle
();
...
...
lib/ui/text/font_collection.cc
浏览文件 @
05458826
...
...
@@ -34,14 +34,15 @@ std::shared_ptr<txt::FontCollection> FontCollection::GetFontCollection() const {
return
collection_
;
}
void
FontCollection
::
RegisterFontsFrom
AssetStor
e
(
fxl
::
RefPtr
<
blink
::
ZipAssetStore
>
asset_stor
e
)
{
if
(
!
asset_stor
e
)
{
void
FontCollection
::
RegisterFontsFrom
DirectoryAssetBundl
e
(
fxl
::
RefPtr
<
blink
::
DirectoryAssetBundle
>
directory_asset_bundl
e
)
{
if
(
!
directory_asset_bundl
e
)
{
return
;
}
std
::
vector
<
uint8_t
>
manifest_data
;
if
(
!
asset_store
->
GetAsBuffer
(
"FontManifest.json"
,
&
manifest_data
))
{
if
(
!
directory_asset_bundle
->
GetAsBuffer
(
"FontManifest.json"
,
&
manifest_data
))
{
FXL_DLOG
(
WARNING
)
<<
"Could not find the font manifest in the asset store."
;
return
;
}
...
...
@@ -91,7 +92,8 @@ void FontCollection::RegisterFontsFromAssetStore(
// TODO: Handle weights and styles.
std
::
vector
<
uint8_t
>
font_data
;
if
(
asset_store
->
GetAsBuffer
(
font_asset
->
value
.
GetString
(),
&
font_data
))
{
if
(
directory_asset_bundle
->
GetAsBuffer
(
font_asset
->
value
.
GetString
(),
&
font_data
))
{
// The data must be copied because it needs to be moved into the
// typeface as a stream.
auto
data
=
...
...
lib/ui/text/font_collection.h
浏览文件 @
05458826
...
...
@@ -7,7 +7,7 @@
#include <memory>
#include <vector>
#include "flutter/assets/
zip_asset_stor
e.h"
#include "flutter/assets/
directory_asset_bundl
e.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/ref_ptr.h"
#include "txt/asset_data_provider.h"
...
...
@@ -21,8 +21,8 @@ class FontCollection {
std
::
shared_ptr
<
txt
::
FontCollection
>
GetFontCollection
()
const
;
void
RegisterFontsFrom
AssetStor
e
(
fxl
::
RefPtr
<
blink
::
ZipAssetStore
>
asset_stor
e
);
void
RegisterFontsFrom
DirectoryAssetBundl
e
(
fxl
::
RefPtr
<
blink
::
DirectoryAssetBundle
>
directory_asset_bundl
e
);
void
RegisterTestFonts
();
...
...
runtime/asset_font_selector.cc
浏览文件 @
05458826
...
...
@@ -4,7 +4,7 @@
#include "flutter/runtime/asset_font_selector.h"
#include "flutter/assets/
zip_asset_stor
e.h"
#include "flutter/assets/
directory_asset_bundl
e.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "flutter/sky/engine/platform/fonts/FontData.h"
#include "flutter/sky/engine/platform/fonts/FontFaceCreationParams.h"
...
...
@@ -80,15 +80,17 @@ struct FontMatcher {
}
// namespace
void
AssetFontSelector
::
Install
(
fxl
::
RefPtr
<
ZipAssetStore
>
asset_store
)
{
void
AssetFontSelector
::
Install
(
fxl
::
RefPtr
<
DirectoryAssetBundle
>
directory_asset_bundle
)
{
RefPtr
<
AssetFontSelector
>
font_selector
=
adoptRef
(
new
AssetFontSelector
(
std
::
move
(
asset_stor
e
)));
adoptRef
(
new
AssetFontSelector
(
std
::
move
(
directory_asset_bundl
e
)));
font_selector
->
parseFontManifest
();
UIDartState
::
Current
()
->
set_font_selector
(
font_selector
);
}
AssetFontSelector
::
AssetFontSelector
(
fxl
::
RefPtr
<
ZipAssetStore
>
asset_store
)
:
asset_store_
(
std
::
move
(
asset_store
))
{}
AssetFontSelector
::
AssetFontSelector
(
fxl
::
RefPtr
<
DirectoryAssetBundle
>
directory_asset_bundle
)
:
directory_asset_bundle_
(
std
::
move
(
directory_asset_bundle
))
{}
AssetFontSelector
::~
AssetFontSelector
()
{}
...
...
@@ -106,7 +108,8 @@ AssetFontSelector::FlutterFontAttributes::~FlutterFontAttributes() {}
void
AssetFontSelector
::
parseFontManifest
()
{
std
::
vector
<
uint8_t
>
font_manifest_data
;
if
(
!
asset_store_
->
GetAsBuffer
(
kFontManifestAssetPath
,
&
font_manifest_data
))
if
(
!
directory_asset_bundle_
->
GetAsBuffer
(
kFontManifestAssetPath
,
&
font_manifest_data
))
return
;
rapidjson
::
Document
document
;
...
...
@@ -222,7 +225,8 @@ sk_sp<SkTypeface> AssetFontSelector::getTypefaceAsset(
}
std
::
unique_ptr
<
TypefaceAsset
>
typeface_asset
(
new
TypefaceAsset
);
if
(
!
asset_store_
->
GetAsBuffer
(
asset_path
,
&
typeface_asset
->
data
))
{
if
(
!
directory_asset_bundle_
->
GetAsBuffer
(
asset_path
,
&
typeface_asset
->
data
))
{
typeface_cache_
.
insert
(
std
::
make_pair
(
asset_path
,
nullptr
));
return
nullptr
;
}
...
...
runtime/asset_font_selector.h
浏览文件 @
05458826
...
...
@@ -8,7 +8,7 @@
#include <unordered_map>
#include <vector>
#include "flutter/assets/
zip_asset_stor
e.h"
#include "flutter/assets/
directory_asset_bundl
e.h"
#include "flutter/sky/engine/platform/fonts/FontCacheKey.h"
#include "flutter/sky/engine/platform/fonts/FontSelector.h"
#include "flutter/sky/engine/platform/fonts/SimpleFontData.h"
...
...
@@ -16,14 +16,14 @@
namespace
blink
{
// A FontSelector implementation that resolves custon font names to assets
// loaded from the
FLX
.
// loaded from the
asset directory
.
class
AssetFontSelector
:
public
FontSelector
{
public:
struct
FlutterFontAttributes
;
~
AssetFontSelector
()
override
;
static
void
Install
(
fxl
::
RefPtr
<
ZipAssetStore
>
asset_stor
e
);
static
void
Install
(
fxl
::
RefPtr
<
DirectoryAssetBundle
>
directory_asset_bundl
e
);
PassRefPtr
<
FontData
>
getFontData
(
const
FontDescription
&
font_description
,
const
AtomicString
&
family_name
)
override
;
...
...
@@ -39,14 +39,15 @@ class AssetFontSelector : public FontSelector {
private:
struct
TypefaceAsset
;
explicit
AssetFontSelector
(
fxl
::
RefPtr
<
ZipAssetStore
>
asset_store
);
explicit
AssetFontSelector
(
fxl
::
RefPtr
<
DirectoryAssetBundle
>
directory_asset_bundle
);
void
parseFontManifest
();
sk_sp
<
SkTypeface
>
getTypefaceAsset
(
const
FontDescription
&
font_description
,
const
AtomicString
&
family_name
);
fxl
::
RefPtr
<
ZipAssetStore
>
asset_stor
e_
;
fxl
::
RefPtr
<
DirectoryAssetBundle
>
directory_asset_bundl
e_
;
HashMap
<
AtomicString
,
std
::
vector
<
FlutterFontAttributes
>>
font_family_map_
;
...
...
shell/common/engine.cc
浏览文件 @
05458826
...
...
@@ -578,8 +578,7 @@ void Engine::SetSemanticsEnabled(bool enabled) {
void
Engine
::
ConfigureAssetBundle
(
const
std
::
string
&
path
)
{
struct
stat
stat_result
=
{};
directory_asset_bundle_
.
reset
();
// TODO(abarth): We should reset asset_store_ as well, but that might break
// TODO(abarth): We should reset directory_asset_bundle_, but that might break
// custom font loading in hot reload.
if
(
::
stat
(
path
.
c_str
(),
&
stat_result
)
!=
0
)
{
...
...
@@ -590,7 +589,7 @@ void Engine::ConfigureAssetBundle(const std::string& path) {
std
::
string
flx_path
;
if
(
S_ISDIR
(
stat_result
.
st_mode
))
{
directory_asset_bundle_
=
std
::
make_unique
<
blink
::
DirectoryAssetBundle
>
(
path
);
fxl
::
MakeRefCounted
<
blink
::
DirectoryAssetBundle
>
(
path
);
flx_path
=
files
::
GetDirectoryName
(
path
)
+
"/app.flx"
;
}
else
if
(
S_ISREG
(
stat_result
.
st_mode
))
{
flx_path
=
path
;
...
...
@@ -622,11 +621,11 @@ void Engine::DidCreateMainIsolate(Dart_Isolate isolate) {
blink
::
TestFontSelector
::
Install
();
if
(
!
blink
::
Settings
::
Get
().
using_blink
)
blink
::
FontCollection
::
ForProcess
().
RegisterTestFonts
();
}
else
if
(
asset_stor
e_
)
{
blink
::
AssetFontSelector
::
Install
(
asset_stor
e_
);
}
else
if
(
directory_asset_bundl
e_
)
{
blink
::
AssetFontSelector
::
Install
(
directory_asset_bundl
e_
);
if
(
!
blink
::
Settings
::
Get
().
using_blink
)
{
blink
::
FontCollection
::
ForProcess
().
RegisterFontsFrom
AssetStor
e
(
asset_stor
e_
);
blink
::
FontCollection
::
ForProcess
().
RegisterFontsFrom
DirectoryAssetBundl
e
(
directory_asset_bundl
e_
);
}
}
}
...
...
shell/common/engine.h
浏览文件 @
05458826
...
...
@@ -120,7 +120,7 @@ class Engine : public blink::RuntimeDelegate {
bool
semantics_enabled_
=
false
;
// TODO(zarah): Remove usage of asset_store_ once app.flx is removed.
fxl
::
RefPtr
<
blink
::
ZipAssetStore
>
asset_store_
;
std
::
unique_p
tr
<
blink
::
DirectoryAssetBundle
>
directory_asset_bundle_
;
fxl
::
RefP
tr
<
blink
::
DirectoryAssetBundle
>
directory_asset_bundle_
;
// TODO(eseidel): This should move into an AnimatorStateMachine.
bool
activity_running_
;
bool
have_surface_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录