| Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [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 <cinttypes> | 
|  | 18 |  | 
|  | 19 | #include <android-base/stringprintf.h> | 
|  | 20 | #include <compositionengine/impl/DumpHelpers.h> | 
|  | 21 |  | 
|  | 22 | namespace android::compositionengine::impl { | 
|  | 23 |  | 
|  | 24 | using android::base::StringAppendF; | 
|  | 25 |  | 
|  | 26 | void dumpVal(std::string& out, const char* name, bool value) { | 
| Lloyd Pique | 207def9 | 2019-02-28 16:09:52 -0800 | [diff] [blame] | 27 | StringAppendF(&out, "%s=%s ", name, value ? "true" : "false"); | 
| Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 28 | } | 
|  | 29 |  | 
|  | 30 | void dumpVal(std::string& out, const char* name, const void* value) { | 
|  | 31 | StringAppendF(&out, "%s=%p ", name, value); | 
|  | 32 | } | 
|  | 33 |  | 
|  | 34 | void dumpVal(std::string& out, const char* name, int value) { | 
|  | 35 | StringAppendF(&out, "%s=%d ", name, value); | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | void dumpVal(std::string& out, const char* name, float value) { | 
|  | 39 | StringAppendF(&out, "%s=%f ", name, value); | 
|  | 40 | } | 
|  | 41 |  | 
|  | 42 | void dumpVal(std::string& out, const char* name, uint32_t value) { | 
|  | 43 | StringAppendF(&out, "%s=%u ", name, value); | 
|  | 44 | } | 
|  | 45 |  | 
|  | 46 | void dumpHex(std::string& out, const char* name, uint64_t value) { | 
|  | 47 | StringAppendF(&out, "%s=0x08%" PRIx64 " ", name, value); | 
|  | 48 | } | 
|  | 49 |  | 
|  | 50 | void dumpVal(std::string& out, const char* name, const char* value) { | 
|  | 51 | StringAppendF(&out, "%s=%s ", name, value); | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | void dumpVal(std::string& out, const char* name, const std::string& value) { | 
|  | 55 | dumpVal(out, name, value.c_str()); | 
|  | 56 | } | 
|  | 57 |  | 
|  | 58 | void dumpVal(std::string& out, const char* name, const char* valueName, int value) { | 
| Lloyd Pique | 207def9 | 2019-02-28 16:09:52 -0800 | [diff] [blame] | 59 | StringAppendF(&out, "%s=%s (%d) ", name, valueName, value); | 
| Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 60 | } | 
|  | 61 |  | 
|  | 62 | void dumpVal(std::string& out, const char* name, const std::string& valueName, int value) { | 
|  | 63 | dumpVal(out, name, valueName.c_str(), value); | 
|  | 64 | } | 
|  | 65 |  | 
| Dominik Laskowski | 29fa146 | 2021-04-27 15:51:50 -0700 | [diff] [blame] | 66 | void dumpVal(std::string& out, const char* name, ui::LayerFilter filter) { | 
|  | 67 | out.append(name); | 
|  | 68 | out.append("={"); | 
|  | 69 | dumpVal(out, "layerStack", filter.layerStack.id); | 
|  | 70 | dumpVal(out, "toInternalDisplay", filter.toInternalDisplay); | 
|  | 71 | out.push_back('}'); | 
|  | 72 | } | 
|  | 73 |  | 
|  | 74 | void dumpVal(std::string& out, const char* name, ui::Size size) { | 
|  | 75 | StringAppendF(&out, "%s=[%d %d] ", name, size.width, size.height); | 
|  | 76 | } | 
|  | 77 |  | 
| Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 78 | void dumpVal(std::string& out, const char* name, const FloatRect& rect) { | 
|  | 79 | StringAppendF(&out, "%s=[%f %f %f %f] ", name, rect.left, rect.top, rect.right, rect.bottom); | 
|  | 80 | } | 
|  | 81 |  | 
|  | 82 | void dumpVal(std::string& out, const char* name, const Rect& rect) { | 
|  | 83 | StringAppendF(&out, "%s=[%d %d %d %d] ", name, rect.left, rect.top, rect.right, rect.bottom); | 
|  | 84 | } | 
|  | 85 |  | 
|  | 86 | void dumpVal(std::string& out, const char* name, const Region& region) { | 
|  | 87 | region.dump(out, name, 0); | 
|  | 88 | } | 
|  | 89 |  | 
|  | 90 | void dumpVal(std::string& out, const char* name, const ui::Transform& transform) { | 
|  | 91 | transform.dump(out, name); | 
|  | 92 | } | 
|  | 93 |  | 
| Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 94 | void dumpVal(std::string& out, const char* name, const mat4& tr) { | 
|  | 95 | StringAppendF(&out, | 
|  | 96 | "%s=[" | 
|  | 97 | /* clang-format off */ | 
|  | 98 | "[%0.3f,%0.3f,%0.3f,%0.3f]" | 
|  | 99 | "[%0.3f,%0.3f,%0.3f,%0.3f]" | 
|  | 100 | "[%0.3f,%0.3f,%0.3f,%0.3f]" | 
| Dominik Laskowski | 0acc384 | 2022-04-07 11:23:42 -0700 | [diff] [blame] | 101 | "[%0.3f,%0.3f,%0.3f,%0.3f]] ", | 
| Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 102 | name, | 
|  | 103 | tr[0][0], tr[1][0], tr[2][0], tr[3][0], | 
|  | 104 | tr[0][1], tr[1][1], tr[2][1], tr[3][1], | 
|  | 105 | tr[0][2], tr[1][2], tr[2][2], tr[3][2], | 
|  | 106 | tr[0][3], tr[1][3], tr[2][3], tr[3][3] | 
|  | 107 | ); /* clang-format on */ | 
|  | 108 | } | 
|  | 109 |  | 
| John Reck | c00c669 | 2021-02-16 11:37:33 -0500 | [diff] [blame] | 110 | void dumpVal(std::string& out, const char* name, const StretchEffect& effect) { | 
| Dominik Laskowski | 0acc384 | 2022-04-07 11:23:42 -0700 | [diff] [blame] | 111 | StringAppendF(&out, "%s={width=%f, height=%f, vec=(%f, %f), max=(%f, %f)} ", name, effect.width, | 
|  | 112 | effect.height, effect.vectorX, effect.vectorY, effect.maxAmountX, | 
|  | 113 | effect.maxAmountY); | 
| John Reck | c00c669 | 2021-02-16 11:37:33 -0500 | [diff] [blame] | 114 | } | 
|  | 115 |  | 
| Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 116 | } // namespace android::compositionengine::impl |