Data types for marker API

Summary:
@public

Adds types for a marker API in Yoga.

This will allow us to register callbacks that Yoga can use to log performance data without hard-coding the backend system for that.

Reviewed By: SidharthGuglani

Differential Revision: D13118830

fbshipit-source-id: b42a42c609f0cf66212186f7f20ee572522d59e3
This commit is contained in:
David Aurelio 2018-11-24 16:23:54 -08:00 committed by Facebook Github Bot
parent c3dea894bd
commit f2894e58cf
2 changed files with 35 additions and 1 deletions

View File

@ -6,6 +6,7 @@
*
*/
#pragma once
#include "YGMarker.h"
#include "Yoga-internal.h"
#include "Yoga.h"
@ -14,11 +15,12 @@ struct YGConfig {
bool useWebDefaults = false;
bool useLegacyStretchBehaviour = false;
bool shouldDiffLayoutWithoutLegacyStretchBehaviour = false;
bool printTree = false;
float pointScaleFactor = 1.0f;
YGLogger logger;
YGCloneNodeFunc cloneNodeCallback = nullptr;
void* context = nullptr;
bool printTree = false;
YGMarkerCallbacks markerCallbacks = {nullptr, nullptr};
YGConfig(YGLogger logger);
};

View File

@ -0,0 +1,32 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include "YGMacros.h"
YG_EXTERN_C_BEGIN
typedef struct YGNode* YGNodeRef;
typedef YG_ENUM_BEGIN(YGMarkerType) {}
YG_ENUM_END(YGMarkerType);
typedef union {
int unused;
} YGMarkerData;
typedef struct {
// accepts marker type, a node ref, and marker data (depends on marker type)
// can return a handle or id that Yoga will pass to endMarker
void* (*startMarker)(YGMarkerType, YGNodeRef, YGMarkerData);
// accepts marker type, a node ref, marker data, and marker id as returned
// by startMarker
void (*endMarker)(YGMarkerType, YGNodeRef, YGMarkerData, void* id);
} YGMarkerCallbacks;
YG_EXTERN_C_END