This commit is contained in:
thomas committed 2026-10-18 14:06:40 +02:00
commit 2c2202e60d
2491 files changed
+1295990

No files matched your search

@@ -0,0 +1 @@
// Build Hash: 7599e5a61760e5965073f959ece7333c2725342e
@@ -0,0 +1,141 @@
#ifndef TOUCHGFX_GPU2DVECTORRENDERER_HPP
#define TOUCHGFX_GPU2DVECTORRENDERER_HPP
#include <touchgfx/hal/Types.hpp>
#include <touchgfx/hal/VectorRenderer.hpp>
namespace touchgfx
{
class GPU2DVectorRenderer : public VectorRenderer
{
public:
/**
* Start a new drawing (invalidated area) within the given canvas area.
* The canvas area typically corresponds to the area of a Widget and is
* given in absolute coordinates, whereas the invalidated area is given
* in relative coordinates.
* Implementations may lock the framebuffer here.
*
* @param canvasAreaAbs The canvas dimensions in absolute coordinates.
* @param invalidatedAreaRel The area which should be updated in relative coordinates.
*/
virtual void setup(const Rect& canvasAreaAbs, const Rect& invalidatedAreaRel);
/**
* Set the drawing mode for the VectorRenderer. The mode will be
* used for all subsequent drawings until setMode is called again.
*
* The default mode is non-zero filling.
*
* @param mode The filling mode.
*/
virtual void setMode(DrawMode mode);
/**
* Finalizes the current drawing. The implementation may block
* here until the drawing is done.
*
* The implementation is required to unlock the framebuffer when
* tearDown is called.
*/
virtual void tearDown();
/**
* Draw a Path defined by the given array of primitives
* (commands) and an array of the corresponding floating point
* coordinates.
*
* @param cmds An array of VectorPrimitives
* @param nCmds The number of commands in cmds
* @param points An array of coordinates for the commands
* @param nPoints The number of values in the points arrays
*/
virtual void drawPath(const uint8_t* cmds, uint32_t nCmds, const float* points, uint32_t nPoints, const float* bbox);
/**
* Set the width used for future drawings using the VECTOR_STROKE
* drawing mode.
*
* @param w The width used for stroke drawing.
*/
virtual void setStrokeWidth(float w);
/**
* Set a constant color used for future drawings.
*
* @param c An ARGB color value
*/
virtual void setColor(colortype c);
/**
* Set the alpha value (opacity) used for future drawings.
* The alpha is specified in the interval [0;255].
*
* @param a The alpha value.
*/
virtual void setAlpha(uint8_t a);
/**
* Set a linear gradient used for future drawings.
* The linear gradient is transformed using the current
* transformation matrix.
* Multiple colors (stops) can be specified for the gradient. The
* stop positions are given in the range [0;1].
*
* @param x0 X-coordinate for gradient starting point
* @param y0 Y-coordinate for gradient starting point
* @param x1 X-coordinate for gradient end point
* @param y1 Y-coordinate for gradient end point
* @param stops Number of stops
* @param stopPositions Positions of the stops on the line
* @param stopColors Colors of the stops
* @param width Width of the box to fill
* @param height Height of the box to fill
* @param solid True if all colors in the gradient are solid
* @param palette The gradient palette
*/
virtual void setLinearGradient(float x0, float y0, float x1, float y1,
uint32_t stops,
const float* stopPositions,
const uint32_t* stopColors,
float width,
float height,
bool solid,
const uint32_t* palette);
/**
* Set a radial gradient used for future drawings.
* The radial gradient is transformed using the current
* transformation matrix.
* Multiple colors (stops) can be specified for the gradient. The
* stop positions are given in the range [0;1].
*
* @param cx X-coordinate for the gradient center
* @param cy Y-coordinate for the gradient center
* @param radius Radius of the gradient
* @param stops Number of stops
* @param stopPositions Positions of the stops on the line
* @param stopColors Colors of the stops
*/
virtual void setRadialGradient(float cx, float cy, float radius,
uint32_t stops,
const float* stopPositions,
const colortype* stopColors);
/**
* Sets the transformation matrix used for future drawings.
* The transformation is reset when setup is called.
*
* @param m The transformation matrix
*
*/
virtual void setTransformationMatrix(const Matrix3x3& m);
virtual void setStrokeMiterLimit(float miterLimit);
virtual void setStrokeLineJoin(VGStrokeLineJoin lineJoin);
virtual void setStrokeLineCap(VGStrokeLineCap lineCap);
};
} //namespace touchgfx
#endif // TOUCHGFX_GPU2DVECTORRENDERER_HPP
@@ -0,0 +1,185 @@
#ifndef TOUCHGFX_HALGPU2D_HPP
#define TOUCHGFX_HALGPU2D_HPP
#include <touchgfx/hal/HAL.hpp>
#include <nema_cmdlist.h>
namespace touchgfx
{
class HALGPU2D : public touchgfx::HAL
{
public:
/**
* @fn STM32GPU2DHAL::STM32GPU2DHAL(touchgfx::DMA_Interface& dma, touchgfx::LCD& display, touchgfx::TouchController& tc, uint16_t width, uint16_t height) : touchgfx::HAL(dma, display, tc, width, height)
*
* @brief Constructor.
*
* Constructor. Initializes members.
*
* @param [in,out] dma Reference to DMA interface.
* @param [in,out] display Reference to LCD interface.
* @param [in,out] tc Reference to Touch Controller driver.
* @param width Width of the display.
* @param height Height of the display.
*/
HALGPU2D(touchgfx::DMA_Interface& dma, touchgfx::LCD& display, touchgfx::TouchController& tc, uint16_t width, uint16_t height);
/**
* This function is responsible for initializing the HALGPU2D and the entire framework.
*
* @param clSize Size of the GPU2D command list in bytes. Suggested value is 8192.
*
* @note The command list size has a big impact on performance. 8192 is a good value in most cases,
* so go with that if unsure. Recommended values are 4-8KB. Due to the nature of command lists,
* assigning a larger buffer size might actually cause a decrease in performance.
*/
void initialize(int clSize);
/**
* This function is responsible for initializing the HALGPU2D and the entire framework.
* The default implementation will assign a GPU2D command list buffer of 8192 bytes.
*
* @see void initialize(int clSize);
*/
void initialize()
{
initialize(8192);
}
/**
* @fn virtual uint16_t* HAL::lockFrameBuffer();
*
* @brief Waits for the frame buffer to become available for use.
*
* Waits for the frame buffer to become available for use (i.e. not used by DMA
* transfers).
*
* @note Function blocks until frame buffer is available. Client code MUST call
* unlockFrameBuffer() when frame buffer operation has completed.
*
* @return A pointer to the beginning of the currently used frame buffer.
*/
virtual uint16_t* lockFrameBuffer();
/**
* @fn virtual void HAL::unlockFrameBuffer();
*
* @brief Unlocks the frame buffer (MUST be called exactly once for each call to
* lockFrameBuffer()).
*
* Unlocks the frame buffer (MUST be called exactly once for each call to
* lockFrameBuffer()).
*/
virtual void unlockFrameBuffer();
/**
* @fn void bindExecBuffer();
*
* @brief Binds a new GPU2D Command List.
*/
void bindExecBuffer();
/**
* Gets client framebuffer.
*
* @return The address of the framebuffer currently used by the framework to draw in.
*/
uint16_t* getClientFrameBuffer()
{
return HAL::getClientFrameBuffer();
}
/**
* @fn void submitExecBuffer();
*
* @brief Unbinds and submits the GPU2D Command List immediately.
*/
void submitExecBuffer();
/**
* @fn void submitExecBufferOnEndframe();
*
* @brief Unbinds and submits the GPU2D Command List when frame ends.
*/
void submitExecBufferOnEndframe()
{
submitOnEndFrame = true;
}
/**
* @fn void clearFrameBuffer();
*
* @brief Clears the framebuffer.
*/
void clearFrameBuffer();
/**
* @fn HALGPU2D* getInstance();
*
* @brief Get an instance of the HALGPU2D.
*/
static HALGPU2D* getInstance()
{
assert(gpu2dHAL && "HALGPU2D not initialized!");
return gpu2dHAL;
}
/**
* Blits a 2D source-array to the framebuffer performing alpha-blending as specified.
*
* @param pSrc The source-array pointer (points to first value to copy)
* @param pClut The CLUT pointer (points to CLUT header data which include
* the type and size of this CLUT followed by colors data)
* @param x The destination x coordinate on the framebuffer.
* @param y The destination y coordinate on the framebuffer.
* @param width The width desired area of the source 2D array.
* @param height The height of desired area of the source 2D array.
* @param srcWidth The distance (in elements) from first value of first line, to
* first value of second line (the source 2D array width)
* @param alpha The alpha value to use for blending (255 = solid, no blending)
* @param hasTransparentPixels If true, this data copy contains transparent pixels and
* require hardware support for that to be enabled.
* @param dstWidth The distance (in elements) from first value of first line, to
* first value of second line (the destination 2D array width)
* @param srcFormat The source buffer color format (default is the framebuffer
* format)
* @param dstFormat The destination buffer color format (default is the
* framebuffer format)
*
* @note Alpha=255 is assumed "solid" and shall be used if HAL does not support
* BLIT_OP_COPY_WITH_ALPHA.
*/
void dma2dBlitCopy(const uint16_t* pSrc, const uint8_t* pClut, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t srcWidth, uint8_t alpha, bool hasTransparentPixels, uint16_t dstWidth, touchgfx::Bitmap::BitmapFormat srcFormat, touchgfx::Bitmap::BitmapFormat dstFormat);
protected:
/**
* @fn virtual bool HAL::beginFrame();
*
* @brief Called when beginning to rendering a frame.
*
* Called when beginning to rendering a frame.
*
* @return true if rendering can begin, false otherwise.
*/
virtual bool beginFrame();
/**
* @fn virtual void HAL::endFrame();
*
* @brief Called when a rendering pass is completed.
*
* Called when a rendering pass is completed.
*/
virtual void endFrame();
private:
static HALGPU2D* gpu2dHAL; // Singleton HAL instance
nema_cmdlist_t execBuf; // Command list buffer for GPU2D
bool dma2dActive;
bool submitOnEndFrame;
};
} // namespace touchgfx
#endif // TOUCHGFX_HALGPU2D_HPP