| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#pragma once |
| 18 |
|
| 19 |
#include "FrameInfo.h" |
| 20 |
#include "Properties.h" |
| 21 |
#include "Rect.h" |
| 22 |
#include "utils/RingBuffer.h" |
| 23 |
|
| 24 |
#include <utils/Timers.h> |
| 25 |
|
| 26 |
#include <memory> |
| 27 |
|
| 28 |
namespace android { |
| 29 |
namespace uirenderer { |
| 30 |
|
| 31 |
class IProfileRenderer; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
typedef RingBuffer<FrameInfo, 120> FrameInfoSource; |
| 39 |
|
| 40 |
class FrameInfoVisualizer { |
| 41 |
public: |
| 42 |
explicit FrameInfoVisualizer(FrameInfoSource& source, nsecs_t frameInterval); |
| 43 |
~FrameInfoVisualizer(); |
| 44 |
|
| 45 |
bool consumeProperties(); |
| 46 |
void setDensity(float density); |
| 47 |
|
| 48 |
void unionDirty(SkRect* dirty); |
| 49 |
void draw(IProfileRenderer& renderer); |
| 50 |
|
| 51 |
void dumpData(int fd); |
| 52 |
|
| 53 |
private: |
| 54 |
void createData(); |
| 55 |
void destroyData(); |
| 56 |
|
| 57 |
void initializeRects(const int baseline, const int width); |
| 58 |
void nextBarSegment(FrameInfoIndex start, FrameInfoIndex end); |
| 59 |
void drawGraph(IProfileRenderer& renderer); |
| 60 |
void drawThreshold(IProfileRenderer& renderer); |
| 61 |
|
| 62 |
inline float durationMS(size_t index, FrameInfoIndex start, FrameInfoIndex end) { |
| 63 |
float duration = mFrameSource[index].duration(start, end) * 0.000001f; |
| 64 |
|
| 65 |
duration = duration > 50.0f ? 50.0f : duration; |
| 66 |
return duration > 0.0f ? duration : 0.0f; |
| 67 |
} |
| 68 |
|
| 69 |
ProfileType mType = ProfileType::None; |
| 70 |
float mDensity = 0; |
| 71 |
|
| 72 |
FrameInfoSource& mFrameSource; |
| 73 |
|
| 74 |
nsecs_t mFrameInterval; |
| 75 |
int mVerticalUnit = 0; |
| 76 |
int mThresholdStroke = 0; |
| 77 |
|
| 78 |
int mNumFastRects; |
| 79 |
std::unique_ptr<float[]> mFastRects; |
| 80 |
int mNumJankyRects; |
| 81 |
std::unique_ptr<float[]> mJankyRects; |
| 82 |
|
| 83 |
bool mShowDirtyRegions = false; |
| 84 |
SkRect mDirtyRegion; |
| 85 |
bool mFlashToggle = false; |
| 86 |
nsecs_t mLastFrameLogged = 0; |
| 87 |
}; |
| 88 |
|
| 89 |
} |
| 90 |
} |