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 #pragma once
18
19 #include <cstdint>
20 #include <optional>
21 #include <string>
22 #include <type_traits>
23
24 #include <math/mat4.h>
25 #include <ui/FloatRect.h>
26 #include <ui/LayerStack.h>
27 #include <ui/Rect.h>
28 #include <ui/Region.h>
29 #include <ui/StretchEffect.h>
30 #include <ui/Transform.h>
31
32 namespace android::compositionengine::impl {
33
34 void dumpVal(std::string& out, const char* name, bool);
35 void dumpVal(std::string& out, const char* name, const void*);
36 void dumpVal(std::string& out, const char* name, int);
37 void dumpVal(std::string& out, const char* name, float);
38 void dumpVal(std::string& out, const char* name, uint32_t);
39 void dumpHex(std::string& out, const char* name, uint64_t);
40 void dumpVal(std::string& out, const char* name, const char* value);
41 void dumpVal(std::string& out, const char* name, const std::string& value);
42
43 // For enums with named values
44 void dumpVal(std::string& out, const char* name, const char*, int);
45 void dumpVal(std::string& out, const char* name, const std::string&, int);
46
47 template <typename EnumType>
dumpVal(std::string & out,const char * name,const char * valueName,EnumType value)48 void dumpVal(std::string& out, const char* name, const char* valueName, EnumType value) {
49 dumpVal(out, name, valueName, static_cast<std::underlying_type_t<EnumType>>(value));
50 }
51
52 template <typename EnumType>
dumpVal(std::string & out,const char * name,const std::string & valueName,EnumType value)53 void dumpVal(std::string& out, const char* name, const std::string& valueName, EnumType value) {
54 dumpVal(out, name, valueName, static_cast<std::underlying_type_t<EnumType>>(value));
55 }
56
57 void dumpVal(std::string& out, const char* name, ui::LayerFilter);
58 void dumpVal(std::string& out, const char* name, ui::Size);
59
60 void dumpVal(std::string& out, const char* name, const FloatRect&);
61 void dumpVal(std::string& out, const char* name, const Rect&);
62 void dumpVal(std::string& out, const char* name, const Region&);
63 void dumpVal(std::string& out, const char* name, const ui::Transform&);
64 void dumpVal(std::string& out, const char* name, const mat4&);
65 void dumpVal(std::string& out, const char* name, const StretchEffect&);
66
67 template <typename T>
dumpVal(std::string & out,const char * name,std::optional<T> value)68 void dumpVal(std::string& out, const char* name, std::optional<T> value) {
69 if (value.has_value()) {
70 return dumpVal(out, name, *value);
71 } else {
72 return dumpVal(out, name, "nullopt");
73 }
74 }
75
76 } // namespace android::compositionengine::impl
77