John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 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 <string> |
| 20 | |
| 21 | #include "JankTracker.h" |
| 22 | #include "utils/Macros.h" |
| 23 | |
| 24 | namespace android { |
Kweku Adams | 228b6d2 | 2018-04-12 13:09:04 -0700 | [diff] [blame] | 25 | namespace uirenderer { |
| 26 | namespace protos { |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 27 | class GraphicsStatsProto; |
| 28 | } |
| 29 | |
Stan Iliev | 637ba5e | 2019-08-16 13:43:08 -0400 | [diff] [blame] | 30 | typedef void (*DumpMemoryFn)(void* buffer, int bufferOffset, int bufferSize, int totalSize, |
| 31 | void* param1, void* param2); |
| 32 | |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 33 | /* |
| 34 | * The exported entry points used by GraphicsStatsService.java in f/b/services/core |
| 35 | * |
| 36 | * NOTE: Avoid exporting a requirement on the protobuf itself. Keep the usage |
| 37 | * of the generated protobuf classes internal to libhwui.so to minimize library |
| 38 | * bloat. |
| 39 | */ |
| 40 | class GraphicsStatsService { |
| 41 | public: |
| 42 | class Dump; |
| 43 | enum class DumpType { |
| 44 | Text, |
| 45 | Protobuf, |
Stan Iliev | 637ba5e | 2019-08-16 13:43:08 -0400 | [diff] [blame] | 46 | ProtobufStatsd, |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | ANDROID_API static void saveBuffer(const std::string& path, const std::string& package, |
Dianne Hackborn | 73453e4 | 2017-12-11 16:30:36 -0800 | [diff] [blame] | 50 | int64_t versionCode, int64_t startTime, int64_t endTime, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 51 | const ProfileData* data); |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 52 | |
| 53 | ANDROID_API static Dump* createDump(int outFd, DumpType type); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 54 | ANDROID_API static void addToDump(Dump* dump, const std::string& path, |
Dianne Hackborn | 73453e4 | 2017-12-11 16:30:36 -0800 | [diff] [blame] | 55 | const std::string& package, int64_t versionCode, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 56 | int64_t startTime, int64_t endTime, const ProfileData* data); |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 57 | ANDROID_API static void addToDump(Dump* dump, const std::string& path); |
| 58 | ANDROID_API static void finishDump(Dump* dump); |
Stan Iliev | 637ba5e | 2019-08-16 13:43:08 -0400 | [diff] [blame] | 59 | ANDROID_API static void finishDumpInMemory(Dump* dump, const DumpMemoryFn& reader, void* param1, |
| 60 | void* param2); |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 61 | |
| 62 | // Visible for testing |
Kweku Adams | 228b6d2 | 2018-04-12 13:09:04 -0700 | [diff] [blame] | 63 | static bool parseFromFile(const std::string& path, protos::GraphicsStatsProto* output); |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | } /* namespace uirenderer */ |
Kweku Adams | 228b6d2 | 2018-04-12 13:09:04 -0700 | [diff] [blame] | 67 | } /* namespace android */ |