blob: de64088bc11feab84e5acf91502d20b1b6d6e624 [file] [log] [blame]
John Reckfe5e7b72014-05-23 17:42:28 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef DRAWPROFILER_H
17#define DRAWPROFILER_H
18
19#include <utils/Timers.h>
20#include "Rect.h"
21
22namespace android {
23namespace uirenderer {
24
25class OpenGLRenderer;
26
27class DrawProfiler {
28public:
29 DrawProfiler();
30 ~DrawProfiler();
31
32 bool loadSystemProperties();
33 void setDensity(float density);
34
35 void startFrame(nsecs_t recordDurationNanos = 0);
36 void markPlaybackStart();
37 void markPlaybackEnd();
38 void finishFrame();
39
John Recke4267ea2014-06-03 15:53:15 -070040 void unionDirty(SkRect* dirty);
John Reckfe5e7b72014-05-23 17:42:28 -070041 void draw(OpenGLRenderer* canvas);
42
43 void dumpData(int fd);
44
45private:
46 enum ProfileType {
47 kNone,
48 kConsole,
49 kBars,
50 };
51
52 typedef struct {
53 float record;
54 float prepare;
55 float playback;
56 float swapBuffers;
57 } FrameTimingData;
58
59 void createData();
60 void destroyData();
61
62 void addRect(Rect& r, float data, float* shapeOutput);
63 void prepareShapes(const int baseline);
64 void drawGraph(OpenGLRenderer* canvas);
65 void drawCurrentFrame(OpenGLRenderer* canvas);
66 void drawThreshold(OpenGLRenderer* canvas);
67
68 ProfileType loadRequestedProfileType();
69
70 ProfileType mType;
71 float mDensity;
72
73 FrameTimingData* mData;
74 int mDataSize;
75
76 int mCurrentFrame;
77 nsecs_t mPreviousTime;
78
79 int mVerticalUnit;
80 int mHorizontalUnit;
81 int mThresholdStroke;
82
83 /*
84 * mRects represents an array of rect shapes, divided into NUM_ELEMENTS
85 * groups such that each group is drawn with the same paint.
86 * For example mRects[0] is the array of rect floats suitable for
87 * OpenGLRenderer:drawRects() that makes up all the FrameTimingData:record
88 * information.
89 */
90 float** mRects;
John Reck23d307c2014-10-27 12:38:48 -070091
92 bool mShowDirtyRegions;
93 SkRect mDirtyRegion;
94 bool mFlashToggle;
John Reckfe5e7b72014-05-23 17:42:28 -070095};
96
97} /* namespace uirenderer */
98} /* namespace android */
99
100#endif /* DRAWPROFILER_H */