Telltales: Rendering Safety-Critical UI

/**************************************************************************** ** ** Copyright (C) 2020 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$ ** ****************************************************************************/
#ifndef QNXWINDOW_H #define QNXWINDOW_H #include <screen/screen.h> #include <QtSafeRenderer/qsaferenderer.h> #include <QtSafeRenderer/qsafelayout.h> #include <QtSafeRenderer/qsafewindow.h> using namespace SafeRenderer; class Pixmap : public AbstractFrameBuffer { public: Pixmap(int width, int height, int format, screen_context_t *screen_context) :AbstractFrameBuffer() ,m_width(width) ,m_height(height) { screen_create_context(screen_context, SCREEN_APPLICATION_CONTEXT); screen_create_pixmap(&m_screen_pixmap, *screen_context); screen_set_pixmap_property_iv(m_screen_pixmap, SCREEN_PROPERTY_FORMAT, &format); int usage = SCREEN_USAGE_WRITE | SCREEN_USAGE_NATIVE; screen_set_pixmap_property_iv(m_screen_pixmap, SCREEN_PROPERTY_USAGE, &usage); int size[2] = { width, height }; screen_set_pixmap_property_iv(m_screen_pixmap, SCREEN_PROPERTY_BUFFER_SIZE, size); screen_create_pixmap_buffer(m_screen_pixmap); screen_get_pixmap_property_pv(m_screen_pixmap, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&m_buffer); } virtual quint8 *bits() { unsigned char *ptr = NULL; int ret = screen_get_buffer_property_pv(m_buffer, SCREEN_PROPERTY_POINTER, (void **)&ptr); if(ret != 0) { printf("FAILED to screen_get_buffer_property_pv"); return NULL; } return ptr; } virtual quint32 bytesPerLine() { int stride = 0; screen_get_buffer_property_iv(m_buffer, SCREEN_PROPERTY_STRIDE, &stride); return stride; } quint8 bitsPerPixel() { return 32; } virtual PixelFormat format() const { return PixelFormat::RGBA8888_LE; } screen_buffer_t buffer() const { return m_buffer; } private: int m_width; int m_height; screen_context_t m_screenContext; screen_buffer_t m_buffer; screen_pixmap_t m_screen_pixmap; }; class RasterWindow : public AbstractWindow { public: RasterWindow(const QSafeSize &size); void render(const Rect &dirtyArea); AbstractFrameBuffer *buffer() { return &m_buffer; } private: Pixmap m_buffer; screen_window_t m_window; screen_context_t m_screen_ctx; QSafeSize m_size; }; #endif // QNXWINDOW_H