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