-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Before a new graphics frame has been prepared in the uncached display buffer. Now a separate cached buffer is used, which speeds up operation. The separate buffer is copied to the display buffer in the vertical sync phase to suppress flickering. Now this class can be used on the Raspberry Pi 5 too, but without vertical sync support. Issue #489
- Loading branch information
Showing
3 changed files
with
22 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
// Copyright (C) 2021 Stephane Damo | ||
// | ||
// Circle - A C++ bare metal environment for Raspberry Pi | ||
// Copyright (C) 2014-2023 R. Stange <[email protected]> | ||
// Copyright (C) 2014-2024 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -39,6 +39,8 @@ C2DGraphics::C2DGraphics (unsigned nWidth, unsigned nHeight, boolean bVSync, uns | |
|
||
C2DGraphics::~C2DGraphics (void) | ||
{ | ||
delete [] m_Buffer; | ||
|
||
if(m_pFrameBuffer) | ||
{ | ||
delete m_pFrameBuffer; | ||
|
@@ -47,8 +49,12 @@ C2DGraphics::~C2DGraphics (void) | |
|
||
boolean C2DGraphics::Initialize (void) | ||
{ | ||
#if RASPPI <= 4 | ||
m_pFrameBuffer = new CBcmFrameBuffer (m_nWidth, m_nHeight, DEPTH, m_nWidth, 2*m_nHeight, | ||
m_nDisplay, TRUE); | ||
#else | ||
m_pFrameBuffer = new CBcmFrameBuffer (m_nWidth, m_nHeight, DEPTH, 0, 0, m_nDisplay, FALSE); | ||
#endif | ||
|
||
#if DEPTH == 8 | ||
m_pFrameBuffer->SetPalette (RED_COLOR, RED_COLOR16); | ||
|
@@ -76,8 +82,13 @@ boolean C2DGraphics::Initialize (void) | |
m_baseBuffer = (TScreenColor *) (uintptr) m_pFrameBuffer->GetBuffer(); | ||
m_nWidth = m_pFrameBuffer->GetWidth(); | ||
m_nHeight = m_pFrameBuffer->GetHeight(); | ||
m_Buffer = m_baseBuffer + m_nWidth * m_nHeight; | ||
|
||
|
||
m_Buffer = new TScreenColor[m_nWidth * m_nHeight]; | ||
if (!m_Buffer) | ||
{ | ||
return FALSE; | ||
} | ||
|
||
return TRUE; | ||
} | ||
|
||
|
@@ -89,6 +100,7 @@ boolean C2DGraphics::Resize (unsigned nWidth, unsigned nHeight) | |
m_nWidth = nWidth; | ||
m_nHeight = nHeight; | ||
|
||
delete [] m_Buffer; | ||
m_Buffer = 0; | ||
m_bBufferSwapped = TRUE; | ||
|
||
|
@@ -361,15 +373,17 @@ TScreenColor* C2DGraphics::GetBuffer () | |
|
||
void C2DGraphics::UpdateDisplay() | ||
{ | ||
#if RASPPI <= 4 | ||
if(m_bVSync) | ||
{ | ||
m_pFrameBuffer->SetVirtualOffset(0, m_bBufferSwapped ? m_nHeight : 0); | ||
m_pFrameBuffer->WaitForVerticalSync(); | ||
memcpy (m_baseBuffer + m_bBufferSwapped * m_nWidth * m_nHeight, m_Buffer, | ||
m_nWidth * m_nHeight * sizeof(TScreenColor)); | ||
m_pFrameBuffer->SetVirtualOffset(0, m_bBufferSwapped ? m_nHeight : 0); | ||
m_bBufferSwapped = !m_bBufferSwapped; | ||
m_Buffer = m_baseBuffer + m_bBufferSwapped * m_nWidth * m_nHeight; | ||
} | ||
else | ||
#endif | ||
{ | ||
memcpy(m_baseBuffer, m_Buffer, m_nWidth * m_nHeight * sizeof(TScreenColor)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters