C

salvatorx.cpp Example File

telltales/integrity/salvatorx.cpp
/**************************************************************************** ** ** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Safe Renderer module ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** 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 https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 as published by the Free Software ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/
#include <INTEGRITY.h> #include "salvatorx.h" //LOC_DISPLAY 0 /* LVDS pannel output */ //LOC_DISPLAY 1 /* HDMI 0 output*/ //LOC_DISPLAY 2 /* HDMI 1 output*/ #define LOC_DISPLAY 0 /* HDMI 0 output*/ FrameBuffer::FrameBuffer(int width, int height) :AbstractFrameBuffer() ,m_width(width) ,m_height(height) ,m_unit(LOC_DISPLAY) { initWindow(); } FrameBuffer::~FrameBuffer() { R_WM_WindowDisable(m_unit, &m_window); R_WM_WindowDelete(m_unit, &m_window); } void FrameBuffer::initWindow() { r_wm_Error_t wm_err = R_WM_DevInit(m_unit); if (R_WM_ERR_OK != wm_err) throw FailedToInitializeDevice; memset(&m_window, 0, sizeof(m_window)); m_window.ColorFmt = R_WM_COLORFMT_ARGB8888; m_window.PosX = 0; m_window.PosY = 0; m_window.PosZ = 4; m_window.Pitch = m_width; m_window.Width = m_width; m_window.Height = m_height; m_window.Alpha = 0xff; /* Opaque*/ m_window.Surface.BufNum = 1; m_window.Surface.Type = R_WM_SURFACE_FB; m_window.Surface.BufMode = R_WM_WINBUF_ALLOC_INTERNAL; wm_err = R_WM_ScreenBgColorSet(m_unit, 0x20, 0x20, 0x20); // Gray if (wm_err != R_WM_ERR_OK) throw FailedToSetScreenBackground; wm_err = R_WM_ScreenEnable(m_unit); if (wm_err != R_WM_ERR_OK) throw FailedToEnableScreen; wm_err = R_WM_WindowCreate(m_unit, &m_window); if (R_WM_ERR_OK != wm_err) throw FailedToCreateWindowLayer; r_mmgr_MemBlock_t *rect = (r_mmgr_MemBlock_t*)R_WM_WindowNewDrawBufGet(m_unit, &m_window); memset((void *)(rect->VmrStartAddr), 0, rect->Size); wm_err = R_WM_DevEventRegister(m_unit, R_WM_EVENT_VBLANK, 0); if (wm_err != R_WM_ERR_OK) throw FailedToRegisterVsyncEvent; wm_err = R_WM_WindowEnable(m_unit, &m_window); if (wm_err != R_WM_ERR_OK) throw FailedToEnableWindowSurface; } quint8 *FrameBuffer::bits() { quint8 *ptr = nullptr; if (m_window.Surface.Buffer[0]) { ptr = (quint8*) m_window.Surface.Buffer[0]->VmrStartAddr; } return ptr; } quint32 FrameBuffer::bytesPerLine() { return m_width * 4; } quint8 FrameBuffer::bitsPerPixel() { quint8 ret = 32; return ret; } RasterWindow::RasterWindow(const QSafeSize &size) : AbstractWindow(size) , m_buffer(size.width(), size.height()) { } void RasterWindow::render() { /* Wait for R_WM_EVENT_VBLANK on unit */ R_WM_DevWaitForEvent(m_buffer.m_unit, R_WM_EVENT_VBLANK); /* Enable the FB Window. */ R_WM_WindowEnable(m_buffer.m_unit, &m_buffer.m_window); }

Available under certain Qt licenses.
Find out more.