Initial Commit
Blank working project
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/button/ButtonController.hpp
|
||||
*
|
||||
* Declares the touchgfx::ButtonController interface class.
|
||||
*/
|
||||
#ifndef BUTTONCONTROLLER_HPP
|
||||
#define BUTTONCONTROLLER_HPP
|
||||
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
/** Interface for sampling external key events. */
|
||||
class ButtonController
|
||||
{
|
||||
public:
|
||||
/** Finalizes an instance of the ButtonController class. */
|
||||
virtual ~ButtonController()
|
||||
{
|
||||
}
|
||||
|
||||
/** Initializes button controller. */
|
||||
virtual void init() = 0;
|
||||
|
||||
/**
|
||||
* Sample external key events.
|
||||
*
|
||||
* @param [out] key Output parameter that will be set to the key value if a keypress was
|
||||
* detected.
|
||||
*
|
||||
* @return True if a keypress was detected and the "key" parameter is set to a value.
|
||||
*/
|
||||
virtual bool sample(uint8_t& key) = 0;
|
||||
|
||||
/** Resets button controller. Does nothing in the default implementation. */
|
||||
virtual void reset()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // BUTTONCONTROLLER_HPP
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/i2c/I2C.hpp
|
||||
*
|
||||
* Declares the touchfgx::I2C interface class.
|
||||
*/
|
||||
#ifndef I2C_HPP
|
||||
#define I2C_HPP
|
||||
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
/** Platform independent interface for I2C drivers. */
|
||||
class I2C
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Initializes a new instance of the I2C class. Stores the channel of the I2C bus to be
|
||||
* configured.
|
||||
*
|
||||
* @param ch I2C channel.
|
||||
*/
|
||||
I2C(uint8_t ch)
|
||||
: channel(ch)
|
||||
{
|
||||
}
|
||||
|
||||
/** Finalizes an instance of the I2C class. */
|
||||
virtual ~I2C()
|
||||
{
|
||||
}
|
||||
|
||||
/** Initializes the I2C driver. */
|
||||
virtual void init() = 0;
|
||||
|
||||
/**
|
||||
* Reads the specified register on the device with the specified address.
|
||||
*
|
||||
* @param addr The I2C device address.
|
||||
* @param reg The register.
|
||||
* @param [out] data Pointer to buffer in which to place the result.
|
||||
* @param cnt Size of buffer in bytes.
|
||||
*
|
||||
* @return true on success, false otherwise.
|
||||
*/
|
||||
virtual bool readRegister(uint8_t addr, uint8_t reg, uint8_t* data, uint32_t cnt) = 0;
|
||||
|
||||
/**
|
||||
* Writes the specified value in a register.
|
||||
*
|
||||
* @param addr The I2C device address.
|
||||
* @param reg The register.
|
||||
* @param val The new value.
|
||||
*
|
||||
* @return true on success, false otherwise.
|
||||
*/
|
||||
virtual bool writeRegister(uint8_t addr, uint8_t reg, uint8_t val) = 0;
|
||||
|
||||
protected:
|
||||
uint8_t channel; ///< I2c channel is stored in order to initialize and recover a specific I2C channel
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // I2C_HPP
|
||||
@@ -0,0 +1,877 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/lcd/LCD16bpp.hpp
|
||||
*
|
||||
* Declares the touchgfx::LCD16bpp and touchgfx::LCD16DebugPrinter classes.
|
||||
*/
|
||||
#ifndef LCD16BPP_HPP
|
||||
#define LCD16BPP_HPP
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <touchgfx/Bitmap.hpp>
|
||||
#include <touchgfx/Font.hpp>
|
||||
#include <touchgfx/TextProvider.hpp>
|
||||
#include <touchgfx/TextureMapTypes.hpp>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
#include <touchgfx/hal/HAL.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
#include <touchgfx/lcd/LCD.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
#undef LCD
|
||||
|
||||
/**
|
||||
* This class contains the various low-level drawing routines for drawing bitmaps, texts and
|
||||
* rectangles on 16 bits per pixel displays.
|
||||
*
|
||||
* @see LCD
|
||||
*
|
||||
* @note All coordinates are expected to be in absolute coordinates!
|
||||
*/
|
||||
class LCD16bpp : public LCD
|
||||
{
|
||||
public:
|
||||
LCD16bpp();
|
||||
|
||||
|
||||
virtual void drawPartialBitmap(const Bitmap& bitmap, int16_t x, int16_t y, const Rect& rect, uint8_t alpha = 255, bool useOptimized = true);
|
||||
|
||||
virtual void blitCopy(const uint16_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual void blitCopy(const uint8_t* sourceData, Bitmap::BitmapFormat sourceFormat, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual uint16_t* copyFrameBufferRegionToMemory(const Rect& visRegion, const Rect& absRegion, const BitmapId bitmapId);
|
||||
|
||||
virtual void fillRect(const Rect& rect, colortype color, uint8_t alpha = 255);
|
||||
|
||||
virtual uint8_t bitDepth() const
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
virtual Bitmap::BitmapFormat framebufferFormat() const
|
||||
{
|
||||
return Bitmap::RGB565;
|
||||
}
|
||||
|
||||
virtual uint16_t framebufferStride() const
|
||||
{
|
||||
return getFramebufferStride();
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffer stride in bytes. The distance (in bytes) from the start of one
|
||||
* framebuffer row, to the next.
|
||||
*
|
||||
* @return The number of bytes in one framebuffer row.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint16_t getFramebufferStride()
|
||||
{
|
||||
assert(HAL::FRAME_BUFFER_WIDTH > 0 && "HAL has not been initialized yet");
|
||||
return HAL::FRAME_BUFFER_WIDTH * 2;
|
||||
}
|
||||
|
||||
virtual colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) const
|
||||
{
|
||||
return getColorFromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a color representation to be used on the LCD, based on 24 bit RGB values.
|
||||
*
|
||||
* @param red Value of the red part (0-255).
|
||||
* @param green Value of the green part (0-255).
|
||||
* @param blue Value of the blue part (0-255).
|
||||
*
|
||||
* @return The color representation depending on LCD color format.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
return ((red << 8) & 0xF800) | ((green << 3) & 0x07E0) | ((blue >> 3) & 0x001F);
|
||||
}
|
||||
|
||||
virtual uint8_t getRedColor(colortype color) const
|
||||
{
|
||||
return getRedFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets red from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The red from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getRedFromColor(colortype color)
|
||||
{
|
||||
return (color & 0xF800) >> 8;
|
||||
}
|
||||
|
||||
virtual uint8_t getGreenColor(colortype color) const
|
||||
{
|
||||
return getGreenFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets green from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The green from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getGreenFromColor(colortype color)
|
||||
{
|
||||
return (color & 0x07E0) >> 3;
|
||||
}
|
||||
|
||||
virtual uint8_t getBlueColor(colortype color) const
|
||||
{
|
||||
return getBlueFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets blue from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The blue from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getBlueFromColor(colortype color)
|
||||
{
|
||||
return (color & 0x001F) << 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for all image formats. This allows drawing any image
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms, but might use a lot of
|
||||
* memory for the drawing algorithms.
|
||||
*/
|
||||
void enableTextureMapperAll();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB565 image format. This allows drawing L8_RGB565
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB565_BilinearInterpolation,
|
||||
* enableTextureMapperL8_RGB565_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB565();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB565 image format. This allows drawing L8_RGB565
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB565, enableTextureMapperL8_RGB565_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB565_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB565 image format. This allows drawing L8_RGB565
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB565, enableTextureMapperL8_RGB565_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperL8_RGB565_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888_BilinearInterpolation,
|
||||
* enableTextureMapperL8_RGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888, enableTextureMapperL8_RGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888, enableTextureMapperL8_RGB888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperL8_ARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888, enableTextureMapperL8_ARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888, enableTextureMapperL8_ARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGB565 image format. This allows drawing RGB565
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperRGB565_Opaque_BilinearInterpolation,
|
||||
* enableTextureMapperRGB565_Opaque_NearestNeighbor,
|
||||
* enableTextureMapperRGB565_NonOpaque_BilinearInterpolation,
|
||||
* enableTextureMapperRGB565_NonOpaque_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperRGB565();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for Opaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565
|
||||
*/
|
||||
void enableTextureMapperRGB565_Opaque_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for NonOpaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565
|
||||
*/
|
||||
void enableTextureMapperRGB565_NonOpaque_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for Opaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565
|
||||
*/
|
||||
void enableTextureMapperRGB565_Opaque_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for NonOpaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565
|
||||
*/
|
||||
void enableTextureMapperRGB565_NonOpaque_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperA4_BilinearInterpolation, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperA4_NearestNeighbor();
|
||||
|
||||
protected:
|
||||
virtual DrawTextureMapScanLineBase* getTextureMapperDrawScanLine(const TextureSurface& texture, RenderingVariant renderVariant, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next pixel.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next pixel.
|
||||
*/
|
||||
static int nextPixel(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next line.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next line.
|
||||
*/
|
||||
static int nextLine(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
virtual void drawGlyph(uint16_t* wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect& invalidatedArea, const GlyphNode* glyph, const uint8_t* glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation);
|
||||
|
||||
/**
|
||||
* Blits a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified. If ARGB8888 is not supported by the DMA a software blend is performed.
|
||||
*
|
||||
* @param sourceData The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 32- bits ARGB8888 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyARGB8888(const uint32_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if indexed format is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyL8(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if L8_ARGB8888 is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries stored as 32-
|
||||
* bits (ARGB8888) format.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyL8_ARGB8888(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if L8_RGB565 is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries stored as 16-
|
||||
* bits (RGB565) format. If the source have per pixel alpha
|
||||
* channel, then alpha channel data will be following the clut
|
||||
* entries data.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyL8_RGB565(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if L8_RGB888 is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries stored as 32-
|
||||
* bits (ARGB8888) format.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyL8_RGB888(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified. Always performs a software blend.
|
||||
*
|
||||
* @param sourceData The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 16- bits RGB565 values.
|
||||
* @param alphaData The alpha channel array pointer (points to the beginning of the data)
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyAlphaPerPixel(const uint16_t* sourceData, const uint8_t* alphaData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
private:
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_NoGA;
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t expandRgb565(uint16_t c)
|
||||
{
|
||||
return ((c & 0x07E0) << 16) | (c & ~0x07E0);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint16_t compactRgb565(uint32_t c)
|
||||
{
|
||||
return ((c >> 16) & 0x07E0) | (c & ~0x07E0);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint16_t bilinearInterpolate565(uint16_t c00, uint16_t c10, uint16_t c01, uint16_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
uint32_t a00 = expandRgb565(c00);
|
||||
uint32_t a10 = expandRgb565(c10);
|
||||
uint32_t a01 = expandRgb565(c01);
|
||||
uint32_t a11 = expandRgb565(c11);
|
||||
|
||||
uint8_t xy = (x * y) >> 3;
|
||||
return compactRgb565((a00 * (32 - 2 * y - 2 * x + xy) + a10 * (2 * x - xy) + a01 * (2 * y - xy) + a11 * xy) >> 5);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint16_t bilinearInterpolate565(uint16_t c00, uint16_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
uint32_t a00 = expandRgb565(c00);
|
||||
uint32_t a10 = expandRgb565(c10);
|
||||
|
||||
return compactRgb565((a00 * (32 - 2 * x) + a10 * (2 * x)) >> 5);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
uint16_t xy10 = 16 * x;
|
||||
uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return (c00 * xy00 + c10 * xy10) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t c01, uint8_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
uint16_t xy11 = x * y;
|
||||
uint16_t xy10 = 16 * x - xy11;
|
||||
uint16_t xy01 = 16 * y - xy11;
|
||||
uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return (c00 * xy00 + c10 * xy10 + c01 * xy01 + c11 * xy11) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
uint16_t xy10 = 16 * x;
|
||||
uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * xy10) >> 8) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * xy10) >> 8) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint32_t c01, uint32_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
uint16_t xy11 = x * y;
|
||||
uint16_t xy10 = 16 * x - xy11;
|
||||
uint16_t xy01 = 16 * y - xy11;
|
||||
uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * xy10 + (c01 & 0xFF00FF) * xy01 + (c11 & 0xFF00FF) * xy11) >> 8) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * xy10 + (c01 & 0x00FF00) * xy01 + (c11 & 0x00FF00) * xy11) >> 8) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return div255rb((val & 0xFF00FF) * factor) | div255g((val & 0x00FF00) * factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888_FFcheck(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return factor < 0xFF ? div255_888(val, factor) : val;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div31rb(uint16_t val, uint8_t factor)
|
||||
{
|
||||
uint32_t val32 = (val & 0xF81F) * (factor >> 3);
|
||||
return ((val32 + 0x0801 + ((val32 >> 5) & 0xF81F)) >> 5) & 0xF81F;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div31g(uint16_t val, uint8_t factor)
|
||||
{
|
||||
uint32_t val32 = (val & 0x07E0) * factor;
|
||||
return ((val32 + 0x0020 + (val32 >> 8)) >> 8) & 0x07E0;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_565(uint16_t val, uint8_t factor)
|
||||
{
|
||||
return div31rb(val, factor) | div31g(val, factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_565_FFcheck(uint16_t val, uint8_t factor)
|
||||
{
|
||||
return factor < 0xFF ? div31rb(val, factor) | div31g(val, factor) : val;
|
||||
}
|
||||
|
||||
class DrawTextureMapScanLineBase16 : public DrawTextureMapScanLineBase
|
||||
{
|
||||
protected:
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckNearestNeighbor(uint16_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckBilinearInterpolation(uint16_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const uint8_t* alphaBits, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const alphaBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const alphaBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t a4, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t a);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const uint32_t offset, const int16_t bitmapStride, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const uint32_t offset, const int16_t bitmapStride, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* The class LCD16DebugPrinter implements the DebugPrinter interface for printing debug messages
|
||||
* on top of 16bit framebuffer.
|
||||
*
|
||||
* @see DebugPrinter
|
||||
*/
|
||||
class LCD16DebugPrinter : public DebugPrinter
|
||||
{
|
||||
public:
|
||||
virtual void draw(const Rect& rect) const;
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // LCD16BPP_HPP
|
||||
@@ -0,0 +1,843 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/lcd/LCD16bppSerialFlash.hpp
|
||||
*
|
||||
* Declares the touchgfx::LCD16bppSerialFlash class.
|
||||
*/
|
||||
#ifndef LCD16BPPSERIALFLASH_HPP
|
||||
#define LCD16BPPSERIALFLASH_HPP
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <touchgfx/Bitmap.hpp>
|
||||
#include <touchgfx/Font.hpp>
|
||||
#include <touchgfx/TextProvider.hpp>
|
||||
#include <touchgfx/TextureMapTypes.hpp>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
#include <touchgfx/hal/FlashDataReader.hpp>
|
||||
#include <touchgfx/hal/HAL.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
#include <touchgfx/lcd/LCD.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
#undef LCD
|
||||
|
||||
/**
|
||||
* This class contains the various low-level drawing routines for drawing bitmaps, texts and
|
||||
* rectangles on 16 bits per pixel displays.
|
||||
*
|
||||
* @see LCD
|
||||
*
|
||||
* @note All coordinates are expected to be in absolute coordinates!
|
||||
*/
|
||||
class LCD16bppSerialFlash : public LCD
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a LCD16bppSerialFlash object. The FlashDataReader object is used to fetch
|
||||
* data from the external flash.
|
||||
*
|
||||
* @param [in] flashReader Reference to a FlashDataReader object.
|
||||
*/
|
||||
LCD16bppSerialFlash(FlashDataReader& flashReader);
|
||||
|
||||
|
||||
virtual void drawPartialBitmap(const Bitmap& bitmap, int16_t x, int16_t y, const Rect& rect, uint8_t alpha = 255, bool useOptimized = true);
|
||||
|
||||
virtual void blitCopy(const uint16_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual void blitCopy(const uint8_t* sourceData, Bitmap::BitmapFormat sourceFormat, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual uint16_t* copyFrameBufferRegionToMemory(const Rect& visRegion, const Rect& absRegion, const BitmapId bitmapId);
|
||||
|
||||
virtual void fillRect(const Rect& rect, colortype color, uint8_t alpha = 255);
|
||||
|
||||
virtual uint8_t bitDepth() const
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
virtual Bitmap::BitmapFormat framebufferFormat() const
|
||||
{
|
||||
return Bitmap::RGB565;
|
||||
}
|
||||
|
||||
virtual uint16_t framebufferStride() const
|
||||
{
|
||||
return getFramebufferStride();
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffer stride in bytes. The distance (in bytes) from the start of one
|
||||
* framebuffer row, to the next.
|
||||
*
|
||||
* @return The number of bytes in one framebuffer row.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint16_t getFramebufferStride()
|
||||
{
|
||||
assert(HAL::FRAME_BUFFER_WIDTH > 0 && "HAL has not been initialized yet");
|
||||
return HAL::FRAME_BUFFER_WIDTH * 2;
|
||||
}
|
||||
|
||||
virtual colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) const
|
||||
{
|
||||
return getColorFromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a color representation to be used on the LCD, based on 24 bit RGB values.
|
||||
*
|
||||
* @param red Value of the red part (0-255).
|
||||
* @param green Value of the green part (0-255).
|
||||
* @param blue Value of the blue part (0-255).
|
||||
*
|
||||
* @return The color representation depending on LCD color format.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
return ((red << 8) & 0xF800) | ((green << 3) & 0x07E0) | ((blue >> 3) & 0x001F);
|
||||
}
|
||||
|
||||
virtual uint8_t getRedColor(colortype color) const
|
||||
{
|
||||
return getRedFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets red from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The red from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getRedFromColor(colortype color)
|
||||
{
|
||||
return (color & 0xF800) >> 8;
|
||||
}
|
||||
|
||||
virtual uint8_t getGreenColor(colortype color) const
|
||||
{
|
||||
return getGreenFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets green from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The green from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getGreenFromColor(colortype color)
|
||||
{
|
||||
return (color & 0x07E0) >> 3;
|
||||
}
|
||||
|
||||
virtual uint8_t getBlueColor(colortype color) const
|
||||
{
|
||||
return getBlueFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets blue from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The blue from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getBlueFromColor(colortype color)
|
||||
{
|
||||
return (color & 0x001F) << 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for all image formats. This allows drawing any image
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms, but might use a lot of
|
||||
* memory for the drawing algorithms.
|
||||
*/
|
||||
void enableTextureMapperAll();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB565 image format. This allows drawing L8_RGB565
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB565_BilinearInterpolation,
|
||||
* enableTextureMapperL8_RGB565_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB565();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB565 image format. This allows drawing L8_RGB565
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB565, enableTextureMapperL8_RGB565_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB565_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB565 image format. This allows drawing L8_RGB565
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB565, enableTextureMapperL8_RGB565_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperL8_RGB565_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Bilinear Interpolation and NearestNeighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888_BilinearInterpolation,
|
||||
* enableTextureMapperL8_RGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888, enableTextureMapperL8_RGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888, enableTextureMapperL8_RGB888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperL8_ARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888, enableTextureMapperL8_ARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888, enableTextureMapperL8_ARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGB565 image format. This allows drawing RGB565
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperRGB565_Opaque_BilinearInterpolation,
|
||||
* enableTextureMapperRGB565_Opaque_NearestNeighbor,
|
||||
* enableTextureMapperRGB565_NonOpaque_BilinearInterpolation,
|
||||
* enableTextureMapperRGB565_NonOpaque_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperRGB565();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for Opaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565
|
||||
*/
|
||||
void enableTextureMapperRGB565_Opaque_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for NonOpaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565
|
||||
*/
|
||||
void enableTextureMapperRGB565_NonOpaque_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for Opaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565
|
||||
*/
|
||||
void enableTextureMapperRGB565_Opaque_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for NonOpaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565
|
||||
*/
|
||||
void enableTextureMapperRGB565_NonOpaque_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperA4_BilinearInterpolation, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperA4_NearestNeighbor();
|
||||
|
||||
protected:
|
||||
virtual DrawTextureMapScanLineBase* getTextureMapperDrawScanLine(const TextureSurface& texture, RenderingVariant renderVariant, uint8_t alpha);
|
||||
|
||||
FlashDataReader& flashReader; ///< Flash reader. Used by routines to read pixel data from the flash.
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next pixel.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next pixel.
|
||||
*/
|
||||
static int nextPixel(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next line.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next line.
|
||||
*/
|
||||
static int nextLine(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
virtual void drawGlyph(uint16_t* wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect& invalidatedArea, const GlyphNode* glyph, const uint8_t* glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation);
|
||||
|
||||
/**
|
||||
* Blits a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified. If ARGB8888 is not supported by the DMA a software blend is performed.
|
||||
*
|
||||
* @param sourceData The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 32- bits ARGB8888 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
void blitCopyARGB8888(const uint32_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if indexed format is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
void blitCopyL8(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if L8_ARGB8888 is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries stored as 32-
|
||||
* bits (ARGB8888) format.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
void blitCopyL8_ARGB8888(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if L8_RGB565 is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries stored as 16-
|
||||
* bits (RGB565) format. If the source have per pixel alpha
|
||||
* channel, then alpha channel data will be following the clut
|
||||
* entries data.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
void blitCopyL8_RGB565(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
private:
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_NoGA;
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t expandRgb565(uint16_t c)
|
||||
{
|
||||
return ((c & 0x07E0) << 16) | (c & ~0x07E0);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint16_t compactRgb565(uint32_t c)
|
||||
{
|
||||
return ((c >> 16) & 0x07E0) | (c & ~0x07E0);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint16_t bilinearInterpolate565(uint16_t c00, uint16_t c10, uint16_t c01, uint16_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
uint32_t a00 = expandRgb565(c00);
|
||||
uint32_t a10 = expandRgb565(c10);
|
||||
uint32_t a01 = expandRgb565(c01);
|
||||
uint32_t a11 = expandRgb565(c11);
|
||||
|
||||
uint8_t xy = (x * y) >> 3;
|
||||
return compactRgb565((a00 * (32 - 2 * y - 2 * x + xy) + a10 * (2 * x - xy) + a01 * (2 * y - xy) + a11 * xy) >> 5);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint16_t bilinearInterpolate565(uint16_t c00, uint16_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
uint32_t a00 = expandRgb565(c00);
|
||||
uint32_t a10 = expandRgb565(c10);
|
||||
|
||||
return compactRgb565((a00 * (32 - 2 * x) + a10 * (2 * x)) >> 5);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
uint16_t xy10 = 16 * x;
|
||||
uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return (c00 * xy00 + c10 * xy10) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t c01, uint8_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
uint16_t xy11 = x * y;
|
||||
uint16_t xy10 = 16 * x - xy11;
|
||||
uint16_t xy01 = 16 * y - xy11;
|
||||
uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return (c00 * xy00 + c10 * xy10 + c01 * xy01 + c11 * xy11) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
uint16_t xy10 = 16 * x;
|
||||
uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * xy10) >> 8) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * xy10) >> 8) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint32_t c01, uint32_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
uint16_t xy11 = x * y;
|
||||
uint16_t xy10 = 16 * x - xy11;
|
||||
uint16_t xy01 = 16 * y - xy11;
|
||||
uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * xy10 + (c01 & 0xFF00FF) * xy01 + (c11 & 0xFF00FF) * xy11) >> 8) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * xy10 + (c01 & 0x00FF00) * xy01 + (c11 & 0x00FF00) * xy11) >> 8) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return div255rb((val & 0xFF00FF) * factor) | div255g((val & 0x00FF00) * factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888_FFcheck(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return factor < 0xFF ? div255_888(val, factor) : val;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div31rb(uint16_t val, uint8_t factor)
|
||||
{
|
||||
uint32_t val32 = (val & 0xF81F) * (factor >> 3);
|
||||
return ((val32 + 0x0801 + ((val32 >> 5) & 0xF81F)) >> 5) & 0xF81F;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div31g(uint16_t val, uint8_t factor)
|
||||
{
|
||||
uint32_t val32 = (val & 0x07E0) * factor;
|
||||
return ((val32 + 0x0020 + (val32 >> 8)) >> 8) & 0x07E0;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_565(uint16_t val, uint8_t factor)
|
||||
{
|
||||
return div31rb(val, factor) | div31g(val, factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_565_FFcheck(uint16_t val, uint8_t factor)
|
||||
{
|
||||
return factor < 0xFF ? div31rb(val, factor) | div31g(val, factor) : val;
|
||||
}
|
||||
|
||||
class DrawTextureMapScanLineBase16 : public DrawTextureMapScanLineBase
|
||||
{
|
||||
protected:
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckNearestNeighbor(uint16_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckBilinearInterpolation(uint16_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const uint8_t* alphaBits, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t* const alphaBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint8_t* const alphaBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t a4, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint8_t a);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_GA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const uint32_t offset, const int16_t bitmapWidth, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase16
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destBits, const uint16_t* const textureBits, const uint32_t offset, const int16_t bitmapWidth, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint16_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // LCD16BPPSERIALFLASH_HPP
|
||||
@@ -0,0 +1,340 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/lcd/LCD1bpp.hpp
|
||||
*
|
||||
* Declares the touchfgx::LCD1bpp and touchgfx::LCD1DebugPrinter classes.
|
||||
*/
|
||||
#ifndef LCD1BPP_HPP
|
||||
#define LCD1BPP_HPP
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <touchgfx/Bitmap.hpp>
|
||||
#include <touchgfx/Font.hpp>
|
||||
#include <touchgfx/TextProvider.hpp>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
#include <touchgfx/hal/HAL.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
#include <touchgfx/lcd/LCD.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
#undef LCD
|
||||
|
||||
/**
|
||||
* This class contains the various low-level drawing routines for drawing bitmaps, texts and
|
||||
* rectangles on 1 bits per pixel displays.
|
||||
*
|
||||
* @see LCD
|
||||
*
|
||||
* @note All coordinates are expected to be in absolute coordinates!
|
||||
*/
|
||||
class LCD1bpp : public LCD
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void drawPartialBitmap(const Bitmap& bitmap, int16_t x, int16_t y, const Rect& rect, uint8_t alpha = 255, bool useOptimized = true);
|
||||
|
||||
virtual void blitCopy(const uint16_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual void blitCopy(const uint8_t* sourceData, Bitmap::BitmapFormat sourceFormat, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual uint16_t* copyFrameBufferRegionToMemory(const Rect& visRegion, const Rect& absRegion, const BitmapId bitmapId);
|
||||
|
||||
virtual void fillRect(const Rect& rect, colortype color, uint8_t alpha = 255);
|
||||
|
||||
virtual uint8_t bitDepth() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
virtual Bitmap::BitmapFormat framebufferFormat() const
|
||||
{
|
||||
return Bitmap::BW;
|
||||
}
|
||||
|
||||
virtual uint16_t framebufferStride() const
|
||||
{
|
||||
return getFramebufferStride();
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffer stride in bytes. The distance (in bytes) from the start of one
|
||||
* framebuffer row, to the next.
|
||||
*
|
||||
* @return The number of bytes in one framebuffer row.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint16_t getFramebufferStride()
|
||||
{
|
||||
assert(HAL::FRAME_BUFFER_WIDTH > 0 && "HAL has not been initialized yet");
|
||||
return (HAL::FRAME_BUFFER_WIDTH + 7) / 8;
|
||||
}
|
||||
|
||||
virtual colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) const
|
||||
{
|
||||
return getColorFromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a color representation to be used on the LCD, based on 24 bit RGB values.
|
||||
*
|
||||
* @param red Value of the red part (0-255).
|
||||
* @param green Value of the green part (0-255).
|
||||
* @param blue Value of the blue part (0-255).
|
||||
*
|
||||
* @return The color representation depending on LCD color format.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
// Find the GRAY value (http://en.wikipedia.org/wiki/Luma_%28video%29) rounded to nearest integer
|
||||
return (red * 54 + green * 183 + blue * 19) >> 15;
|
||||
}
|
||||
|
||||
virtual uint8_t getRedColor(colortype color) const
|
||||
{
|
||||
return getRedFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets red from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The red from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getRedFromColor(colortype color)
|
||||
{
|
||||
return (color & 0x1) * 0xFF;
|
||||
}
|
||||
|
||||
virtual uint8_t getGreenColor(colortype color) const
|
||||
{
|
||||
return getGreenFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets green from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The green from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getGreenFromColor(colortype color)
|
||||
{
|
||||
return (color & 0x1) * 0xFF;
|
||||
}
|
||||
|
||||
virtual uint8_t getBlueColor(colortype color) const
|
||||
{
|
||||
return getBlueFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets blue from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The blue from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getBlueFromColor(colortype color)
|
||||
{
|
||||
return (color & 0x1) * 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for all image formats. Currently texture mapping is not
|
||||
* supported on 1bpp displays, so this function does not do anything. It is merely
|
||||
* included to allow function enableTextureMapperAll() to be called on any subclass of
|
||||
* LCD.
|
||||
*/
|
||||
void enableTextureMapperAll();
|
||||
|
||||
protected:
|
||||
virtual void drawTextureMapScanLine(const DrawingSurface& dest, const Gradients& gradients, const Edge* leftEdge, const Edge* rightEdge, const TextureSurface& texture, const Rect& absoluteRect, const Rect& dirtyAreaAbsolute, RenderingVariant renderVariant, uint8_t alpha, uint16_t subDivisionSize)
|
||||
{
|
||||
assert(0 && "Texture mapping not supported for 1bpp");
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next pixel.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next pixel.
|
||||
*/
|
||||
static int nextPixel(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next line.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next line.
|
||||
*/
|
||||
static int nextLine(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
virtual void drawGlyph(uint16_t* wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect& invalidatedArea, const GlyphNode* glyph, const uint8_t* glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation);
|
||||
|
||||
/**
|
||||
* Fill memory efficiently. Try to get 32bit aligned or 16bit aligned and then copy as
|
||||
* quickly as possible.
|
||||
*
|
||||
* @param [out] dst Pointer to memory to fill.
|
||||
* @param color Color to write to memory, either 0 => 0x00000000 or 1 =>
|
||||
* 0xFFFFFFFF.
|
||||
* @param bytesToFill Number of bytes to fill.
|
||||
*/
|
||||
static void fillMemory(void* RESTRICT dst, colortype color, uint16_t bytesToFill);
|
||||
|
||||
/**
|
||||
* Blits a run-length encoded2D source-array to the framebuffer if alpha > zero.
|
||||
*
|
||||
* @param _sourceData The source-array pointer (points to the beginning of the data). Data
|
||||
* stored in RLE format, where each byte indicates number of
|
||||
* pixels with certain color, alternating between black and
|
||||
* white. First byte represents black.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending (0 = invisible, otherwise solid).
|
||||
*/
|
||||
virtual void blitCopyRLE(const uint16_t* _sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Copies a rectangular area from the framebuffer til a givene memory address, which is
|
||||
* typically in the animation storage or a dynamic bitmap.
|
||||
*
|
||||
* @param srcAddress Source address (byte address).
|
||||
* @param srcStride Source stride (number of bytes to advance to next line).
|
||||
* @param srcPixelOffset Source pixel offset (first pixel in first source byte).
|
||||
* @param [in] dstAddress If destination address (byte address).
|
||||
* @param dstStride Destination stride (number of bytes to advance to next line).
|
||||
* @param dstPixelOffset Destination pixel offset (first pixel in destination byte).
|
||||
* @param width The width of area (in pixels).
|
||||
* @param height The height of area (in pixels).
|
||||
*/
|
||||
void copyRect(const uint8_t* srcAddress, uint16_t srcStride, uint8_t srcPixelOffset, uint8_t* RESTRICT dstAddress, uint16_t dstStride, uint8_t dstPixelOffset, uint16_t width, uint16_t height) const;
|
||||
|
||||
private:
|
||||
class bwRLEdata
|
||||
{
|
||||
public:
|
||||
bwRLEdata(const uint8_t* src = 0)
|
||||
: data(src), thisHalfByte(0), nextHalfByte(0), rleByte(0), firstHalfByte(true), color(0), length(0)
|
||||
{
|
||||
init(src);
|
||||
}
|
||||
void init(const uint8_t* src)
|
||||
{
|
||||
data = src;
|
||||
rleByte = 0;
|
||||
firstHalfByte = true;
|
||||
color = ~0; // Will be flipped to 0 by first call to getNextLength() below
|
||||
if (src != 0)
|
||||
{
|
||||
// Read two half-bytes ahead
|
||||
thisHalfByte = getNextHalfByte();
|
||||
nextHalfByte = getNextHalfByte();
|
||||
getNextLength();
|
||||
}
|
||||
}
|
||||
void skipNext(uint32_t skip)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (length > skip) // is the current length enough?
|
||||
{
|
||||
length -= skip; // Reduce the length
|
||||
skip = 0; // No more to skip
|
||||
break; // Done!
|
||||
}
|
||||
else
|
||||
{
|
||||
skip -= length; // Skip the entire run
|
||||
getNextLength(); // Swap colors and Read length of next run
|
||||
}
|
||||
}
|
||||
}
|
||||
uint8_t getColor() const
|
||||
{
|
||||
return color;
|
||||
}
|
||||
uint32_t getLength() const
|
||||
{
|
||||
return length;
|
||||
}
|
||||
|
||||
private:
|
||||
void getNextLength()
|
||||
{
|
||||
length = thisHalfByte; // Length is the next byte
|
||||
// update read ahead buffer
|
||||
thisHalfByte = nextHalfByte;
|
||||
nextHalfByte = getNextHalfByte();
|
||||
color = ~color; // Update the color of next run
|
||||
// If number after 'length' is 0
|
||||
while (thisHalfByte == 0)
|
||||
{
|
||||
length <<= 4; // Multiply length by 16 and
|
||||
length += nextHalfByte; // add the number after 0
|
||||
// We have used the next two half bytes, read two new ones
|
||||
thisHalfByte = getNextHalfByte();
|
||||
nextHalfByte = getNextHalfByte();
|
||||
}
|
||||
if (length == 0)
|
||||
{
|
||||
getNextLength();
|
||||
}
|
||||
}
|
||||
uint8_t getNextHalfByte()
|
||||
{
|
||||
if (firstHalfByte) // Start of new byte, read data from BW_RLE stream
|
||||
{
|
||||
rleByte = *data++;
|
||||
}
|
||||
uint8_t length = rleByte & 0xF; // Read lower half
|
||||
rleByte >>= 4; // Shift upper half down to make it ready
|
||||
firstHalfByte = !firstHalfByte; // Toggle 'start of byte'
|
||||
return length;
|
||||
}
|
||||
const uint8_t* data; // Pointer to compressed data (BW_RLE)
|
||||
uint8_t thisHalfByte; // The next half byte from the input
|
||||
uint8_t nextHalfByte; // The next half byte after 'thisHalfByte'
|
||||
uint8_t rleByte; // Byte read from compressed data
|
||||
bool firstHalfByte; // Are we about to process first half byte of rleByte?
|
||||
uint8_t color; // Current color
|
||||
uint32_t length; // Number of pixels with the given color
|
||||
};
|
||||
|
||||
friend class PainterBWBitmap;
|
||||
};
|
||||
|
||||
/**
|
||||
* The class LCD1DebugPrinter implements the DebugPrinter interface for printing debug messages
|
||||
* on top of 24bit framebuffer.
|
||||
*
|
||||
* @see DebugPrinter
|
||||
*/
|
||||
class LCD1DebugPrinter : public DebugPrinter
|
||||
{
|
||||
public:
|
||||
virtual void draw(const Rect& rect) const;
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // LCD1BPP_HPP
|
||||
@@ -0,0 +1,673 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/lcd/LCD24bpp.hpp
|
||||
*
|
||||
* Declares the touchgfx::LCD24bpp and touchgfx::LCD24DebugPrinter classes.
|
||||
*/
|
||||
#ifndef LCD24BPP_HPP
|
||||
#define LCD24BPP_HPP
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <touchgfx/Bitmap.hpp>
|
||||
#include <touchgfx/Font.hpp>
|
||||
#include <touchgfx/TextProvider.hpp>
|
||||
#include <touchgfx/TextureMapTypes.hpp>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
#include <touchgfx/hal/HAL.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
#include <touchgfx/lcd/LCD.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
#undef LCD
|
||||
|
||||
/**
|
||||
* This class contains the various low-level drawing routines for drawing bitmaps, texts and
|
||||
* rectangles on 16 bits per pixel displays.
|
||||
*
|
||||
* @see LCD
|
||||
*
|
||||
* @note All coordinates are expected to be in absolute coordinates!
|
||||
*/
|
||||
class LCD24bpp : public LCD
|
||||
{
|
||||
public:
|
||||
LCD24bpp();
|
||||
|
||||
|
||||
virtual void drawPartialBitmap(const Bitmap& bitmap, int16_t x, int16_t y, const Rect& rect, uint8_t alpha = 255, bool useOptimized = true);
|
||||
|
||||
virtual void blitCopy(const uint16_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual void blitCopy(const uint8_t* sourceData, Bitmap::BitmapFormat sourceFormat, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual uint16_t* copyFrameBufferRegionToMemory(const Rect& visRegion, const Rect& absRegion, const BitmapId bitmapId);
|
||||
|
||||
virtual void fillRect(const Rect& rect, colortype color, uint8_t alpha = 255);
|
||||
|
||||
virtual uint8_t bitDepth() const
|
||||
{
|
||||
return 24;
|
||||
}
|
||||
|
||||
virtual Bitmap::BitmapFormat framebufferFormat() const
|
||||
{
|
||||
return Bitmap::RGB888;
|
||||
}
|
||||
|
||||
virtual uint16_t framebufferStride() const
|
||||
{
|
||||
return getFramebufferStride();
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffer stride in bytes. The distance (in bytes) from the start of one
|
||||
* framebuffer row, to the next.
|
||||
*
|
||||
* @return The number of bytes in one framebuffer row.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint16_t getFramebufferStride()
|
||||
{
|
||||
assert(HAL::FRAME_BUFFER_WIDTH > 0 && "HAL has not been initialized yet");
|
||||
return HAL::FRAME_BUFFER_WIDTH * 3;
|
||||
}
|
||||
|
||||
virtual colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) const
|
||||
{
|
||||
return getColorFromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets color from RGB.
|
||||
*
|
||||
* @param red The red.
|
||||
* @param green The green.
|
||||
* @param blue The blue.
|
||||
*
|
||||
* @return The color from RGB.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
return (red << 16) | (green << 8) | (blue);
|
||||
}
|
||||
|
||||
virtual uint8_t getRedColor(colortype color) const
|
||||
{
|
||||
return getRedFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets red from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The red from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getRedFromColor(colortype color)
|
||||
{
|
||||
return color >> 16;
|
||||
}
|
||||
|
||||
virtual uint8_t getGreenColor(colortype color) const
|
||||
{
|
||||
return getGreenFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets green from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The green from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getGreenFromColor(colortype color)
|
||||
{
|
||||
return color >> 8;
|
||||
}
|
||||
|
||||
virtual uint8_t getBlueColor(colortype color) const
|
||||
{
|
||||
return getBlueFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets blue from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The blue from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getBlueFromColor(colortype color)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for all image formats. This allows drawing any image
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms, but might use a lot of
|
||||
* memory for the drawing algorithms.
|
||||
*/
|
||||
void enableTextureMapperAll();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888_BilinearInterpolation,
|
||||
* enableTextureMapperL8_RGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888, enableTextureMapperL8_RGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888, enableTextureMapperL8_RGB888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperL8_ARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888, enableTextureMapperL8_ARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888, enableTextureMapperL8_ARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGB888 image format. This allows drawing RGB888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperRGB888_BilinearInterpolation,
|
||||
* enableTextureMapperRGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperRGB888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGB888 image format. This allows drawing RGB888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB888, enableTextureMapperRGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperRGB888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGB888 image format. This allows drawing RGB888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB888, enableTextureMapperRGB888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperRGB888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperA4_BilinearInterpolation, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperA4_NearestNeighbor();
|
||||
|
||||
protected:
|
||||
virtual DrawTextureMapScanLineBase* getTextureMapperDrawScanLine(const TextureSurface& texture, RenderingVariant renderVariant, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next pixel.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next pixel.
|
||||
*/
|
||||
static int nextPixel(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next line.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next line.
|
||||
*/
|
||||
static int nextLine(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
virtual void drawGlyph(uint16_t* wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect& invalidatedArea, const GlyphNode* glyph, const uint8_t* glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation);
|
||||
|
||||
/**
|
||||
* Blits a 2D source-array to the framebuffer. Per pixel alpha is not supported, only
|
||||
* global alpha.
|
||||
*
|
||||
* @param sourceData16 The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 16- bits RGB565 values.
|
||||
* @param source The location and dimension of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyRGB565(const uint16_t* sourceData16, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified if ARGB8888 is not supported by the DMA a software blend is performed.
|
||||
*
|
||||
* @param sourceData The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 32- bits ARGB8888 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyARGB8888(const uint32_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if indexed format is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyL8(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if L8_ARGB8888 is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries stored as 32-
|
||||
* bits (ARGB8888) format.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyL8_ARGB8888(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if L8_RGB888 is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries stored as 32-
|
||||
* bits (RGB888) format.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyL8_RGB888(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
private:
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB888_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB888_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB888_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB888_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_NoGA;
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
return (c00 * (16 - x) + c10 * x) >> 4;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t c01, uint8_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
const uint16_t xy11 = x * y;
|
||||
const uint16_t xy10 = 16 * x - xy11;
|
||||
const uint16_t xy01 = 16 * y - xy11;
|
||||
const uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return (c00 * xy00 + c10 * xy10 + c01 * xy01 + c11 * xy11) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
const uint16_t xy00 = 16 - x;
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * x) >> 4) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * x) >> 4) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint32_t c01, uint32_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
const uint16_t xy11 = x * y;
|
||||
const uint16_t xy10 = 16 * x - xy11;
|
||||
const uint16_t xy01 = 16 * y - xy11;
|
||||
const uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * xy10 + (c01 & 0xFF00FF) * xy01 + (c11 & 0xFF00FF) * xy11) >> 8) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * xy10 + (c01 & 0x00FF00) * xy01 + (c11 & 0x00FF00) * xy11) >> 8) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return div255rb((val & 0xFF00FF) * factor) | div255g((val & 0x00FF00) * factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888_FFcheck(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return factor < 0xFF ? div255_888(val, factor) : val;
|
||||
}
|
||||
|
||||
class DrawTextureMapScanLineBase24 : public DrawTextureMapScanLineBase
|
||||
{
|
||||
protected:
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckNearestNeighbor(uint8_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckBilinearInterpolation(uint8_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint16_t* const textureBits, const uint8_t* const palette, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint16_t* const textureBits, const uint8_t* const palette, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint16_t* const textureBits, const uint8_t* const palette, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint16_t* const textureBits, const uint8_t* const palette, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB888_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB888_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB888_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB888_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_GA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t a4, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t a4);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_GA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase24
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* The class LCD24DebugPrinter implements the DebugPrinter interface for printing debug messages
|
||||
* on top of 24bit framebuffer.
|
||||
*
|
||||
* @see DebugPrinter
|
||||
*/
|
||||
class LCD24DebugPrinter : public DebugPrinter
|
||||
{
|
||||
public:
|
||||
virtual void draw(const Rect& rect) const;
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // LCD24BPP_HPP
|
||||
@@ -0,0 +1,426 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/lcd/LCD2bpp.hpp
|
||||
*
|
||||
* Declares the touchgfx::LCD2bpp and touchgfx::LCD2DebugPrinter class.
|
||||
*/
|
||||
#ifndef LCD2BPP_HPP
|
||||
#define LCD2BPP_HPP
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <touchgfx/Bitmap.hpp>
|
||||
#include <touchgfx/Font.hpp>
|
||||
#include <touchgfx/TextProvider.hpp>
|
||||
#include <touchgfx/TextureMapTypes.hpp>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
#include <touchgfx/hal/HAL.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
#include <touchgfx/lcd/LCD.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
#undef LCD
|
||||
#define USE_LSB
|
||||
|
||||
/**
|
||||
* This class contains the various low-level drawing routines for drawing bitmaps, texts and
|
||||
* rectangles on 2 bits per pixel grayscale displays.
|
||||
*
|
||||
* @see LCD
|
||||
*
|
||||
* @note All coordinates are expected to be in absolute coordinates!
|
||||
*/
|
||||
class LCD2bpp : public LCD
|
||||
{
|
||||
public:
|
||||
LCD2bpp();
|
||||
|
||||
|
||||
virtual void drawPartialBitmap(const Bitmap& bitmap, int16_t x, int16_t y, const Rect& rect, uint8_t alpha = 255, bool useOptimized = true);
|
||||
|
||||
virtual void blitCopy(const uint16_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual void blitCopy(const uint8_t* sourceData, Bitmap::BitmapFormat sourceFormat, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual uint16_t* copyFrameBufferRegionToMemory(const Rect& visRegion, const Rect& absRegion, const BitmapId bitmapId);
|
||||
|
||||
virtual void fillRect(const Rect& rect, colortype color, uint8_t alpha = 255);
|
||||
|
||||
virtual uint8_t bitDepth() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
virtual Bitmap::BitmapFormat framebufferFormat() const
|
||||
{
|
||||
return Bitmap::GRAY2;
|
||||
}
|
||||
|
||||
virtual uint16_t framebufferStride() const
|
||||
{
|
||||
return getFramebufferStride();
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffer stride in bytes. The distance (in bytes) from the start of one
|
||||
* framebuffer row, to the next.
|
||||
*
|
||||
* @return The number of bytes in one framebuffer row.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint16_t getFramebufferStride()
|
||||
{
|
||||
assert(HAL::FRAME_BUFFER_WIDTH > 0 && "HAL has not been initialized yet");
|
||||
return (HAL::FRAME_BUFFER_WIDTH + 3) / 4;
|
||||
}
|
||||
|
||||
virtual colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) const
|
||||
{
|
||||
return getColorFromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a color representation to be used on the LCD, based on 24 bit RGB values.
|
||||
*
|
||||
* @param red Value of the red part (0-255).
|
||||
* @param green Value of the green part (0-255).
|
||||
* @param blue Value of the blue part (0-255).
|
||||
*
|
||||
* @return The color representation depending on LCD color format.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
// Find the GRAY value (http://en.wikipedia.org/wiki/Luma_%28video%29) rounded to nearest integer
|
||||
return (red * 54 + green * 183 + blue * 19) >> 14;
|
||||
}
|
||||
|
||||
virtual uint8_t getRedColor(colortype color) const
|
||||
{
|
||||
return getRedFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets red from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The red from color.
|
||||
*/
|
||||
virtual uint8_t getRedFromColor(colortype color) const
|
||||
{
|
||||
return (color & 0x3) * 0x55;
|
||||
}
|
||||
|
||||
virtual uint8_t getGreenColor(colortype color) const
|
||||
{
|
||||
return getGreenFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets green from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The green from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getGreenFromColor(colortype color)
|
||||
{
|
||||
return (color & 0x3) * 0x55;
|
||||
}
|
||||
|
||||
virtual uint8_t getBlueColor(colortype color) const
|
||||
{
|
||||
return getBlueFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets blue from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The blue from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getBlueFromColor(colortype color)
|
||||
{
|
||||
return (color & 0x3) * 0x55;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for all image formats. This allows drawing any image
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms, but might use a lot of
|
||||
* memory for the drawing algorithms.
|
||||
*/
|
||||
void enableTextureMapperAll();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for GRAY2 image format. This allows drawing GRAY2 images
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperGRAY2_BilinearInterpolation,
|
||||
* enableTextureMapperGRAY2_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperGRAY2();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for GRAY2 image format. This allows drawing GRAY2 images
|
||||
* using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperGRAY2, enableTextureMapperGRAY2_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperGRAY2_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for GRAY2 image format. This allows drawing GRAY2 images
|
||||
* using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperGRAY2, enableTextureMapperGRAY2_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperGRAY2_NearestNeighbor();
|
||||
|
||||
protected:
|
||||
static const uint8_t alphaTable2bpp[256]; ///< The alpha lookup table to avoid arithmetics when alpha blending
|
||||
|
||||
virtual DrawTextureMapScanLineBase* getTextureMapperDrawScanLine(const TextureSurface& texture, RenderingVariant renderVariant, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next pixel.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next pixel.
|
||||
*/
|
||||
static int nextPixel(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next line.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next line.
|
||||
*/
|
||||
static int nextLine(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
virtual void drawGlyph(uint16_t* wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect& invalidatedArea, const GlyphNode* glyph, const uint8_t* glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation);
|
||||
|
||||
/**
|
||||
* Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified Performs always a software blend.
|
||||
*
|
||||
* @param sourceData16 The source-array pointer (points to the beginning of the
|
||||
* data). The sourceData must be stored as 2bpp GRAY2 values.
|
||||
* @param sourceAlphaData The alpha channel array pointer (points to the beginning of
|
||||
* the data)
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole
|
||||
* image (255 = solid, no blending)
|
||||
*/
|
||||
static void blitCopyAlphaPerPixel(const uint16_t* sourceData16, const uint8_t* sourceAlphaData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Copies a rectangular area.
|
||||
*
|
||||
* @param srcAddress Source address (byte address).
|
||||
* @param srcStride Source stride (number of bytes to advance to next line).
|
||||
* @param srcPixelOffset Source pixel offset (first pixel in first source byte).
|
||||
* @param [in] dstAddress If destination address (byte address).
|
||||
* @param dstStride Destination stride (number of bytes to advance to next line).
|
||||
* @param dstPixelOffset Destination pixel offset (first pixel in destination byte).
|
||||
* @param width The width of area (in pixels).
|
||||
* @param height The height of area (in pixels).
|
||||
*/
|
||||
void copyRect(const uint8_t* srcAddress, uint16_t srcStride, uint8_t srcPixelOffset, uint8_t* RESTRICT dstAddress, uint16_t dstStride, uint8_t dstPixelOffset, uint16_t width, uint16_t height) const;
|
||||
|
||||
private:
|
||||
DrawTextureMapScanLineBase* textureMapper_GRAY2_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_GRAY2_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_GRAY2_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_GRAY2_Opaque_BilinearInterpolation_GA;
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
uint16_t xy10 = 16 * x;
|
||||
uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return (c00 * xy00 + c10 * xy10) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t c01, uint8_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
uint16_t xy11 = x * y;
|
||||
uint16_t xy10 = 16 * x - xy11;
|
||||
uint16_t xy01 = 16 * y - xy11;
|
||||
uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return (c00 * xy00 + c10 * xy10 + c01 * xy01 + c11 * xy11) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t div255_2(uint16_t value)
|
||||
{
|
||||
return div255(value * 0x55) >> 6;
|
||||
}
|
||||
|
||||
class DrawTextureMapScanLineBase2 : public DrawTextureMapScanLineBase
|
||||
{
|
||||
protected:
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckBilinearInterpolation(uint32_t& destOffset, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckNearestNeighbor(uint32_t& destOffset, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
};
|
||||
|
||||
class TextureMapper_GRAY2_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase2
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_GRAY2_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase2
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_GRAY2_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase2
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_GRAY2_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase2
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_GA : public DrawTextureMapScanLineBase2
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destAddress, const uint32_t destOffset, const uint8_t a4, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_GA : public DrawTextureMapScanLineBase2
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destAddress, const uint32_t destOffset, const uint16_t* const textureBits, const uint32_t offset, const int16_t bitmapStride, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destAddress, const uint32_t destOffset, const uint16_t* const textureBits, const uint16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Shift value to get the right pixel in a byte.
|
||||
*
|
||||
* @param offset The offset.
|
||||
*
|
||||
* @return The shift value.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION int LCD2shiftVal(int offset)
|
||||
{
|
||||
#ifdef USE_LSB
|
||||
return (offset & 3) << 1;
|
||||
#else
|
||||
return (3 - (offset & 3)) << 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pixel from buffer/image.
|
||||
*
|
||||
* @param addr The address.
|
||||
* @param offset The offset.
|
||||
*
|
||||
* @return The pixel value.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION uint8_t LCD2getPixel(const uint8_t* addr, int offset)
|
||||
{
|
||||
return (addr[offset >> 2] >> LCD2shiftVal(offset)) & 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pixel from buffer/image.
|
||||
*
|
||||
* @param addr The address.
|
||||
* @param offset The offset.
|
||||
*
|
||||
* @return The pixel value.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION uint8_t LCD2getPixel(const uint16_t* addr, int offset)
|
||||
{
|
||||
return LCD2getPixel(reinterpret_cast<const uint8_t*>(addr), offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pixel in buffer.
|
||||
*
|
||||
* @param [in] addr The address.
|
||||
* @param offset The offset.
|
||||
* @param value The value.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION void LCD2setPixel(uint8_t* addr, int offset, uint8_t value)
|
||||
{
|
||||
int shift = LCD2shiftVal(offset);
|
||||
addr[offset >> 2] = (addr[offset >> 2] & ~(3 << shift)) | ((value & 3) << shift);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pixel in buffer.
|
||||
*
|
||||
* @param [in] addr The address.
|
||||
* @param offset The offset.
|
||||
* @param value The value.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION void LCD2setPixel(uint16_t* addr, int offset, uint8_t value)
|
||||
{
|
||||
LCD2setPixel(reinterpret_cast<uint8_t*>(addr), offset, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class LCD2DebugPrinter implements the DebugPrinter interface for printing debug messages
|
||||
* on top of 24bit framebuffer.
|
||||
*
|
||||
* @see DebugPrinter
|
||||
*/
|
||||
class LCD2DebugPrinter : public DebugPrinter
|
||||
{
|
||||
public:
|
||||
virtual void draw(const Rect& rect) const;
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // LCD2BPP_HPP
|
||||
@@ -0,0 +1,932 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/lcd/LCD32bpp.hpp
|
||||
*
|
||||
* Declares the touchgfx::LCD32bpp and touchgfx::LCD32DebugPrinter classes.
|
||||
*/
|
||||
#ifndef LCD32BPP_HPP
|
||||
#define LCD32BPP_HPP
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <touchgfx/Bitmap.hpp>
|
||||
#include <touchgfx/Font.hpp>
|
||||
#include <touchgfx/TextProvider.hpp>
|
||||
#include <touchgfx/TextureMapTypes.hpp>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
#include <touchgfx/hal/HAL.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
#include <touchgfx/lcd/LCD.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
#undef LCD
|
||||
|
||||
/**
|
||||
* This class contains the various low-level drawing routines for drawing bitmaps, texts and
|
||||
* rectangles on 16 bits per pixel displays.
|
||||
*
|
||||
* @see LCD
|
||||
*
|
||||
* @note All coordinates are expected to be in absolute coordinates!
|
||||
*/
|
||||
class LCD32bpp : public LCD
|
||||
{
|
||||
public:
|
||||
LCD32bpp();
|
||||
|
||||
|
||||
virtual void drawPartialBitmap(const Bitmap& bitmap, int16_t x, int16_t y, const Rect& rect, uint8_t alpha = 255, bool useOptimized = true);
|
||||
|
||||
virtual void blitCopy(const uint16_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual void blitCopy(const uint8_t* sourceData, Bitmap::BitmapFormat sourceFormat, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual uint16_t* copyFrameBufferRegionToMemory(const Rect& visRegion, const Rect& absRegion, const BitmapId bitmapId);
|
||||
|
||||
virtual void fillRect(const Rect& rect, colortype color, uint8_t alpha = 255);
|
||||
|
||||
virtual uint8_t bitDepth() const
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
virtual Bitmap::BitmapFormat framebufferFormat() const
|
||||
{
|
||||
return Bitmap::ARGB8888;
|
||||
}
|
||||
|
||||
virtual uint16_t framebufferStride() const
|
||||
{
|
||||
return getFramebufferStride();
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffer stride in bytes. The distance (in bytes) from the start of one
|
||||
* framebuffer row, to the next.
|
||||
*
|
||||
* @return The number of bytes in one framebuffer row.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint16_t getFramebufferStride()
|
||||
{
|
||||
assert(HAL::FRAME_BUFFER_WIDTH > 0 && "HAL has not been initialized yet");
|
||||
return HAL::FRAME_BUFFER_WIDTH * 4;
|
||||
}
|
||||
|
||||
virtual colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) const
|
||||
{
|
||||
return getColorFromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a color representation to be used on the LCD, based on 24 bit RGB values.
|
||||
*
|
||||
* @param red Value of the red part (0-255).
|
||||
* @param green Value of the green part (0-255).
|
||||
* @param blue Value of the blue part (0-255).
|
||||
*
|
||||
* @return The color from RGB.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
return 0xFF000000 | (red << 16) | (green << 8) | (blue);
|
||||
}
|
||||
|
||||
virtual uint8_t getRedColor(colortype color) const
|
||||
{
|
||||
return getRedFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets red from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The red from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getRedFromColor(colortype color)
|
||||
{
|
||||
return (color >> 16) & 0xFF;
|
||||
}
|
||||
|
||||
virtual uint8_t getGreenColor(colortype color) const
|
||||
{
|
||||
return getGreenFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets green from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The green from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getGreenFromColor(colortype color)
|
||||
{
|
||||
return (color >> 8) & 0xFF;
|
||||
}
|
||||
|
||||
virtual uint8_t getBlueColor(colortype color) const
|
||||
{
|
||||
return getBlueFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets blue from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The blue from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getBlueFromColor(colortype color)
|
||||
{
|
||||
return color & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for all image formats. This allows drawing any image
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms, but might use a lot of
|
||||
* memory for the drawing algorithms.
|
||||
*/
|
||||
void enableTextureMapperAll();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB565 image format. This allows drawing L8_RGB565
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB565_BilinearInterpolation,
|
||||
* enableTextureMapperL8_RGB565_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB565();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB565 image format. This allows drawing L8_RGB565
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB565, enableTextureMapperL8_RGB565_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB565_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB565 image format. This allows drawing L8_RGB565
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB565, enableTextureMapperL8_RGB565_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperL8_RGB565_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888_BilinearInterpolation,
|
||||
* enableTextureMapperL8_RGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888, enableTextureMapperL8_RGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_RGB888 image format. This allows drawing L8_RGB888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_RGB888, enableTextureMapperL8_RGB888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperL8_RGB888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperL8_ARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888, enableTextureMapperL8_ARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for L8_ARGB8888 image format. This allows drawing
|
||||
* L8_ARGB8888 images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperL8_ARGB8888, enableTextureMapperL8_ARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperL8_ARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGB565 image format. This allows drawing RGB565
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*/
|
||||
void enableTextureMapperRGB565();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for Opaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565, enableTextureMapperRGB565_NonOpaque_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperRGB565_Opaque_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for NonOpaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565, enableTextureMapperRGB565_Opaque_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperRGB565_NonOpaque_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for Opaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565, enableTextureMapperRGB565_NonOpaque_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperRGB565_Opaque_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for NonOpaque RGB565 image format. This allows drawing
|
||||
* RGB565 images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB565, enableTextureMapperRGB565_Opaque_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperRGB565_NonOpaque_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGB888 image format. This allows drawing RGB888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperRGB888_BilinearInterpolation,
|
||||
* enableTextureMapperRGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperRGB888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGB888 image format. This allows drawing RGB888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB888, enableTextureMapperRGB888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperRGB888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGB888 image format. This allows drawing RGB888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGB888, enableTextureMapperRGB888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperRGB888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperA4_BilinearInterpolation, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperA4_NearestNeighbor();
|
||||
|
||||
protected:
|
||||
virtual DrawTextureMapScanLineBase* getTextureMapperDrawScanLine(const TextureSurface& texture, RenderingVariant renderVariant, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next pixel.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next pixel.
|
||||
*/
|
||||
static int nextPixel(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next line.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next line.
|
||||
*/
|
||||
static int nextLine(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
virtual void drawGlyph(uint16_t* wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect& invalidatedArea, const GlyphNode* glyph, const uint8_t* glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation);
|
||||
|
||||
/**
|
||||
* Blits a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified. If RGB888 is not supported by the DMA a software blend is performed.
|
||||
*
|
||||
* @param sourceData16 The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 24- bits RGB888 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyRGB888(const uint16_t* sourceData16, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified. If! RGB565 is not supported by the DMA a software blend is performed.
|
||||
*
|
||||
* @param sourceData16 The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 16- bits RGB565 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyRGB565(const uint16_t* sourceData16, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if indexed format is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyL8(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if L8_ARGB8888 is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries stored as 32-
|
||||
* bits (ARGB8888) format.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyL8_ARGB8888(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if L8_RGB888 is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries stored as 32-
|
||||
* bits (RGB888) format.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyL8_RGB888(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blits a 2D indexed 8-bit source to the framebuffer performing alpha-blending per
|
||||
* pixel as specified if L8_RGB565 is not supported by the DMA a software blend is
|
||||
* performed.
|
||||
*
|
||||
* @param sourceData The source-indexes pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8- bits indexes.
|
||||
* @param clutData The source-clut pointer (points to the beginning of the CLUT color
|
||||
* format and size data followed by colors entries stored as 16-
|
||||
* bits (RGB565) format.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyL8_RGB565(const uint8_t* sourceData, const uint8_t* clutData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
private:
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB565_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_RGB888_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_NonOpaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB565_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB888_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB888_Opaque_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB888_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGB888_Opaque_BilinearInterpolation_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_NoGA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_NoGA;
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t expandRgb565(uint16_t c)
|
||||
{
|
||||
return ((c & 0x07E0) << 16) | (c & ~0x07E0);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint16_t compactRgb565(uint32_t c)
|
||||
{
|
||||
return ((c >> 16) & 0x07E0) | (c & ~0x07E0);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t convertRgb565toArgb8888(uint16_t rgb565)
|
||||
{
|
||||
uint8_t r = (rgb565 & 0xF800) >> 8;
|
||||
r |= r >> 5;
|
||||
uint8_t g = (rgb565 & 0x07E0) >> 3;
|
||||
g |= g >> 6;
|
||||
uint8_t b = rgb565 << 3;
|
||||
b |= b >> 5;
|
||||
return (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static void copy888(const uint8_t* const rgb888, uint8_t* const destBits)
|
||||
{
|
||||
destBits[0] = rgb888[0];
|
||||
destBits[1] = rgb888[1];
|
||||
destBits[2] = rgb888[2];
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static void alphaBlend888(const uint8_t r, const uint8_t g, const uint8_t b, uint8_t* const destBits, const uint8_t alpha, const uint8_t ialpha)
|
||||
{
|
||||
destBits[0] = div255(b * alpha + destBits[0] * ialpha);
|
||||
destBits[1] = div255(g * alpha + destBits[1] * ialpha);
|
||||
destBits[2] = div255(r * alpha + destBits[2] * ialpha);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static void alphaBlend888(const uint8_t* const rgb888, uint8_t* const destBits, const uint8_t alpha, const uint8_t ialpha)
|
||||
{
|
||||
alphaBlend888(rgb888[2], rgb888[1], rgb888[0], destBits, alpha, ialpha);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static void alphaBlend565(const uint16_t rgb565, uint8_t* const destBits, const uint8_t alpha, const uint8_t ialpha)
|
||||
{
|
||||
const uint8_t r = (rgb565 & 0xF800) >> 8;
|
||||
const uint8_t g = (rgb565 & 0x07E0) >> 3;
|
||||
const uint8_t b = rgb565 << 3;
|
||||
alphaBlend888(r, g, b, destBits, alpha, ialpha);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint16_t bilinearInterpolate565(uint16_t c00, uint16_t c10, uint16_t c01, uint16_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
uint32_t a00 = expandRgb565(c00);
|
||||
uint32_t a10 = expandRgb565(c10);
|
||||
uint32_t a01 = expandRgb565(c01);
|
||||
uint32_t a11 = expandRgb565(c11);
|
||||
|
||||
uint8_t xy = (x * y) >> 3;
|
||||
return compactRgb565((a00 * (32 - 2 * y - 2 * x + xy) + a10 * (2 * x - xy) + a01 * (2 * y - xy) + a11 * xy) >> 5);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint16_t bilinearInterpolate565(uint16_t c00, uint16_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
uint32_t a00 = expandRgb565(c00);
|
||||
uint32_t a10 = expandRgb565(c10);
|
||||
|
||||
return compactRgb565((a00 * (32 - 2 * x) + a10 * (2 * x)) >> 5);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
uint16_t xy10 = 16 * x;
|
||||
uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return (c00 * xy00 + c10 * xy10) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t c01, uint8_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
uint16_t xy11 = x * y;
|
||||
uint16_t xy10 = 16 * x - xy11;
|
||||
uint16_t xy01 = 16 * y - xy11;
|
||||
uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return (c00 * xy00 + c10 * xy10 + c01 * xy01 + c11 * xy11) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
uint16_t xy10 = 16 * x;
|
||||
uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * xy10) >> 8) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * xy10) >> 8) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint32_t c01, uint32_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
uint16_t xy11 = x * y;
|
||||
uint16_t xy10 = 16 * x - xy11;
|
||||
uint16_t xy01 = 16 * y - xy11;
|
||||
uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * xy10 + (c01 & 0xFF00FF) * xy01 + (c11 & 0xFF00FF) * xy11) >> 8) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * xy10 + (c01 & 0x00FF00) * xy01 + (c11 & 0x00FF00) * xy11) >> 8) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return div255rb((val & 0xFF00FF) * factor) | div255g((val & 0x00FF00) * factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888_FFcheck(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return factor < 0xFF ? div255_888(val, factor) : val;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div31rb(uint16_t val, uint8_t factor)
|
||||
{
|
||||
uint32_t val32 = (val & 0xF81F) * (factor >> 3);
|
||||
return ((val32 + 0x0801 + ((val32 >> 5) & 0xF81F)) >> 5) & 0xF81F;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div31g(uint16_t val, uint8_t factor)
|
||||
{
|
||||
uint32_t val32 = (val & 0x07E0) * factor;
|
||||
return ((val32 + 0x0020 + (val32 >> 8)) >> 8) & 0x07E0;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_565(uint16_t val, uint8_t factor)
|
||||
{
|
||||
return div31rb(val, factor) | div31g(val, factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_565_FFcheck(uint16_t val, uint8_t factor)
|
||||
{
|
||||
return factor < 0xFF ? div31rb(val, factor) | div31g(val, factor) : val;
|
||||
}
|
||||
|
||||
class DrawTextureMapScanLineBase32 : public DrawTextureMapScanLineBase
|
||||
{
|
||||
protected:
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckNearestNeighbor(uint32_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckBilinearInterpolation(uint32_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB565_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint8_t* const textureBits8, const uint16_t* const palette16, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_RGB888_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint8_t* const textureBits8, const uint8_t* const palette8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_L8_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint8_t* const textureBits8, const uint32_t* const palette32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint16_t* const textureBits, const uint8_t* alphaBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint16_t* const textureBits, const uint8_t* alphaBits, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint16_t* const textureBits, const uint8_t* alphaBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint16_t* const textureBits, const uint8_t* alphaBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_NonOpaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint16_t* const textureBits, const uint8_t* alphaBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint16_t* const textureBits, const uint8_t* alphaBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB565_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB888_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB888_Opaque_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int UInt, const int VInt);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB888_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGB888_Opaque_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint8_t* const textureBits8, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t a4, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint8_t a4);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_GA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_NoGA : public DrawTextureMapScanLineBase32
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint32_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
void writePixelOnEdge(uint32_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* The class LCD32DebugPrinter implements the DebugPrinter interface for printing debug messages
|
||||
* on top of 32bit framebuffer.
|
||||
*
|
||||
* @see DebugPrinter
|
||||
*/
|
||||
class LCD32DebugPrinter : public DebugPrinter
|
||||
{
|
||||
public:
|
||||
virtual void draw(const Rect& rect) const;
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // LCD32BPP_HPP
|
||||
@@ -0,0 +1,443 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/lcd/LCD4bpp.hpp
|
||||
*
|
||||
* Declares the touchgfx::LCD4bpp and touchgfx::LCD4DebugPrinter classes.
|
||||
*/
|
||||
#ifndef LCD4BPP_HPP
|
||||
#define LCD4BPP_HPP
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <touchgfx/Bitmap.hpp>
|
||||
#include <touchgfx/Font.hpp>
|
||||
#include <touchgfx/TextProvider.hpp>
|
||||
#include <touchgfx/TextureMapTypes.hpp>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
#include <touchgfx/hal/HAL.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
#include <touchgfx/lcd/LCD.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
#undef LCD
|
||||
#define USE_LSB
|
||||
|
||||
/**
|
||||
* This class contains the various low-level drawing routines for drawing bitmaps, texts and
|
||||
* rectangles on 4 bits per pixel grayscale displays.
|
||||
*
|
||||
* @see LCD
|
||||
*
|
||||
* @note All coordinates are expected to be in absolute coordinates!
|
||||
*/
|
||||
class LCD4bpp : public LCD
|
||||
{
|
||||
public:
|
||||
LCD4bpp();
|
||||
|
||||
|
||||
virtual void drawPartialBitmap(const Bitmap& bitmap, int16_t x, int16_t y, const Rect& rect, uint8_t alpha = 255, bool useOptimized = true);
|
||||
|
||||
virtual void blitCopy(const uint16_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual void blitCopy(const uint8_t* sourceData, Bitmap::BitmapFormat sourceFormat, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual uint16_t* copyFrameBufferRegionToMemory(const Rect& visRegion, const Rect& absRegion, const BitmapId bitmapId);
|
||||
|
||||
virtual void fillRect(const Rect& rect, colortype color, uint8_t alpha = 255);
|
||||
|
||||
virtual uint8_t bitDepth() const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
virtual Bitmap::BitmapFormat framebufferFormat() const
|
||||
{
|
||||
return Bitmap::GRAY4;
|
||||
}
|
||||
|
||||
virtual uint16_t framebufferStride() const
|
||||
{
|
||||
return getFramebufferStride();
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffer stride in bytes. The distance (in bytes) from the start of one
|
||||
* framebuffer row, to the next.
|
||||
*
|
||||
* @return The number of bytes in one framebuffer row.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint16_t getFramebufferStride()
|
||||
{
|
||||
assert(HAL::FRAME_BUFFER_WIDTH > 0 && "HAL has not been initialized yet");
|
||||
return (HAL::FRAME_BUFFER_WIDTH + 1) / 2;
|
||||
}
|
||||
|
||||
virtual colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) const
|
||||
{
|
||||
return getColorFromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a color representation to be used on the LCD, based on 24 bit RGB values.
|
||||
*
|
||||
* @param red Value of the red part (0-255).
|
||||
* @param green Value of the green part (0-255).
|
||||
* @param blue Value of the blue part (0-255).
|
||||
*
|
||||
* @return The color representation depending on LCD color format.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
// Find the GRAY value (http://en.wikipedia.org/wiki/Luma_%28video%29) rounded to nearest integer
|
||||
return (red * 54 + green * 183 + blue * 19) >> 12;
|
||||
}
|
||||
|
||||
virtual uint8_t getRedColor(colortype color) const
|
||||
{
|
||||
return getRedFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets red from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The red from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getRedFromColor(colortype color)
|
||||
{
|
||||
return (color & 0xF) * 0x11;
|
||||
}
|
||||
|
||||
virtual uint8_t getGreenColor(colortype color) const
|
||||
{
|
||||
return getGreenFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets green from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The green from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getGreenFromColor(colortype color)
|
||||
{
|
||||
return (color & 0xF) * 0x11;
|
||||
}
|
||||
|
||||
virtual uint8_t getBlueColor(colortype color) const
|
||||
{
|
||||
return getBlueFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets blue from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The blue from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getBlueFromColor(colortype color)
|
||||
{
|
||||
return (color & 0xF) * 0x11;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for all image formats. This allows drawing any image
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms, but might use a lot of
|
||||
* memory for the drawing algorithms.
|
||||
*/
|
||||
void enableTextureMapperAll();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for GRAY4 image format. This allows drawing GRAY4 images
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperGRAY4_BilinearInterpolation,
|
||||
* enableTextureMapperGRAY4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperGRAY4();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for GRAY4 image format. This allows drawing GRAY4 images
|
||||
* using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperGRAY4, enableTextureMapperGRAY4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperGRAY4_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for GRAY4 image format. This allows drawing GRAY4 images
|
||||
* using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperGRAY4, enableTextureMapperGRAY4_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperGRAY4_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperA4_BilinearInterpolation, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperA4_NearestNeighbor();
|
||||
|
||||
protected:
|
||||
virtual DrawTextureMapScanLineBase* getTextureMapperDrawScanLine(const TextureSurface& texture, RenderingVariant renderVariant, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next pixel.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next pixel.
|
||||
*/
|
||||
static int nextPixel(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next line.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next line.
|
||||
*/
|
||||
static int nextLine(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
virtual void drawGlyph(uint16_t* wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect& invalidatedArea, const GlyphNode* glyph, const uint8_t* glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation);
|
||||
|
||||
/**
|
||||
* Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified Performs always a software blend.
|
||||
*
|
||||
* @param sourceData16 The source-array pointer (points to the beginning of the
|
||||
* data). The sourceData must be stored as 4bpp GRAY4 values.
|
||||
* @param sourceAlphaData The alpha channel array pointer (points to the beginning of
|
||||
* the data)
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole
|
||||
* image (255 = solid, no blending)
|
||||
*/
|
||||
static void blitCopyAlphaPerPixel(const uint16_t* sourceData16, const uint8_t* sourceAlphaData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Copies a rectangular area.
|
||||
*
|
||||
* @param srcAddress Source address (byte address).
|
||||
* @param srcStride Source stride (number of bytes to advance to next line).
|
||||
* @param srcPixelOffset Source pixel offset (first pixel in first source byte).
|
||||
* @param [in] dstAddress If destination address (byte address).
|
||||
* @param dstStride Destination stride (number of bytes to advance to next line).
|
||||
* @param dstPixelOffset Destination pixel offset (first pixel in destination byte).
|
||||
* @param width The width of area (in pixels).
|
||||
* @param height The height of area (in pixels).
|
||||
*/
|
||||
void copyRect(const uint8_t* srcAddress, uint16_t srcStride, uint8_t srcPixelOffset, uint8_t* RESTRICT dstAddress, uint16_t dstStride, uint8_t dstPixelOffset, uint16_t width, uint16_t height) const;
|
||||
|
||||
private:
|
||||
DrawTextureMapScanLineBase* textureMapper_GRAY4_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_GRAY4_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_GRAY4_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_GRAY4_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_GA;
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
uint16_t xy10 = 16 * x;
|
||||
uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return (c00 * xy00 + c10 * xy10) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t c01, uint8_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
uint16_t xy11 = x * y;
|
||||
uint16_t xy10 = 16 * x - xy11;
|
||||
uint16_t xy01 = 16 * y - xy11;
|
||||
uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return (c00 * xy00 + c10 * xy10 + c01 * xy01 + c11 * xy11) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t div255_4(uint16_t value)
|
||||
{
|
||||
return div255(value * 0x11) >> 4;
|
||||
}
|
||||
|
||||
class DrawTextureMapScanLineBase4 : public DrawTextureMapScanLineBase
|
||||
{
|
||||
protected:
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckBilinearInterpolation(uint32_t& destOffset, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckNearestNeighbor(uint32_t& destOffset, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
};
|
||||
|
||||
class TextureMapper_GRAY4_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase4
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_GRAY4_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase4
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_GRAY4_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase4
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const uint8_t* const alphaBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_GRAY4_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase4
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* destAddress, uint32_t const destOffset, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_GA : public DrawTextureMapScanLineBase4
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destAddress, const uint32_t destOffset, const uint8_t a4, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_GA : public DrawTextureMapScanLineBase4
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint16_t* const destAddress, const uint32_t destOffset, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint16_t* const destAddress, const uint32_t destOffset, const uint16_t* const textureBits, const uint16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Get pixel from buffer/image.
|
||||
*
|
||||
* @param addr The address.
|
||||
* @param offset The offset.
|
||||
*
|
||||
* @return The pixel value.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION uint8_t LCD4getPixel(const uint8_t* addr, int offset)
|
||||
{
|
||||
uint8_t data = addr[offset / 2];
|
||||
#ifdef USE_LSB
|
||||
return (offset & 1) ? data >> 4 : data & 0xF;
|
||||
#else
|
||||
return (offset & 1) ? data & 0xF : data >> 4;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pixel from buffer/image.
|
||||
*
|
||||
* @param addr The address.
|
||||
* @param offset The offset.
|
||||
*
|
||||
* @return The pixel value.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION uint8_t LCD4getPixel(const uint16_t* addr, int offset)
|
||||
{
|
||||
return LCD4getPixel(reinterpret_cast<const uint8_t*>(addr), offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pixel in buffer.
|
||||
*
|
||||
* @param [in] addr The address.
|
||||
* @param offset The offset.
|
||||
* @param value The value.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION void LCD4setPixel(uint8_t* addr, int offset, uint8_t value)
|
||||
{
|
||||
uint8_t data = addr[offset / 2];
|
||||
#ifdef USE_LSB
|
||||
addr[offset / 2] = (offset & 1) ? (data & 0x0F) | (value << 4) : (data & 0xF0) | value;
|
||||
#else
|
||||
addr[offset / 2] = (offset & 1) ? (data & 0xF0) | value : (data & 0x0F) | (value << 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pixel in buffer.
|
||||
*
|
||||
* @param [in] addr The address.
|
||||
* @param offset The offset.
|
||||
* @param value The value.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION void LCD4setPixel(uint16_t* addr, int offset, uint8_t value)
|
||||
{
|
||||
LCD4setPixel(reinterpret_cast<uint8_t*>(addr), offset, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class LCD4DebugPrinter implements the DebugPrinter interface for printing debug messages
|
||||
* on top of 8bit framebuffer.
|
||||
*
|
||||
* @see DebugPrinter
|
||||
*/
|
||||
class LCD4DebugPrinter : public DebugPrinter
|
||||
{
|
||||
public:
|
||||
virtual void draw(const Rect& rect) const;
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // LCD4BPP_HPP
|
||||
@@ -0,0 +1,464 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/lcd/LCD8bpp_ABGR2222.hpp
|
||||
*
|
||||
* Declares the touchgfx::LCD8bpp_ABGR2222 and touchgfx::LCD8ABGR2222DebugPrinter classes.
|
||||
*/
|
||||
#ifndef LCD8BPP_ABGR2222_HPP
|
||||
#define LCD8BPP_ABGR2222_HPP
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <touchgfx/Bitmap.hpp>
|
||||
#include <touchgfx/Font.hpp>
|
||||
#include <touchgfx/TextProvider.hpp>
|
||||
#include <touchgfx/TextureMapTypes.hpp>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
#include <touchgfx/hal/HAL.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
#include <touchgfx/lcd/LCD.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
#undef LCD
|
||||
|
||||
/**
|
||||
* This class contains the various low-level drawing routines for drawing bitmaps, texts and
|
||||
* rectangles on 16 bits per pixel displays.
|
||||
*
|
||||
* @see LCD
|
||||
*
|
||||
* @note All coordinates are expected to be in absolute coordinates!
|
||||
*/
|
||||
class LCD8bpp_ABGR2222 : public LCD
|
||||
{
|
||||
public:
|
||||
LCD8bpp_ABGR2222();
|
||||
|
||||
|
||||
virtual void drawPartialBitmap(const Bitmap& bitmap, int16_t x, int16_t y, const Rect& rect, uint8_t alpha = 255, bool useOptimized = true);
|
||||
|
||||
virtual void blitCopy(const uint16_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual void blitCopy(const uint8_t* sourceData, Bitmap::BitmapFormat sourceFormat, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual uint16_t* copyFrameBufferRegionToMemory(const Rect& visRegion, const Rect& absRegion, const BitmapId bitmapId);
|
||||
|
||||
virtual void fillRect(const Rect& rect, colortype color, uint8_t alpha = 255);
|
||||
|
||||
virtual uint8_t bitDepth() const
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
virtual Bitmap::BitmapFormat framebufferFormat() const
|
||||
{
|
||||
return Bitmap::ABGR2222;
|
||||
}
|
||||
|
||||
virtual uint16_t framebufferStride() const
|
||||
{
|
||||
return getFramebufferStride();
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffer stride in bytes. The distance (in bytes) from the start of one
|
||||
* framebuffer row, to the next.
|
||||
*
|
||||
* @return The number of bytes in one framebuffer row.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint16_t getFramebufferStride()
|
||||
{
|
||||
assert(HAL::FRAME_BUFFER_WIDTH > 0 && "HAL has not been initialized yet");
|
||||
return HAL::FRAME_BUFFER_WIDTH;
|
||||
}
|
||||
|
||||
virtual colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) const
|
||||
{
|
||||
return getColorFromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets color from RGB.
|
||||
*
|
||||
* @param red The red.
|
||||
* @param green The green.
|
||||
* @param blue The blue.
|
||||
*
|
||||
* @return The color from RGB.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
return ((red & 0xC0) >> 6) | ((green & 0xC0) >> 4) | ((blue & 0xC0) >> 2);
|
||||
}
|
||||
|
||||
virtual uint8_t getRedColor(colortype color) const
|
||||
{
|
||||
return getRedFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets red from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The red from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getRedFromColor(colortype color)
|
||||
{
|
||||
return (color & 0x03) * 0x55;
|
||||
}
|
||||
|
||||
virtual uint8_t getGreenColor(colortype color) const
|
||||
{
|
||||
return getGreenFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets green from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The green from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getGreenFromColor(colortype color)
|
||||
{
|
||||
return ((color & 0x0C) >> 2) * 0x55;
|
||||
}
|
||||
|
||||
virtual uint8_t getBlueColor(colortype color) const
|
||||
{
|
||||
return getBlueFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets blue from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The blue from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getBlueFromColor(colortype color)
|
||||
{
|
||||
return ((color & 0x30) >> 4) * 0x55;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for all image formats. This allows drawing any image
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms, but might use a lot of
|
||||
* memory for the drawing algorithms.
|
||||
*/
|
||||
void enableTextureMapperAll();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ABGR2222 image format. This allows drawing ABGR2222
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperABGR2222_BilinearInterpolation,
|
||||
* enableTextureMapperABGR2222_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperABGR2222();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ABGR2222 image format. This allows drawing ABGR2222
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperABGR2222, enableTextureMapperABGR2222_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperABGR2222_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ABGR2222 image format. This allows drawing ABGR2222
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperABGR2222, enableTextureMapperABGR2222_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperABGR2222_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperA4_BilinearInterpolation, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperA4_NearestNeighbor();
|
||||
|
||||
protected:
|
||||
virtual DrawTextureMapScanLineBase* getTextureMapperDrawScanLine(const TextureSurface& texture, RenderingVariant renderVariant, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next pixel.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next pixel.
|
||||
*/
|
||||
static int nextPixel(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next line.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next line.
|
||||
*/
|
||||
static int nextLine(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
virtual void drawGlyph(uint16_t* wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect& invalidatedArea, const GlyphNode* glyph, const uint8_t* glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation);
|
||||
|
||||
/**
|
||||
* Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified if ARGB8888 is not supported by the DMA a software blend is performed.
|
||||
*
|
||||
* @param sourceData The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 32- bits ARGB8888 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyARGB8888(const uint32_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified Performs always a software blend.
|
||||
*
|
||||
* @param sourceData16 The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8-bits ABGR2222 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyAlphaPerPixel(const uint16_t* sourceData16, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
private:
|
||||
DrawTextureMapScanLineBase* textureMapper_ABGR2222_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ABGR2222_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ABGR2222_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ABGR2222_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_GA;
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
const uint16_t xy10 = 16 * x;
|
||||
const uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return (c00 * xy00 + c10 * xy10) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t c01, uint8_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
const uint16_t xy11 = x * y;
|
||||
const uint16_t xy10 = 16 * x - xy11;
|
||||
const uint16_t xy01 = 16 * y - xy11;
|
||||
const uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return (c00 * xy00 + c10 * xy10 + c01 * xy01 + c11 * xy11) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION uint32_t convertABGR2222toARGB8888(colortype col) const
|
||||
{
|
||||
return (((col & 0xC0) << 18) | ((col & 0x03) << 16) | ((col & 0x0C) << 6) | ((col & 0x30) >> 4)) * 0x55;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t convertABGR2222toRGB888(uint8_t val)
|
||||
{
|
||||
return (((val & 0x03) << 16) | ((val & 0x0C) << 6) | ((val & 0x30) >> 4)) * 0x55;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t convertRGB888toXBGR2222(uint32_t val)
|
||||
{
|
||||
val &= 0xC0C0C0;
|
||||
return (val >> 2) | (val >> 12) | (val >> 22);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint32_t c01, uint32_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
const uint16_t xy11 = x * y;
|
||||
const uint16_t xy10 = 16 * x - xy11;
|
||||
const uint16_t xy01 = 16 * y - xy11;
|
||||
const uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * xy10 + (c01 & 0xFF00FF) * xy01 + (c11 & 0xFF00FF) * xy11) >> 8) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * xy10 + (c01 & 0x00FF00) * xy01 + (c11 & 0x00FF00) * xy11) >> 8) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return div255rb((val & 0xFF00FF) * factor) | div255g((val & 0x00FF00) * factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888_FFcheck(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return factor < 0xFF ? div255_888(val, factor) : val;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t alphaBlend(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t alpha, const uint8_t fbr, const uint8_t fbg, const uint8_t fbb, const uint8_t ialpha)
|
||||
{
|
||||
return getColorFromRGB(div255(r * alpha + fbr * ialpha), div255(g * alpha + fbg * ialpha), div255(b * alpha + fbb * ialpha));
|
||||
}
|
||||
|
||||
class DrawTextureMapScanLineBase8 : public DrawTextureMapScanLineBase
|
||||
{
|
||||
protected:
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckNearestNeighbor(uint8_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckBilinearInterpolation(uint8_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
};
|
||||
|
||||
class TextureMapper_ABGR2222_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ABGR2222_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ABGR2222_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ABGR2222_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t a4, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* The class LCD8ABGR2222DebugPrinter implements the DebugPrinter interface for printing debug
|
||||
* messages on top of 8bit framebuffer.
|
||||
*
|
||||
* @see DebugPrinter
|
||||
*/
|
||||
class LCD8ABGR2222DebugPrinter : public DebugPrinter
|
||||
{
|
||||
public:
|
||||
virtual void draw(const Rect& rect) const;
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // LCD8BPP_ABGR2222_HPP
|
||||
@@ -0,0 +1,464 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/lcd/LCD8bpp_ARGB2222.hpp
|
||||
*
|
||||
* Declares the touchgfx::LCD8bpp_ARGB2222 and touchgfx::LCD8ARGB2222DebugPrinter classes.
|
||||
*/
|
||||
#ifndef LCD8BPP_ARGB2222_HPP
|
||||
#define LCD8BPP_ARGB2222_HPP
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <touchgfx/Bitmap.hpp>
|
||||
#include <touchgfx/Font.hpp>
|
||||
#include <touchgfx/TextProvider.hpp>
|
||||
#include <touchgfx/TextureMapTypes.hpp>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
#include <touchgfx/hal/HAL.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
#include <touchgfx/lcd/LCD.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
#undef LCD
|
||||
|
||||
/**
|
||||
* This class contains the various low-level drawing routines for drawing bitmaps, texts and
|
||||
* rectangles on 16 bits per pixel displays.
|
||||
*
|
||||
* @see LCD
|
||||
*
|
||||
* @note All coordinates are expected to be in absolute coordinates!
|
||||
*/
|
||||
class LCD8bpp_ARGB2222 : public LCD
|
||||
{
|
||||
public:
|
||||
LCD8bpp_ARGB2222();
|
||||
|
||||
|
||||
virtual void drawPartialBitmap(const Bitmap& bitmap, int16_t x, int16_t y, const Rect& rect, uint8_t alpha = 255, bool useOptimized = true);
|
||||
|
||||
virtual void blitCopy(const uint16_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual void blitCopy(const uint8_t* sourceData, Bitmap::BitmapFormat sourceFormat, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual uint16_t* copyFrameBufferRegionToMemory(const Rect& visRegion, const Rect& absRegion, const BitmapId bitmapId);
|
||||
|
||||
virtual void fillRect(const Rect& rect, colortype color, uint8_t alpha = 255);
|
||||
|
||||
virtual uint8_t bitDepth() const
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
virtual Bitmap::BitmapFormat framebufferFormat() const
|
||||
{
|
||||
return Bitmap::ARGB2222;
|
||||
}
|
||||
|
||||
virtual uint16_t framebufferStride() const
|
||||
{
|
||||
return getFramebufferStride();
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffer stride in bytes. The distance (in bytes) from the start of one
|
||||
* framebuffer row, to the next.
|
||||
*
|
||||
* @return The number of bytes in one framebuffer row.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint16_t getFramebufferStride()
|
||||
{
|
||||
assert(HAL::FRAME_BUFFER_WIDTH > 0 && "HAL has not been initialized yet");
|
||||
return HAL::FRAME_BUFFER_WIDTH;
|
||||
}
|
||||
|
||||
virtual colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) const
|
||||
{
|
||||
return getColorFromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets color from RGB.
|
||||
*
|
||||
* @param red The red.
|
||||
* @param green The green.
|
||||
* @param blue The blue.
|
||||
*
|
||||
* @return The color from RGB.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
return ((red & 0xC0) >> 2) | ((green & 0xC0) >> 4) | ((blue & 0xC0) >> 6);
|
||||
}
|
||||
|
||||
virtual uint8_t getRedColor(colortype color) const
|
||||
{
|
||||
return getRedFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets red from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The red from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getRedFromColor(colortype color)
|
||||
{
|
||||
return ((color & 0x30) >> 4) * 0x55;
|
||||
}
|
||||
|
||||
virtual uint8_t getGreenColor(colortype color) const
|
||||
{
|
||||
return getGreenFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets green from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The green from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getGreenFromColor(colortype color)
|
||||
{
|
||||
return ((color & 0x0C) >> 2) * 0x55;
|
||||
}
|
||||
|
||||
virtual uint8_t getBlueColor(colortype color) const
|
||||
{
|
||||
return getBlueFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets blue from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The blue from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getBlueFromColor(colortype color)
|
||||
{
|
||||
return (color & 0x03) * 0x55;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for all image formats. This allows drawing any image
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms, but might use a lot of
|
||||
* memory for the drawing algorithms.
|
||||
*/
|
||||
void enableTextureMapperAll();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB2222 image format. This allows drawing ARGB2222
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperARGB2222_BilinearInterpolation,
|
||||
* enableTextureMapperARGB2222_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB2222();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB2222 image format. This allows drawing ARGB2222
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB2222, enableTextureMapperARGB2222_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB2222_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB2222 image format. This allows drawing ARGB2222
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB2222, enableTextureMapperARGB2222_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperARGB2222_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperA4_BilinearInterpolation, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperA4_NearestNeighbor();
|
||||
|
||||
protected:
|
||||
virtual DrawTextureMapScanLineBase* getTextureMapperDrawScanLine(const TextureSurface& texture, RenderingVariant renderVariant, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next pixel.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next pixel.
|
||||
*/
|
||||
static int nextPixel(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next line.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next line.
|
||||
*/
|
||||
static int nextLine(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
virtual void drawGlyph(uint16_t* wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect& invalidatedArea, const GlyphNode* glyph, const uint8_t* glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation);
|
||||
|
||||
/**
|
||||
* Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified if ARGB8888 is not supported by the DMA a software blend is performed.
|
||||
*
|
||||
* @param sourceData The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 32- bits ARGB8888 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyARGB8888(const uint32_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified Performs always a software blend.
|
||||
*
|
||||
* @param sourceData16 The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8-bits ARGB2222 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyAlphaPerPixel(const uint16_t* sourceData16, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
private:
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB2222_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB2222_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB2222_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB2222_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_GA;
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
const uint16_t xy10 = 16 * x;
|
||||
const uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return (c00 * xy00 + c10 * xy10) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t c01, uint8_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
const uint16_t xy11 = x * y;
|
||||
const uint16_t xy10 = 16 * x - xy11;
|
||||
const uint16_t xy01 = 16 * y - xy11;
|
||||
const uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return (c00 * xy00 + c10 * xy10 + c01 * xy01 + c11 * xy11) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION uint32_t convertARGB2222toARGB8888(colortype col) const
|
||||
{
|
||||
return (((col & 0xC0) << 18) | ((col & 0x30) << 12) | ((col & 0x0C) << 6) | (col & 0x03)) * 0x55;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t convertARGB2222toRGB888(uint8_t val)
|
||||
{
|
||||
return (((val & 0x30) << 12) | ((val & 0x0C) << 6) | (val & 0x03)) * 0x55;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t convertRGB888toXRGB2222(uint32_t val)
|
||||
{
|
||||
val &= 0xC0C0C0;
|
||||
return (val >> 6) | (val >> 12) | (val >> 18);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint32_t c01, uint32_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
const uint16_t xy11 = x * y;
|
||||
const uint16_t xy10 = 16 * x - xy11;
|
||||
const uint16_t xy01 = 16 * y - xy11;
|
||||
const uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * xy10 + (c01 & 0xFF00FF) * xy01 + (c11 & 0xFF00FF) * xy11) >> 8) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * xy10 + (c01 & 0x00FF00) * xy01 + (c11 & 0x00FF00) * xy11) >> 8) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return div255rb((val & 0xFF00FF) * factor) | div255g((val & 0x00FF00) * factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888_FFcheck(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return factor < 0xFF ? div255_888(val, factor) : val;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t alphaBlend(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t alpha, const uint8_t fbr, const uint8_t fbg, const uint8_t fbb, const uint8_t ialpha)
|
||||
{
|
||||
return getColorFromRGB(div255(r * alpha + fbr * ialpha), div255(g * alpha + fbg * ialpha), div255(b * alpha + fbb * ialpha));
|
||||
}
|
||||
|
||||
class DrawTextureMapScanLineBase8 : public DrawTextureMapScanLineBase
|
||||
{
|
||||
protected:
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckNearestNeighbor(uint8_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckBilinearInterpolation(uint8_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB2222_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB2222_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB2222_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB2222_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t a4, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* The class LCD8ARGB2222DebugPrinter implements the DebugPrinter interface for printing debug
|
||||
* messages on top of 8bit framebuffer.
|
||||
*
|
||||
* @see DebugPrinter
|
||||
*/
|
||||
class LCD8ARGB2222DebugPrinter : public DebugPrinter
|
||||
{
|
||||
public:
|
||||
virtual void draw(const Rect& rect) const;
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // LCD8BPP_ARGB2222_HPP
|
||||
@@ -0,0 +1,465 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/lcd/LCD8bpp_BGRA2222.hpp
|
||||
*
|
||||
* Declares the touchgfx::LCD8bpp_BGRA2222 and touchgfx::LCD8BGRA2222DebugPrinter classes.
|
||||
*/
|
||||
#ifndef LCD8BPP_BGRA2222_HPP
|
||||
#define LCD8BPP_BGRA2222_HPP
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <touchgfx/Bitmap.hpp>
|
||||
#include <touchgfx/Font.hpp>
|
||||
#include <touchgfx/TextProvider.hpp>
|
||||
#include <touchgfx/TextureMapTypes.hpp>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
#include <touchgfx/hal/HAL.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
#include <touchgfx/lcd/LCD.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
#undef LCD
|
||||
|
||||
/**
|
||||
* This class contains the various low-level drawing routines for drawing bitmaps, texts and
|
||||
* rectangles on 16 bits per pixel displays.
|
||||
*
|
||||
* @see LCD
|
||||
*
|
||||
* @note All coordinates are expected to be in absolute coordinates!
|
||||
*/
|
||||
class LCD8bpp_BGRA2222 : public LCD
|
||||
{
|
||||
public:
|
||||
LCD8bpp_BGRA2222();
|
||||
|
||||
|
||||
virtual void drawPartialBitmap(const Bitmap& bitmap, int16_t x, int16_t y, const Rect& rect, uint8_t alpha = 255, bool useOptimized = true);
|
||||
|
||||
virtual void blitCopy(const uint16_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual void blitCopy(const uint8_t* sourceData, Bitmap::BitmapFormat sourceFormat, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual uint16_t* copyFrameBufferRegionToMemory(const Rect& visRegion, const Rect& absRegion, const BitmapId bitmapId);
|
||||
|
||||
virtual void fillRect(const Rect& rect, colortype color, uint8_t alpha = 255);
|
||||
|
||||
virtual uint8_t bitDepth() const
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
virtual Bitmap::BitmapFormat framebufferFormat() const
|
||||
{
|
||||
return Bitmap::BGRA2222;
|
||||
}
|
||||
|
||||
virtual uint16_t framebufferStride() const
|
||||
{
|
||||
return getFramebufferStride();
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffer stride in bytes. The distance (in bytes) from the start of one
|
||||
* framebuffer row, to the next.
|
||||
*
|
||||
* @return The number of bytes in one framebuffer row.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint16_t getFramebufferStride()
|
||||
{
|
||||
assert(HAL::FRAME_BUFFER_WIDTH > 0 && "HAL has not been initialized yet");
|
||||
return HAL::FRAME_BUFFER_WIDTH;
|
||||
}
|
||||
|
||||
virtual colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) const
|
||||
{
|
||||
return getColorFromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets color from RGB.
|
||||
*
|
||||
* @param red The red.
|
||||
* @param green The green.
|
||||
* @param blue The blue.
|
||||
*
|
||||
* @return The color from RGB.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
return ((red & 0xC0) >> 4) | ((green & 0xC0) >> 2) | (blue & 0xC0);
|
||||
}
|
||||
|
||||
virtual uint8_t getRedColor(colortype color) const
|
||||
{
|
||||
return getRedFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets red from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The red from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getRedFromColor(colortype color)
|
||||
{
|
||||
return ((color & 0x0C) >> 2) * 0x55;
|
||||
}
|
||||
|
||||
virtual uint8_t getGreenColor(colortype color) const
|
||||
{
|
||||
return getGreenFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets green from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The green from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getGreenFromColor(colortype color)
|
||||
{
|
||||
return ((color & 0x30) >> 4) * 0x55;
|
||||
}
|
||||
|
||||
virtual uint8_t getBlueColor(colortype color) const
|
||||
{
|
||||
return getBlueFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets blue from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The blue from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getBlueFromColor(colortype color)
|
||||
{
|
||||
return ((color & 0xC0) >> 6) * 0x55;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for all image formats. This allows drawing any image
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms, but might use a lot of
|
||||
* memory for the drawing algorithms.
|
||||
*/
|
||||
void enableTextureMapperAll();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for BGRA2222 image format. This allows drawing BGRA2222
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperBGRA2222_BilinearInterpolation,
|
||||
* enableTextureMapperBGRA2222_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperBGRA2222();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for BGRA2222 image format. This allows drawing BGRA2222
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperBGRA2222, enableTextureMapperBGRA2222_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperBGRA2222_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for BGRA2222 image format. This allows drawing BGRA2222
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperBGRA2222, enableTextureMapperBGRA2222_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperBGRA2222_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperA4_BilinearInterpolation, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperA4_NearestNeighbor();
|
||||
|
||||
protected:
|
||||
virtual DrawTextureMapScanLineBase* getTextureMapperDrawScanLine(const TextureSurface& texture, RenderingVariant renderVariant, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next pixel.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next pixel.
|
||||
*/
|
||||
static int nextPixel(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next line.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next line.
|
||||
*/
|
||||
static int nextLine(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
virtual void drawGlyph(uint16_t* wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect& invalidatedArea, const GlyphNode* glyph, const uint8_t* glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation);
|
||||
|
||||
/**
|
||||
* Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified if ARGB8888 is not supported by the DMA a software blend is performed.
|
||||
*
|
||||
* @param sourceData The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 32- bits ARGB8888 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyARGB8888(const uint32_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified Performs always a software blend.
|
||||
*
|
||||
* @param sourceData16 The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8-bits BGRA2222 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyAlphaPerPixel(const uint16_t* sourceData16, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
private:
|
||||
DrawTextureMapScanLineBase* textureMapper_BGRA2222_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_BGRA2222_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_BGRA2222_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_BGRA2222_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_GA;
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
const uint16_t xy10 = 16 * x;
|
||||
const uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return (c00 * xy00 + c10 * xy10) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t c01, uint8_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
const uint16_t xy11 = x * y;
|
||||
const uint16_t xy10 = 16 * x - xy11;
|
||||
const uint16_t xy01 = 16 * y - xy11;
|
||||
const uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return (c00 * xy00 + c10 * xy10 + c01 * xy01 + c11 * xy11) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION uint32_t convertBGRA2222toARGB8888(colortype col) const
|
||||
{
|
||||
return (((col & 0x03) << 24) | ((col & 0x0C) << 14) | ((col & 0x30) << 4) | ((col & 0xC0) >> 6)) * 0x55;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t convertBGRA2222toRGB888(uint8_t val)
|
||||
{
|
||||
return (((val & 0x0C) << 14) | ((val & 0x30) << 4) | ((val & 0xC0) >> 6)) * 0x55;
|
||||
;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t convertRGB888toBGRX2222(uint32_t val)
|
||||
{
|
||||
val &= 0xC0C0C0;
|
||||
return (val) | (val >> 10) | (val >> 20);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint32_t c01, uint32_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
const uint16_t xy11 = x * y;
|
||||
const uint16_t xy10 = 16 * x - xy11;
|
||||
const uint16_t xy01 = 16 * y - xy11;
|
||||
const uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * xy10 + (c01 & 0xFF00FF) * xy01 + (c11 & 0xFF00FF) * xy11) >> 8) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * xy10 + (c01 & 0x00FF00) * xy01 + (c11 & 0x00FF00) * xy11) >> 8) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return div255rb((val & 0xFF00FF) * factor) | div255g((val & 0x00FF00) * factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888_FFcheck(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return factor < 0xFF ? div255_888(val, factor) : val;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t alphaBlend(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t alpha, const uint8_t fbr, const uint8_t fbg, const uint8_t fbb, const uint8_t ialpha)
|
||||
{
|
||||
return getColorFromRGB(div255(r * alpha + fbr * ialpha), div255(g * alpha + fbg * ialpha), div255(b * alpha + fbb * ialpha));
|
||||
}
|
||||
|
||||
class DrawTextureMapScanLineBase8 : public DrawTextureMapScanLineBase
|
||||
{
|
||||
protected:
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckNearestNeighbor(uint8_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckBilinearInterpolation(uint8_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
};
|
||||
|
||||
class TextureMapper_BGRA2222_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_BGRA2222_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_BGRA2222_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_BGRA2222_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t a4, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* The class LCD8BGRA2222DebugPrinter implements the DebugPrinter interface for printing debug
|
||||
* messages on top of 8bit framebuffer.
|
||||
*
|
||||
* @see DebugPrinter
|
||||
*/
|
||||
class LCD8BGRA2222DebugPrinter : public DebugPrinter
|
||||
{
|
||||
public:
|
||||
virtual void draw(const Rect& rect) const;
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // LCD8BPP_BGRA2222_HPP
|
||||
@@ -0,0 +1,464 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/lcd/LCD8bpp_RGBA2222.hpp
|
||||
*
|
||||
* Declares the touchgfx::LCD8bppRGBA2222 and touchgfx::LCD8RGBA2222DebugPrinter classes.
|
||||
*/
|
||||
#ifndef LCD8BPP_RGBA2222_HPP
|
||||
#define LCD8BPP_RGBA2222_HPP
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <touchgfx/Bitmap.hpp>
|
||||
#include <touchgfx/Font.hpp>
|
||||
#include <touchgfx/TextProvider.hpp>
|
||||
#include <touchgfx/TextureMapTypes.hpp>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
#include <touchgfx/hal/HAL.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
#include <touchgfx/lcd/LCD.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
#undef LCD
|
||||
|
||||
/**
|
||||
* This class contains the various low-level drawing routines for drawing bitmaps, texts and
|
||||
* rectangles on 16 bits per pixel displays.
|
||||
*
|
||||
* @see LCD
|
||||
*
|
||||
* @note All coordinates are expected to be in absolute coordinates!
|
||||
*/
|
||||
class LCD8bpp_RGBA2222 : public LCD
|
||||
{
|
||||
public:
|
||||
LCD8bpp_RGBA2222();
|
||||
|
||||
|
||||
virtual void drawPartialBitmap(const Bitmap& bitmap, int16_t x, int16_t y, const Rect& rect, uint8_t alpha = 255, bool useOptimized = true);
|
||||
|
||||
virtual void blitCopy(const uint16_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual void blitCopy(const uint8_t* sourceData, Bitmap::BitmapFormat sourceFormat, const Rect& source, const Rect& blitRect, uint8_t alpha, bool hasTransparentPixels);
|
||||
|
||||
virtual uint16_t* copyFrameBufferRegionToMemory(const Rect& visRegion, const Rect& absRegion, const BitmapId bitmapId);
|
||||
|
||||
virtual void fillRect(const Rect& rect, colortype color, uint8_t alpha = 255);
|
||||
|
||||
virtual uint8_t bitDepth() const
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
virtual Bitmap::BitmapFormat framebufferFormat() const
|
||||
{
|
||||
return Bitmap::RGBA2222;
|
||||
}
|
||||
|
||||
virtual uint16_t framebufferStride() const
|
||||
{
|
||||
return getFramebufferStride();
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffer stride in bytes. The distance (in bytes) from the start of one
|
||||
* framebuffer row, to the next.
|
||||
*
|
||||
* @return The number of bytes in one framebuffer row.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint16_t getFramebufferStride()
|
||||
{
|
||||
assert(HAL::FRAME_BUFFER_WIDTH > 0 && "HAL has not been initialized yet");
|
||||
return HAL::FRAME_BUFFER_WIDTH;
|
||||
}
|
||||
|
||||
virtual colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue) const
|
||||
{
|
||||
return getColorFromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets color from RGB.
|
||||
*
|
||||
* @param red The red.
|
||||
* @param green The green.
|
||||
* @param blue The blue.
|
||||
*
|
||||
* @return The color from RGB.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static colortype getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
return (red & 0xC0) | ((green & 0xC0) >> 2) | ((blue & 0xC0) >> 4);
|
||||
}
|
||||
|
||||
virtual uint8_t getRedColor(colortype color) const
|
||||
{
|
||||
return getRedFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets red from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The red from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getRedFromColor(colortype color)
|
||||
{
|
||||
return ((color & 0xC0) >> 6) * 0x55;
|
||||
}
|
||||
|
||||
virtual uint8_t getGreenColor(colortype color) const
|
||||
{
|
||||
return getGreenFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets green from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The green from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getGreenFromColor(colortype color)
|
||||
{
|
||||
return ((color & 0x30) >> 4) * 0x55;
|
||||
}
|
||||
|
||||
virtual uint8_t getBlueColor(colortype color) const
|
||||
{
|
||||
return getBlueFromColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets blue from color.
|
||||
*
|
||||
* @param color The color.
|
||||
*
|
||||
* @return The blue from color.
|
||||
*/
|
||||
FORCE_INLINE_FUNCTION static uint8_t getBlueFromColor(colortype color)
|
||||
{
|
||||
return ((color & 0x0C) >> 2) * 0x55;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for all image formats. This allows drawing any image
|
||||
* using Bilinear Interpolation and Nearest Neighbor algorithms, but might use a lot of
|
||||
* memory for the drawing algorithms.
|
||||
*/
|
||||
void enableTextureMapperAll();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGBA2222 image format. This allows drawing RGBA2222
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperRGBA2222_BilinearInterpolation,
|
||||
* enableTextureMapperRGBA2222_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperRGBA2222();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGBA2222 image format. This allows drawing RGBA2222
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGBA2222, enableTextureMapperRGBA2222_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperRGBA2222_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for RGBA2222 image format. This allows drawing RGBA2222
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperRGBA2222, enableTextureMapperRGBA2222_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperRGBA2222_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888_BilinearInterpolation,
|
||||
* enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperARGB8888_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for ARGB8888 image format. This allows drawing ARGB8888
|
||||
* images using Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperARGB8888, enableTextureMapperARGB8888_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperARGB8888_NearestNeighbor();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation and Nearest Neighbor algorithms.
|
||||
*
|
||||
* @see enableTextureMapperA4_BilinearInterpolation, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Bilinear Interpolation algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_NearestNeighbor
|
||||
*/
|
||||
void enableTextureMapperA4_BilinearInterpolation();
|
||||
|
||||
/**
|
||||
* Enables the texture mappers for A4 image format. This allows drawing A4 images using
|
||||
* Nearest Neighbor algorithm.
|
||||
*
|
||||
* @see enableTextureMapperA4, enableTextureMapperA4_BilinearInterpolation
|
||||
*/
|
||||
void enableTextureMapperA4_NearestNeighbor();
|
||||
|
||||
protected:
|
||||
virtual DrawTextureMapScanLineBase* getTextureMapperDrawScanLine(const TextureSurface& texture, RenderingVariant renderVariant, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next pixel.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next pixel.
|
||||
*/
|
||||
static int nextPixel(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
/**
|
||||
* Find out how much to advance in the display buffer to get to the next line.
|
||||
*
|
||||
* @param rotatedDisplay Is the display running in portrait mode?
|
||||
* @param textRotation Rotation to perform.
|
||||
*
|
||||
* @return How much to advance to get to the next line.
|
||||
*/
|
||||
static int nextLine(bool rotatedDisplay, TextRotation textRotation);
|
||||
|
||||
virtual void drawGlyph(uint16_t* wbuf16, Rect widgetArea, int16_t x, int16_t y, uint16_t offsetX, uint16_t offsetY, const Rect& invalidatedArea, const GlyphNode* glyph, const uint8_t* glyphData, uint8_t byteAlignRow, colortype color, uint8_t bitsPerPixel, uint8_t alpha, TextRotation rotation);
|
||||
|
||||
/**
|
||||
* Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified if ARGB8888 is not supported by the DMA a software blend is performed.
|
||||
*
|
||||
* @param sourceData The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 32- bits ARGB8888 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyARGB8888(const uint32_t* sourceData, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
/**
|
||||
* Blit a 2D source-array to the framebuffer performing alpha-blending per pixel as
|
||||
* specified Performs always a software blend.
|
||||
*
|
||||
* @param sourceData16 The source-array pointer (points to the beginning of the data). The
|
||||
* sourceData must be stored as 8-bit RGBA2222 values.
|
||||
* @param source The location and dimensions of the source.
|
||||
* @param blitRect A rectangle describing what region is to be drawn.
|
||||
* @param alpha The alpha value to use for blending applied to the whole image (255 =
|
||||
* solid, no blending)
|
||||
*/
|
||||
static void blitCopyAlphaPerPixel(const uint16_t* sourceData16, const Rect& source, const Rect& blitRect, uint8_t alpha);
|
||||
|
||||
private:
|
||||
DrawTextureMapScanLineBase* textureMapper_RGBA2222_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGBA2222_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGBA2222_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_RGBA2222_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_Opaque_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_ARGB8888_Opaque_BilinearInterpolation_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_NearestNeighbor_GA;
|
||||
DrawTextureMapScanLineBase* textureMapper_A4_BilinearInterpolation_GA;
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t x)
|
||||
{
|
||||
assert(x < 16);
|
||||
const uint16_t xy10 = 16 * x;
|
||||
const uint16_t xy00 = 256 - xy10;
|
||||
|
||||
return (c00 * xy00 + c10 * xy10) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t bilinearInterpolate8(uint8_t c00, uint8_t c10, uint8_t c01, uint8_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
const uint16_t xy11 = x * y;
|
||||
const uint16_t xy10 = 16 * x - xy11;
|
||||
const uint16_t xy01 = 16 * y - xy11;
|
||||
const uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return (c00 * xy00 + c10 * xy10 + c01 * xy01 + c11 * xy11) >> 8;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION uint32_t convertRGBA2222toARGB8888(colortype col) const
|
||||
{
|
||||
return (((col & 0x03) << 24) | ((col & 0xC0) << 10) | ((col & 0x30) << 4) | ((col & 0x0C) >> 2)) * 0x55;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t convertRGBA2222toRGB888(uint8_t val)
|
||||
{
|
||||
return (((val & 0xC0) << 10) | ((val & 0x30) << 4) | ((val & 0x0C) >> 2)) * 0x55;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t convertRGB888toRGBX2222(uint32_t val)
|
||||
{
|
||||
val &= 0xC0C0C0;
|
||||
return (val >> 4) | (val >> 10) | (val >> 16);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t bilinearInterpolate888(uint32_t c00, uint32_t c10, uint32_t c01, uint32_t c11, uint8_t x, uint8_t y)
|
||||
{
|
||||
assert(x < 16 && y < 16);
|
||||
const uint16_t xy11 = x * y;
|
||||
const uint16_t xy10 = 16 * x - xy11;
|
||||
const uint16_t xy01 = 16 * y - xy11;
|
||||
const uint16_t xy00 = 256 - (xy11 + xy10 + xy01);
|
||||
|
||||
return ((((c00 & 0xFF00FF) * xy00 + (c10 & 0xFF00FF) * xy10 + (c01 & 0xFF00FF) * xy01 + (c11 & 0xFF00FF) * xy11) >> 8) & 0xFF00FF)
|
||||
| ((((c00 & 0x00FF00) * xy00 + (c10 & 0x00FF00) * xy10 + (c01 & 0x00FF00) * xy01 + (c11 & 0x00FF00) * xy11) >> 8) & 0x00FF00);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return div255rb((val & 0xFF00FF) * factor) | div255g((val & 0x00FF00) * factor);
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint32_t div255_888_FFcheck(uint32_t val, uint8_t factor)
|
||||
{
|
||||
return factor < 0xFF ? div255_888(val, factor) : val;
|
||||
}
|
||||
|
||||
FORCE_INLINE_FUNCTION static uint8_t alphaBlend(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t alpha, const uint8_t fbr, const uint8_t fbg, const uint8_t fbb, const uint8_t ialpha)
|
||||
{
|
||||
return getColorFromRGB(div255(r * alpha + fbr * ialpha), div255(g * alpha + fbg * ialpha), div255(b * alpha + fbb * ialpha));
|
||||
}
|
||||
|
||||
class DrawTextureMapScanLineBase8 : public DrawTextureMapScanLineBase
|
||||
{
|
||||
protected:
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckNearestNeighbor(uint8_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
FORCE_INLINE_FUNCTION bool overrunCheckBilinearInterpolation(uint8_t*& destBits, int& pixelsToDraw, fixed16_16& U, fixed16_16& V, fixed16_16 deltaU, fixed16_16 deltaV, const int16_t maxWidth, const int16_t maxHeight);
|
||||
};
|
||||
|
||||
class TextureMapper_RGBA2222_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGBA2222_Opaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGBA2222_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_RGBA2222_Opaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint8_t* const textureBits, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_ARGB8888_NonOpaque_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint32_t* const textureBits32, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_NearestNeighbor_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint8_t a4, const uint8_t alpha);
|
||||
};
|
||||
|
||||
class TextureMapper_A4_BilinearInterpolation_GA : public DrawTextureMapScanLineBase8
|
||||
{
|
||||
public:
|
||||
virtual void drawTextureMapScanLineSubdivisions(int subdivisions, const int widthModLength, int pixelsToDraw, const int affineLength, float oneOverZRight, float UOverZRight, float VOverZRight, fixed16_16 U, fixed16_16 V, fixed16_16 deltaU, fixed16_16 deltaV, float ULeft, float VLeft, float URight, float VRight, float ZRight, const DrawingSurface& dest, const int destX, const int destY, const int16_t bitmapWidth, const int16_t bitmapHeight, const TextureSurface& texture, uint8_t alpha, const float dOneOverZdXAff, const float dUOverZdXAff, const float dVOverZdXAff);
|
||||
|
||||
private:
|
||||
FORCE_INLINE_FUNCTION void writePixel(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
void writePixelOnEdge(uint8_t* const destBits, const uint16_t* const textureBits, const int16_t bitmapStride, const int16_t bitmapWidth, const int16_t bitmapHeight, const int UInt, const int VInt, const uint8_t UFrac, const uint8_t VFrac, const uint8_t alpha);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* The class LCD8RGBA2222DebugPrinter implements the DebugPrinter interface for printing debug
|
||||
* messages on top of 8bit framebuffer.
|
||||
*
|
||||
* @see DebugPrinter
|
||||
*/
|
||||
class LCD8RGBA2222DebugPrinter : public DebugPrinter
|
||||
{
|
||||
public:
|
||||
virtual void draw(const Rect& rect) const;
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // LCD8BPP_RGBA2222_HPP
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/touch/I2CTouchController.hpp
|
||||
*
|
||||
* Declares the touchgfx::I2CTouchController interface class.
|
||||
*/
|
||||
#ifndef I2CTOUCHCONTROLLER_HPP
|
||||
#define I2CTOUCHCONTROLLER_HPP
|
||||
|
||||
#include <platform/driver/i2c/I2C.hpp>
|
||||
#include <platform/driver/touch/TouchController.hpp>
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
/**
|
||||
* Specific I2C-enabled type of Touch Controller.
|
||||
*
|
||||
* @see TouchController
|
||||
*/
|
||||
class I2CTouchController : public TouchController
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor. Initializes I2C driver.
|
||||
*
|
||||
* @param [in] i2c I2C driver.
|
||||
*/
|
||||
I2CTouchController(I2C& i2c)
|
||||
: i2c(i2c)
|
||||
{
|
||||
i2c.init();
|
||||
}
|
||||
|
||||
virtual ~I2CTouchController()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void init() = 0;
|
||||
|
||||
virtual bool sampleTouch(int32_t& x, int32_t& y) = 0;
|
||||
|
||||
protected:
|
||||
I2C& i2c; ///< I2C driver
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // I2CTOUCHCONTROLLER_HPP
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/touch/NoTouchController.hpp
|
||||
*
|
||||
* Declares the touchgfx::NoTouchController class.
|
||||
*/
|
||||
#ifndef NOTOUCHCONTROLLER_HPP
|
||||
#define NOTOUCHCONTROLLER_HPP
|
||||
|
||||
#include <platform/driver/touch/TouchController.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
/**
|
||||
* Empty TouchController implementation which does nothing. Use this if your display does not
|
||||
* have touch input capabilities.
|
||||
*/
|
||||
class NoTouchController : public TouchController
|
||||
{
|
||||
public:
|
||||
virtual void init()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~NoTouchController()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool sampleTouch(int32_t& x, int32_t& y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // NOTOUCHCONTROLLER_HPP
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/touch/SDL2TouchController.hpp
|
||||
*
|
||||
* Declares the touchgfx::SDL2TouchController class.
|
||||
*/
|
||||
#ifndef SDL2TOUCHCONTROLLER_HPP
|
||||
#define SDL2TOUCHCONTROLLER_HPP
|
||||
|
||||
#include <platform/driver/touch/TouchController.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
/**
|
||||
* TouchController for the simulator.
|
||||
*
|
||||
* @see TouchController
|
||||
*/
|
||||
class SDL2TouchController : public TouchController
|
||||
{
|
||||
public:
|
||||
virtual void init();
|
||||
|
||||
virtual bool sampleTouch(int32_t& x, int32_t& y);
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // SDL2TOUCHCONTROLLER_HPP
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/touch/SDLTouchController.hpp
|
||||
*
|
||||
* Declares the touchgfx::SDLTouchController class.
|
||||
*/
|
||||
#ifndef SDLTOUCHCONTROLLER_HPP
|
||||
#define SDLTOUCHCONTROLLER_HPP
|
||||
|
||||
#include <platform/driver/touch/TouchController.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
/**
|
||||
* TouchController for the simulator.
|
||||
*
|
||||
* @see TouchController
|
||||
*
|
||||
* @deprecated Use SDL2TouchController
|
||||
*/
|
||||
class SDLTouchController : public TouchController
|
||||
{
|
||||
public:
|
||||
virtual void init();
|
||||
|
||||
virtual bool sampleTouch(int32_t& x, int32_t& y);
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // SDLTOUCHCONTROLLER_HPP
|
||||
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/touch/ST1232TouchController.hpp
|
||||
*
|
||||
* Declares the touchgfx::ST1232TouchController class.
|
||||
*/
|
||||
#ifndef ST1232TOUCHCONTROLLER_HPP
|
||||
#define ST1232TOUCHCONTROLLER_HPP
|
||||
|
||||
#include <platform/driver/touch/I2CTouchController.hpp>
|
||||
#include <platform/driver/touch/TouchController.hpp>
|
||||
|
||||
/** Represents the coordinates of a finger on the display. */
|
||||
typedef struct
|
||||
{
|
||||
int16_t x; ///< x coordinate
|
||||
int16_t y; ///< y coordinate
|
||||
int16_t z; ///< z coordinate
|
||||
} Finger;
|
||||
|
||||
/** Defines the transformation types. */
|
||||
typedef enum
|
||||
{
|
||||
NO_TRANSFORM = 0, ///< No transformation
|
||||
FLIP_X_AXIS, ///< Swap along the x axis
|
||||
FLIP_Y_AXIS ///< Swap along the y axis
|
||||
} TransformationType;
|
||||
|
||||
//General
|
||||
#define I2C_ADDR 0x55
|
||||
#define SIZE_BYTES 8
|
||||
#define MAX_FINGERS 2
|
||||
#define MASK_NR_OF_FINGERS 0x07
|
||||
#define MASK_MSB 0x80
|
||||
#define MASK_X0_COORD_LOW_BYTE 0x70
|
||||
#define MASK_Y0_COORD_LOW_BYTE 0x07
|
||||
|
||||
// Register addresses
|
||||
#define REG_FIRMWARE_VERSION 0x00
|
||||
#define REG_STATUS 0x01
|
||||
#define REG_DEVICE_CONTROL 0x02
|
||||
#define REG_TIMEOUT_TO_IDLE 0x03
|
||||
#define REG_XY_RESOLUTION_HIGH 0x04
|
||||
#define REG_X_RESOLUTION_L 0x05
|
||||
#define REG_Y_RESOLUTION_L 0x06
|
||||
#define REG_KEYS 0x11
|
||||
#define REG_PAGE 0xFF
|
||||
|
||||
//Touch
|
||||
#define REG_FINGERS_GESTURE 0x10
|
||||
#define REG_XY0_COORD_HIGH_BYTE 0x12
|
||||
#define REG_X0_COORD_LOW_BYTE 0x13
|
||||
#define REG_Y0_COORD_LOW_BYTE 0x14
|
||||
#define REG_XY1_COORD_HIGH_BYTE 0x15
|
||||
#define REG_X1_COORD_LOW_BYTE 0x16
|
||||
#define REG_Y1_COORD_LOW_BYTE 0x17
|
||||
#define REG_Z0_COORD 0x18
|
||||
#define REG_Z1_COORD 0x19
|
||||
|
||||
//Gestures
|
||||
/*
|
||||
#define REG_NO_GESTURE 0x00
|
||||
#define REG_SINGLE_TOUCH_TAP 0x01
|
||||
#define SINGLE_TOUCH_DOUBLE_TAP 0x02
|
||||
#define SINGLE_TOUCH_SLIDE_UP 0x03
|
||||
#define SINGLE_TOUCH_SLIDE_DOWN 0x04
|
||||
#define SINGLE_TOUCH_SLIDE_LEFT 0x05
|
||||
#define SINGLE_TOUCH_SLIDE_RIGHT 0x06
|
||||
#define TWO_FINGER_SLIDE_UP 0x07
|
||||
#define TWO_FINGER_SLIDE_DOWN 0x08
|
||||
#define TWO_FINGER_SLIDE_LEFT 0x09
|
||||
#define TWO_FINGER_SLIDE_RIGHT 0x0A
|
||||
#define PINCH_IN 0x0B
|
||||
#define PINCH_OUT 0x0C
|
||||
*/
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
/**
|
||||
* ST1232 I2C Touch controller driver.
|
||||
*
|
||||
* @see I2CTouchController
|
||||
*/
|
||||
class ST1232TouchController : public I2CTouchController
|
||||
{
|
||||
/** Function definition for touch correction. */
|
||||
typedef void (*TransformFuncPtr)(int32_t&, int32_t&, Finger&);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Initializes a new instance of the ST1232TouchController class.
|
||||
*
|
||||
* @param [in] i2c I2C driver handle.
|
||||
* @param displayWidth Width of the display.
|
||||
* @param displayHeight Height of the display.
|
||||
* @param transType (Optional) Type of transformation to perform on coordinate
|
||||
* readout.
|
||||
*/
|
||||
ST1232TouchController(I2C& i2c, int16_t displayWidth, int16_t displayHeight, TransformationType transType = NO_TRANSFORM)
|
||||
: I2CTouchController(i2c),
|
||||
linearTransform(transType),
|
||||
displayWidth(displayWidth),
|
||||
displayHeight(displayHeight)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void init();
|
||||
|
||||
virtual bool sampleTouch(int32_t& x, int32_t& y);
|
||||
|
||||
/**
|
||||
* Set pointer to user defined callback method that applies correction to touch
|
||||
* coordinates.
|
||||
*
|
||||
* Set pointer to user defined callback method that applies correction to touch
|
||||
* coordinates.
|
||||
*
|
||||
* @param ptr Function pointer.
|
||||
*/
|
||||
void setTransformCallback(TransformFuncPtr ptr)
|
||||
{
|
||||
transformFunc = ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Checks whether 1 or more fingers have been placed on the screen.
|
||||
*
|
||||
* @return number of fingers.
|
||||
*/
|
||||
uint8_t touchDetected();
|
||||
|
||||
/**
|
||||
* Get touchdata for one or more fingers. Currently, this method only tracks 1
|
||||
* finger due to HALs notion of sampling touch returns a single coordinate. X and Y
|
||||
* Low bytes are full 8 bits.
|
||||
*
|
||||
* LE bitfield notation for XY_High_Byte for both fingers
|
||||
* @code
|
||||
* Y_HIGH_BYTE : 3
|
||||
* RESERVED : 1
|
||||
* X_HIGH_BYTE : 3
|
||||
* VALID : 1
|
||||
* //XY0 valid.
|
||||
* @endcode
|
||||
*
|
||||
* @param [out] touchData Touchdata.
|
||||
*
|
||||
* @return true if nothing went wrong, false otherwise.
|
||||
*/
|
||||
bool getSample(Finger* touchData);
|
||||
|
||||
/**
|
||||
* Transform touch data based on the linear transformation configuration and user
|
||||
* defined transformation, if defined.
|
||||
*
|
||||
* @param [out] x The x position of the touch.
|
||||
* @param [out] y The y position of the touch.
|
||||
*/
|
||||
void transformTouchData(int32_t& x, int32_t& y);
|
||||
|
||||
TransformFuncPtr transformFunc; ///< Store transform func pointer
|
||||
TransformationType linearTransform; ///< Store type of transformation to make on coordinates read from the touch controller.
|
||||
int16_t displayWidth; ///< Store width of display
|
||||
int16_t displayHeight; ///< Store height of display
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // ST1232TOUCHCONTROLLER_HPP
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* This file is part of the TouchGFX 4.14.0 distribution.
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file platform/driver/touch/TouchController.hpp
|
||||
*
|
||||
* Declares the touchgfx::TouchController interface class.
|
||||
*/
|
||||
#ifndef TOUCHCONTROLLER_HPP
|
||||
#define TOUCHCONTROLLER_HPP
|
||||
|
||||
#include <touchgfx/hal/Types.hpp>
|
||||
|
||||
namespace touchgfx
|
||||
{
|
||||
/** Basic Touch Controller interface. */
|
||||
class TouchController
|
||||
{
|
||||
public:
|
||||
/** Finalizes an instance of the TouchController class. */
|
||||
virtual ~TouchController()
|
||||
{
|
||||
}
|
||||
|
||||
/** Initializes touch controller. */
|
||||
virtual void init() = 0;
|
||||
|
||||
/**
|
||||
* Checks whether the touch screen is being touched, and if so, what coordinates.
|
||||
*
|
||||
* @param [out] x The x position of the touch.
|
||||
* @param [out] y The y position of the touch.
|
||||
*
|
||||
* @return True if a touch has been detected, otherwise false.
|
||||
*/
|
||||
virtual bool sampleTouch(int32_t& x, int32_t& y) = 0;
|
||||
};
|
||||
|
||||
} // namespace touchgfx
|
||||
|
||||
#endif // TOUCHCONTROLLER_HPP
|
||||
Reference in New Issue
Block a user