C
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 "cygfx.h" #include <platforminterface/log.h> namespace CyGfx { CYGFX_SM_FORMAT convertFormat(Qul::PixelFormat format) { CYGFX_SM_FORMAT result = CYGFX_SM_FORMAT_A8R8G8B8; switch (format) { case Qul::PixelFormat_ARGB32: case Qul::PixelFormat_ARGB32_Premultiplied: result = CYGFX_SM_FORMAT_A8R8G8B8; break; case Qul::PixelFormat_RGB32: result = CYGFX_SM_FORMAT_X8R8G8B8; break; case Qul::PixelFormat_RGB888: result = CYGFX_SM_FORMAT_R8G8B8; break; case Qul::PixelFormat_RGB16: result = CYGFX_SM_FORMAT_R5G6B5; break; case Qul::PixelFormat_Alpha8: result = CYGFX_SM_FORMAT_A8; break; default: Qul::PlatformInterface::log("[%s] Unsupported Format! (%d)\n\r", __PRETTY_FUNCTION__, format); } return result; } void loadSurface(CSurface<1> *surface, const Qul::PlatformInterface::Texture &texture) { CYGFX_ERROR ret = CYGFX_OK; if (texture.format() >= Qul::PixelFormat_Custom) { UTIL_SUCCESS(ret, surface->SurfLoadBitmap(texture.data(), false)); } else { UTIL_SUCCESS(ret, CyGfx_SmAssignBuffer(*surface, texture.width(), texture.height(), convertFormat(texture.format()), const_cast<unsigned char *>(texture.data()), 0)); UTIL_SUCCESS(ret, CyGfx_SmSetAttribute(*surface, CYGFX_SM_ATTR_STRIDE, texture.bytesPerLine())); UTIL_SUCCESS(ret, CyGfx_SmSetAttribute(*surface, CYGFX_SM_ATTR_BITPERPIXEL, texture.bitsPerPixel())); } } } // namespace CyGfx