Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.
All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.
All imported code from other projects is compatible with this license.
All GPL licensed code from other projects had previously been removed.
Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-02 17:38:16 -05:00
|
|
|
/*
|
2016-09-03 17:46:10 -04:00
|
|
|
* Copyright (c) 2012, 2013, 2014, 2015, 2016 Jonas 'Sortie' Termansen.
|
Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.
All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.
All imported code from other projects is compatible with this license.
All GPL licensed code from other projects had previously been removed.
Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-02 17:38:16 -05:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* lfbtextbuffer.h
|
|
|
|
* An indexable text buffer rendered to a graphical linear frame buffer.
|
|
|
|
*/
|
2012-07-30 13:02:05 -04:00
|
|
|
|
|
|
|
#ifndef SORTIX_LFBTEXTBUFFER_H
|
|
|
|
#define SORTIX_LFBTEXTBUFFER_H
|
|
|
|
|
2012-12-22 15:10:06 -05:00
|
|
|
#include <sortix/kernel/kthread.h>
|
2012-07-30 13:02:05 -04:00
|
|
|
#include <sortix/kernel/textbuffer.h>
|
|
|
|
|
|
|
|
namespace Sortix {
|
|
|
|
|
2012-12-22 15:10:06 -05:00
|
|
|
enum TextBufferCmdType
|
2012-07-30 13:02:05 -04:00
|
|
|
{
|
2012-12-22 15:10:06 -05:00
|
|
|
TEXTBUFCMD_EXIT = 0,
|
|
|
|
TEXTBUFCMD_SYNC,
|
|
|
|
TEXTBUFCMD_PAUSE,
|
|
|
|
TEXTBUFCMD_CHAR,
|
|
|
|
TEXTBUFCMD_CURSOR_SET_ENABLED,
|
|
|
|
TEXTBUFCMD_CURSOR_MOVE,
|
|
|
|
TEXTBUFCMD_MOVE,
|
|
|
|
TEXTBUFCMD_FILL,
|
|
|
|
TEXTBUFCMD_SCROLL,
|
2015-05-10 14:28:33 -04:00
|
|
|
TEXTBUFCMD_REDRAW,
|
2012-12-22 15:10:06 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TextBufferCmd
|
|
|
|
{
|
|
|
|
union { TextBufferCmdType type; size_t align; };
|
|
|
|
union { size_t x; size_t from_x; ssize_t scroll_offset; };
|
|
|
|
union { size_t y; size_t from_y; };
|
|
|
|
union { size_t to_x; };
|
|
|
|
union { size_t to_y; };
|
|
|
|
union
|
|
|
|
{
|
|
|
|
bool b;
|
2015-10-04 12:55:06 -04:00
|
|
|
TextCharPOD c;
|
2012-12-22 15:10:06 -05:00
|
|
|
size_t val;
|
|
|
|
};
|
2012-07-30 13:02:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class LFBTextBuffer : public TextBuffer
|
|
|
|
{
|
|
|
|
friend LFBTextBuffer* CreateLFBTextBuffer(uint8_t* lfb, uint32_t lfbformat,
|
|
|
|
size_t xres, size_t yres,
|
|
|
|
size_t scansize);
|
|
|
|
private:
|
|
|
|
LFBTextBuffer();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~LFBTextBuffer();
|
2016-09-03 17:46:10 -04:00
|
|
|
virtual size_t Width();
|
|
|
|
virtual size_t Height();
|
|
|
|
virtual TextChar GetChar(TextPos pos);
|
2012-07-30 13:02:05 -04:00
|
|
|
virtual void SetChar(TextPos pos, TextChar c);
|
|
|
|
virtual void Scroll(ssize_t off, TextChar fillwith);
|
|
|
|
virtual void Move(TextPos to, TextPos from, size_t numchars);
|
2015-10-04 12:55:06 -04:00
|
|
|
virtual void Fill(TextPos from, TextPos to, TextChar fillwith);
|
2016-09-03 17:46:10 -04:00
|
|
|
virtual bool GetCursorEnabled();
|
2012-07-30 13:02:05 -04:00
|
|
|
virtual void SetCursorEnabled(bool enablecursor);
|
2016-09-03 17:46:10 -04:00
|
|
|
virtual TextPos GetCursorPos();
|
2012-07-30 13:02:05 -04:00
|
|
|
virtual void SetCursorPos(TextPos newcursorpos);
|
2015-03-19 19:08:08 -04:00
|
|
|
virtual void SpawnThreads();
|
2015-05-10 14:28:33 -04:00
|
|
|
virtual void Invalidate();
|
2013-11-11 16:21:56 -05:00
|
|
|
virtual bool EmergencyIsImpaired();
|
|
|
|
virtual bool EmergencyRecoup();
|
|
|
|
virtual void EmergencyReset();
|
2016-09-03 17:46:10 -04:00
|
|
|
virtual void Resume();
|
|
|
|
virtual void Pause();
|
2012-07-30 13:02:05 -04:00
|
|
|
|
2012-12-22 15:10:06 -05:00
|
|
|
public:
|
|
|
|
virtual void RenderThread();
|
|
|
|
|
2012-07-30 13:02:05 -04:00
|
|
|
private:
|
2014-04-19 14:28:54 -04:00
|
|
|
void RenderChar(TextChar textchar, size_t posx, size_t posy);
|
2012-07-30 13:02:05 -04:00
|
|
|
void RenderCharAt(TextPos pos);
|
|
|
|
void RenderRegion(size_t c1, size_t r1, size_t c2, size_t r2);
|
|
|
|
void RenderRange(TextPos from, TextPos to);
|
|
|
|
bool UsablePosition(TextPos pos) const;
|
|
|
|
size_t OffsetOfPos(TextPos pos) const;
|
|
|
|
TextPos CropPosition(TextPos pos) const;
|
|
|
|
TextPos AddToPosition(TextPos pos, size_t count);
|
2014-04-19 14:28:54 -04:00
|
|
|
void DoScroll(ssize_t off, TextChar entry);
|
2012-12-22 15:10:06 -05:00
|
|
|
void DoMove(TextPos to, TextPos from, size_t numchars);
|
2015-10-04 12:55:06 -04:00
|
|
|
void DoFill(TextPos from, TextPos to, TextChar fillwith);
|
2018-07-24 17:02:36 -04:00
|
|
|
void IssueCommand(TextBufferCmd* cmd, bool already_locked = false);
|
2016-09-03 17:46:10 -04:00
|
|
|
bool StopRendering();
|
2012-12-22 15:10:06 -05:00
|
|
|
void ResumeRendering();
|
2013-11-11 16:21:56 -05:00
|
|
|
bool IsCommandIdempotent(const TextBufferCmd* cmd) const;
|
|
|
|
void ExecuteCommand(TextBufferCmd* cmd,
|
|
|
|
bool& exit_requested,
|
|
|
|
bool& sync_requested,
|
|
|
|
bool& pause_requested,
|
|
|
|
TextPos& render_from,
|
|
|
|
TextPos& render_to);
|
2012-07-30 13:02:05 -04:00
|
|
|
|
|
|
|
private:
|
2013-11-11 16:21:56 -05:00
|
|
|
kthread_mutex_t execute_lock;
|
2012-12-22 15:10:06 -05:00
|
|
|
kthread_mutex_t queue_lock;
|
|
|
|
kthread_cond_t queue_not_full;
|
|
|
|
kthread_cond_t queue_not_empty;
|
|
|
|
kthread_cond_t queue_exit;
|
|
|
|
kthread_cond_t queue_sync;
|
|
|
|
kthread_cond_t queue_paused;
|
|
|
|
kthread_cond_t queue_resume;
|
|
|
|
TextBufferCmd* queue;
|
|
|
|
size_t queue_length;
|
|
|
|
size_t queue_offset;
|
|
|
|
size_t queue_used;
|
|
|
|
bool queue_is_paused;
|
|
|
|
bool queue_thread;
|
2012-07-30 13:02:05 -04:00
|
|
|
uint8_t* lfb;
|
2012-12-22 15:10:06 -05:00
|
|
|
uint8_t* backbuf;
|
2012-07-30 13:02:05 -04:00
|
|
|
uint8_t* font;
|
2014-04-19 14:28:54 -04:00
|
|
|
TextChar* chars;
|
2012-07-30 13:02:05 -04:00
|
|
|
size_t columns;
|
|
|
|
size_t rows;
|
|
|
|
size_t pixelsx;
|
|
|
|
size_t pixelsy;
|
|
|
|
size_t scansize;
|
|
|
|
uint32_t lfbformat;
|
2016-07-29 20:47:47 -04:00
|
|
|
size_t bytes_per_pixel;
|
2012-07-30 13:02:05 -04:00
|
|
|
bool cursorenabled;
|
|
|
|
TextPos cursorpos;
|
2013-11-11 16:21:56 -05:00
|
|
|
bool emergency_state;
|
2015-05-10 14:28:33 -04:00
|
|
|
bool invalidated;
|
2016-09-03 17:46:10 -04:00
|
|
|
bool need_clear;
|
|
|
|
bool exit_after_pause;
|
2013-11-11 16:21:56 -05:00
|
|
|
size_t execute_amount;
|
2012-07-30 13:02:05 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
LFBTextBuffer* CreateLFBTextBuffer(uint8_t* lfb, uint32_t lfbformat,
|
|
|
|
size_t xres, size_t yres, size_t scansize);
|
|
|
|
|
|
|
|
} // namespace Sortix
|
|
|
|
|
|
|
|
#endif
|