Skip to content

Commit

Permalink
Add logging.{h,cpp}
Browse files Browse the repository at this point in the history
Rename hwc logging category and add core category.
  • Loading branch information
Tomin1 committed Apr 15, 2020
1 parent 67179c2 commit a8f7b9b
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 56 deletions.
9 changes: 5 additions & 4 deletions src/compositor/eglhybrisbuffer.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2018 Jolla Ltd.
** Contact: Andrew den Exter <andrew.den.exter@jolla.com>
** Copyright (C) 2018 - 2020 Jolla Ltd.
** Copyright (C) 2020 Open Mobile Platform LLC.
**
** This file is part of lipstick.
**
Expand All @@ -16,6 +16,7 @@
#include "eglhybrisbuffer.h"
#include <QImage>
#include "hwcrenderstage.h"
#include "logging.h"

EglHybrisBuffer::EglHybrisBuffer(
Format format, const QSize &size, Usage usage, const EglHybrisFunctions &functions)
Expand Down Expand Up @@ -55,15 +56,15 @@ bool EglHybrisBuffer::allocate()
if (!eglHybrisCreateNativeBuffer(
m_size.width(), m_size.height(), m_usage, m_format, &m_bufferStride, &m_buffer)
|| !m_buffer) {
qCWarning(LIPSTICK_LOG_HWC, "EGL native buffer error");
qCWarning(lcLipstickHwcLog, "EGL native buffer error");
return false;
} else if (!(m_eglImage = eglCreateImageKHR(
eglGetDisplay(EGL_DEFAULT_DISPLAY),
EGL_NO_CONTEXT,
EGL_NATIVE_BUFFER_HYBRIS,
m_buffer,
0))) {
qCWarning(LIPSTICK_LOG_HWC, "EGLImage allocation error");
qCWarning(lcLipstickHwcLog, "EGLImage allocation error");
return false;
} else {
return true;
Expand Down
43 changes: 22 additions & 21 deletions src/compositor/hwcimage.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2015 Jolla Ltd.
** Contact: Gunnar Sletta <gunnar.sletta@jollamobile.com>
** Copyright (C) 2015 - 2020 Jolla Ltd.
** Copyright (C) 2019 - 2020 Open Mobile Platform LLC.
**
** This file is part of lipstick.
**
Expand All @@ -17,6 +17,7 @@
#include "hwcrenderstage.h"

#include "eglhybrisbuffer.h"
#include "logging.h"

#include <MGConfItem>

Expand Down Expand Up @@ -51,7 +52,7 @@ class HwcImageLoadRequest : public QRunnable, public QEvent
}

~HwcImageLoadRequest() {
qCDebug(LIPSTICK_LOG_HWC, "HwcImageLoadRequest completed and destroyed...");
qCDebug(lcLipstickHwcLog, "HwcImageLoadRequest completed and destroyed...");
}

void execute() {
Expand All @@ -61,10 +62,10 @@ class HwcImageLoadRequest : public QRunnable, public QEvent


if (!originalSize.isValid()) {
qCWarning(LIPSTICK_LOG_HWC, "%s is not a valid file or doesn't support reading image size: %s", qPrintable(file), qPrintable(reader.errorString()));
qCWarning(lcLipstickHwcLog, "%s is not a valid file or doesn't support reading image size: %s", qPrintable(file), qPrintable(reader.errorString()));
return;
} else if (Q_UNLIKELY(rotation != 0 && rotation != 90 && rotation != 180 && rotation != 270)) {
qCWarning(LIPSTICK_LOG_HWC, "%d is not a supported rotation: %s", rotation, qPrintable(file));
qCWarning(lcLipstickHwcLog, "%d is not a supported rotation: %s", rotation, qPrintable(file));
return;
}

Expand Down Expand Up @@ -131,7 +132,7 @@ class HwcImageLoadRequest : public QRunnable, public QEvent
image = QImage(bytes, imageSize.width(), imageSize.height(), stride, reader.imageFormat());

if (!reader.read(&image)) {
qCWarning(LIPSTICK_LOG_HWC, "Error reading %s: %s", qPrintable(file), qPrintable(reader.errorString()));
qCWarning(lcLipstickHwcLog, "Error reading %s: %s", qPrintable(file), qPrintable(reader.errorString()));

hybrisBuffer->unlock();
hybrisBuffer = EglHybrisBuffer::Pointer();
Expand All @@ -142,7 +143,7 @@ class HwcImageLoadRequest : public QRunnable, public QEvent
image = reader.read();

if (image.isNull()) {
qCWarning(LIPSTICK_LOG_HWC, "Error reading %s: %s", qPrintable(file), qPrintable(reader.errorString()));
qCWarning(lcLipstickHwcLog, "Error reading %s: %s", qPrintable(file), qPrintable(reader.errorString()));
return;
}
}
Expand All @@ -168,7 +169,7 @@ class HwcImageLoadRequest : public QRunnable, public QEvent
const auto themeName = MGConfItem("/meegotouch/theme/name").value(DEFAULT_THEME).toString();
auto shaderImage = shaderImageTemplate.arg(themeName);
if (themeName != QStringLiteral(DEFAULT_THEME) && !QFile::exists(shaderImage)) {
qCDebug(LIPSTICK_LOG_HWC, "Shader texture file does not exist: %s", qPrintable(shaderImage));
qCDebug(lcLipstickHwcLog, "Shader texture file does not exist: %s", qPrintable(shaderImage));
shaderImage = shaderImageTemplate.arg(DEFAULT_THEME);
}
QImage glass(shaderImage);
Expand Down Expand Up @@ -358,7 +359,7 @@ HwcImage::~HwcImage()
void HwcImage::setRotationHandler(QQuickItem *item)
{
if (!HwcRenderStage::isHwcEnabled()) {
qCDebug(LIPSTICK_LOG_HWC, "HwcImage ignoring rotation handler as HWC is disabled");
qCDebug(lcLipstickHwcLog, "HwcImage ignoring rotation handler as HWC is disabled");
return;
}

Expand All @@ -372,7 +373,7 @@ void HwcImage::setRotationHandler(QQuickItem *item)
emit rotationHandlerChanged();
polish();

qCDebug(LIPSTICK_LOG_HWC) << "HwcImage" << this << "tracking rotation handler" << item;
qCDebug(lcLipstickHwcLog) << "HwcImage" << this << "tracking rotation handler" << item;
}

void HwcImage::setAsynchronous(bool is)
Expand Down Expand Up @@ -448,7 +449,7 @@ void HwcImage::handlerRotationChanged()
{
qreal rotation = hwcimage_get_rotation(m_rotationHandler);
bool is90 = qFuzzyCompare(0.0, fmod(rotation, 90));
qCDebug(LIPSTICK_LOG_HWC, " - rotation changed: %6.3f, 90 degree=%s", rotation, is90 ? "yes" : "no");
qCDebug(lcLipstickHwcLog, " - rotation changed: %6.3f, 90 degree=%s", rotation, is90 ? "yes" : "no");
if (is90 && m_textureRotation != rotation)
polish();
}
Expand All @@ -465,7 +466,7 @@ void HwcImage::updatePolish()
}

if (!QFileInfo(m_source.toLocalFile()).exists()) {
qCDebug(LIPSTICK_LOG_HWC, "HwcImage: source file does not exist (%s)", qPrintable(m_source.toString()));
qCDebug(lcLipstickHwcLog, "HwcImage: source file does not exist (%s)", qPrintable(m_source.toString()));
return;
}

Expand All @@ -486,7 +487,7 @@ void HwcImage::updatePolish()
if (m_maxTextureSize > 0 && m_textureSize.width() > 0 && m_textureSize.height() > 0)
qWarning() << "HwcImage: both 'textureSize' and 'maxTextureSize' are set; 'textureSize' will take presedence" << this;

