Qt Quick Ultralite tvii_effects Example

/****************************************************************************** ** ** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
#include <qul/painteditemdelegate.h> #include <qul/image.h> #include <platforminterface/drawingdevice.h> #include <platforminterface/rect.h> #include <platforminterface/rgba32.h> #ifdef QUL_TVIIC_PLATFORM #include <ut_class_surface.h> #endif class GaussianBlurDelegate : public Qul::PaintedItemDelegate { public: Qul::Property<double> blur; Qul::Property<Qul::SharedImage> source; void blurChanged(); Qul::PlatformInterface::Rect boundingRect(Qul::PlatformInterface::Size size) const override; void paint(Qul::PlatformInterface::DrawingDevice *device, const Qul::PlatformInterface::Rect &clip, const Qul::PlatformInterface::Transform &transform, Qul::PlatformInterface::Size size, float opacity) const override; private: float blurValue() const { if (blur.value() < 0) return 0; // Blur values above 2.5 cause graphical glitches on Traveo II if (blur.value() > 2.5) return 2.5; return blur.value(); } mutable bool m_initialized = false; mutable bool m_blurDirty = true; #ifdef QUL_TVIIC_PLATFORM mutable CSurface<1> m_source; mutable CSurface<1> m_blurred[3]; mutable int m_index = 0; #endif };