Adrian Roos | 1e1a128 | 2017-11-01 19:05:31 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include <layerproto/LayerProtoHeader.h> |
| 20 | #include <utils/Errors.h> |
Yichi Chen | adc6961 | 2018-09-15 14:51:18 +0800 | [diff] [blame] | 21 | #include <utils/String8.h> |
Adrian Roos | 1e1a128 | 2017-11-01 19:05:31 +0100 | [diff] [blame] | 22 | |
Chia-I Wu | a3e7ddc | 2018-09-20 11:42:46 -0700 | [diff] [blame^] | 23 | #include <memory> |
Adrian Roos | 1e1a128 | 2017-11-01 19:05:31 +0100 | [diff] [blame] | 24 | #include <mutex> |
| 25 | |
| 26 | using namespace android::surfaceflinger; |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | /* |
| 31 | * SurfaceTracing records layer states during surface flinging. |
| 32 | */ |
| 33 | class SurfaceTracing { |
| 34 | public: |
| 35 | void enable(); |
| 36 | status_t disable(); |
Yichi Chen | adc6961 | 2018-09-15 14:51:18 +0800 | [diff] [blame] | 37 | bool isEnabled() const; |
Adrian Roos | 1e1a128 | 2017-11-01 19:05:31 +0100 | [diff] [blame] | 38 | |
| 39 | void traceLayers(const char* where, LayersProto); |
Yichi Chen | adc6961 | 2018-09-15 14:51:18 +0800 | [diff] [blame] | 40 | void dump(String8& result) const; |
Adrian Roos | 1e1a128 | 2017-11-01 19:05:31 +0100 | [diff] [blame] | 41 | |
| 42 | private: |
Vishnu Nair | 36b4cdb | 2017-11-17 10:27:05 -0800 | [diff] [blame] | 43 | static constexpr auto DEFAULT_FILENAME = "/data/misc/wmtrace/layers_trace.pb"; |
Adrian Roos | 1e1a128 | 2017-11-01 19:05:31 +0100 | [diff] [blame] | 44 | |
| 45 | status_t writeProtoFileLocked(); |
| 46 | |
| 47 | bool mEnabled = false; |
| 48 | std::string mOutputFileName = DEFAULT_FILENAME; |
Yichi Chen | adc6961 | 2018-09-15 14:51:18 +0800 | [diff] [blame] | 49 | mutable std::mutex mTraceMutex; |
Chia-I Wu | a3e7ddc | 2018-09-20 11:42:46 -0700 | [diff] [blame^] | 50 | std::unique_ptr<LayersTraceFileProto> mTrace; |
Adrian Roos | 1e1a128 | 2017-11-01 19:05:31 +0100 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | } // namespace android |