提交 55b290c4 编写于 作者: W wanngtiantian 提交者: wangtiantian

IssueNo:#I3D437

Description:support A4/A8/L4/L8 image formats hardware drawing
Sig:graphic
Feature or Bugfix:Feature
Binary Source:No
上级 0c824f55
......@@ -127,6 +127,7 @@ public:
* @param srcStride Indicates the number of bytes in a single row of source memory
* @param srcLineNumber Indicates the number of source memory rows
* @param srcColorMode Indicates the source memory color format
* @param srcLutColorMode Indicates the source memory lut(Lookup Table) color format
* @param color 32-bit XRGB8888 value
* (valid when the source memory is in a format with only alph information such as A1)
* @param opa Indicates the transparency
......@@ -144,6 +145,7 @@ public:
uint32_t srcStride,
uint32_t srcLineNumber,
ColorMode srcColorMode,
LutColorMode srcLutColorMode,
uint32_t color,
OpacityType opa,
uint8_t* dst,
......
......@@ -66,6 +66,7 @@ public:
uint32_t srcStride,
uint32_t srcLineNumber,
ColorMode srcColorMode,
LutColorMode srcLutColorMode,
uint32_t color,
OpacityType opa,
uint8_t* dst,
......@@ -75,8 +76,8 @@ public:
uint32_t y)
{
if (device_ != nullptr) {
return device_->HardwareBlend(src, srcRect, srcStride, srcLineNumber, srcColorMode, color, opa, dst,
dstStride, dstColorMode, x, y);
return device_->HardwareBlend(src, srcRect, srcStride, srcLineNumber, srcColorMode, srcLutColorMode,
color, opa, dst, dstStride, dstColorMode, x, y);
}
return false;
}
......
......@@ -27,10 +27,33 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask,
return;
}
OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.imageOpa_);
/* 3 : when single pixel change bit to byte, the buffer should divide by 8, equal to shift right 3 bits. */
uint8_t pxByteSize = DrawUtils::GetPxSizeByImageInfo(*img) >> 3;
DrawUtils::GetInstance()->DrawImage(coords, mask, img->data, opa, pxByteSize);
uint8_t pxBitSize = DrawUtils::GetPxSizeByColorMode(img->header.colorMode);
LutColorMode lutColorMode = LUT_UNKNOW;
uint8_t size = 0;
switch (img->header.colorMode) {
case L1:
// One index represents 1 bit, 8 : convert to bytes, 1 : 2 color values
size = (img->dataSize - (img->header.width * img->header.height / 8)) >> 1;
break;
case L2:
// One index represents 2 bit, 4 : convert to bytes, 2 : 4 color values
size = (img->dataSize - (img->header.width * img->header.height / 4)) >> 2;
break;
case L4:
// One index represents 4 bit, 2 : convert to bytes, 4 : 16 color values
size = (img->dataSize - (img->header.width * img->header.height / 2)) >> 4;
break;
case L8:
// One index represents 8 bit, 8 : 256 color values
size = (img->dataSize - (img->header.width * img->header.height)) >> 8;
break;
default:
size = 0;
break;
}
lutColorMode = DrawUtils::GetLutColorModeBySize(size);
DrawUtils::GetInstance()->DrawImage(coords, mask, img->data, opa, pxBitSize,
static_cast<ColorMode>(img->header.colorMode), lutColorMode);
}
void DrawImage::DrawCommon(const Rect& coords, const Rect& mask,
......@@ -46,10 +69,10 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask,
return;
}
/* 3 : when single pixel change bit to byte, the buffer should divide by 8, equal to shift right 3 bits. */
uint8_t pxByteSize = DrawUtils::GetPxSizeByImageInfo(entry.GetImageInfo()) >> 3;
uint8_t pxBitSize = DrawUtils::GetPxSizeByColorMode(entry.GetImageInfo().header.colorMode);
if (entry.InCache()) {
DrawUtils::GetInstance()->DrawImage(coords, mask, entry.GetImgData(), opa, pxByteSize);
DrawUtils::GetInstance()->DrawImage(coords, mask, entry.GetImgData(), opa, pxBitSize,
static_cast<ColorMode>(entry.GetImageInfo().header.colorMode));
} else {
Rect valid = coords;
if (!valid.Intersect(valid, mask)) {
......@@ -77,7 +100,8 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask,
UIFree(buf);
return;
}
DrawUtils::GetInstance()->DrawImage(line, mask, buf, opa, pxByteSize);
DrawUtils::GetInstance()->DrawImage(line, mask, buf, opa, pxBitSize,
static_cast<ColorMode>(entry.GetImageInfo().header.colorMode));
line.SetTop(line.GetTop() + 1);
line.SetBottom(line.GetBottom() + 1);
start.y++;
......
......@@ -206,6 +206,7 @@ void DrawUtils::DrawColorArea(const Rect& area, const Rect& mask, const ColorTyp
uint8_t DrawUtils::GetPxSizeByColorMode(uint8_t colorMode)
{
switch (colorMode) {
case TSC:
case ARGB8888:
return 32; // 32: 32 bit
case RGB888:
......@@ -247,14 +248,18 @@ uint8_t DrawUtils::GetByteSizeByColorMode(uint8_t colorMode)
}
}
uint8_t DrawUtils::GetPxSizeByImageInfo(ImageInfo imageInfo)
LutColorMode DrawUtils::GetLutColorModeBySize(uint8_t size)
{
if ((imageInfo.header.width == 0) || (imageInfo.header.height == 0)) {
return 0;
switch (size) {
case 2: // 2: 2 Byte
return LUT_RGB565;
case 3: // 3: 3 Byte
return LUT_RGB888;
case 4: // 4: 4 Byte
return LUT_ARGB8888;
default:
return LUT_UNKNOW;
}
/* 3 : when change byte to single pixel, the buffer should multiply by 8, equal to shift left 3 bits. */
uint8_t pxSize = (imageInfo.dataSize / (imageInfo.header.width * imageInfo.header.height)) << 3;
return pxSize;
}
void DrawUtils::DrawPixel(int16_t x, int16_t y, const Rect& mask, const ColorType& color, OpacityType opa) const
......@@ -348,7 +353,7 @@ void DrawUtils::DrawLetter(const LabelLetterInfo& letterInfo) const
(posX + letterW <= letterInfo.mask.GetRight()) ? letterW : (letterInfo.mask.GetRight() - posX + 1);
uint8_t letterWidthInByte = (letterW * fontWeight) >> SHIFT_3;
if ((letterW * fontWeight) & 0x7) {
if ((letterW * fontWeight) & 0x7) { // 0x7 : less than 1 byte is counted as 1 byte
letterWidthInByte++;
}
......@@ -363,7 +368,7 @@ void DrawUtils::DrawLetter(const LabelLetterInfo& letterInfo) const
#if ENABLE_HARDWARE_ACCELERATION && ENABLE_HARDWARE_ACCELERATION_FOR_TEXT
Rect srcRect(colStart, rowStart, colEnd - 1, rowEnd - 1);
if (ScreenDeviceProxy::GetInstance()->HardwareBlend(fontMap, srcRect, letterWidthInByte, letterH,
static_cast<ColorMode>(colorMode),
static_cast<ColorMode>(colorMode), LUT_UNKNOW,
Color::ColorTo32(letterInfo.color), opa, reinterpret_cast<uint8_t*>(screenBuffer),
screenBufferWidth * bufferPxSize, bufferMode, dstPosX, dstPosY)) {
return;
......@@ -414,7 +419,9 @@ void DrawUtils::DrawImage(const Rect& area,
const Rect& mask,
const uint8_t* image,
OpacityType opa,
uint8_t pxByteSize) const
uint8_t pxBitSize,
ColorMode colorMode,
LutColorMode LutColorMode) const
{
if (image == nullptr) {
return;
......@@ -435,32 +442,24 @@ void DrawUtils::DrawImage(const Rect& area,
int16_t mapWidth = area.GetWidth();
int16_t imageX = originMaskedArea.GetLeft() - area.GetLeft();
int16_t imageY = originMaskedArea.GetTop() - area.GetTop();
ColorMode srcMode;
if (pxByteSize == static_cast<uint8_t>(PixelType::IMG_RGB888)) {
srcMode = RGB888;
} else if (pxByteSize == static_cast<uint8_t>(PixelType::IMG_RGB565)) {
srcMode = RGB565;
} else if (pxByteSize == static_cast<uint8_t>(PixelType::IMG_ARGB8888)) {
srcMode = ARGB8888;
} else {
GRAPHIC_LOGE("DrawUtils::DrawImage image format err\n");
return;
uint32_t imageWidthInByte = (static_cast<uint32_t>(mapWidth) * pxBitSize) >> SHIFT_3;
if ((mapWidth * pxBitSize) & 0x7) { // 0x7 : less than 1 byte is counted as 1 byte
imageWidthInByte++;
}
#if ENABLE_HARDWARE_ACCELERATION
Rect srcRect(imageX, imageY, imageX + maskedArea.GetWidth() - 1, imageY + maskedArea.GetHeight() - 1);
if (ScreenDeviceProxy::GetInstance()->HardwareBlend(image, srcRect, mapWidth * pxByteSize, area.GetHeight(),
srcMode, 0, opa, screenBuffer, screenBufferWidth * bufferPxSize, bufferMode, maskedArea.GetLeft(),
maskedArea.GetTop())) {
if (ScreenDeviceProxy::GetInstance()->HardwareBlend(image, srcRect, imageWidthInByte, area.GetHeight(),
colorMode, lutColorMode, 0, opa, screenBuffer, screenBufferWidth * bufferPxSize, bufferMode,
maskedArea.GetLeft(), maskedArea.GetTop())) {
return;
}
#endif
screenBuffer += static_cast<uint32_t>(screenBufferWidth) * maskedArea.GetTop() * bufferPxSize;
screenBuffer += static_cast<uint32_t>(maskedArea.GetLeft()) * bufferPxSize;
image += (static_cast<uint32_t>(mapWidth) * imageY + imageX) * pxByteSize;
image += (static_cast<uint32_t>(mapWidth) * imageY + imageX) * (pxBitSize >> SHIFT_3);
/* RGB565 RGB888 color mode, image src don't have alpha */
BlendWithSoftWare(image, mapWidth * pxByteSize, srcMode, screenBuffer, screenBufferWidth * bufferPxSize, bufferMode,
BlendWithSoftWare(image, imageWidthInByte, colorMode, screenBuffer, screenBufferWidth * bufferPxSize, bufferMode,
maskedArea.GetWidth(), maskedArea.GetHeight(), opa);
}
......
......@@ -167,12 +167,6 @@ enum {
IMG_SRC_UNKNOWN,
};
enum PixelType {
IMG_RGB565 = 2,
IMG_RGB888 = 3,
IMG_ARGB8888 = 4,
};
class DrawUtils : public HeapBase {
public:
static DrawUtils* GetInstance()
......@@ -189,7 +183,8 @@ public:
void DrawLetter(const LabelLetterInfo& letterInfo) const;
void DrawImage(const Rect& area, const Rect& mask, const uint8_t* image, OpacityType opa, uint8_t pxByteSize) const;
void DrawImage(const Rect& area, const Rect& mask, const uint8_t* image, OpacityType opa, uint8_t pxBitSize,
ColorMode colorMode, LutColorMode lutColorMode = LUT_UNKNOW) const;
static void
GetXAxisErrForJunctionLine(bool ignoreJunctionPoint, bool isRightPart, int16_t& xMinErr, int16_t& xMaxErr);
......@@ -221,7 +216,7 @@ public:
static uint8_t GetByteSizeByColorMode(uint8_t colorMode);
static uint8_t GetPxSizeByImageInfo(ImageInfo imageInfo);
static LutColorMode GetLutColorModeBySize(uint8_t size);
static OpacityType GetMixOpacity(OpacityType opa1, OpacityType opa2)
{
......
......@@ -139,7 +139,7 @@ RetCode FileImgDecoder::ReadToCache(ImgResDsc& dsc)
RetCode FileImgDecoder::ReadLineTrueColor(ImgResDsc& dsc, const Point& start, int16_t len, uint8_t* buf)
{
uint8_t pxSizeInBit = DrawUtils::GetPxSizeByImageInfo(dsc.imgInfo);
uint8_t pxSizeInBit = DrawUtils::GetPxSizeByColorMode(dsc.imgInfo.header.colorMode);
off_t res;
uint32_t pos = ((start.y * dsc.imgInfo.header.width + start.x) * pxSizeInBit) >> BYTE_TO_BIT_SHIFT;
......
......@@ -52,6 +52,7 @@ public:
uint32_t srcStride,
uint32_t srcLineNumber,
ColorMode srcColorMode,
LutColorMode srcLutColorMode,
uint32_t color,
OpacityType opa,
uint8_t* dst,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册