Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
4fa03ded
E
engine
项目概览
qq_34031325
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
4fa03ded
编写于
8月 08, 2016
作者:
A
Adam Barth
提交者:
GitHub
8月 08, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove //base dependencies from //sky/shell (#2888)
上级
11dbbd0b
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
103 addition
and
129 deletion
+103
-129
sky/shell/diagnostic/diagnostic_server.cc
sky/shell/diagnostic/diagnostic_server.cc
+14
-16
sky/shell/diagnostic/diagnostic_server.h
sky/shell/diagnostic/diagnostic_server.h
+0
-1
sky/shell/gpu/direct/ganesh_canvas.cc
sky/shell/gpu/direct/ganesh_canvas.cc
+6
-5
sky/shell/gpu/direct/rasterizer_direct.cc
sky/shell/gpu/direct/rasterizer_direct.cc
+2
-2
sky/shell/gpu/mojo/rasterizer_mojo.cc
sky/shell/gpu/mojo/rasterizer_mojo.cc
+1
-1
sky/shell/gpu/picture_serializer.cc
sky/shell/gpu/picture_serializer.cc
+2
-2
sky/shell/gpu/picture_serializer.h
sky/shell/gpu/picture_serializer.h
+3
-2
sky/shell/platform/android/flutter_main.cc
sky/shell/platform/android/flutter_main.cc
+7
-6
sky/shell/platform/ios/framework/Source/FlutterViewController.mm
...ll/platform/ios/framework/Source/FlutterViewController.mm
+1
-4
sky/shell/platform_view_service_protocol.cc
sky/shell/platform_view_service_protocol.cc
+24
-33
sky/shell/testing/platform_view_test.h
sky/shell/testing/platform_view_test.h
+2
-2
sky/shell/tracing_controller.cc
sky/shell/tracing_controller.cc
+28
-44
sky/shell/tracing_controller.h
sky/shell/tracing_controller.h
+13
-11
未找到文件。
sky/shell/diagnostic/diagnostic_server.cc
浏览文件 @
4fa03ded
...
...
@@ -4,12 +4,10 @@
#include "sky/shell/diagnostic/diagnostic_server.h"
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "dart/runtime/include/dart_api.h"
#include "dart/runtime/include/dart_native_api.h"
#include "flow/compositor_context.h"
#include "lib/ftl/logging.h"
#include "lib/tonic/dart_binding_macros.h"
#include "lib/tonic/dart_library_natives.h"
#include "lib/tonic/logging/dart_invoke.h"
...
...
@@ -38,17 +36,17 @@ namespace {
DartLibraryNatives
*
g_natives
=
nullptr
;
const
char
kDiagnosticServerScript
[]
=
"/diagnostic_server.dart"
;
const
expr
char
kDiagnosticServerScript
[]
=
"/diagnostic_server.dart"
;
Dart_NativeFunction
GetNativeFunction
(
Dart_Handle
name
,
int
argument_count
,
bool
*
auto_setup_scope
)
{
CHECK
(
g_natives
);
FTL_
CHECK
(
g_natives
);
return
g_natives
->
GetNativeFunction
(
name
,
argument_count
,
auto_setup_scope
);
}
const
uint8_t
*
GetSymbol
(
Dart_NativeFunction
native_function
)
{
CHECK
(
g_natives
);
FTL_
CHECK
(
g_natives
);
return
g_natives
->
GetSymbol
(
native_function
);
}
...
...
@@ -73,35 +71,35 @@ void DiagnosticServer::Start() {
EmbedderResources
resources
(
&
mojo
::
dart
::
__sky_embedder_diagnostic_server_resources_
[
0
]);
const
char
*
source
=
NULL
;
const
char
*
source
=
nullptr
;
int
source_length
=
resources
.
ResourceLookup
(
kDiagnosticServerScript
,
&
source
);
DCHECK
(
source_length
!=
EmbedderResources
::
kNoSuchInstance
);
FTL_
DCHECK
(
source_length
!=
EmbedderResources
::
kNoSuchInstance
);
Dart_Handle
diagnostic_library
=
Dart_LoadLibrary
(
Dart_NewStringFromCString
(
"dart:diagnostic_server"
),
Dart_Null
(),
Dart_NewStringFromUTF8
(
reinterpret_cast
<
const
uint8_t
*>
(
source
),
source_length
),
0
,
0
);
CHECK
(
!
LogIfError
(
diagnostic_library
));
CHECK
(
!
LogIfError
(
Dart_SetNativeResolver
(
diagnostic_library
,
GetNativeFunction
,
GetSymbol
)));
FTL_CHECK
(
!
LogIfError
(
diagnostic_library
));
FTL_CHECK
(
!
LogIfError
(
Dart_SetNativeResolver
(
diagnostic_library
,
GetNativeFunction
,
GetSymbol
)));
CHECK
(
!
LogIfError
(
Dart_LibraryImportLibrary
(
FTL_
CHECK
(
!
LogIfError
(
Dart_LibraryImportLibrary
(
Dart_RootLibrary
(),
diagnostic_library
,
Dart_Null
())));
CHECK
(
!
LogIfError
(
Dart_FinalizeLoading
(
false
)));
FTL_
CHECK
(
!
LogIfError
(
Dart_FinalizeLoading
(
false
)));
DartInvokeField
(
Dart_RootLibrary
(),
"diagnosticServerStart"
,
{});
}
void
DiagnosticServer
::
HandleSkiaPictureRequest
(
Dart_Handle
send_port
)
{
Dart_Port
port_id
;
CHECK
(
!
LogIfError
(
Dart_SendPortGetId
(
send_port
,
&
port_id
)));
FTL_
CHECK
(
!
LogIfError
(
Dart_SendPortGetId
(
send_port
,
&
port_id
)));
Shell
::
Shared
().
gpu_task_runner
()
->
PostTask
(
FROM_HERE
,
base
::
Bind
(
SkiaPictureTask
,
port_id
)
);
Shell
::
Shared
().
gpu_
ftl_
task_runner
()
->
PostTask
(
[
port_id
]()
{
SkiaPictureTask
(
port_id
);
}
);
}
void
DiagnosticServer
::
SkiaPictureTask
(
Dart_Port
port_id
)
{
...
...
sky/shell/diagnostic/diagnostic_server.h
浏览文件 @
4fa03ded
...
...
@@ -5,7 +5,6 @@
#ifndef SKY_ENGINE_CORE_DIAGNOSTIC_DIAGNOSTIC_SERVER_H_
#define SKY_ENGINE_CORE_DIAGNOSTIC_DIAGNOSTIC_SERVER_H_
#include "base/memory/weak_ptr.h"
#include "dart/runtime/include/dart_api.h"
namespace
sky
{
...
...
sky/shell/gpu/direct/ganesh_canvas.cc
浏览文件 @
4fa03ded
...
...
@@ -4,7 +4,8 @@
#include "sky/shell/gpu/direct/ganesh_canvas.h"
#include "base/logging.h"
#include "lib/ftl/arraysize.h"
#include "lib/ftl/logging.h"
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
namespace
sky
{
...
...
@@ -55,7 +56,7 @@ bool GaneshCanvas::SelectPixelConfig(GrPixelConfig* config) {
}
SkCanvas
*
GaneshCanvas
::
GetCanvas
(
int32_t
fbo
,
const
SkISize
&
size
)
{
DCHECK
(
IsValid
());
FTL_
DCHECK
(
IsValid
());
if
(
sk_surface_
&&
sk_surface_
->
width
()
==
size
.
width
()
&&
sk_surface_
->
height
()
==
size
.
height
())
...
...
@@ -64,16 +65,16 @@ SkCanvas* GaneshCanvas::GetCanvas(int32_t fbo, const SkISize& size) {
GrBackendRenderTargetDesc
desc
;
desc
.
fWidth
=
size
.
width
();
desc
.
fHeight
=
size
.
height
();
CHECK
(
SelectPixelConfig
(
&
desc
.
fConfig
));
FTL_
CHECK
(
SelectPixelConfig
(
&
desc
.
fConfig
));
desc
.
fStencilBits
=
8
;
desc
.
fOrigin
=
kBottomLeft_GrSurfaceOrigin
;
desc
.
fRenderTargetHandle
=
fbo
;
sk_sp
<
GrRenderTarget
>
target
(
gr_context_
->
textureProvider
()
->
wrapBackendRenderTarget
(
desc
));
DCHECK
(
target
);
FTL_
DCHECK
(
target
);
sk_surface_
=
SkSurface
::
MakeRenderTargetDirect
(
target
.
get
(),
nullptr
);
DCHECK
(
sk_surface_
);
FTL_
DCHECK
(
sk_surface_
);
return
sk_surface_
->
getCanvas
();
}
...
...
sky/shell/gpu/direct/rasterizer_direct.cc
浏览文件 @
4fa03ded
...
...
@@ -4,7 +4,7 @@
#include "sky/shell/gpu/direct/rasterizer_direct.h"
#include "
base/trace_event
/trace_event.h"
#include "
glue
/trace_event.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "sky/engine/wtf/PassRefPtr.h"
#include "sky/engine/wtf/RefPtr.h"
...
...
@@ -143,7 +143,7 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr,
const
auto
&
tracingController
=
Shell
::
Shared
().
tracing_controller
();
if
(
frameExceededThreshold
||
tracingController
.
picture_tracing_enabled
())
{
base
::
FilePath
path
=
tracingController
.
PictureTracingPathForCurrentTime
();
std
::
string
path
=
tracingController
.
PictureTracingPathForCurrentTime
();
SkPictureRecorder
recoder
;
recoder
.
beginRecording
(
SkRect
::
MakeWH
(
size
.
width
(),
size
.
height
()));
...
...
sky/shell/gpu/mojo/rasterizer_mojo.cc
浏览文件 @
4fa03ded
...
...
@@ -6,7 +6,7 @@
#include <MGL/mgl_echo.h>
#include "
base/trace_event
/trace_event.h"
#include "
glue
/trace_event.h"
#include "mojo/gpu/gl_texture.h"
#include "mojo/skia/ganesh_texture_surface.h"
#include "sky/shell/shell.h"
...
...
sky/shell/gpu/picture_serializer.cc
浏览文件 @
4fa03ded
...
...
@@ -27,8 +27,8 @@ SkData* PngPixelSerializer::onEncode(const SkPixmap& pixmap) {
SkImageEncoder
::
kDefaultQuality
);
}
void
SerializePicture
(
const
base
::
FilePath
&
file_name
,
SkPicture
*
picture
)
{
SkFILEWStream
stream
(
file_name
.
AsUTF8Unsafe
()
.
c_str
());
void
SerializePicture
(
const
std
::
string
&
path
,
SkPicture
*
picture
)
{
SkFILEWStream
stream
(
path
.
c_str
());
PngPixelSerializer
serializer
;
picture
->
serialize
(
&
stream
,
&
serializer
);
}
...
...
sky/shell/gpu/picture_serializer.h
浏览文件 @
4fa03ded
...
...
@@ -5,7 +5,8 @@
#ifndef SKY_SHELL_GPU_PICTURE_SERIALIZER_H_
#define SKY_SHELL_GPU_PICTURE_SERIALIZER_H_
#include "base/files/file_path.h"
#include <string>
#include "third_party/skia/include/core/SkPicture.h"
#include "third_party/skia/include/core/SkPixelSerializer.h"
...
...
@@ -17,7 +18,7 @@ class PngPixelSerializer : public SkPixelSerializer {
SkData
*
onEncode
(
const
SkPixmap
&
pixmap
)
override
;
};
void
SerializePicture
(
const
base
::
FilePath
&
file_name
,
SkPicture
*
);
void
SerializePicture
(
const
std
::
string
&
path
,
SkPicture
*
picture
);
}
// namespace sky
...
...
sky/shell/platform/android/flutter_main.cc
浏览文件 @
4fa03ded
...
...
@@ -50,9 +50,8 @@ void InitializeTracing() {
base
::
FilePath
path
;
bool
result
=
::
PathService
::
Get
(
base
::
DIR_ANDROID_APP_DATA
,
&
path
);
DCHECK
(
result
);
sky
::
shell
::
Shell
::
Shared
()
.
tracing_controller
()
.
set_traces_base_path
(
path
);
sky
::
shell
::
Shell
::
Shared
().
tracing_controller
().
set_traces_base_path
(
path
.
AsUTF8Unsafe
());
}
}
// namespace
...
...
@@ -84,9 +83,11 @@ static void Init(JNIEnv* env,
InitializeTracing
();
}
static
void
RecordStartTimestamp
(
JNIEnv
*
env
,
jclass
jcaller
,
jlong
initTimeMillis
)
{
int64_t
initTimeMicros
=
static_cast
<
int64_t
>
(
initTimeMillis
)
*
static_cast
<
int64_t
>
(
1000
);
static
void
RecordStartTimestamp
(
JNIEnv
*
env
,
jclass
jcaller
,
jlong
initTimeMillis
)
{
int64_t
initTimeMicros
=
static_cast
<
int64_t
>
(
initTimeMillis
)
*
static_cast
<
int64_t
>
(
1000
);
blink
::
engine_main_enter_ts
=
Dart_TimelineGetMicros
()
-
initTimeMicros
;
}
...
...
sky/shell/platform/ios/framework/Source/FlutterViewController.mm
浏览文件 @
4fa03ded
...
...
@@ -110,11 +110,8 @@ void FlutterInit(int argc, const char* argv[]) {
-
(
void
)
setupTracing
{
NSArray
*
paths
=
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
);
base
::
FilePath
tracesPath
=
base
::
FilePath
::
FromUTF8Unsafe
([
paths
.
firstObject
UTF8String
]);
sky
::
shell
::
Shell
::
Shared
().
tracing_controller
().
set_traces_base_path
(
tracesPath
);
[
paths
.
firstObject
UTF8String
]
);
}
-
(
void
)
setupNotificationCenterObservers
{
...
...
sky/shell/platform_view_service_protocol.cc
浏览文件 @
4fa03ded
...
...
@@ -4,16 +4,19 @@
#include "sky/shell/platform_view_service_protocol.h"
#include <string.h>
#include <string>
#include "base/strings/string_util.h"
#include "sky/shell/shell.h"
namespace
sky
{
namespace
shell
{
namespace
{
constexpr
char
kViewIdPrefx
[]
=
"_flutterView/"
;
constexpr
size_t
kViewIdPrefxLength
=
sizeof
(
kViewIdPrefx
)
-
1
;
static
intptr_t
KeyIndex
(
const
char
**
param_keys
,
intptr_t
num_params
,
const
char
*
key
)
{
...
...
@@ -39,8 +42,7 @@ static const char* ValueForKey(const char** param_keys,
return
param_values
[
index
];
}
static
bool
ErrorMissingParameter
(
const
char
**
json_object
,
const
char
*
name
)
{
static
bool
ErrorMissingParameter
(
const
char
**
json_object
,
const
char
*
name
)
{
const
intptr_t
kInvalidParams
=
-
32602
;
std
::
stringstream
response
;
response
<<
"{
\"
code
\"
:"
<<
std
::
to_string
(
kInvalidParams
)
<<
","
;
...
...
@@ -63,8 +65,7 @@ static bool ErrorBadParameter(const char** json_object,
return
false
;
}
static
bool
ErrorUnknownView
(
const
char
**
json_object
,
const
char
*
view_id
)
{
static
bool
ErrorUnknownView
(
const
char
**
json_object
,
const
char
*
view_id
)
{
const
intptr_t
kInvalidParams
=
-
32602
;
std
::
stringstream
response
;
response
<<
"{
\"
code
\"
:"
<<
std
::
to_string
(
kInvalidParams
)
<<
","
;
...
...
@@ -74,8 +75,7 @@ static bool ErrorUnknownView(const char** json_object,
return
false
;
}
static
bool
ErrorIsolateSpawn
(
const
char
**
json_object
,
const
char
*
view_id
)
{
static
bool
ErrorIsolateSpawn
(
const
char
**
json_object
,
const
char
*
view_id
)
{
const
intptr_t
kInvalidParams
=
-
32602
;
std
::
stringstream
response
;
response
<<
"{
\"
code
\"
:"
<<
std
::
to_string
(
kInvalidParams
)
<<
","
;
...
...
@@ -86,18 +86,15 @@ static bool ErrorIsolateSpawn(const char** json_object,
return
false
;
}
}
// namespace
}
// namespace
void
PlatformViewServiceProtocol
::
RegisterHook
(
bool
running_precompiled_code
)
{
if
(
running_precompiled_code
)
{
return
;
}
Dart_RegisterRootServiceRequestCallback
(
kRunInViewExtensionName
,
&
RunInView
,
Dart_RegisterRootServiceRequestCallback
(
kRunInViewExtensionName
,
&
RunInView
,
nullptr
);
Dart_RegisterRootServiceRequestCallback
(
kListViewsExtensionName
,
&
ListViews
,
Dart_RegisterRootServiceRequestCallback
(
kListViewsExtensionName
,
&
ListViews
,
nullptr
);
}
...
...
@@ -121,7 +118,7 @@ bool PlatformViewServiceProtocol::RunInView(const char* method,
if
(
view_id
==
NULL
)
{
return
ErrorMissingParameter
(
json_object
,
"viewId"
);
}
if
(
!
base
::
StartsWithASCII
(
view_id
,
"_flutterView/"
,
true
)
)
{
if
(
strncmp
(
view_id
,
kViewIdPrefx
,
kViewIdPrefxLength
)
!=
0
)
{
return
ErrorBadParameter
(
json_object
,
"viewId"
,
view_id
);
}
if
(
asset_directory
==
NULL
)
{
...
...
@@ -136,19 +133,15 @@ bool PlatformViewServiceProtocol::RunInView(const char* method,
// Convert the actual flutter view hex id into a number.
uintptr_t
view_id_as_num
=
std
::
stoull
((
view_id
+
strlen
(
"_flutterView/"
)
),
nullptr
,
16
);
std
::
stoull
((
view_id
+
kViewIdPrefxLength
),
nullptr
,
16
);
// Ask the Shell to run this script in the specified view. This will run a
// task on the UI thread before returning.
Shell
&
shell
=
Shell
::
Shared
();
bool
view_existed
=
false
;
Dart_Port
main_port
=
ILLEGAL_PORT
;
shell
.
RunInPlatformView
(
view_id_as_num
,
main_script
,
packages_file
,
asset_directory
,
&
view_existed
,
&
main_port
);
shell
.
RunInPlatformView
(
view_id_as_num
,
main_script
,
packages_file
,
asset_directory
,
&
view_existed
,
&
main_port
);
if
(
!
view_existed
)
{
// If the view did not exist this request has definitely failed.
...
...
@@ -159,12 +152,11 @@ bool PlatformViewServiceProtocol::RunInView(const char* method,
}
else
{
// The view existed and the isolate was created. Success.
std
::
stringstream
response
;
response
<<
"{
\"
type
\"
:
\"
Success
\"
,"
;
response
<<
"
\"
viewId
\"
:
\"
_flutterView/"
;
response
<<
"0x"
<<
std
::
hex
<<
view_id
;
response
<<
"
\"
,"
;
response
<<
"
\"
isolateId
\"
:
\"
isolates/"
<<
std
::
dec
<<
main_port
<<
"
\"
"
;
response
<<
"}"
;
response
<<
"{
\"
type
\"
:
\"
Success
\"
,"
<<
"
\"
viewId
\"
:
\"
"
<<
kViewIdPrefx
<<
"0x"
<<
std
::
hex
<<
view_id
<<
"
\"
,"
<<
"
\"
isolateId
\"
:
\"
isolates/"
<<
std
::
dec
<<
main_port
<<
"
\"
"
<<
"}"
;
*
json_object
=
strdup
(
response
.
str
().
c_str
());
return
true
;
}
...
...
@@ -201,11 +193,10 @@ bool PlatformViewServiceProtocol::ListViews(const char* method,
}
else
{
prefix_comma
=
true
;
}
response
<<
"{
\"
type
\"
:
\"
FlutterView
\"
,
\"
id
\"
:
\"
_flutterView/"
;
response
<<
"0x"
<<
std
::
hex
<<
view_id
;
response
<<
"
\"
,"
;
response
<<
"
\"
isolateId
\"
:
\"
isolates/"
<<
std
::
dec
<<
isolate_id
<<
"
\"
"
;
response
<<
"}"
;
response
<<
"{
\"
type
\"
:
\"
FlutterView
\"
,
\"
id
\"
:
\"
"
<<
kViewIdPrefx
<<
"0x"
<<
std
::
hex
<<
view_id
<<
"
\"
,"
<<
"
\"
isolateId
\"
:
\"
isolates/"
<<
std
::
dec
<<
isolate_id
<<
"
\"
"
<<
"}"
;
}
response
<<
"]}"
;
// Copy the response.
...
...
sky/shell/testing/platform_view_test.h
浏览文件 @
4fa03ded
...
...
@@ -5,7 +5,7 @@
#ifndef SKY_SHELL_TESTING_PLATFORM_VIEW_TEST_H_
#define SKY_SHELL_TESTING_PLATFORM_VIEW_TEST_H_
#include "
base
/macros.h"
#include "
lib/ftl
/macros.h"
#include "sky/shell/platform_view.h"
namespace
sky
{
...
...
@@ -32,7 +32,7 @@ class PlatformViewTest : public PlatformView {
private:
base
::
WeakPtrFactory
<
PlatformViewTest
>
weak_factory_
;
DISALLOW_COPY_AND_ASSIGN
(
PlatformViewTest
);
FTL_
DISALLOW_COPY_AND_ASSIGN
(
PlatformViewTest
);
};
}
// namespace shell
...
...
sky/shell/tracing_controller.cc
浏览文件 @
4fa03ded
...
...
@@ -4,9 +4,9 @@
#include "sky/shell/tracing_controller.h"
#include "base/threading/platform_thread.h"
#include "base/trace_event/trace_event.h"
#include "dart/runtime/include/dart_tools_api.h"
#include "lib/ftl/logging.h"
#include "sky/engine/core/script/dart_init.h"
#include "sky/engine/wtf/MakeUnique.h"
#include "sky/shell/shell.h"
...
...
@@ -18,11 +18,9 @@ namespace shell {
TracingController
::
TracingController
()
:
picture_tracing_enabled_
(
false
),
tracing_active_
(
false
)
{
auto
start
=
[
this
]()
{
StartTracing
();
};
auto
stop
=
[
this
]()
{
StopTracing
();
};
blink
::
SetEmbedderTracingCallbacks
(
WTF
::
MakeUnique
<
blink
::
EmbedderTracingCallbacks
>
(
start
,
stop
));
WTF
::
MakeUnique
<
blink
::
EmbedderTracingCallbacks
>
(
[
this
]()
{
StartTracing
();
},
[
this
]()
{
StopTracing
();
}));
}
TracingController
::~
TracingController
()
{
...
...
@@ -86,7 +84,7 @@ static void BaseTraceEventCallback(base::TraceTicks timestamp,
// discrete begin-end pairs. This greatly simplifies things. We dont have
// to track the second timestamp to pass to the Dart timeline event
// because we never see a Dart_Timeline_Event_Duration event.
DCHECK
(
false
)
<<
"Unknown trace event phase"
;
FTL_
DCHECK
(
false
)
<<
"Unknown trace event phase"
;
return
;
}
...
...
@@ -145,43 +143,30 @@ static void BaseTraceEventCallback(base::TraceTicks timestamp,
}
}
static
void
TraceThreadMetadataToObservatory
()
{
const
char
*
name
=
base
::
PlatformThread
::
GetName
();
if
(
name
==
nullptr
)
{
return
;
}
Dart_SetThreadName
(
name
);
}
static
void
AddTraceMetadata
()
{
Shell
::
Shared
().
gpu_task_runner
()
->
PostTask
(
FROM_HERE
,
base
::
Bind
(
&
TraceThreadMetadataToObservatory
)
);
Shell
::
Shared
().
ui_task_runner
()
->
PostTask
(
FROM_HERE
,
base
::
Bind
(
&
TraceThreadMetadataToObservatory
)
);
Shell
::
Shared
().
io_task_runner
()
->
PostTask
(
FROM_HERE
,
base
::
Bind
(
&
TraceThreadMetadataToObservatory
)
);
Shell
::
Shared
().
gpu_
ftl_
task_runner
()
->
PostTask
(
[]()
{
Dart_SetThreadName
(
"gpu_thread"
);
}
);
Shell
::
Shared
().
ui_
ftl_
task_runner
()
->
PostTask
(
[]()
{
Dart_SetThreadName
(
"ui_thread"
);
}
);
Shell
::
Shared
().
io_
ftl_
task_runner
()
->
PostTask
(
[]()
{
Dart_SetThreadName
(
"io_thread"
);
}
);
}
void
TracingController
::
StartTracing
()
{
if
(
tracing_active_
)
{
if
(
tracing_active_
)
return
;
}
tracing_active_
=
true
;
StartBaseTracing
();
AddTraceMetadata
();
}
void
TracingController
::
StartBaseTracing
()
{
namespace
TE
=
base
::
trace_event
;
auto
config
=
TE
::
TraceConfig
(
"*,disabled-by-default-skia"
,
TE
::
RECORD_CONTINUOUSLY
);
auto
config
=
base
::
trace_event
::
TraceConfig
(
"*,disabled-by-default-skia"
,
base
::
trace_event
::
RECORD_CONTINUOUSLY
);
auto
log
=
TE
::
TraceLog
::
GetInstance
();
auto
log
=
base
::
trace_event
::
TraceLog
::
GetInstance
();
log
->
SetEnabled
(
config
,
TE
::
TraceLog
::
MONITORING_MODE
);
log
->
SetEnabled
(
config
,
base
::
trace_event
::
TraceLog
::
MONITORING_MODE
);
log
->
SetEventCallbackEnabled
(
config
,
&
BaseTraceEventCallback
);
}
...
...
@@ -196,15 +181,14 @@ void TracingController::StopTracing() {
}
void
TracingController
::
StopBaseTracing
()
{
auto
log
=
base
::
trace_event
::
TraceLog
::
GetInstance
();
log
->
SetDisabled
();
log
->
SetEventCallbackDisabled
();
auto
trace_log
=
base
::
trace_event
::
TraceLog
::
GetInstance
();
trace_log
->
SetDisabled
();
trace_log
->
SetEventCallbackDisabled
();
}
base
::
FilePath
TracingController
::
TracePathWithExtension
(
base
::
FilePath
dir
,
std
::
string
extension
)
const
{
std
::
string
TracingController
::
TracePathWithExtension
(
const
std
::
string
&
directory
,
const
std
::
string
&
extension
)
const
{
base
::
Time
::
Exploded
exploded
;
base
::
Time
now
=
base
::
Time
::
Now
();
...
...
@@ -212,20 +196,20 @@ base::FilePath TracingController::TracePathWithExtension(
std
::
stringstream
stream
;
// Example: trace_2015-10-08_at_11.38.25.121_.extension
stream
<<
"trace_"
<<
exploded
.
year
<<
"-"
<<
exploded
.
month
<<
"-"
<<
exploded
.
day_of_month
<<
"_at_"
<<
exploded
.
hour
<<
"."
stream
<<
directory
<<
"/trace_"
<<
exploded
.
year
<<
"-"
<<
exploded
.
month
<<
"-"
<<
exploded
.
day_of_month
<<
"_at_"
<<
exploded
.
hour
<<
"."
<<
exploded
.
minute
<<
"."
<<
exploded
.
second
<<
"."
<<
exploded
.
millisecond
<<
"."
<<
extension
;
return
dir
.
Append
(
stream
.
str
()
);
return
stream
.
str
(
);
}
base
::
FilePath
TracingController
::
PictureTracingPathForCurrentTime
()
const
{
std
::
string
TracingController
::
PictureTracingPathForCurrentTime
()
const
{
return
PictureTracingPathForCurrentTime
(
traces_base_path_
);
}
base
::
FilePath
TracingController
::
PictureTracingPathForCurrentTime
(
base
::
FilePath
dir
)
const
{
return
TracePathWithExtension
(
dir
,
"skp"
);
std
::
string
TracingController
::
PictureTracingPathForCurrentTime
(
const
std
::
string
&
directory
)
const
{
return
TracePathWithExtension
(
dir
ectory
,
"skp"
);
}
}
// namespace shell
...
...
sky/shell/tracing_controller.h
浏览文件 @
4fa03ded
...
...
@@ -5,8 +5,9 @@
#ifndef __SKY_SHELL_TRACING_CONTROLLER__
#define __SKY_SHELL_TRACING_CONTROLLER__
#include "base/macros.h"
#include "base/files/file.h"
#include <string>
#include "lib/ftl/macros.h"
namespace
sky
{
namespace
shell
{
...
...
@@ -26,14 +27,14 @@ class TracingController {
// tracing controller should be used.
static
void
StartBaseTracing
();
base
::
FilePath
PictureTracingPathForCurrentTime
()
const
;
base
::
FilePath
PictureTracingPathForCurrentTime
(
base
::
FilePath
dir
)
const
;
std
::
string
PictureTracingPathForCurrentTime
()
const
;
std
::
string
PictureTracingPathForCurrentTime
(
const
std
::
string
&
directory
)
const
;
bool
tracing_active
()
const
{
return
tracing_active_
;
}
void
set_traces_base_path
(
const
base
::
FilePath
&
base_path
)
{
traces_base_path_
=
base_path
;
void
set_traces_base_path
(
std
::
string
base_path
)
{
traces_base_path_
=
std
::
move
(
base_path
)
;
}
void
set_picture_tracing_enabled
(
bool
enabled
)
{
...
...
@@ -43,17 +44,18 @@ class TracingController {
bool
picture_tracing_enabled
()
const
{
return
picture_tracing_enabled_
;
}
private:
base
::
FilePath
traces_base_path_
;
std
::
string
traces_base_path_
;
bool
picture_tracing_enabled_
;
bool
tracing_active_
;
void
StopBaseTracing
();
base
::
FilePath
TracePathWithExtension
(
base
::
FilePath
dir
,
std
::
string
extension
)
const
;
std
::
string
TracePathWithExtension
(
const
std
::
string
&
directory
,
const
std
::
string
&
extension
)
const
;
DISALLOW_COPY_AND_ASSIGN
(
TracingController
);
FTL_
DISALLOW_COPY_AND_ASSIGN
(
TracingController
);
};
}
// namespace shell
}
// namespace sky
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录