Skip to content
Snippets Groups Projects
Commit 1301752d authored by Roman Stratiienko's avatar Roman Stratiienko
Browse files

drm_hwcomposer: Restore HWC2 API logging functionality


Process and log __PRETTY_FUNCTION__ compiler string.

Prints HWC2 API logs as follows:

hwc2-device: Display #0 Layer: #0 hook: android::HwcLayer::SetLayerBuffer
hwc2-device: Display #0 hook: android::HwcDisplay::ValidateDisplay
hwc2-device: Display #0 hook: android::HwcDisplay::GetChangedCompositionTypes
hwc2-device: Display #0 hook: android::HwcDisplay::GetChangedCompositionTypes
hwc2-device: Display #0 hook: android::HwcDisplay::GetDisplayRequests
hwc2-device: Display #0 hook: android::HwcDisplay::GetDisplayRequests
hwc2-device: Display #0 hook: android::HwcDisplay::AcceptDisplayChanges
hwc2-device: Display #0 hook: android::HwcDisplay::PresentDisplay
hwc2-device: Display #0 hook: android::HwcDisplay::GetReleaseFences
hwc2-device: Display #0 hook: android::HwcDisplay::GetReleaseFences

Signed-off-by: default avatarRoman Stratiienko <roman.o.stratiienko@globallogic.com>
parent 780f7dac
No related branches found
No related tags found
No related merge requests found
......@@ -14,14 +14,35 @@
* limitations under the License.
*/
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
// #define LOG_NDEBUG 0 // Uncomment to see HWC2 API calls in logcat
#define LOG_TAG "hwc2-device"
#include <cinttypes>
#include "DrmHwcTwo.h"
#include "backend/Backend.h"
#include "utils/log.h"
namespace android {
/* Converts long __PRETTY_FUNCTION__ result, e.g.:
* "int32_t android::LayerHook(hwc2_device_t *, hwc2_display_t, hwc2_layer_t,"
* "Args...) [HookType = HWC2::Error (android::HwcLayer::*)(const native_handle"
* "*,int), func = &android::HwcLayer::SetLayerBuffer, Args = <const
* "native_handle, int>"
* to the short "android::HwcLayer::SetLayerBuffer" for better logs readability
*/
static std::string GetFuncName(const char *pretty_function) {
std::string str(pretty_function);
const char *start = "func = &";
size_t p1 = str.find(start);
p1 += strlen(start);
size_t p2 = str.find(',', p1);
return str.substr(p1, p2 - p1);
}
struct Drmhwc2Device : hwc2_device {
DrmHwcTwo drmhwctwo;
};
......@@ -40,6 +61,7 @@ static hwc2_function_pointer_t ToHook(T function) {
template <typename T, typename HookType, HookType func, typename... Args>
static T DeviceHook(hwc2_device_t *dev, Args... args) {
ALOGV("Device hook: %s", GetFuncName(__PRETTY_FUNCTION__).c_str());
DrmHwcTwo *hwc = ToDrmHwcTwo(dev);
return static_cast<T>(((*hwc).*func)(std::forward<Args>(args)...));
}
......@@ -48,6 +70,8 @@ template <typename HookType, HookType func, typename... Args>
static int32_t DisplayHook(hwc2_device_t *dev, hwc2_display_t display_handle,
Args... args) {
HwcDisplay *display = DrmHwcTwo::GetDisplay(ToDrmHwcTwo(dev), display_handle);
ALOGV("Display #%" PRIu64 " hook: %s", display_handle,
GetFuncName(__PRETTY_FUNCTION__).c_str());
if (!display)
return static_cast<int32_t>(HWC2::Error::BadDisplay);
......@@ -58,6 +82,8 @@ template <typename HookType, HookType func, typename... Args>
static int32_t LayerHook(hwc2_device_t *dev, hwc2_display_t display_handle,
hwc2_layer_t layer_handle, Args... args) {
HwcDisplay *display = DrmHwcTwo::GetDisplay(ToDrmHwcTwo(dev), display_handle);
ALOGV("Display #%" PRIu64 " Layer: #%" PRIu64 " hook: %s", display_handle,
layer_handle, GetFuncName(__PRETTY_FUNCTION__).c_str());
if (!display)
return static_cast<int32_t>(HWC2::Error::BadDisplay);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment