Skip to content

Commit

Permalink
Align fuchsia and non-fuchsia tracing (flutter#9199)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnfield authored Jun 5, 2019
1 parent 5ea125e commit 7826548
Show file tree
Hide file tree
Showing 61 changed files with 207 additions and 227 deletions.
4 changes: 2 additions & 2 deletions assets/asset_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ std::unique_ptr<fml::Mapping> AssetManager::GetAsMapping(
if (asset_name.size() == 0) {
return nullptr;
}
TRACE_EVENT1("flutter", "AssetManager::GetAsMapping", "name",
asset_name.c_str());
FML_TRACE_EVENT1("flutter", "AssetManager::GetAsMapping", "name",
asset_name.c_str());
for (const auto& resolver : resolvers_) {
auto mapping = resolver->GetAsMapping(asset_name);
if (mapping != nullptr) {
Expand Down
6 changes: 3 additions & 3 deletions assets/zip_asset_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ bool ZipAssetStore::IsValid() const {
// |AssetResolver|
std::unique_ptr<fml::Mapping> ZipAssetStore::GetAsMapping(
const std::string& asset_name) const {
TRACE_EVENT1("flutter", "ZipAssetStore::GetAsMapping", "name",
asset_name.c_str());
FML_TRACE_EVENT1("flutter", "ZipAssetStore::GetAsMapping", "name",
asset_name.c_str());

auto found = stat_cache_.find(directory_ + "/" + asset_name);
if (found == stat_cache_.end()) {
Expand Down Expand Up @@ -84,7 +84,7 @@ std::unique_ptr<fml::Mapping> ZipAssetStore::GetAsMapping(
}

void ZipAssetStore::BuildStatCache() {
TRACE_EVENT0("flutter", "ZipAssetStore::BuildStatCache");
FML_TRACE_EVENT0("flutter", "ZipAssetStore::BuildStatCache");

auto unzipper = CreateUnzipper();

Expand Down
2 changes: 1 addition & 1 deletion flow/layers/backdrop_filter_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BackdropFilterLayer::BackdropFilterLayer() = default;
BackdropFilterLayer::~BackdropFilterLayer() = default;

void BackdropFilterLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "BackdropFilterLayer::Paint");
FML_TRACE_EVENT0("flutter", "BackdropFilterLayer::Paint");
FML_DCHECK(needs_painting());

Layer::AutoSaveLayer save = Layer::AutoSaveLayer::Create(
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/clip_path_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void ClipPathLayer::UpdateScene(SceneUpdateContext& context) {
#endif // defined(OS_FUCHSIA)

void ClipPathLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ClipPathLayer::Paint");
FML_TRACE_EVENT0("flutter", "ClipPathLayer::Paint");
FML_DCHECK(needs_painting());

SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/clip_rect_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void ClipRectLayer::UpdateScene(SceneUpdateContext& context) {
#endif // defined(OS_FUCHSIA)

void ClipRectLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ClipRectLayer::Paint");
FML_TRACE_EVENT0("flutter", "ClipRectLayer::Paint");
FML_DCHECK(needs_painting());

SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/clip_rrect_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void ClipRRectLayer::UpdateScene(SceneUpdateContext& context) {
#endif // defined(OS_FUCHSIA)

void ClipRRectLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ClipRRectLayer::Paint");
FML_TRACE_EVENT0("flutter", "ClipRRectLayer::Paint");
FML_DCHECK(needs_painting());

SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/color_filter_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ColorFilterLayer::ColorFilterLayer() = default;
ColorFilterLayer::~ColorFilterLayer() = default;

void ColorFilterLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ColorFilterLayer::Paint");
FML_TRACE_EVENT0("flutter", "ColorFilterLayer::Paint");
FML_DCHECK(needs_painting());

SkPaint paint;
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/container_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void ContainerLayer::Add(std::shared_ptr<Layer> layer) {
}

void ContainerLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
TRACE_EVENT0("flutter", "ContainerLayer::Preroll");
FML_TRACE_EVENT0("flutter", "ContainerLayer::Preroll");

SkRect child_paint_bounds = SkRect::MakeEmpty();
PrerollChildren(context, matrix, &child_paint_bounds);
Expand Down
8 changes: 4 additions & 4 deletions flow/layers/layer_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LayerTree::~LayerTree() = default;

void LayerTree::Preroll(CompositorContext::ScopedFrame& frame,
bool ignore_raster_cache) {
TRACE_EVENT0("flutter", "LayerTree::Preroll");
FML_TRACE_EVENT0("flutter", "LayerTree::Preroll");
SkColorSpace* color_space =
frame.canvas() ? frame.canvas()->imageInfo().colorSpace() : nullptr;
frame.context().raster_cache().SetCheckboardCacheImages(
Expand All @@ -43,7 +43,7 @@ void LayerTree::Preroll(CompositorContext::ScopedFrame& frame,
#if defined(OS_FUCHSIA)
void LayerTree::UpdateScene(SceneUpdateContext& context,
scenic::ContainerNode& container) {
TRACE_EVENT0("flutter", "LayerTree::UpdateScene");
FML_TRACE_EVENT0("flutter", "LayerTree::UpdateScene");
const auto& metrics = context.metrics();
SceneUpdateContext::Transform transform(context, // context
1.0f / metrics->scale_x, // X
Expand All @@ -67,7 +67,7 @@ void LayerTree::UpdateScene(SceneUpdateContext& context,

void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
bool ignore_raster_cache) const {
TRACE_EVENT0("flutter", "LayerTree::Paint");
FML_TRACE_EVENT0("flutter", "LayerTree::Paint");
SkISize canvas_size = frame.canvas()->getBaseLayerSize();
SkNWayCanvas internal_nodes_canvas(canvas_size.width(), canvas_size.height());
internal_nodes_canvas.addCanvas(frame.canvas());
Expand All @@ -94,7 +94,7 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
}

sk_sp<SkPicture> LayerTree::Flatten(const SkRect& bounds) {
TRACE_EVENT0("flutter", "LayerTree::Flatten");
FML_TRACE_EVENT0("flutter", "LayerTree::Flatten");

SkPictureRecorder recorder;
auto* canvas = recorder.beginRecording(bounds);
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/opacity_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
}

void OpacityLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "OpacityLayer::Paint");
FML_TRACE_EVENT0("flutter", "OpacityLayer::Paint");
FML_DCHECK(needs_painting());

SkPaint paint;
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/performance_overlay_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void PerformanceOverlayLayer::Paint(PaintContext& context) const {
if (!options_)
return;

TRACE_EVENT0("flutter", "PerformanceOverlayLayer::Paint");
FML_TRACE_EVENT0("flutter", "PerformanceOverlayLayer::Paint");
SkScalar x = paint_bounds().x() + padding;
SkScalar y = paint_bounds().y() + padding;
SkScalar width = paint_bounds().width() - (padding * 2);
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/physical_shape_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void PhysicalShapeLayer::UpdateScene(SceneUpdateContext& context) {
#endif // defined(OS_FUCHSIA)

void PhysicalShapeLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "PhysicalShapeLayer::Paint");
FML_TRACE_EVENT0("flutter", "PhysicalShapeLayer::Paint");
FML_DCHECK(needs_painting());

if (elevation_ != 0) {
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/picture_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
}

void PictureLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "PictureLayer::Paint");
FML_TRACE_EVENT0("flutter", "PictureLayer::Paint");
FML_DCHECK(picture_.get());
FML_DCHECK(needs_painting());

Expand Down
2 changes: 1 addition & 1 deletion flow/layers/shader_mask_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ShaderMaskLayer::ShaderMaskLayer() = default;
ShaderMaskLayer::~ShaderMaskLayer() = default;

void ShaderMaskLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ShaderMaskLayer::Paint");
FML_TRACE_EVENT0("flutter", "ShaderMaskLayer::Paint");
FML_DCHECK(needs_painting());

Layer::AutoSaveLayer save =
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/transform_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void TransformLayer::UpdateScene(SceneUpdateContext& context) {
#endif // defined(OS_FUCHSIA)

void TransformLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "TransformLayer::Paint");
FML_TRACE_EVENT0("flutter", "TransformLayer::Paint");
FML_DCHECK(needs_painting());

SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
Expand Down
2 changes: 1 addition & 1 deletion flow/raster_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static RasterCacheResult Rasterize(
bool checkerboard,
const SkRect& logical_rect,
std::function<void(SkCanvas*)> draw_function) {
TRACE_EVENT0("flutter", "RasterCachePopulate");
FML_TRACE_EVENT0("flutter", "RasterCachePopulate");
SkIRect cache_rect = RasterCache::GetDeviceBounds(logical_rect, ctm);

const SkImageInfo image_info = SkImageInfo::MakeN32Premul(
Expand Down
2 changes: 1 addition & 1 deletion flow/scene_update_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ scenic::Image* SceneUpdateContext::GenerateImageIfNeeded(
std::vector<
std::unique_ptr<flutter::SceneUpdateContext::SurfaceProducerSurface>>
SceneUpdateContext::ExecutePaintTasks(CompositorContext::ScopedFrame& frame) {
TRACE_EVENT0("flutter", "SceneUpdateContext::ExecutePaintTasks");
FML_TRACE_EVENT0("flutter", "SceneUpdateContext::ExecutePaintTasks");
std::vector<std::unique_ptr<SurfaceProducerSurface>> surfaces_to_submit;
for (auto& task : paint_tasks_) {
FML_DCHECK(task.surface);
Expand Down
2 changes: 1 addition & 1 deletion fml/concurrent_message_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void ConcurrentMessageLoop::WorkerMain() {
if (!shutdown_) {
wait_condition_.wait(lock);
}
TRACE_EVENT0("fml", "ConcurrentWorkerWake");
FML_TRACE_EVENT0("fml", "ConcurrentWorkerWake");
RunSingleExpiredTaskNow();
}

Expand Down
2 changes: 1 addition & 1 deletion fml/message_loop_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void MessageLoopImpl::RegisterTask(fml::closure task,
}

void MessageLoopImpl::FlushTasks(FlushType type) {
TRACE_EVENT0("fml", "MessageLoop::FlushTasks");
FML_TRACE_EVENT0("fml", "MessageLoop::FlushTasks");
std::vector<fml::closure> invocations;

// We are grabbing this lock here as a proxy to indicate
Expand Down
57 changes: 17 additions & 40 deletions fml/trace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,8 @@
#if defined(OS_FUCHSIA)
#if !defined(FUCHSIA_SDK)

// Forward to the system tracing mechanism on Fuchsia.

#include <trace/event.h>

// TODO(DNO-448): This is disabled because the Fuchsia counter id json parsing
// only handles ints whereas this can produce ints or strings.
#define FML_TRACE_COUNTER(a, b, c, args...)
#define FML_TRACE_EVENT(a, b, args...) TRACE_DURATION(a, b)

#define TRACE_EVENT0(a, b) TRACE_DURATION(a, b)
#define TRACE_EVENT1(a, b, c, d) TRACE_DURATION(a, b, c, d)
#define TRACE_EVENT2(a, b, c, d, e, f) TRACE_DURATION(a, b, c, d, e, f)
#define TRACE_EVENT_ASYNC_BEGIN0(a, b, c) TRACE_ASYNC_BEGIN(a, b, c)
#define TRACE_EVENT_ASYNC_END0(a, b, c) TRACE_ASYNC_END(a, b, c)
#define TRACE_EVENT_ASYNC_BEGIN1(a, b, c, d, e) TRACE_ASYNC_BEGIN(a, b, c, d, e)
#define TRACE_EVENT_ASYNC_END1(a, b, c, d, e) TRACE_ASYNC_END(a, b, c, d, e)
#define TRACE_EVENT_INSTANT0(a, b) TRACE_INSTANT(a, b, TRACE_SCOPE_THREAD)

#endif // !defined(FUCHSIA_SDK)
#endif // defined(OS_FUCHSIA)

Expand All @@ -41,9 +25,6 @@
#include "flutter/fml/time/time_point.h"
#include "third_party/dart/runtime/include/dart_tools_api.h"

#if !defined(OS_FUCHSIA) || defined(FUCHSIA_SDK)
#ifndef TRACE_EVENT_HIDE_MACROS

#define __FML__TOKEN_CAT__(x, y) x##y
#define __FML__TOKEN_CAT__2(x, y) __FML__TOKEN_CAT__(x, y)
#define __FML__AUTO_TRACE_END(name) \
Expand All @@ -52,8 +33,6 @@

// This macro has the FML_ prefix so that it does not collide with the macros
// from trace/event.h on Fuchsia.
//
// TODO(chinmaygarde): All macros here should have the FML prefix.
#define FML_TRACE_COUNTER(category_group, name, counter_id, arg1, ...) \
::fml::tracing::TraceCounter((category_group), (name), (counter_id), (arg1), \
__VA_ARGS__);
Expand All @@ -62,50 +41,48 @@
::fml::tracing::TraceEvent((category_group), (name), __VA_ARGS__); \
__FML__AUTO_TRACE_END(name)

#define TRACE_EVENT0(category_group, name) \
#define FML_TRACE_EVENT0(category_group, name) \
::fml::tracing::TraceEvent0(category_group, name); \
__FML__AUTO_TRACE_END(name)

#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \
#define FML_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \
::fml::tracing::TraceEvent1(category_group, name, arg1_name, arg1_val); \
__FML__AUTO_TRACE_END(name)

#define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, \
arg2_val) \
::fml::tracing::TraceEvent2(category_group, name, arg1_name, arg1_val, \
arg2_name, arg2_val); \
#define FML_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, \
arg2_val) \
::fml::tracing::TraceEvent2(category_group, name, arg1_name, arg1_val, \
arg2_name, arg2_val); \
__FML__AUTO_TRACE_END(name)

#define TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id) \
#define FML_TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id) \
::fml::tracing::TraceEventAsyncBegin0(category_group, name, id);

#define TRACE_EVENT_ASYNC_END0(category_group, name, id) \
#define FML_TRACE_EVENT_ASYNC_END0(category_group, name, id) \
::fml::tracing::TraceEventAsyncEnd0(category_group, name, id);

#define TRACE_EVENT_ASYNC_BEGIN1(category_group, name, id, arg1_name, \
arg1_val) \
#define FML_TRACE_EVENT_ASYNC_BEGIN1(category_group, name, id, arg1_name, \
arg1_val) \
::fml::tracing::TraceEventAsyncBegin1(category_group, name, id, arg1_name, \
arg1_val);

#define TRACE_EVENT_ASYNC_END1(category_group, name, id, arg1_name, arg1_val) \
::fml::tracing::TraceEventAsyncEnd1(category_group, name, id, arg1_name, \
#define FML_TRACE_EVENT_ASYNC_END1(category_group, name, id, arg1_name, \
arg1_val) \
::fml::tracing::TraceEventAsyncEnd1(category_group, name, id, arg1_name, \
arg1_val);

#define TRACE_EVENT_INSTANT0(category_group, name) \
#define FML_TRACE_EVENT_INSTANT0(category_group, name) \
::fml::tracing::TraceEventInstant0(category_group, name);

#define TRACE_FLOW_BEGIN(category, name, id) \
#define FML_TRACE_FLOW_BEGIN(category, name, id) \
::fml::tracing::TraceEventFlowBegin0(category, name, id);

#define TRACE_FLOW_STEP(category, name, id) \
#define FML_TRACE_FLOW_STEP(category, name, id) \
::fml::tracing::TraceEventFlowStep0(category, name, id);

#define TRACE_FLOW_END(category, name, id) \
#define FML_TRACE_FLOW_END(category, name, id) \
::fml::tracing::TraceEventFlowEnd0(category, name, id);

#endif // TRACE_EVENT_HIDE_MACROS
#endif // !defined(OS_FUCHSIA) || defined(FUCHSIA_SDK)

namespace fml {
namespace tracing {

Expand Down
2 changes: 1 addition & 1 deletion lib/ui/compositing/scene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void Scene::dispose() {
Dart_Handle Scene::toImage(uint32_t width,
uint32_t height,
Dart_Handle raw_image_callback) {
TRACE_EVENT0("flutter", "Scene::toImage");
FML_TRACE_EVENT0("flutter", "Scene::toImage");

if (!m_layerTree) {
return tonic::ToDart("Scene did not contain a layer tree.");
Expand Down
Loading

0 comments on commit 7826548

Please sign in to comment.