1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Direct2D: Fix ETW tracing build errors

This makes Direct2DMetrics and current frameId accessible to implementation subclasses.

It also replaces JUCE_WRITE_TRACE_LOG with JUCE_WRITE_TRACE_LOG_VA as intended in original implementation.

Co-authored-by: Matt Gonzalez <matt@echoaudio.com>
This commit is contained in:
Oli 2025-04-25 13:51:01 +01:00
parent 3ff8d4f640
commit 6972c4f0e3
4 changed files with 23 additions and 19 deletions

View file

@ -89,6 +89,16 @@ public:
return directWrite->getFonts(); return directWrite->getFonts();
} }
uint64_t getFrameId() const
{
return owner.getFrameId();
}
Direct2DMetrics::Ptr getMetrics() const
{
return owner.metrics;
}
bool fillSpriteBatch (const RectangleList<float>& list); bool fillSpriteBatch (const RectangleList<float>& list);
DirectWriteGlyphRun glyphRun; DirectWriteGlyphRun glyphRun;

View file

@ -176,13 +176,7 @@ private:
struct Direct2DScopedElapsedTime struct Direct2DScopedElapsedTime
{ {
Direct2DScopedElapsedTime (Direct2DMetrics::Ptr& metricsIn, size_t accumulatorIndexIn) Direct2DScopedElapsedTime (Direct2DMetrics::Ptr metricsIn, size_t accumulatorIndexIn)
: metrics (metricsIn.get()),
accumulatorIndex (accumulatorIndexIn)
{
}
Direct2DScopedElapsedTime (Direct2DMetrics* metricsIn, size_t accumulatorIndexIn)
: metrics (metricsIn), : metrics (metricsIn),
accumulatorIndex (accumulatorIndexIn) accumulatorIndex (accumulatorIndexIn)
{ {
@ -195,7 +189,7 @@ struct Direct2DScopedElapsedTime
} }
int64 startTicks = Time::getHighResolutionTicks(); int64 startTicks = Time::getHighResolutionTicks();
Direct2DMetrics* metrics; Direct2DMetrics::Ptr metrics;
size_t accumulatorIndex; size_t accumulatorIndex;
}; };

View file

@ -289,18 +289,18 @@ auto toVector (const RectangleList<Number>& list)
#define JUCE_TRACE_EVENT_INT_RECT_LIST(code, keyword, frameNumber, rect) \ #define JUCE_TRACE_EVENT_INT_RECT_LIST(code, keyword, frameNumber, rect) \
{ \ { \
const std::vector<INT32> vec = ::juce::etw::toVector (rect); \ const std::vector<INT32> vec = ::juce::etw::toVector (rect); \
JUCE_WRITE_TRACE_LOG (code, \ JUCE_WRITE_TRACE_LOG_VA (code, \
etw::softwareRendererKeyword, \ etw::softwareRendererKeyword, \
TraceLoggingValue ((UINT64) frameNumber, "frame"), \ TraceLoggingValue ((UINT64) frameNumber, "frame"), \
TraceLoggingInt32Array (vec.data(), (UINT16) vec.size(), "rect")); \ TraceLoggingInt32Array (vec.data(), (UINT16) vec.size(), "rect")); \
} }
#define JUCE_TRACE_EVENT_INT_RECT(code, keyword, rect) \ #define JUCE_TRACE_EVENT_INT_RECT(code, keyword, rect) \
{ \ { \
const std::vector<INT32> vec = ::juce::etw::toVector (rect); \ const std::vector<INT32> vec = ::juce::etw::toVector (rect); \
JUCE_WRITE_TRACE_LOG (code, \ JUCE_WRITE_TRACE_LOG_VA (code, \
etw::softwareRendererKeyword, \ etw::softwareRendererKeyword, \
TraceLoggingInt32Array (vec.data(), (UINT16) vec.size(), "rect")); \ TraceLoggingInt32Array (vec.data(), (UINT16) vec.size(), "rect")); \
} }
#else #else
#define JUCE_TRACE_EVENT_INT_RECT_LIST(code, keyword, frameNumber, rect) #define JUCE_TRACE_EVENT_INT_RECT_LIST(code, keyword, frameNumber, rect)

View file

@ -554,7 +554,7 @@ public:
{ {
deferredRepaints.add (deferredRepaint); deferredRepaints.add (deferredRepaint);
JUCE_TRACE_EVENT_INT_RECT (etw::repaint, etw::paintKeyword, snappedRectangle); JUCE_TRACE_EVENT_INT_RECT (etw::repaint, etw::paintKeyword, deferredRepaint);
} }
SavedState* startFrame() override SavedState* startFrame() override
@ -572,7 +572,7 @@ public:
dirtyRegionsInBackBuffer.add (deferredRepaints); dirtyRegionsInBackBuffer.add (deferredRepaints);
deferredRepaints.clear(); deferredRepaints.clear();
JUCE_TRACE_LOG_D2D_PAINT_CALL (etw::direct2dHwndPaintStart, owner.getFrameId()); JUCE_TRACE_LOG_D2D_PAINT_CALL (etw::direct2dHwndPaintStart, getFrameId());
return savedState; return savedState;
} }
@ -587,7 +587,7 @@ public:
void present() void present()
{ {
JUCE_D2DMETRICS_SCOPED_ELAPSED_TIME (owner.metrics, present1Duration); JUCE_D2DMETRICS_SCOPED_ELAPSED_TIME (getMetrics(), present1Duration);
if (swap.getBuffer() == nullptr || dirtyRegionsInBackBuffer.isEmpty() || ! swapEventReceived) if (swap.getBuffer() == nullptr || dirtyRegionsInBackBuffer.isEmpty() || ! swapEventReceived)
return; return;
@ -629,7 +629,7 @@ public:
// There's nothing waiting to be displayed in the backbuffer. // There's nothing waiting to be displayed in the backbuffer.
dirtyRegionsInBackBuffer.clear(); dirtyRegionsInBackBuffer.clear();
JUCE_TRACE_LOG_D2D_PAINT_CALL (etw::direct2dHwndPaintEnd, owner.getFrameId()); JUCE_TRACE_LOG_D2D_PAINT_CALL (etw::direct2dHwndPaintEnd, getFrameId());
} }
Image createSnapshot() const Image createSnapshot() const