Yiwei Zhang | f40fb10 | 2019-02-27 21:05:06 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 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 | #include <inttypes.h> |
| 18 | |
| 19 | #include <android-base/stringprintf.h> |
| 20 | #include <binder/Parcel.h> |
| 21 | #include <graphicsenv/GpuStatsInfo.h> |
| 22 | |
| 23 | namespace android { |
| 24 | |
| 25 | using base::StringAppendF; |
| 26 | |
| 27 | status_t GpuStatsGlobalInfo::writeToParcel(Parcel* parcel) const { |
| 28 | status_t status; |
| 29 | if ((status = parcel->writeUtf8AsUtf16(driverPackageName)) != OK) return status; |
| 30 | if ((status = parcel->writeUtf8AsUtf16(driverVersionName)) != OK) return status; |
| 31 | if ((status = parcel->writeUint64(driverVersionCode)) != OK) return status; |
| 32 | if ((status = parcel->writeInt64(driverBuildTime)) != OK) return status; |
| 33 | if ((status = parcel->writeInt32(glLoadingCount)) != OK) return status; |
| 34 | if ((status = parcel->writeInt32(glLoadingFailureCount)) != OK) return status; |
| 35 | if ((status = parcel->writeInt32(vkLoadingCount)) != OK) return status; |
| 36 | if ((status = parcel->writeInt32(vkLoadingFailureCount)) != OK) return status; |
Yiwei Zhang | 794d295 | 2019-05-06 17:43:59 -0700 | [diff] [blame^] | 37 | if ((status = parcel->writeInt32(vulkanVersion)) != OK) return status; |
Yiwei Zhang | f40fb10 | 2019-02-27 21:05:06 -0800 | [diff] [blame] | 38 | return OK; |
| 39 | } |
| 40 | |
| 41 | status_t GpuStatsGlobalInfo::readFromParcel(const Parcel* parcel) { |
| 42 | status_t status; |
| 43 | if ((status = parcel->readUtf8FromUtf16(&driverPackageName)) != OK) return status; |
| 44 | if ((status = parcel->readUtf8FromUtf16(&driverVersionName)) != OK) return status; |
| 45 | if ((status = parcel->readUint64(&driverVersionCode)) != OK) return status; |
| 46 | if ((status = parcel->readInt64(&driverBuildTime)) != OK) return status; |
| 47 | if ((status = parcel->readInt32(&glLoadingCount)) != OK) return status; |
| 48 | if ((status = parcel->readInt32(&glLoadingFailureCount)) != OK) return status; |
| 49 | if ((status = parcel->readInt32(&vkLoadingCount)) != OK) return status; |
| 50 | if ((status = parcel->readInt32(&vkLoadingFailureCount)) != OK) return status; |
Yiwei Zhang | 794d295 | 2019-05-06 17:43:59 -0700 | [diff] [blame^] | 51 | if ((status = parcel->readInt32(&vulkanVersion)) != OK) return status; |
Yiwei Zhang | f40fb10 | 2019-02-27 21:05:06 -0800 | [diff] [blame] | 52 | return OK; |
| 53 | } |
| 54 | |
| 55 | std::string GpuStatsGlobalInfo::toString() const { |
| 56 | std::string result; |
| 57 | StringAppendF(&result, "driverPackageName = %s\n", driverPackageName.c_str()); |
| 58 | StringAppendF(&result, "driverVersionName = %s\n", driverVersionName.c_str()); |
| 59 | StringAppendF(&result, "driverVersionCode = %" PRIu64 "\n", driverVersionCode); |
| 60 | StringAppendF(&result, "driverBuildTime = %" PRId64 "\n", driverBuildTime); |
| 61 | StringAppendF(&result, "glLoadingCount = %d\n", glLoadingCount); |
| 62 | StringAppendF(&result, "glLoadingFailureCount = %d\n", glLoadingFailureCount); |
| 63 | StringAppendF(&result, "vkLoadingCount = %d\n", vkLoadingCount); |
| 64 | StringAppendF(&result, "vkLoadingFailureCount = %d\n", vkLoadingFailureCount); |
Yiwei Zhang | 794d295 | 2019-05-06 17:43:59 -0700 | [diff] [blame^] | 65 | StringAppendF(&result, "vulkanVersion = %d\n", vulkanVersion); |
Yiwei Zhang | f40fb10 | 2019-02-27 21:05:06 -0800 | [diff] [blame] | 66 | return result; |
| 67 | } |
| 68 | |
| 69 | status_t GpuStatsAppInfo::writeToParcel(Parcel* parcel) const { |
| 70 | status_t status; |
| 71 | if ((status = parcel->writeUtf8AsUtf16(appPackageName)) != OK) return status; |
| 72 | if ((status = parcel->writeUint64(driverVersionCode)) != OK) return status; |
| 73 | if ((status = parcel->writeInt64Vector(glDriverLoadingTime)) != OK) return status; |
| 74 | if ((status = parcel->writeInt64Vector(vkDriverLoadingTime)) != OK) return status; |
| 75 | return OK; |
| 76 | } |
| 77 | |
| 78 | status_t GpuStatsAppInfo::readFromParcel(const Parcel* parcel) { |
| 79 | status_t status; |
| 80 | if ((status = parcel->readUtf8FromUtf16(&appPackageName)) != OK) return status; |
| 81 | if ((status = parcel->readUint64(&driverVersionCode)) != OK) return status; |
| 82 | if ((status = parcel->readInt64Vector(&glDriverLoadingTime)) != OK) return status; |
| 83 | if ((status = parcel->readInt64Vector(&vkDriverLoadingTime)) != OK) return status; |
| 84 | return OK; |
| 85 | } |
| 86 | |
| 87 | std::string GpuStatsAppInfo::toString() const { |
| 88 | std::string result; |
| 89 | StringAppendF(&result, "appPackageName = %s\n", appPackageName.c_str()); |
| 90 | StringAppendF(&result, "driverVersionCode = %" PRIu64 "\n", driverVersionCode); |
| 91 | result.append("glDriverLoadingTime:"); |
| 92 | for (int32_t loadingTime : glDriverLoadingTime) { |
| 93 | StringAppendF(&result, " %d", loadingTime); |
| 94 | } |
| 95 | result.append("\n"); |
| 96 | result.append("vkDriverLoadingTime:"); |
| 97 | for (int32_t loadingTime : vkDriverLoadingTime) { |
| 98 | StringAppendF(&result, " %d", loadingTime); |
| 99 | } |
| 100 | result.append("\n"); |
| 101 | return result; |
| 102 | } |
| 103 | |
| 104 | } // namespace android |