Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
FML_TRACE_EVENT1("flutter", "AssetManager::GetAsMapping", "name",
asset_name.c_str());
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 {
FML_TRACE_EVENT1("flutter", "ZipAssetStore::GetAsMapping", "name",
asset_name.c_str());
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() {
FML_TRACE_EVENT0("flutter", "ZipAssetStore::BuildStatCache");
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 @@ -12,7 +12,7 @@ BackdropFilterLayer::BackdropFilterLayer(sk_sp<SkImageFilter> filter)
BackdropFilterLayer::~BackdropFilterLayer() = default;

void BackdropFilterLayer::Paint(PaintContext& context) const {
FML_TRACE_EVENT0("flutter", "BackdropFilterLayer::Paint");
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 {
FML_TRACE_EVENT0("flutter", "ClipPathLayer::Paint");
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 {
FML_TRACE_EVENT0("flutter", "ClipRectLayer::Paint");
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 {
FML_TRACE_EVENT0("flutter", "ClipRRectLayer::Paint");
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 @@ -12,7 +12,7 @@ ColorFilterLayer::ColorFilterLayer(SkColor color, SkBlendMode blend_mode)
ColorFilterLayer::~ColorFilterLayer() = default;

void ColorFilterLayer::Paint(PaintContext& context) const {
FML_TRACE_EVENT0("flutter", "ColorFilterLayer::Paint");
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) {
FML_TRACE_EVENT0("flutter", "ContainerLayer::Preroll");
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 @@ -26,7 +26,7 @@ void LayerTree::RecordBuildTime(fml::TimePoint start) {

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

void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
bool ignore_raster_cache) const {
FML_TRACE_EVENT0("flutter", "LayerTree::Paint");
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 @@ -99,7 +99,7 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
}

sk_sp<SkPicture> LayerTree::Flatten(const SkRect& bounds) {
FML_TRACE_EVENT0("flutter", "LayerTree::Flatten");
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 @@ -53,7 +53,7 @@ void OpacityLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
}

void OpacityLayer::Paint(PaintContext& context) const {
FML_TRACE_EVENT0("flutter", "OpacityLayer::Paint");
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;

FML_TRACE_EVENT0("flutter", "PerformanceOverlayLayer::Paint");
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 @@ -143,7 +143,7 @@ void PhysicalShapeLayer::UpdateScene(SceneUpdateContext& context) {
#endif // defined(OS_FUCHSIA)

void PhysicalShapeLayer::Paint(PaintContext& context) const {
FML_TRACE_EVENT0("flutter", "PhysicalShapeLayer::Paint");
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 @@ -37,7 +37,7 @@ void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
}

void PictureLayer::Paint(PaintContext& context) const {
FML_TRACE_EVENT0("flutter", "PictureLayer::Paint");
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 @@ -14,7 +14,7 @@ ShaderMaskLayer::ShaderMaskLayer(sk_sp<SkShader> shader,
ShaderMaskLayer::~ShaderMaskLayer() = default;

void ShaderMaskLayer::Paint(PaintContext& context) const {
FML_TRACE_EVENT0("flutter", "ShaderMaskLayer::Paint");
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 @@ -57,7 +57,7 @@ void TransformLayer::UpdateScene(SceneUpdateContext& context) {
#endif // defined(OS_FUCHSIA)

void TransformLayer::Paint(PaintContext& context) const {
FML_TRACE_EVENT0("flutter", "TransformLayer::Paint");
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) {
FML_TRACE_EVENT0("flutter", "RasterCachePopulate");
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) {
FML_TRACE_EVENT0("flutter", "SceneUpdateContext::ExecutePaintTasks");
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);
}
FML_TRACE_EVENT0("fml", "ConcurrentWorkerWake");
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) {
FML_TRACE_EVENT0("fml", "MessageLoop::FlushTasks");
TRACE_EVENT0("fml", "MessageLoop::FlushTasks");
std::vector<fml::closure> invocations;

// We are grabbing this lock here as a proxy to indicate
Expand Down
79 changes: 40 additions & 39 deletions fml/trace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,27 @@
#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)

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

#define TRACE_DURATION(args, ...)
#define TRACE_ASYNC_BEGIN(args, ...)
#define TRACE_ASYNC_END(args, ...)
#define TRACE_INSTANT(a, b, c)
#define TRACE_SCOPE_THREAD 0

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

#include <cstddef>
#include <cstdint>
#include <string>
Expand All @@ -35,6 +41,9 @@
#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 @@ -43,68 +52,60 @@

// This macro has the FML_ prefix so that it does not collide with the macros
// from trace/event.h on Fuchsia.
// TODO(DNO-448): This is disabled because Fuchsia counter id json parsing
// only handles ints whereas this can produce ints or strings.
//
// 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__);

#define FML_TRACE_EVENT(category_group, name, ...) \
TRACE_DURATION(category_group, name); \
::fml::tracing::TraceEvent((category_group), (name), __VA_ARGS__); \
__FML__AUTO_TRACE_END(name)

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

#define FML_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \
TRACE_DURATION(category_group, name, arg1_name, arg1_val); \
#define 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 FML_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, \
arg2_val) \
TRACE_DURATION(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 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 FML_TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id) \
TRACE_ASYNC_BEGIN(category_group, name, id); \
#define TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id) \
::fml::tracing::TraceEventAsyncBegin0(category_group, name, id);

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

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

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

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

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

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

#define FML_TRACE_FLOW_END(category, name, id) \
#define 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) {
FML_TRACE_EVENT0("flutter", "Scene::toImage");
TRACE_EVENT0("flutter", "Scene::toImage");

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