qCDebug(LIPSTICK_LOG_HWC,
qCDebug(lcLipstickHwcLog,
"Scheduling HwcImage request, source=%s, (%d x %d), eff=%s, olay=%s, rot=%d, pr=%f, %s",
qPrintable(m_source.toString()),
m_textureSize.width(), m_textureSize.height(),
Expand Down Expand Up @@ -542,7 +543,7 @@ bool HwcImage::event(QEvent *e)
&& m_textureSize == req->textureSize
&& m_pixelRatio == req->pixelRatio
&& m_overlayColor == req->overlay;
qCDebug(LIPSTICK_LOG_HWC,
qCDebug(lcLipstickHwcLog,
"HwcImage request completed: %s, source=%s, (%d x %d), eff=%s, olay=%s, rot=%d, pr=%f",
(accept ? "accepted" : "rejected"),
qPrintable(req->file),
Expand Down Expand Up @@ -617,12 +618,12 @@ class HwcImageNode : public QSGSimpleTextureNode
{
public:
HwcImageNode() {
qCDebug(LIPSTICK_LOG_HWC) << "HwcImageNode is created...";
qCDebug(lcLipstickHwcLog) << "HwcImageNode is created...";
qsgnode_set_description(this, QStringLiteral("hwc-image-node"));
setOwnsTexture(true);
}
~HwcImageNode() {
qCDebug(LIPSTICK_LOG_HWC) << "HwcImageNode is gone...";
qCDebug(lcLipstickHwcLog) << "HwcImageNode is gone...";
}
void *handle() const {
HwcImageTexture *t = static_cast<HwcImageTexture *>(texture());
Expand Down Expand Up @@ -677,7 +678,7 @@ QMatrix4x4 HwcImage::reverseTransform() const
QSGNode *HwcImage::updatePaintNode(QSGNode *old, UpdatePaintNodeData *)
{
if (!HwcRenderStage::isHwcEnabled()) {
qCDebug(LIPSTICK_LOG_HWC) << "HwcImage" << this << "updating paint node without HWC support";
qCDebug(lcLipstickHwcLog) << "HwcImage" << this << "updating paint node without HWC support";
return updateActualPaintNode(old);
}

Expand All @@ -698,7 +699,7 @@ QSGNode *HwcImage::updatePaintNode(QSGNode *old, UpdatePaintNodeData *)
HwcNode *hwcNode = 0;

if (old) {
qCDebug(LIPSTICK_LOG_HWC) << "HwcImage" << this << "updating paint existing node";
qCDebug(lcLipstickHwcLog) << "HwcImage" << this << "updating paint existing node";
hwcNode = static_cast<HwcNode *>(old);
HwcImageNode *contentNode = updateActualPaintNode(hwcNode->firstChild()->firstChild());
if (contentNode == 0) {
Expand All @@ -713,7 +714,7 @@ QSGNode *HwcImage::updatePaintNode(QSGNode *old, UpdatePaintNodeData *)
static_cast<QSGTransformNode *>(hwcNode->firstChild())->setMatrix(reverseTransform());
hwcNode->update(contentNode, contentNode->handle());
} else if (HwcImageNode *contentNode = updateActualPaintNode(0)) {
qCDebug(LIPSTICK_LOG_HWC) << "HwcImage" << this << "creating new node";
qCDebug(lcLipstickHwcLog) << "HwcImage" << this << "creating new node";
hwcNode = new HwcNode(window());
QSGTransformNode *xnode = new QSGTransformNode();
xnode->setMatrix(reverseTransform());
Expand All @@ -736,7 +737,7 @@ HwcImageTexture::HwcImageTexture(const EglHybrisBuffer::Pointer &buffer, HwcRend
, m_hwc(hwc)
{
glGenTextures(1, &m_id);
qCDebug(LIPSTICK_LOG_HWC,
qCDebug(lcLipstickHwcLog,
"HwcImageTexture(%p) created, size=(%d x %d), texId=%d",
this, m_buffer->size().width(), m_buffer->size().height(), m_id);
}
Expand All @@ -753,7 +754,7 @@ HwcImageTexture::~HwcImageTexture()
m_hwc->signalOnBufferRelease(EglHybrisBuffer::destroy, handle(), m_buffer.data());
}

qCDebug(LIPSTICK_LOG_HWC,
qCDebug(lcLipstickHwcLog,
"HwcImageTexture(%p) destroyed, size=(%d x %d), texId=%d",
this, m_buffer->size().width(), m_buffer->size().height(), m_id);
}
Expand Down
27 changes: 13 additions & 14 deletions src/compositor/hwcrenderstage.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2015 Jolla Ltd.
** Contact: Gunnar Sletta <gunnar.sletta@jollamobile.com>
** Copyright (C) 2020 Open Mobile Platform LLC.
**
** This file is part of lipstick.
**
Expand All @@ -17,6 +17,7 @@
#include "hwcinterface.h"

#include "lipstickcompositor.h"
#include "logging.h"

#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
Expand All @@ -28,8 +29,6 @@

#include <EGL/egl.h>

Q_LOGGING_CATEGORY(LIPSTICK_LOG_HWC, "qt.lipstick.hwc")

const QEvent::Type HWC_BufferRelease = (QEvent::Type) (QEvent::User + 1);

class HwcBufferReleaseEvent : public QEvent
Expand Down Expand Up @@ -128,7 +127,7 @@ void HwcRenderStage::initialize(LipstickCompositor *lipstick)
EGLDisplay eglDisplay = iface->nativeResourceForIntegration("egldisplay");
Q_ASSERT(eglDisplay);

qCDebug(LIPSTICK_LOG_HWC, "EGL Extensions: %s", eglQueryString(eglDisplay, EGL_EXTENSIONS));
qCDebug(lcLipstickHwcLog, "EGL Extensions: %s", eglQueryString(eglDisplay, EGL_EXTENSIONS));

void *compositor = iface->nativeResourceForIntegration(HWC_INTERFACE_STRING);
if (!compositor) {
Expand Down Expand Up @@ -180,10 +179,10 @@ static void hwc_renderstage_invalidate(void *hwc)

static void hwc_renderstage_dump_layerlist(HwcInterface::LayerList *list)
{
qCDebug(LIPSTICK_LOG_HWC, " - eglRenderingEnabled: %d", list->eglRenderingEnabled);
qCDebug(lcLipstickHwcLog, " - eglRenderingEnabled: %d", list->eglRenderingEnabled);
for (int i=0; i<list->layerCount; ++i) {
const HwcInterface::Layer &l = list->layers[i];
qCDebug(LIPSTICK_LOG_HWC, " - layer %d: target=(%d,%d, %dx%d), source=(%d,%d, %dx%d) handle=%p, accepted=%d",
qCDebug(lcLipstickHwcLog, " - layer %d: target=(%d,%d, %dx%d), source=(%d,%d, %dx%d) handle=%p, accepted=%d",
i,
l.tx, l.ty, l.tw, l.th,
l.sx, l.sy, l.sw, l.sh,
Expand Down Expand Up @@ -263,15 +262,15 @@ bool HwcRenderStage::render()
// it.
if (m_invalidationCountdown > 0 && m_layerList != m_hwc->acceptedLayerList()) {
--m_invalidationCountdown;
qCDebug(LIPSTICK_LOG_HWC, "HwcRenderStage::render(): invalidation countdown: %d", m_invalidationCountdown);
qCDebug(lcLipstickHwcLog, "HwcRenderStage::render(): invalidation countdown: %d", m_invalidationCountdown);
scheduleAgain = true;
}

if (scheduleAgain) {
m_layerList = hwc_renderstage_create_list(m_nodesToTry);
m_layerList->eglRenderingEnabled = !layersOnly;
if (LIPSTICK_LOG_HWC().isDebugEnabled()) {
qCDebug(LIPSTICK_LOG_HWC, "HwcRenderStage::render(), scheduling new layer list (using GL)");
if (lcLipstickHwcLog().isDebugEnabled()) {
qCDebug(lcLipstickHwcLog, "HwcRenderStage::render(), scheduling new layer list (using GL)");
hwc_renderstage_dump_layerlist(m_layerList);
}
foreach (HwcNode *n, m_nodesInList)
Expand All @@ -285,8 +284,8 @@ bool HwcRenderStage::render()
m_invalidationCountdown = 0;
if (m_scheduledLayerList) {
// newly accepted, toggle blocking in the scene graph...
if (LIPSTICK_LOG_HWC().isDebugEnabled()) {
qCDebug(LIPSTICK_LOG_HWC, "HwcRenderStage::render(), layer list was accepted (using HWC%s)",
if (lcLipstickHwcLog().isDebugEnabled()) {
qCDebug(lcLipstickHwcLog, "HwcRenderStage::render(), layer list was accepted (using HWC%s)",
m_layerList->eglRenderingEnabled ? "+GL" : "");
hwc_renderstage_dump_layerlist(m_layerList);
}
Expand Down Expand Up @@ -316,10 +315,10 @@ bool HwcRenderStage::render()
}

} else {
if (LIPSTICK_LOG_HWC().isDebugEnabled()) {
if (lcLipstickHwcLog().isDebugEnabled()) {
static bool once = false;
if (m_layerList || !once) {
qCDebug(LIPSTICK_LOG_HWC, "HwcRenderStage::render(), no layers (using GL)");
qCDebug(lcLipstickHwcLog, "HwcRenderStage::render(), no layers (using GL)");
once = true;
}
}
Expand Down Expand Up @@ -367,7 +366,7 @@ void HwcRenderStage::disableHwc()
{
if (!m_layerList)
return;
qCDebug(LIPSTICK_LOG_HWC, "HwcRenderStage: Hwc has been disabled, using only GL");
qCDebug(lcLipstickHwcLog, "HwcRenderStage: Hwc has been disabled, using only GL");
foreach (HwcNode *n, m_nodesInList)
n->setBlocked(false);
m_nodesInList.clear();
Expand Down
4 changes: 1 addition & 3 deletions src/compositor/hwcrenderstage.h
Expand Up @@ -18,8 +18,6 @@

#include <private/qquickwindow_p.h>

Q_DECLARE_LOGGING_CATEGORY(LIPSTICK_LOG_HWC)

class LipstickCompositor;
class HwcRenderStage;

Expand Down Expand Up @@ -130,4 +128,4 @@ public slots:
static bool m_hwcEnabled;
};

#endif // HWCRENDERSTAGE
#endif // HWCRENDERSTAGE

0 comments on commit a8f7b9b

Please sign in to comment.