| 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 | 174a2a0 | 2019-05-06 19:08:31 -0700 | [diff] [blame] | 38 | if ((status = parcel->writeInt32(cpuVulkanVersion)) != OK) return status; | 
|  | 39 | if ((status = parcel->writeInt32(glesVersion)) != OK) return status; | 
| Yiwei Zhang | 8e7c4b6 | 2019-05-08 15:57:59 -0700 | [diff] [blame] | 40 | if ((status = parcel->writeInt32(angleLoadingCount)) != OK) return status; | 
|  | 41 | if ((status = parcel->writeInt32(angleLoadingFailureCount)) != OK) return status; | 
| Yiwei Zhang | f40fb10 | 2019-02-27 21:05:06 -0800 | [diff] [blame] | 42 | return OK; | 
|  | 43 | } | 
|  | 44 |  | 
|  | 45 | status_t GpuStatsGlobalInfo::readFromParcel(const Parcel* parcel) { | 
|  | 46 | status_t status; | 
|  | 47 | if ((status = parcel->readUtf8FromUtf16(&driverPackageName)) != OK) return status; | 
|  | 48 | if ((status = parcel->readUtf8FromUtf16(&driverVersionName)) != OK) return status; | 
|  | 49 | if ((status = parcel->readUint64(&driverVersionCode)) != OK) return status; | 
|  | 50 | if ((status = parcel->readInt64(&driverBuildTime)) != OK) return status; | 
|  | 51 | if ((status = parcel->readInt32(&glLoadingCount)) != OK) return status; | 
|  | 52 | if ((status = parcel->readInt32(&glLoadingFailureCount)) != OK) return status; | 
|  | 53 | if ((status = parcel->readInt32(&vkLoadingCount)) != OK) return status; | 
|  | 54 | if ((status = parcel->readInt32(&vkLoadingFailureCount)) != OK) return status; | 
| Yiwei Zhang | 794d295 | 2019-05-06 17:43:59 -0700 | [diff] [blame] | 55 | if ((status = parcel->readInt32(&vulkanVersion)) != OK) return status; | 
| Yiwei Zhang | 174a2a0 | 2019-05-06 19:08:31 -0700 | [diff] [blame] | 56 | if ((status = parcel->readInt32(&cpuVulkanVersion)) != OK) return status; | 
|  | 57 | if ((status = parcel->readInt32(&glesVersion)) != OK) return status; | 
| Yiwei Zhang | 8e7c4b6 | 2019-05-08 15:57:59 -0700 | [diff] [blame] | 58 | if ((status = parcel->readInt32(&angleLoadingCount)) != OK) return status; | 
|  | 59 | if ((status = parcel->readInt32(&angleLoadingFailureCount)) != OK) return status; | 
| Yiwei Zhang | f40fb10 | 2019-02-27 21:05:06 -0800 | [diff] [blame] | 60 | return OK; | 
|  | 61 | } | 
|  | 62 |  | 
|  | 63 | std::string GpuStatsGlobalInfo::toString() const { | 
|  | 64 | std::string result; | 
|  | 65 | StringAppendF(&result, "driverPackageName = %s\n", driverPackageName.c_str()); | 
|  | 66 | StringAppendF(&result, "driverVersionName = %s\n", driverVersionName.c_str()); | 
|  | 67 | StringAppendF(&result, "driverVersionCode = %" PRIu64 "\n", driverVersionCode); | 
|  | 68 | StringAppendF(&result, "driverBuildTime = %" PRId64 "\n", driverBuildTime); | 
|  | 69 | StringAppendF(&result, "glLoadingCount = %d\n", glLoadingCount); | 
|  | 70 | StringAppendF(&result, "glLoadingFailureCount = %d\n", glLoadingFailureCount); | 
| Yiwei Zhang | 8e7c4b6 | 2019-05-08 15:57:59 -0700 | [diff] [blame] | 71 | StringAppendF(&result, "angleLoadingCount = %d\n", angleLoadingCount); | 
|  | 72 | StringAppendF(&result, "angleLoadingFailureCount = %d\n", angleLoadingFailureCount); | 
| Yiwei Zhang | f40fb10 | 2019-02-27 21:05:06 -0800 | [diff] [blame] | 73 | StringAppendF(&result, "vkLoadingCount = %d\n", vkLoadingCount); | 
|  | 74 | StringAppendF(&result, "vkLoadingFailureCount = %d\n", vkLoadingFailureCount); | 
| Yiwei Zhang | 794d295 | 2019-05-06 17:43:59 -0700 | [diff] [blame] | 75 | StringAppendF(&result, "vulkanVersion = %d\n", vulkanVersion); | 
| Yiwei Zhang | 174a2a0 | 2019-05-06 19:08:31 -0700 | [diff] [blame] | 76 | StringAppendF(&result, "cpuVulkanVersion = %d\n", cpuVulkanVersion); | 
|  | 77 | StringAppendF(&result, "glesVersion = %d\n", glesVersion); | 
| Yiwei Zhang | f40fb10 | 2019-02-27 21:05:06 -0800 | [diff] [blame] | 78 | return result; | 
|  | 79 | } | 
|  | 80 |  | 
|  | 81 | status_t GpuStatsAppInfo::writeToParcel(Parcel* parcel) const { | 
|  | 82 | status_t status; | 
|  | 83 | if ((status = parcel->writeUtf8AsUtf16(appPackageName)) != OK) return status; | 
|  | 84 | if ((status = parcel->writeUint64(driverVersionCode)) != OK) return status; | 
|  | 85 | if ((status = parcel->writeInt64Vector(glDriverLoadingTime)) != OK) return status; | 
|  | 86 | if ((status = parcel->writeInt64Vector(vkDriverLoadingTime)) != OK) return status; | 
| Yiwei Zhang | 8e7c4b6 | 2019-05-08 15:57:59 -0700 | [diff] [blame] | 87 | if ((status = parcel->writeInt64Vector(angleDriverLoadingTime)) != OK) return status; | 
| Yiwei Zhang | f40fb10 | 2019-02-27 21:05:06 -0800 | [diff] [blame] | 88 | return OK; | 
|  | 89 | } | 
|  | 90 |  | 
|  | 91 | status_t GpuStatsAppInfo::readFromParcel(const Parcel* parcel) { | 
|  | 92 | status_t status; | 
|  | 93 | if ((status = parcel->readUtf8FromUtf16(&appPackageName)) != OK) return status; | 
|  | 94 | if ((status = parcel->readUint64(&driverVersionCode)) != OK) return status; | 
|  | 95 | if ((status = parcel->readInt64Vector(&glDriverLoadingTime)) != OK) return status; | 
|  | 96 | if ((status = parcel->readInt64Vector(&vkDriverLoadingTime)) != OK) return status; | 
| Yiwei Zhang | 8e7c4b6 | 2019-05-08 15:57:59 -0700 | [diff] [blame] | 97 | if ((status = parcel->readInt64Vector(&angleDriverLoadingTime)) != OK) return status; | 
| Yiwei Zhang | f40fb10 | 2019-02-27 21:05:06 -0800 | [diff] [blame] | 98 | return OK; | 
|  | 99 | } | 
|  | 100 |  | 
|  | 101 | std::string GpuStatsAppInfo::toString() const { | 
|  | 102 | std::string result; | 
|  | 103 | StringAppendF(&result, "appPackageName = %s\n", appPackageName.c_str()); | 
|  | 104 | StringAppendF(&result, "driverVersionCode = %" PRIu64 "\n", driverVersionCode); | 
|  | 105 | result.append("glDriverLoadingTime:"); | 
|  | 106 | for (int32_t loadingTime : glDriverLoadingTime) { | 
|  | 107 | StringAppendF(&result, " %d", loadingTime); | 
|  | 108 | } | 
|  | 109 | result.append("\n"); | 
| Yiwei Zhang | 8e7c4b6 | 2019-05-08 15:57:59 -0700 | [diff] [blame] | 110 | result.append("angleDriverLoadingTime:"); | 
|  | 111 | for (int32_t loadingTime : angleDriverLoadingTime) { | 
|  | 112 | StringAppendF(&result, " %d", loadingTime); | 
|  | 113 | } | 
|  | 114 | result.append("\n"); | 
| Yiwei Zhang | f40fb10 | 2019-02-27 21:05:06 -0800 | [diff] [blame] | 115 | result.append("vkDriverLoadingTime:"); | 
|  | 116 | for (int32_t loadingTime : vkDriverLoadingTime) { | 
|  | 117 | StringAppendF(&result, " %d", loadingTime); | 
|  | 118 | } | 
|  | 119 | result.append("\n"); | 
|  | 120 | return result; | 
|  | 121 | } | 
|  | 122 |  | 
|  | 123 | } // namespace android |