John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 19 | #include "Properties.h" |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 20 | #include "Rect.h" |
| 21 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 22 | #include <utils/Timers.h> |
| 23 | |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 24 | namespace android { |
| 25 | namespace uirenderer { |
| 26 | |
| 27 | class OpenGLRenderer; |
| 28 | |
| 29 | class DrawProfiler { |
| 30 | public: |
| 31 | DrawProfiler(); |
| 32 | ~DrawProfiler(); |
| 33 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 34 | bool consumeProperties(); |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 35 | void setDensity(float density); |
| 36 | |
| 37 | void startFrame(nsecs_t recordDurationNanos = 0); |
| 38 | void markPlaybackStart(); |
| 39 | void markPlaybackEnd(); |
| 40 | void finishFrame(); |
| 41 | |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 42 | void unionDirty(SkRect* dirty); |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 43 | void draw(OpenGLRenderer* canvas); |
| 44 | |
| 45 | void dumpData(int fd); |
| 46 | |
| 47 | private: |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 48 | typedef struct { |
| 49 | float record; |
| 50 | float prepare; |
| 51 | float playback; |
| 52 | float swapBuffers; |
| 53 | } FrameTimingData; |
| 54 | |
| 55 | void createData(); |
| 56 | void destroyData(); |
| 57 | |
| 58 | void addRect(Rect& r, float data, float* shapeOutput); |
| 59 | void prepareShapes(const int baseline); |
| 60 | void drawGraph(OpenGLRenderer* canvas); |
| 61 | void drawCurrentFrame(OpenGLRenderer* canvas); |
| 62 | void drawThreshold(OpenGLRenderer* canvas); |
| 63 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 64 | ProfileType mType = ProfileType::None; |
| 65 | float mDensity = 0; |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 66 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 67 | FrameTimingData* mData = nullptr; |
| 68 | int mDataSize = 0; |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 69 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 70 | int mCurrentFrame = -1; |
| 71 | nsecs_t mPreviousTime = 0; |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 72 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 73 | int mVerticalUnit = 0; |
| 74 | int mHorizontalUnit = 0; |
| 75 | int mThresholdStroke = 0; |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 76 | |
| 77 | /* |
| 78 | * mRects represents an array of rect shapes, divided into NUM_ELEMENTS |
| 79 | * groups such that each group is drawn with the same paint. |
| 80 | * For example mRects[0] is the array of rect floats suitable for |
| 81 | * OpenGLRenderer:drawRects() that makes up all the FrameTimingData:record |
| 82 | * information. |
| 83 | */ |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 84 | float** mRects = nullptr; |
John Reck | 23d307c | 2014-10-27 12:38:48 -0700 | [diff] [blame] | 85 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 86 | bool mShowDirtyRegions = false; |
John Reck | 23d307c | 2014-10-27 12:38:48 -0700 | [diff] [blame] | 87 | SkRect mDirtyRegion; |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 88 | bool mFlashToggle = false; |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | } /* namespace uirenderer */ |
| 92 | } /* namespace android */ |
| 93 | |
| 94 | #endif /* DRAWPROFILER_H */ |