17#include <circle/sched/task.h>
18#include <circle/device.h>
19#include <circle/display.h>
20#include <circle/string.h>
21#include <circle/chargenerator.h>
22#include <circle/bcmframebuffer.h>
23#include <circle/spinlock.h>
24#include <circle/types.h>
55 static constexpr TRendererColor kColorBlack = DISPLAY_COLOR(0, 0, 0);
56 static constexpr TRendererColor kColorWhite = DISPLAY_COLOR(235, 235, 235);
57 static constexpr TRendererColor kColorAmber = DISPLAY_COLOR(255, 176, 0);
58 static constexpr TRendererColor kColorGreen = DISPLAY_COLOR(51, 255, 51);
63 CCharGenerator::TFontFlags fontFlags;
64 CDisplay::TRawColor foreground;
65 CDisplay::TRawColor background;
66 CDisplay::TRawColor defaultForeground;
67 CDisplay::TRawColor defaultBackground;
72 boolean cursorVisible;
78 boolean reverseAttribute;
79 boolean boldAttribute;
80 boolean underlineAttribute;
81 boolean blinkAttribute;
84 boolean delayedUpdate;
85 unsigned lastUpdateTicks;
113 boolean SetFont(
const TFont &rFont,
114 CCharGenerator::TFontFlags FontFlags = CCharGenerator::FontFlagsNone);
120 boolean SetFont(EFontSelection selection,
121 CCharGenerator::TFontFlags FontFlags = CCharGenerator::FontFlagsNone);
126 TRendererColor
MapColor(EColorSelection color);
162 int Write(
const void *pBuffer,
size_t nCount)
override;
170 void Goto(
unsigned nRow,
unsigned nColumn);
176 void SetPixel(
unsigned nPosX,
unsigned nPosY, TRendererColor Color);
182 void SetPixel(
unsigned nPosX,
unsigned nPosY, CDisplay::TRawColor nColor);
188 TRendererColor
GetPixel(
unsigned nPosX,
unsigned nPosY);
194 boolean SetColors(EColorSelection Foreground, EColorSelection Background);
199 void SetColors(TRendererColor Foreground = kColorWhite, TRendererColor Background = kColorBlack);
208 void SetBlinkingCursor(
boolean bBlinkingCursor,
unsigned nPeriodMilliSeconds = 500);
238 void Run(
void)
override;
245 void SetRawPixel(
unsigned nPosX,
unsigned nPosY, CDisplay::TRawColor nColor);
252 CDisplay::TRawColor
GetRawPixel(
unsigned nPosX,
unsigned nPosY);
271 float reverseBackgroundFactor = 0.7f,
272 float reverseForegroundFactor = 1.25f);
295 void Write(
char chChar);
298 void CarriageReturn(
void);
300 void ClearDisplayEnd(
void);
302 void ClearLineEnd(
void);
304 void CursorDown(
void);
306 void CursorHome(
void);
308 void CursorLeft(
void);
310 void CursorMove(
unsigned nRow,
unsigned nColumn);
312 void CursorRight(
void);
316 void DeleteChars(
unsigned nCount);
318 void DeleteLines(
unsigned nCount);
320 void DisplayChar(
char chChar);
322 void EraseChars(
unsigned nCount);
324 CDisplay::TRawColor GetTextBackgroundColor(
void);
326 CDisplay::TRawColor GetTextColor(
void);
328 void InsertLines(
unsigned nCount);
330 void InsertMode(
boolean bBegin);
334 void ReverseScroll(
void);
337 void SetScrollRegion(
unsigned nStartRow,
unsigned nEndRow);
339 void SetStandoutMode(
unsigned nMode);
341 void Tabulator(
void);
343 void BackTabulator(
void);
346 void SaveCursor(
void);
349 void RestoreCursor(
void);
354 boolean BeginSmoothScrollAnimation(
unsigned nStartY,
unsigned nEndY,
boolean bScrollDown);
356 void RenderSmoothScrollFrame(
void);
359 void DisplayChar(
char chChar,
unsigned nPosX,
unsigned nPosY, CDisplay::TRawColor nColor);
361 void EraseChar(
unsigned nPosX,
unsigned nPosY);
363 void InvertCursor(
void);
368 void SetUpdateArea(
unsigned nPosY1,
unsigned nPosY2)
370 if (nPosY1 < m_UpdateArea.y1)
372 m_UpdateArea.y1 = nPosY1;
375 if (nPosY2 > m_UpdateArea.y2)
377 m_UpdateArea.y2 = nPosY2;
406 const TFont *m_pFont;
407 CCharGenerator::TFontFlags m_FontFlags;
408 CCharGenerator *m_pCharGen;
409 CCharGenerator *m_pGraphicsCharGen;
410 EFontSelection m_CurrentFontSelection;
412 ECharacterSet m_G0CharSet;
413 ECharacterSet m_G1CharSet;
416 CDisplay::TRawColor *m_pCursorPixels;
423 CBcmFrameBuffer *m_pFrameBuffer;
424 unsigned m_nDisplayIndex;
429 unsigned m_nUsedWidth;
430 unsigned m_nUsedHeight;
432 CDisplay::TArea m_UpdateArea;
434 unsigned m_nScrollStart;
435 unsigned m_nScrollEnd;
439 boolean m_bCursorBlock;
440 boolean m_bBlinkingCursor;
441 boolean m_bCursorVisible;
442 unsigned m_nCursorBlinkPeriodTicks;
443 unsigned m_nNextCursorBlink;
444 CDisplay::TRawColor m_ForegroundColor;
445 CDisplay::TRawColor m_BackgroundColor;
446 CDisplay::TRawColor m_DefaultForegroundColor;
447 CDisplay::TRawColor m_DefaultBackgroundColor;
448 float m_BoldScaleFactor;
449 float m_DimScaleFactor;
450 float m_ReverseBackgroundScaleFactor;
451 float m_ReverseForegroundScaleFactor;
452 boolean m_bReverseAttribute;
453 boolean m_bBoldAttribute;
454 boolean m_bDimAttribute;
455 boolean m_bUnderlineAttribute;
456 boolean m_bBlinkAttribute;
462 boolean m_bDelayedUpdate;
463 unsigned m_nLastUpdateTicks;
464 boolean m_bSmoothScrollEnabled;
465 boolean m_bSmoothScrollActive;
466 boolean m_bSmoothScrollDown;
467 unsigned m_nSmoothScrollStartY;
468 unsigned m_nSmoothScrollEndY;
469 unsigned m_nSmoothScrollOffset;
470 unsigned m_nSmoothScrollStep;
471 unsigned m_nSmoothScrollLastTick;
472 unsigned m_nSmoothScrollTickInterval;
473 u8 *m_pSmoothScrollSnapshot;
474 u8 *m_pSmoothScrollCompose;
475 size_t m_nSmoothScrollBufferSize;
476 unsigned m_nSmoothScrollStartTick;
477 unsigned m_nSmoothScrollDebounceUntil;
478 unsigned m_nScrollStatsLastLogTick;
479 unsigned long long m_ScrollNormalTicksAccum;
480 unsigned long long m_ScrollSmoothTicksAccum;
481 unsigned m_ScrollNormalCount;
482 unsigned m_ScrollSmoothCount;
483 TRendererState m_SavedState;
492 mutable CSpinLock m_SpinLock;
Declares shared color selection enums for the VT100 renderer stack.
Declares the task that prepares VT100 font assets for rendering.
Combines Circle framebuffer access with a VT100-aware state machine.
Definition TRenderer.h:51
void RestoreState(const TRendererState &state)
Restore a previously saved renderer state.
Definition TRenderer.cpp:2936
void Update(void)
Periodic display maintenance invoked from the task loop.
Definition TRenderer.cpp:921
void RestoreScreenBuffer(const void *buffer, size_t bufferSize)
Restore the internal pixel buffer from a caller-provided buffer.
Definition TRenderer.cpp:3013
TRendererColor GetPixel(unsigned nPosX, unsigned nPosY)
Get the color value of a pixel.
Definition TRenderer.cpp:879
void SetVT52Mode(boolean bEnable)
Enable or disable VT52 emulation mode.
Definition TRenderer.cpp:2329
boolean SetFont(const TFont &rFont, CCharGenerator::TFontFlags FontFlags=CCharGenerator::FontFlagsNone)
Set the font to be used.
Definition TRenderer.cpp:256
void SetBlinkingCursor(boolean bBlinkingCursor, unsigned nPeriodMilliSeconds=500)
Enable or disable cursor blinking.
Definition TRenderer.cpp:894
void SetCursorBlock(boolean bCursorBlock)
Enable a block cursor instead of the default underline.
Definition TRenderer.cpp:889
~CTRenderer(void)
Release renderer resources and buffers.
Definition TRenderer.cpp:130
boolean SetColors(EColorSelection Foreground, EColorSelection Background)
Set the text colors using logical selections.
Definition TRenderer.cpp:418
unsigned GetHeight(void) const
Query the screen height in pixels.
Definition TRenderer.cpp:536
void Run(void) override
Entry point of the rendering task.
Definition TRenderer.cpp:488
unsigned GetCursorRow(void) const
Query the current cursor row (0-based).
Definition TRenderer.cpp:580
void SetRawPixel(unsigned nPosX, unsigned nPosY, CDisplay::TRawColor nColor)
Set a pixel to a specific raw color.
Definition TRenderer.cpp:684
void ResetParserState(void)
Reset ANSI parser state (used by VT tests).
Definition TRenderer.cpp:675
CBcmFrameBuffer * GetDisplay(void)
Access the underlying framebuffer device.
Definition TRenderer.cpp:599
void SaveState(TRendererState &state)
Save the current renderer state for later restore.
Definition TRenderer.cpp:2900
unsigned GetColumns(void) const
Query the screen width in characters.
Definition TRenderer.cpp:541
static CTRenderer * Get(void)
Access the singleton renderer instance.
Definition TRenderer.cpp:43
void SetSmoothScrollEnabled(boolean bEnable)
Enable or disable smooth-scroll animation.
Definition TRenderer.cpp:2272
unsigned GetCursorColumn(void) const
Query the current cursor column (0-based).
Definition TRenderer.cpp:561
void SetPixel(unsigned nPosX, unsigned nPosY, TRendererColor Color)
Set a pixel to a specific logical color.
Definition TRenderer.cpp:853
void ClearDisplay(void)
Clear entire display area and home the cursor.
Definition TRenderer.cpp:1768
boolean GetSmoothScrollEnabled(void) const
Query whether smooth-scroll animation is enabled.
Definition TRenderer.h:231
unsigned GetWidth(void) const
Query the screen width in pixels.
Definition TRenderer.cpp:531
CTRenderer(void)
Definition TRenderer.cpp:52
void SetBrightnessScaling(float boldFactor=1.6f, float reverseBackgroundFactor=0.7f, float reverseForegroundFactor=1.25f)
Set scaling factors for bold and reverse video attributes.
Definition TRenderer.cpp:2300
void ForceHideCursor(void)
Force-hide the cursor and restore underlying pixels.
Definition TRenderer.cpp:2334
boolean Initialize(void)
Initialize framebuffer access and Circle device registration.
Definition TRenderer.cpp:156
int Write(const void *pBuffer, size_t nCount) override
Write characters to screen.
Definition TRenderer.cpp:624
CDisplay::TRawColor GetRawPixel(unsigned nPosX, unsigned nPosY)
Get the raw color value of a pixel.
Definition TRenderer.cpp:715
size_t GetBufferSize(void) const
Query the size of the internal pixel buffer.
Definition TRenderer.cpp:2992
void doRenderTest(void)
Conduct a rendering self-test using various attributes.
Definition TRenderer.cpp:2751
void Goto(unsigned nRow, unsigned nColumn)
Move the cursor to a specific position.
Definition TRenderer.cpp:448
unsigned GetRows(void) const
Query the screen height in characters.
Definition TRenderer.cpp:551
void SetAutoPageMode(boolean bEnable)
Enable or disable automatic page mode (cursor wrap to top).
Definition TRenderer.cpp:2295
TRendererColor MapColor(EColorSelection color)
Translate a configured color selection into the renderer palette.
Definition TRenderer.cpp:401
CDisplay::TRawColor AdjustBrightness565(CDisplay::TRawColor color, float factor)
Adjust brightness of a raw RGB565 color.
Definition TRenderer.cpp:754
void SaveScreenBuffer(void *buffer, size_t bufferSize)
Save the internal pixel buffer into a caller-provided buffer.
Definition TRenderer.cpp:2997
CDisplay::TColor AdjustBrightness(CDisplay::TColor color, float factor)
Adjust brightness of a logical color.
Definition TRenderer.cpp:738
void SetCursorMode(boolean bVisible)
Enable or disable cursor visibility.
Definition TRenderer.cpp:2324
Definition TRenderer.h:61