提交 abc3617c 编写于 作者: 邓志豪 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/graphic_ui into weekly_20210510

...@@ -32,6 +32,7 @@ config("graphic_define_config") { ...@@ -32,6 +32,7 @@ config("graphic_define_config") {
defines = [ defines = [
"ENABLE_VECTOR_FONT=1", "ENABLE_VECTOR_FONT=1",
"ENABLE_BITMAP_FONT=0",
"ENABLE_SHAPING=0", "ENABLE_SHAPING=0",
"ENABLE_ICU=1", "ENABLE_ICU=1",
"ENABLE_MULTI_FONT=0", "ENABLE_MULTI_FONT=0",
...@@ -68,7 +69,6 @@ shared_library("ui") { ...@@ -68,7 +69,6 @@ shared_library("ui") {
"frameworks/common/task.cpp", "frameworks/common/task.cpp",
"frameworks/common/text.cpp", "frameworks/common/text.cpp",
"frameworks/common/typed_text.cpp", "frameworks/common/typed_text.cpp",
"frameworks/common/ui_font_header.cpp",
"frameworks/components/root_view.cpp", "frameworks/components/root_view.cpp",
"frameworks/components/text_adapter.cpp", "frameworks/components/text_adapter.cpp",
"frameworks/components/ui_abstract_clock.cpp", "frameworks/components/ui_abstract_clock.cpp",
...@@ -136,6 +136,8 @@ shared_library("ui") { ...@@ -136,6 +136,8 @@ shared_library("ui") {
"frameworks/font/ui_font.cpp", "frameworks/font/ui_font.cpp",
"frameworks/font/ui_font_adaptor.cpp", "frameworks/font/ui_font_adaptor.cpp",
"frameworks/font/ui_font_allocator.cpp", "frameworks/font/ui_font_allocator.cpp",
"frameworks/font/ui_font_bitmap.cpp",
"frameworks/font/ui_font_builder.cpp",
"frameworks/font/ui_font_cache.cpp", "frameworks/font/ui_font_cache.cpp",
"frameworks/font/ui_font_vector.cpp", "frameworks/font/ui_font_vector.cpp",
"frameworks/font/ui_line_break.cpp", "frameworks/font/ui_line_break.cpp",
...@@ -151,6 +153,8 @@ shared_library("ui") { ...@@ -151,6 +153,8 @@ shared_library("ui") {
"frameworks/themes/theme_manager.cpp", "frameworks/themes/theme_manager.cpp",
"frameworks/window/window.cpp", "frameworks/window/window.cpp",
"frameworks/window/window_impl.cpp", "frameworks/window/window_impl.cpp",
"frameworks/engines/gfx/gfx_engine_manager.cpp",
"frameworks/engines/gfx/hi3516/hi3516_engine.cpp",
] ]
include_dirs = [ "//foundation/graphic/ui/frameworks" ] include_dirs = [ "//foundation/graphic/ui/frameworks" ]
deps = [ deps = [
......
...@@ -47,24 +47,26 @@ void GraphicStartUp::InitFontEngine(uintptr_t cacheMemAddr, ...@@ -47,24 +47,26 @@ void GraphicStartUp::InitFontEngine(uintptr_t cacheMemAddr,
const char* dPath, const char* dPath,
const char* ttfName) const char* ttfName)
{ {
#if ENABLE_VECTOR_FONT UIFont* uiFont = UIFont::GetInstance();
UIFont* fontEngine = UIFont::GetInstance(); if (uiFont == nullptr) {
if (fontEngine == nullptr) {
GRAPHIC_LOGE("Get UIFont error"); GRAPHIC_LOGE("Get UIFont error");
return; return;
} }
fontEngine->SetPsramMemory(cacheMemAddr, cacheMemLen); uiFont->SetPsramMemory(cacheMemAddr, cacheMemLen);
int8_t ret = fontEngine->SetFontPath(const_cast<char*>(dPath), nullptr); int8_t ret = uiFont->SetFontPath(const_cast<char*>(dPath), nullptr);
if (ret == INVALID_RET_VALUE) { if (ret == INVALID_RET_VALUE) {
GRAPHIC_LOGW("SetFontPath failed"); GRAPHIC_LOGW("SetFontPath failed");
} }
if (ttfName != nullptr) { if (uiFont->IsVectorFont()) {
uint8_t ret2 = fontEngine->RegisterFontInfo(ttfName); if (ttfName != nullptr) {
if (ret2 == INVALID_UCHAR_ID) { uint8_t ret2 = uiFont->RegisterFontInfo(ttfName);
GRAPHIC_LOGW("SetTtfName failed"); if (ret2 == INVALID_UCHAR_ID) {
GRAPHIC_LOGW("SetTtfName failed");
}
} }
} else {
(void)uiFont->SetCurrentLangId(0); // set language
} }
#endif
} }
void GraphicStartUp::InitLineBreakEngine(uintptr_t cacheMemAddr, uint32_t cacheMemLen, const char* path, void GraphicStartUp::InitLineBreakEngine(uintptr_t cacheMemAddr, uint32_t cacheMemLen, const char* path,
......
...@@ -224,12 +224,16 @@ bool Image::SetSrc(const ImageInfo* src) ...@@ -224,12 +224,16 @@ bool Image::SetSrc(const ImageInfo* src)
return true; return true;
} }
void Image::DrawImage(const Rect& coords, const Rect& mask, const Style& style, uint8_t opaScale) const void Image::DrawImage(BufferInfo& gfxDstBuffer,
const Rect& coords,
const Rect& mask,
const Style& style,
uint8_t opaScale) const
{ {
if (srcType_ == IMG_SRC_VARIABLE) { if (srcType_ == IMG_SRC_VARIABLE) {
DrawImage::DrawCommon(coords, mask, imageInfo_, style, opaScale); DrawImage::DrawCommon(gfxDstBuffer, coords, mask, imageInfo_, style, opaScale);
} else if (srcType_ == IMG_SRC_FILE) { } else if (srcType_ == IMG_SRC_FILE) {
DrawImage::DrawCommon(coords, mask, path_, style, opaScale); DrawImage::DrawCommon(gfxDstBuffer, coords, mask, path_, style, opaScale);
} else { } else {
GRAPHIC_LOGE("Image::DrawImage:: failed with error srctype!\n"); GRAPHIC_LOGE("Image::DrawImage:: failed with error srctype!\n");
} }
......
...@@ -15,9 +15,10 @@ ...@@ -15,9 +15,10 @@
#include "common/screen.h" #include "common/screen.h"
#include "core/render_manager.h" #include "core/render_manager.h"
#include "dock/screen_device_proxy.h"
#include "draw/draw_utils.h" #include "draw/draw_utils.h"
#include "engines/gfx/gfx_engine_manager.h"
#include "gfx_utils/mem_api.h" #include "gfx_utils/mem_api.h"
#include "securec.h"
namespace OHOS { namespace OHOS {
Screen& Screen::GetInstance() Screen& Screen::GetInstance()
...@@ -28,26 +29,32 @@ Screen& Screen::GetInstance() ...@@ -28,26 +29,32 @@ Screen& Screen::GetInstance()
uint16_t Screen::GetWidth() uint16_t Screen::GetWidth()
{ {
return ScreenDeviceProxy::GetInstance()->GetScreenWidth(); return BaseGfxEngine::GetInstance()->GetScreenWidth();
} }
uint16_t Screen::GetHeight() uint16_t Screen::GetHeight()
{ {
return ScreenDeviceProxy::GetInstance()->GetScreenHeight(); return BaseGfxEngine::GetInstance()->GetScreenHeight();
} }
bool Screen::GetCurrentScreenBitmap(ImageInfo& info) bool Screen::GetCurrentScreenBitmap(ImageInfo& info)
{ {
uint16_t screenWidth = ScreenDeviceProxy::GetInstance()->GetScreenWidth(); BufferInfo* bufferInfo = BaseGfxEngine::GetInstance()->GetBufferInfo();
uint16_t screenHeight = ScreenDeviceProxy::GetInstance()->GetScreenHeight(); if (bufferInfo == nullptr) {
info.header.colorMode = ScreenDeviceProxy::GetInstance()->GetBufferMode(); return false;
}
uint16_t screenWidth = BaseGfxEngine::GetInstance()->GetScreenWidth();
uint16_t screenHeight = BaseGfxEngine::GetInstance()->GetScreenHeight();
info.header.colorMode = bufferInfo->mode;
info.dataSize = screenWidth * screenHeight * DrawUtils::GetByteSizeByColorMode(info.header.colorMode); info.dataSize = screenWidth * screenHeight * DrawUtils::GetByteSizeByColorMode(info.header.colorMode);
info.data = reinterpret_cast<uint8_t*>(ImageCacheMalloc(info)); info.data = reinterpret_cast<uint8_t*>(ImageCacheMalloc(info));
info.header.width = screenWidth; info.header.width = screenWidth;
info.header.height = screenHeight; info.header.height = screenHeight;
info.header.reserved = 0; info.header.reserved = 0;
info.header.compressMode = 0; info.header.compressMode = 0;
if (!ScreenDeviceProxy::GetInstance()->GetScreenBitmapBuffer(const_cast<uint8_t*>(info.data), info.dataSize)) {
if (memcpy_s(static_cast<void *>(const_cast<uint8_t *>(info.data)), info.dataSize,
bufferInfo->virAddr, info.dataSize) != EOK) {
ImageCacheFree(info); ImageCacheFree(info);
return false; return false;
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "draw/draw_label.h" #include "draw/draw_label.h"
#include "font/ui_font.h" #include "font/ui_font.h"
#include "font/ui_font_adaptor.h" #include "font/ui_font_adaptor.h"
#include "font/ui_font_builder.h"
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
#include "securec.h" #include "securec.h"
...@@ -82,7 +83,8 @@ void Text::SetFont(const char* name, uint8_t size) ...@@ -82,7 +83,8 @@ void Text::SetFont(const char* name, uint8_t size)
} }
if (UIFont::GetInstance()->IsVectorFont()) { if (UIFont::GetInstance()->IsVectorFont()) {
uint8_t fontId = UIFont::GetInstance()->GetFontId(name); uint8_t fontId = UIFont::GetInstance()->GetFontId(name);
if ((fontId != GetTotalFontId()) && ((fontId_ != fontId) || (fontSize_ != size))) { if ((fontId != UIFontBuilder::GetInstance()->GetTotalFontId()) &&
((fontId_ != fontId) || (fontSize_ != size))) {
fontId_ = fontId; fontId_ = fontId;
fontSize_ = size; fontSize_ = size;
needRefresh_ = true; needRefresh_ = true;
...@@ -127,17 +129,18 @@ void Text::SetFont(const char* name, uint8_t size, char*& destName, uint8_t& des ...@@ -127,17 +129,18 @@ void Text::SetFont(const char* name, uint8_t size, char*& destName, uint8_t& des
void Text::SetFontId(uint8_t fontId) void Text::SetFontId(uint8_t fontId)
{ {
if ((fontId >= GetTotalFontId()) || (fontId_ == fontId)) { if ((fontId >= UIFontBuilder::GetInstance()->GetTotalFontId()) || (fontId_ == fontId)) {
GRAPHIC_LOGE("Text::SetFontId invalid fontId(%d)", fontId); GRAPHIC_LOGE("Text::SetFontId invalid fontId(%d)", fontId);
return; return;
} }
UITextLanguageFontParam* fontParam = GetTextLangFontsTable(fontId); UITextLanguageFontParam* fontParam = UIFontBuilder::GetInstance()->GetTextLangFontsTable(fontId);
if (fontParam == nullptr) { if (fontParam == nullptr) {
return; return;
} }
if (UIFont::GetInstance()->IsVectorFont()) { if (UIFont::GetInstance()->IsVectorFont()) {
uint8_t fontId = UIFont::GetInstance()->GetFontId(fontParam->ttfName); uint8_t fontId = UIFont::GetInstance()->GetFontId(fontParam->ttfName);
if ((fontId != GetTotalFontId()) && ((fontId_ != fontId) || (fontSize_ != fontParam->size))) { if ((fontId != UIFontBuilder::GetInstance()->GetTotalFontId()) && ((fontId_ != fontId) ||
(fontSize_ != fontParam->size))) {
fontId_ = fontId; fontId_ = fontId;
fontSize_ = fontParam->size; fontSize_ = fontParam->size;
needRefresh_ = true; needRefresh_ = true;
...@@ -177,8 +180,8 @@ void Text::ReMeasureTextWidthInEllipsisMode(const Rect& textRect, const Style& s ...@@ -177,8 +180,8 @@ void Text::ReMeasureTextWidthInEllipsisMode(const Rect& textRect, const Style& s
} }
} }
} }
void Text::OnDraw(BufferInfo& gfxDstBuffer,
void Text::OnDraw(const Rect& invalidatedArea, const Rect& invalidatedArea,
const Rect& viewOrigRect, const Rect& viewOrigRect,
const Rect& textRect, const Rect& textRect,
int16_t offsetX, int16_t offsetX,
...@@ -193,11 +196,12 @@ void Text::OnDraw(const Rect& invalidatedArea, ...@@ -193,11 +196,12 @@ void Text::OnDraw(const Rect& invalidatedArea,
Rect mask = invalidatedArea; Rect mask = invalidatedArea;
if (mask.Intersect(mask, textRect)) { if (mask.Intersect(mask, textRect)) {
Draw(mask, textRect, style, offsetX, ellipsisIndex, opaScale); Draw(gfxDstBuffer, mask, textRect, style, offsetX, ellipsisIndex, opaScale);
} }
} }
void Text::Draw(const Rect& mask, void Text::Draw(BufferInfo& gfxDstBuffer,
const Rect& mask,
const Rect& coords, const Rect& coords,
const Style& style, const Style& style,
int16_t offsetX, int16_t offsetX,
...@@ -236,13 +240,13 @@ void Text::Draw(const Rect& mask, ...@@ -236,13 +240,13 @@ void Text::Draw(const Rect& mask,
0, 0,
static_cast<UITextLanguageDirect>(direct_), static_cast<UITextLanguageDirect>(direct_),
nullptr}; nullptr};
DrawLabel::DrawTextOneLine(labelLine); DrawLabel::DrawTextOneLine(gfxDstBuffer, labelLine);
if ((i == (lineCount - 1)) && (ellipsisIndex != TEXT_ELLIPSIS_END_INV)) { if ((i == (lineCount - 1)) && (ellipsisIndex != TEXT_ELLIPSIS_END_INV)) {
labelLine.offset.x = 0; labelLine.offset.x = 0;
labelLine.text = TEXT_ELLIPSIS; labelLine.text = TEXT_ELLIPSIS;
labelLine.lineLength = TEXT_ELLIPSIS_DOT_NUM; labelLine.lineLength = TEXT_ELLIPSIS_DOT_NUM;
labelLine.length = TEXT_ELLIPSIS_DOT_NUM; labelLine.length = TEXT_ELLIPSIS_DOT_NUM;
DrawLabel::DrawTextOneLine(labelLine); DrawLabel::DrawTextOneLine(gfxDstBuffer, labelLine);
} }
} }
lineBegin += textLine_[i].lineBytes; lineBegin += textLine_[i].lineBytes;
......
...@@ -17,11 +17,12 @@ ...@@ -17,11 +17,12 @@
#include "common/screen.h" #include "common/screen.h"
#include "core/render_manager.h" #include "core/render_manager.h"
#include "dock/screen_device_proxy.h" #include "draw/draw_utils.h"
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
#if ENABLE_WINDOW #if ENABLE_WINDOW
#include "window/window_impl.h" #include "window/window_impl.h"
#endif #endif
#include "securec.h"
namespace OHOS { namespace OHOS {
namespace { namespace {
#if LOCAL_RENDER #if LOCAL_RENDER
...@@ -39,6 +40,7 @@ RootView::RootView() ...@@ -39,6 +40,7 @@ RootView::RootView()
#if defined __linux__ || defined __LITEOS__ || defined __APPLE__ #if defined __linux__ || defined __LITEOS__ || defined __APPLE__
pthread_mutex_init(&lock_, nullptr); pthread_mutex_init(&lock_, nullptr);
#endif #endif
InitDrawContext();
} }
RootView* RootView::GetInstance() RootView* RootView::GetInstance()
...@@ -47,6 +49,13 @@ RootView* RootView::GetInstance() ...@@ -47,6 +49,13 @@ RootView* RootView::GetInstance()
return &instance; return &instance;
} }
RootView::~RootView()
{
DestroyDrawContext();
#if defined __linux__ || defined __LITEOS__ || defined __APPLE__
pthread_mutex_destroy(&lock_);
#endif
}
#if ENABLE_WINDOW #if ENABLE_WINDOW
Window* RootView::GetBoundWindow() const Window* RootView::GetBoundWindow() const
{ {
...@@ -465,16 +474,13 @@ void RootView::Render() ...@@ -465,16 +474,13 @@ void RootView::Render()
pthread_mutex_lock(&lock_); pthread_mutex_lock(&lock_);
#endif #endif
Rect mask;
#if LOCAL_RENDER #if LOCAL_RENDER
if (!invalidateMap_.empty()) { if (!invalidateMap_.empty()) {
mask = GetRect(); RenderManager::RenderRect(GetRect(), this);
RenderManager::RenderRect(mask, this);
invalidateMap_.clear(); invalidateMap_.clear();
#else #else
if (renderFlag_) { if (renderFlag_) {
mask = invalidRect_; RenderManager::RenderRect(invalidRect_, this);
RenderManager::RenderRect(mask, this);
invalidRect_ = {0, 0, 0, 0}; invalidRect_ = {0, 0, 0, 0};
renderFlag_ = false; renderFlag_ = false;
#endif #endif
...@@ -485,7 +491,7 @@ void RootView::Render() ...@@ -485,7 +491,7 @@ void RootView::Render()
boundWindow_->Update(); boundWindow_->Update();
} }
#endif #endif
ScreenDeviceProxy::GetInstance()->OnRenderFinish(mask); BaseGfxEngine::GetInstance()->Flush();
} }
#if defined __linux__ || defined __LITEOS__ || defined __APPLE__ #if defined __linux__ || defined __LITEOS__ || defined __APPLE__
...@@ -493,6 +499,37 @@ void RootView::Render() ...@@ -493,6 +499,37 @@ void RootView::Render()
#endif #endif
} }
void RootView::BlitMapBuffer(Rect& curViewRect, TransformMap& transMap, const Rect& invalidatedArea)
{
Rect invalidRect = curViewRect;
transMap.SetTransMapRect(curViewRect);
invalidRect.Join(invalidRect, transMap.GetBoxRect());
if (invalidRect.Intersect(invalidRect, invalidatedArea)) {
uint8_t pxSize = DrawUtils::GetPxSizeByColorMode(dc_.mapBufferInfo->mode);
ImageInfo imageInfo;
imageInfo.header.colorMode = dc_.mapBufferInfo->mode;
imageInfo.dataSize = dc_.mapBufferInfo->width * dc_.mapBufferInfo->height * (pxSize >> 3);
imageInfo.header.width = dc_.mapBufferInfo->width;
imageInfo.header.height = dc_.mapBufferInfo->height;
imageInfo.header.reserved = 0;
imageInfo.data = reinterpret_cast<uint8_t*>(dc_.mapBufferInfo->virAddr);
TransformDataInfo imageTranDataInfo = {imageInfo.header, imageInfo.data, pxSize, LEVEL0,
BILINEAR};
BaseGfxEngine::GetInstance()->DrawTransform(*dc_.bufferInfo, invalidRect, {0, 0}, Color::Black(),
OPA_OPAQUE, transMap, imageTranDataInfo);
}
}
void RootView::ClearMapBuffer()
{
uint8_t pxSize = DrawUtils::GetPxSizeByColorMode(dc_.mapBufferInfo->mode);
uint32_t dataSize = dc_.mapBufferInfo->width * dc_.mapBufferInfo->height * (pxSize >> 3);
if (memset_s(dc_.mapBufferInfo->virAddr, dataSize, 0, dataSize) != EOK) {
GRAPHIC_LOGE("animator buffer memset failed.");
}
}
void RootView::DrawTop(UIView* view, const Rect& rect) void RootView::DrawTop(UIView* view, const Rect& rect)
{ {
if (view == nullptr) { if (view == nullptr) {
...@@ -511,6 +548,8 @@ void RootView::DrawTop(UIView* view, const Rect& rect) ...@@ -511,6 +548,8 @@ void RootView::DrawTop(UIView* view, const Rect& rect)
Rect origRect; Rect origRect;
Rect relativeRect; Rect relativeRect;
bool enableAnimator = false; bool enableAnimator = false;
TransformMap curTransMap;
while (par != nullptr) { while (par != nullptr) {
if (curView != nullptr) { if (curView != nullptr) {
if (curView->IsVisible()) { if (curView->IsVisible()) {
...@@ -522,13 +561,21 @@ void RootView::DrawTop(UIView* view, const Rect& rect) ...@@ -522,13 +561,21 @@ void RootView::DrawTop(UIView* view, const Rect& rect)
curView->GetTransformMap().SetInvalid(true); curView->GetTransformMap().SetInvalid(true);
curView->SetPosition(relativeRect.GetX() - origRect.GetX(), curView->SetPosition(relativeRect.GetX() - origRect.GetX(),
relativeRect.GetY() - origRect.GetY()); relativeRect.GetY() - origRect.GetY());
curViewRect = curView->GetMaskedRect();
ScreenDeviceProxy::GetInstance()->EnableAnimatorBuffer(true); ClearMapBuffer();
ScreenDeviceProxy::GetInstance()->SetAnimatorRect(origRect); curTransMap = curView->GetTransformMap();
ScreenDeviceProxy::GetInstance()->SetAnimatorTransMap(curView->GetTransformMap());
enableAnimator = true; enableAnimator = true;
} }
curView->OnDraw(curViewRect);
if (enableAnimator) {
Rect invalidatedArea;
invalidatedArea.SetWidth(dc_.mapBufferInfo->width);
invalidatedArea.SetHeight(dc_.mapBufferInfo->height);
curView->OnDraw(*dc_.mapBufferInfo, invalidatedArea);
curViewRect = invalidatedArea;
} else {
curView->OnDraw(*dc_.bufferInfo, curViewRect);
}
if ((curView->IsViewGroup()) && (stackCount < COMPONENT_NESTING_DEPTH)) { if ((curView->IsViewGroup()) && (stackCount < COMPONENT_NESTING_DEPTH)) {
if (enableAnimator && (transViewGroup == nullptr)) { if (enableAnimator && (transViewGroup == nullptr)) {
...@@ -543,10 +590,15 @@ void RootView::DrawTop(UIView* view, const Rect& rect) ...@@ -543,10 +590,15 @@ void RootView::DrawTop(UIView* view, const Rect& rect)
mask.Intersect(mask, curViewRect); mask.Intersect(mask, curViewRect);
continue; continue;
} }
curView->OnPostDraw(curViewRect);
if (enableAnimator) {
curView->OnPostDraw(*dc_.mapBufferInfo, curViewRect);
} else {
curView->OnPostDraw(*dc_.bufferInfo, curViewRect);
}
if (enableAnimator && (transViewGroup == nullptr)) { if (enableAnimator && (transViewGroup == nullptr)) {
ScreenDeviceProxy::GetInstance()->EnableAnimatorBuffer(false); BlitMapBuffer(origRect, curTransMap, mask);
ScreenDeviceProxy::GetInstance()->DrawAnimatorBuffer(mask);
curView->GetTransformMap().SetInvalid(false); curView->GetTransformMap().SetInvalid(false);
enableAnimator = false; enableAnimator = false;
curView->SetPosition(relativeRect.GetX(), relativeRect.GetY()); curView->SetPosition(relativeRect.GetX(), relativeRect.GetY());
...@@ -559,12 +611,14 @@ void RootView::DrawTop(UIView* view, const Rect& rect) ...@@ -559,12 +611,14 @@ void RootView::DrawTop(UIView* view, const Rect& rect)
if (--stackCount >= 0) { if (--stackCount >= 0) {
curViewRect = par->GetMaskedRect(); curViewRect = par->GetMaskedRect();
mask = g_maskStack[stackCount]; mask = g_maskStack[stackCount];
if (enableAnimator || curViewRect.Intersect(curViewRect, mask)) { if (enableAnimator) {
par->OnPostDraw(curViewRect); par->OnPostDraw(*dc_.mapBufferInfo, curViewRect);
} else if (curViewRect.Intersect(curViewRect, mask)) {
par->OnPostDraw(*dc_.bufferInfo, curViewRect);
} }
if (enableAnimator && transViewGroup == g_viewStack[stackCount]) { if (enableAnimator && transViewGroup == g_viewStack[stackCount]) {
ScreenDeviceProxy::GetInstance()->EnableAnimatorBuffer(false); BlitMapBuffer(origRect, curTransMap, mask);
ScreenDeviceProxy::GetInstance()->DrawAnimatorBuffer(mask);
transViewGroup->GetTransformMap().SetInvalid(false); transViewGroup->GetTransformMap().SetInvalid(false);
enableAnimator = false; enableAnimator = false;
transViewGroup->SetPosition(relativeRect.GetX(), relativeRect.GetY()); transViewGroup->SetPosition(relativeRect.GetX(), relativeRect.GetY());
...@@ -638,4 +692,83 @@ bool RootView::FindSubView(const UIView& parentView, const UIView* subView) ...@@ -638,4 +692,83 @@ bool RootView::FindSubView(const UIView& parentView, const UIView* subView)
} }
return false; return false;
} }
} // namespace OHOS
\ No newline at end of file void RootView::InitMapBufferInfo(BufferInfo* bufferInfo)
{
uint32_t bufferSize = bufferInfo->width * bufferInfo->height *
(DrawUtils::GetPxSizeByColorMode(bufferInfo->mode) >> 3); // 3: Shift right 3 bits
dc_.mapBufferInfo = new BufferInfo();
if (dc_.mapBufferInfo == nullptr) {
return;
}
if (memcpy_s(dc_.mapBufferInfo, sizeof(BufferInfo), bufferInfo, sizeof(BufferInfo)) != EOK) {
delete dc_.mapBufferInfo;
dc_.mapBufferInfo = nullptr;
return;
}
dc_.mapBufferInfo->virAddr = dc_.mapBufferInfo->phyAddr =
BaseGfxEngine::GetInstance()->AllocBuffer(bufferSize, BUFFER_MAP_SURFACE);
}
void RootView::DestroyMapBufferInfo()
{
if (dc_.mapBufferInfo != nullptr) {
BaseGfxEngine::GetInstance()->FreeBuffer(static_cast<uint8_t *>(dc_.mapBufferInfo->virAddr));
dc_.mapBufferInfo->virAddr = dc_.mapBufferInfo->phyAddr = nullptr;
delete dc_.mapBufferInfo;
dc_.mapBufferInfo = nullptr;
}
}
void RootView::InitDrawContext()
{
dc_.bufferInfo = BaseGfxEngine::GetInstance()->GetBufferInfo();
if (dc_.bufferInfo != nullptr) {
InitMapBufferInfo(dc_.bufferInfo);
}
}
void RootView::DestroyDrawContext()
{
DestroyMapBufferInfo();
}
void RootView::UpdateBufferInfo(BufferInfo* fbBufferInfo)
{
if (dc_.bufferInfo == nullptr) {
dc_.bufferInfo = fbBufferInfo;
InitMapBufferInfo(fbBufferInfo);
} else {
if (dc_.bufferInfo->width != fbBufferInfo->width ||
dc_.bufferInfo->height != fbBufferInfo->height ||
dc_.bufferInfo->mode != fbBufferInfo->mode) {
DestroyMapBufferInfo();
InitMapBufferInfo(fbBufferInfo);
}
dc_.bufferInfo = fbBufferInfo;
}
}
void RootView::SaveDrawContext()
{
bakDc_.bufferInfo = dc_.bufferInfo;
dc_.bufferInfo = nullptr;
bakDc_.mapBufferInfo = dc_.mapBufferInfo;
dc_.mapBufferInfo = nullptr;
}
void RootView::RestoreDrawContext()
{
DestroyDrawContext();
dc_.bufferInfo = bakDc_.bufferInfo;
bakDc_.bufferInfo = nullptr;
dc_.mapBufferInfo = bakDc_.mapBufferInfo;
bakDc_.mapBufferInfo = nullptr;
}
} // namespace OHOS
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
#include "components/ui_analog_clock.h" #include "components/ui_analog_clock.h"
#include "components/ui_image_view.h" #include "components/ui_image_view.h"
#include "draw/draw_image.h" #include "draw/draw_image.h"
#include "draw/draw_line.h" #include "engines/gfx/gfx_engine_manager.h"
#include "draw/draw_rect.h"
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
#include "gfx_utils/style.h" #include "gfx_utils/style.h"
#include "imgdecode/cache_manager.h" #include "imgdecode/cache_manager.h"
...@@ -206,18 +205,18 @@ void UIAnalogClock::UpdateClock(bool clockInit) ...@@ -206,18 +205,18 @@ void UIAnalogClock::UpdateClock(bool clockInit)
} }
} }
void UIAnalogClock::OnDraw(const Rect& invalidatedArea) void UIAnalogClock::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
DrawRect::Draw(GetRect(), invalidatedArea, *style_, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, GetRect(), invalidatedArea, *style_, opaScale_);
} }
void UIAnalogClock::OnPostDraw(const Rect& invalidatedArea) void UIAnalogClock::OnPostDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
Rect current = GetOrigRect(); Rect current = GetOrigRect();
DrawHand(current, invalidatedArea, hourHand_); DrawHand(gfxDstBuffer, current, invalidatedArea, hourHand_);
DrawHand(current, invalidatedArea, minuteHand_); DrawHand(gfxDstBuffer, current, invalidatedArea, minuteHand_);
if (GetWorkMode() == WorkMode::NORMAL) { if (GetWorkMode() == WorkMode::NORMAL) {
DrawHand(current, invalidatedArea, secondHand_); DrawHand(gfxDstBuffer, current, invalidatedArea, secondHand_);
} }
} }
...@@ -265,27 +264,30 @@ void UIAnalogClock::CalculateRedrawArea(const Rect& current, Hand& hand, bool cl ...@@ -265,27 +264,30 @@ void UIAnalogClock::CalculateRedrawArea(const Rect& current, Hand& hand, bool cl
} }
} }
void UIAnalogClock::DrawHand(const Rect& current, const Rect& invalidatedArea, Hand& hand) void UIAnalogClock::DrawHand(BufferInfo& gfxDstBuffer, const Rect& current, const Rect& invalidatedArea, Hand& hand)
{ {
if (hand.drawtype_ == DrawType::DRAW_IMAGE) { if (hand.drawtype_ == DrawType::DRAW_IMAGE) {
DrawHandImage(current, invalidatedArea, hand); DrawHandImage(gfxDstBuffer, current, invalidatedArea, hand);
} else { } else {
DrawHandLine(invalidatedArea, hand); DrawHandLine(gfxDstBuffer, invalidatedArea, hand);
} }
} }
void UIAnalogClock::DrawHandImage(const Rect& current, const Rect& invalidatedArea, Hand& hand) void UIAnalogClock::DrawHandImage(BufferInfo& gfxDstBuffer,
const Rect& current,
const Rect& invalidatedArea,
Hand& hand)
{ {
uint8_t pxSize = DrawUtils::GetPxSizeByColorMode(hand.imageInfo_.header.colorMode); uint8_t pxSize = DrawUtils::GetPxSizeByColorMode(hand.imageInfo_.header.colorMode);
TransformDataInfo imageTranDataInfo = { TransformDataInfo imageTranDataInfo = {
hand.imageInfo_.header, hand.imageInfo_.data, pxSize, hand.imageInfo_.header, hand.imageInfo_.data, pxSize,
BlurLevel::LEVEL0, TransformAlgorithm::BILINEAR BlurLevel::LEVEL0, TransformAlgorithm::BILINEAR
}; };
DrawUtils::GetInstance()->DrawTransform(invalidatedArea, { 0, 0 }, BaseGfxEngine::GetInstance()->DrawTransform(gfxDstBuffer, invalidatedArea, { 0, 0 },
Color::Black(), opaScale_, hand.trans_, imageTranDataInfo); Color::Black(), opaScale_, hand.trans_, imageTranDataInfo);
} }
void UIAnalogClock::DrawHandLine(const Rect& invalidatedArea, Hand& hand) void UIAnalogClock::DrawHandLine(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, Hand& hand)
{ {
float sinma = Sin(hand.nextAngle_); float sinma = Sin(hand.nextAngle_);
float cosma = Sin(hand.nextAngle_ + THREE_QUARTER_IN_DEGREE); float cosma = Sin(hand.nextAngle_ + THREE_QUARTER_IN_DEGREE);
...@@ -316,7 +318,8 @@ void UIAnalogClock::DrawHandLine(const Rect& invalidatedArea, Hand& hand) ...@@ -316,7 +318,8 @@ void UIAnalogClock::DrawHandLine(const Rect& invalidatedArea, Hand& hand)
end.x = xlength + curCenter.x; end.x = xlength + curCenter.x;
end.y = ylength + curCenter.y; end.y = ylength + curCenter.y;
DrawLine::Draw(start, end, invalidatedArea, hand.width_, hand.color_, hand.opacity_); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, end, invalidatedArea,
hand.width_, hand.color_, hand.opacity_);
} }
void UIAnalogClock::SetWorkMode(WorkMode newMode) void UIAnalogClock::SetWorkMode(WorkMode newMode)
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "components/ui_arc_label.h" #include "components/ui_arc_label.h"
#include "common/typed_text.h" #include "common/typed_text.h"
#include "draw/draw_label.h" #include "draw/draw_label.h"
#include "draw/draw_rect.h" #include "engines/gfx/gfx_engine_manager.h"
#include "font/ui_font.h" #include "font/ui_font.h"
#include "themes/theme_manager.h" #include "themes/theme_manager.h"
...@@ -115,7 +115,7 @@ void UIArcLabel::SetFont(const char* name, uint8_t size) ...@@ -115,7 +115,7 @@ void UIArcLabel::SetFont(const char* name, uint8_t size)
} }
} }
void UIArcLabel::OnDraw(const Rect& invalidatedArea) void UIArcLabel::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
InitArcLabelText(); InitArcLabelText();
const char* text = arcLabelText_->GetText(); const char* text = arcLabelText_->GetText();
...@@ -124,19 +124,19 @@ void UIArcLabel::OnDraw(const Rect& invalidatedArea) ...@@ -124,19 +124,19 @@ void UIArcLabel::OnDraw(const Rect& invalidatedArea)
} }
Rect trunc = invalidatedArea; Rect trunc = invalidatedArea;
OpacityType opa = GetMixOpaScale(); OpacityType opa = GetMixOpaScale();
UIView::OnDraw(invalidatedArea); UIView::OnDraw(gfxDstBuffer, invalidatedArea);
DrawArcText(trunc, opa); DrawArcText(gfxDstBuffer, trunc, opa);
} }
void UIArcLabel::DrawArcText(const Rect& mask, OpacityType opaScale) void UIArcLabel::DrawArcText(BufferInfo& gfxDstBuffer, const Rect& mask, OpacityType opaScale)
{ {
Point center; Point center;
center.x = arcTextInfo_.arcCenter.x + GetRect().GetX(); center.x = arcTextInfo_.arcCenter.x + GetRect().GetX();
center.y = arcTextInfo_.arcCenter.y + GetRect().GetY(); center.y = arcTextInfo_.arcCenter.y + GetRect().GetY();
InitArcLabelText(); InitArcLabelText();
UIFont::GetInstance()->SetCurrentFontId(arcLabelText_->GetFontId(), arcLabelText_->GetFontSize()); UIFont::GetInstance()->SetCurrentFontId(arcLabelText_->GetFontId(), arcLabelText_->GetFontSize());
DrawLabel::DrawArcText(mask, arcLabelText_->GetText(), center, arcLabelText_->GetFontId(), arcTextInfo_, DrawLabel::DrawArcText(gfxDstBuffer, mask, arcLabelText_->GetText(), center, arcLabelText_->GetFontId(),
orientation_, *style_, opaScale); arcTextInfo_, orientation_, *style_, opaScale);
} }
void UIArcLabel::RefreshArcLabel() void UIArcLabel::RefreshArcLabel()
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "components/ui_axis.h" #include "components/ui_axis.h"
#include "common/screen.h" #include "common/screen.h"
#include "draw/draw_line.h" #include "engines/gfx/gfx_engine_manager.h"
namespace OHOS { namespace OHOS {
UIAxis::UIAxis() UIAxis::UIAxis()
...@@ -91,13 +91,14 @@ void UIXAxis::TranslateToPixel(int16_t& value) ...@@ -91,13 +91,14 @@ void UIXAxis::TranslateToPixel(int16_t& value)
value = start_.x + static_cast<int16_t>((value - minRange_) * minXStep); value = start_.x + static_cast<int16_t>((value - minRange_) * minXStep);
} }
void UIAxis::OnDraw(const Rect& invalidatedArea) void UIAxis::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
DrawLine::Draw(start_, end_, invalidatedArea, style_->lineWidth_, style_->lineColor_, style_->lineOpa_); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start_, end_, invalidatedArea, style_->lineWidth_,
DrawAxisMark(invalidatedArea); style_->lineColor_, style_->lineOpa_);
DrawAxisMark(gfxDstBuffer, invalidatedArea);
} }
void UIXAxis::DrawAxisMark(const Rect& invalidatedArea) void UIXAxis::DrawAxisMark(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
Point start; Point start;
Point end; Point end;
...@@ -108,7 +109,8 @@ void UIXAxis::DrawAxisMark(const Rect& invalidatedArea) ...@@ -108,7 +109,8 @@ void UIXAxis::DrawAxisMark(const Rect& invalidatedArea)
end.y = enableReverse_ ? (start.y + AXIS_DEFAULT_MARK_LENGTH) : (start.y - AXIS_DEFAULT_MARK_LENGTH); end.y = enableReverse_ ? (start.y + AXIS_DEFAULT_MARK_LENGTH) : (start.y - AXIS_DEFAULT_MARK_LENGTH);
end.x = start.x; end.x = start.x;
DrawLine::Draw(start, end, invalidatedArea, style_->lineWidth_, style_->lineColor_, style_->lineOpa_); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, end, invalidatedArea,
style_->lineWidth_, style_->lineColor_, style_->lineOpa_);
index++; index++;
} }
} }
...@@ -178,7 +180,7 @@ bool UIYAxis::UpdateAxis() ...@@ -178,7 +180,7 @@ bool UIYAxis::UpdateAxis()
return true; return true;
} }
void UIYAxis::DrawAxisMark(const Rect& invalidatedArea) void UIYAxis::DrawAxisMark(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
uint16_t index = 1; uint16_t index = 1;
while (index <= markDataCount_) { while (index <= markDataCount_) {
...@@ -190,7 +192,8 @@ void UIYAxis::DrawAxisMark(const Rect& invalidatedArea) ...@@ -190,7 +192,8 @@ void UIYAxis::DrawAxisMark(const Rect& invalidatedArea)
end.x = start.x + AXIS_DEFAULT_MARK_LENGTH; end.x = start.x + AXIS_DEFAULT_MARK_LENGTH;
end.y = start.y; end.y = start.y;
DrawLine::Draw(start, end, invalidatedArea, style_->lineWidth_, style_->lineColor_, style_->lineOpa_); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, end, invalidatedArea,
style_->lineWidth_, style_->lineColor_, style_->lineOpa_);
index++; index++;
} }
} }
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
*/ */
#include "components/ui_box_progress.h" #include "components/ui_box_progress.h"
#include "draw/draw_arc.h" #include "draw/draw_utils.h"
#include "draw/draw_rect.h" #include "engines/gfx/gfx_engine_manager.h"
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
namespace OHOS { namespace OHOS {
...@@ -25,7 +25,8 @@ UIBoxProgress::UIBoxProgress() ...@@ -25,7 +25,8 @@ UIBoxProgress::UIBoxProgress()
SetDirection(Direction::DIR_LEFT_TO_RIGHT); SetDirection(Direction::DIR_LEFT_TO_RIGHT);
} }
void UIBoxProgress::DrawValidRect(const Image* image, void UIBoxProgress::DrawValidRect(BufferInfo& gfxDstBuffer,
const Image* image,
const Rect& rect, const Rect& rect,
const Rect& invalidatedArea, const Rect& invalidatedArea,
const Style& style, const Style& style,
...@@ -57,18 +58,19 @@ void UIBoxProgress::DrawValidRect(const Image* image, ...@@ -57,18 +58,19 @@ void UIBoxProgress::DrawValidRect(const Image* image,
cordsTmp.SetHeight(header.height); cordsTmp.SetHeight(header.height);
cordsTmp.SetWidth(header.width); cordsTmp.SetWidth(header.width);
if (area.Intersect(area, invalidatedArea)) { if (area.Intersect(area, invalidatedArea)) {
image->DrawImage(cordsTmp, area, style, opaScale_); image->DrawImage(gfxDstBuffer, cordsTmp, area, style, opaScale_);
} }
} else { } else {
DrawRect::Draw(rect, invalidatedArea, style, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, rect, invalidatedArea, style, opaScale_);
} }
if (style.lineCap_ == CapType::CAP_ROUND) { if (style.lineCap_ == CapType::CAP_ROUND) {
DrawRoundCap(image, {cordsTmp.GetX(), cordsTmp.GetY()}, rect, invalidatedArea, radius, style); DrawRoundCap(gfxDstBuffer, image, {cordsTmp.GetX(), cordsTmp.GetY()}, rect, invalidatedArea, radius, style);
} }
} }
void UIBoxProgress::DrawRoundCap(const Image* image, void UIBoxProgress::DrawRoundCap(BufferInfo& gfxDstBuffer,
const Image* image,
const Point& imgPos, const Point& imgPos,
const Rect& rect, const Rect& rect,
const Rect& invalidatedArea, const Rect& invalidatedArea,
...@@ -129,22 +131,26 @@ void UIBoxProgress::DrawRoundCap(const Image* image, ...@@ -129,22 +131,26 @@ void UIBoxProgress::DrawRoundCap(const Image* image,
arcInfo.center = leftTop; arcInfo.center = leftTop;
arcInfo.startAngle = THREE_QUARTER_IN_DEGREE; arcInfo.startAngle = THREE_QUARTER_IN_DEGREE;
arcInfo.endAngle = 0; arcInfo.endAngle = 0;
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, capStyle, opaScale_, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_,
CapType::CAP_NONE);
arcInfo.center = leftBottom; arcInfo.center = leftBottom;
arcInfo.startAngle = SEMICIRCLE_IN_DEGREE; arcInfo.startAngle = SEMICIRCLE_IN_DEGREE;
arcInfo.endAngle = THREE_QUARTER_IN_DEGREE; arcInfo.endAngle = THREE_QUARTER_IN_DEGREE;
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, capStyle, opaScale_, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_,
CapType::CAP_NONE);
arcInfo.center = rightTop; arcInfo.center = rightTop;
arcInfo.startAngle = 0; arcInfo.startAngle = 0;
arcInfo.endAngle = QUARTER_IN_DEGREE; arcInfo.endAngle = QUARTER_IN_DEGREE;
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, capStyle, opaScale_, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_,
CapType::CAP_NONE);
arcInfo.center = rightBottom; arcInfo.center = rightBottom;
arcInfo.startAngle = QUARTER_IN_DEGREE; arcInfo.startAngle = QUARTER_IN_DEGREE;
arcInfo.endAngle = SEMICIRCLE_IN_DEGREE; arcInfo.endAngle = SEMICIRCLE_IN_DEGREE;
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, capStyle, opaScale_, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_,
CapType::CAP_NONE);
} else { } else {
switch (direction_) { switch (direction_) {
case Direction::DIR_LEFT_TO_RIGHT: case Direction::DIR_LEFT_TO_RIGHT:
...@@ -152,12 +158,14 @@ void UIBoxProgress::DrawRoundCap(const Image* image, ...@@ -152,12 +158,14 @@ void UIBoxProgress::DrawRoundCap(const Image* image,
arcInfo.center = leftTop; arcInfo.center = leftTop;
arcInfo.startAngle = SEMICIRCLE_IN_DEGREE; arcInfo.startAngle = SEMICIRCLE_IN_DEGREE;
arcInfo.endAngle = 0; arcInfo.endAngle = 0;
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, capStyle, opaScale_, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_,
CapType::CAP_NONE);
arcInfo.center = leftBottom; arcInfo.center = leftBottom;
arcInfo.startAngle = 0; arcInfo.startAngle = 0;
arcInfo.endAngle = SEMICIRCLE_IN_DEGREE; arcInfo.endAngle = SEMICIRCLE_IN_DEGREE;
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, capStyle, opaScale_, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_,
CapType::CAP_NONE);
break; break;
} }
...@@ -166,12 +174,14 @@ void UIBoxProgress::DrawRoundCap(const Image* image, ...@@ -166,12 +174,14 @@ void UIBoxProgress::DrawRoundCap(const Image* image,
arcInfo.center = leftTop; arcInfo.center = leftTop;
arcInfo.startAngle = THREE_QUARTER_IN_DEGREE; arcInfo.startAngle = THREE_QUARTER_IN_DEGREE;
arcInfo.endAngle = QUARTER_IN_DEGREE; arcInfo.endAngle = QUARTER_IN_DEGREE;
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, capStyle, opaScale_, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_,
CapType::CAP_NONE);
arcInfo.center = leftBottom; arcInfo.center = leftBottom;
arcInfo.startAngle = QUARTER_IN_DEGREE; arcInfo.startAngle = QUARTER_IN_DEGREE;
arcInfo.endAngle = THREE_QUARTER_IN_DEGREE; arcInfo.endAngle = THREE_QUARTER_IN_DEGREE;
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, capStyle, opaScale_, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, capStyle, opaScale_,
CapType::CAP_NONE);
break; break;
} }
default: default:
...@@ -217,7 +227,7 @@ void UIBoxProgress::GetBackgroundParam(Point& startPoint, ...@@ -217,7 +227,7 @@ void UIBoxProgress::GetBackgroundParam(Point& startPoint,
} }
} }
void UIBoxProgress::DrawBackground(const Rect& invalidatedArea) void UIBoxProgress::DrawBackground(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
Point startPoint; Point startPoint;
int16_t progressWidth; int16_t progressWidth;
...@@ -227,10 +237,10 @@ void UIBoxProgress::DrawBackground(const Rect& invalidatedArea) ...@@ -227,10 +237,10 @@ void UIBoxProgress::DrawBackground(const Rect& invalidatedArea)
Rect coords(startPoint.x, startPoint.y, startPoint.x + progressWidth - 1, startPoint.y + progressHeight - 1); Rect coords(startPoint.x, startPoint.y, startPoint.x + progressWidth - 1, startPoint.y + progressHeight - 1);
DrawValidRect(backgroundImage_, coords, invalidatedArea, *backgroundStyle_, radius); DrawValidRect(gfxDstBuffer, backgroundImage_, coords, invalidatedArea, *backgroundStyle_, radius);
} }
void UIBoxProgress::DrawForeground(const Rect& invalidatedArea, Rect& coords) void UIBoxProgress::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, Rect& coords)
{ {
Point startPoint; Point startPoint;
int16_t progressWidth; int16_t progressWidth;
...@@ -268,19 +278,19 @@ void UIBoxProgress::DrawForeground(const Rect& invalidatedArea, Rect& coords) ...@@ -268,19 +278,19 @@ void UIBoxProgress::DrawForeground(const Rect& invalidatedArea, Rect& coords)
} }
} }
DrawValidRect(foregroundImage_, coords, invalidatedArea, *foregroundStyle_, radius); DrawValidRect(gfxDstBuffer, foregroundImage_, coords, invalidatedArea, *foregroundStyle_, radius);
} }
void UIBoxProgress::OnDraw(const Rect& invalidatedArea) void UIBoxProgress::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
UIView::OnDraw(invalidatedArea); UIView::OnDraw(gfxDstBuffer, invalidatedArea);
if (enableBackground_) { if (enableBackground_) {
DrawBackground(invalidatedArea); DrawBackground(gfxDstBuffer, invalidatedArea);
} }
if ((lastValue_ - rangeMin_ != 0) || (foregroundStyle_->lineCap_ == CapType::CAP_ROUND)) { if ((lastValue_ - rangeMin_ != 0) || (foregroundStyle_->lineCap_ == CapType::CAP_ROUND)) {
Rect coords; Rect coords;
DrawForeground(invalidatedArea, coords); DrawForeground(gfxDstBuffer, invalidatedArea, coords);
} }
} }
} // namespace OHOS } // namespace OHOS
\ No newline at end of file
...@@ -14,11 +14,10 @@ ...@@ -14,11 +14,10 @@
*/ */
#include "components/ui_button.h" #include "components/ui_button.h"
#include "animator/interpolation.h" #include "animator/interpolation.h"
#include "common/image.h" #include "common/image.h"
#include "draw/draw_image.h" #include "draw/draw_image.h"
#include "draw/draw_rect.h" #include "engines/gfx/gfx_engine_manager.h"
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
#include "gfx_utils/style.h" #include "gfx_utils/style.h"
#include "imgdecode/cache_manager.h" #include "imgdecode/cache_manager.h"
...@@ -66,7 +65,7 @@ UIButton::~UIButton() ...@@ -66,7 +65,7 @@ UIButton::~UIButton()
} }
} }
void UIButton::DrawImg(const Rect& invalidatedArea, OpacityType opaScale) void UIButton::DrawImg(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, OpacityType opaScale)
{ {
const Image* image = GetCurImageSrc(); const Image* image = GetCurImageSrc();
if (image == nullptr) { if (image == nullptr) {
...@@ -84,15 +83,15 @@ void UIButton::DrawImg(const Rect& invalidatedArea, OpacityType opaScale) ...@@ -84,15 +83,15 @@ void UIButton::DrawImg(const Rect& invalidatedArea, OpacityType opaScale)
Rect trunc(invalidatedArea); Rect trunc(invalidatedArea);
if (trunc.Intersect(trunc, viewRect)) { if (trunc.Intersect(trunc, viewRect)) {
image->DrawImage(coords, trunc, *buttonStyles_[state_], opaScale); image->DrawImage(gfxDstBuffer, coords, trunc, *buttonStyles_[state_], opaScale);
} }
} }
void UIButton::OnDraw(const Rect& invalidatedArea) void UIButton::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
OpacityType opa = GetMixOpaScale(); OpacityType opa = GetMixOpaScale();
DrawRect::Draw(GetOrigRect(), invalidatedArea, *buttonStyles_[state_], opa); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, GetOrigRect(), invalidatedArea, *buttonStyles_[state_], opa);
DrawImg(invalidatedArea, opa); DrawImg(gfxDstBuffer, invalidatedArea, opa);
} }
void UIButton::SetupThemeStyles() void UIButton::SetupThemeStyles()
...@@ -295,10 +294,10 @@ bool UIButton::OnPreDraw(Rect& invalidatedArea) const ...@@ -295,10 +294,10 @@ bool UIButton::OnPreDraw(Rect& invalidatedArea) const
} }
#if DEFAULT_ANIMATION #if DEFAULT_ANIMATION
void UIButton::OnPostDraw(const Rect& invalidatedArea) void UIButton::OnPostDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
if (state_ == ButtonState::PRESSED) { if (state_ == ButtonState::PRESSED) {
animator_.DrawMask(invalidatedArea); animator_.DrawMask(gfxDstBuffer, invalidatedArea);
} }
} }
...@@ -333,14 +332,14 @@ void UIButton::ButtonAnimator::Start() ...@@ -333,14 +332,14 @@ void UIButton::ButtonAnimator::Start()
isReverseAnimation_ = isReverse; isReverseAnimation_ = isReverse;
} }
void UIButton::ButtonAnimator::DrawMask(const Rect& invalidatedArea) void UIButton::ButtonAnimator::DrawMask(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
Style maskStyle; Style maskStyle;
maskStyle.SetStyle(STYLE_BACKGROUND_COLOR, Color::White().full); maskStyle.SetStyle(STYLE_BACKGROUND_COLOR, Color::White().full);
maskStyle.SetStyle(STYLE_BACKGROUND_OPA, MASK_OPA); maskStyle.SetStyle(STYLE_BACKGROUND_OPA, MASK_OPA);
maskStyle.SetStyle(STYLE_BORDER_RADIUS, button_.GetStyle(STYLE_BORDER_RADIUS)); maskStyle.SetStyle(STYLE_BORDER_RADIUS, button_.GetStyle(STYLE_BORDER_RADIUS));
OpacityType opa = button_.GetMixOpaScale(); OpacityType opa = button_.GetMixOpaScale();
DrawRect::Draw(button_.GetRect(), invalidatedArea, maskStyle, opa); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, button_.GetRect(), invalidatedArea, maskStyle, opa);
} }
static inline void ScaleButton(UIButton& button, float scale) static inline void ScaleButton(UIButton& button, float scale)
......
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
#include "components/ui_canvas.h" #include "components/ui_canvas.h"
#include "common/image.h" #include "common/image.h"
#include "draw/draw_arc.h" #include "draw/draw_arc.h"
#include "draw/draw_curve.h"
#include "draw/draw_image.h" #include "draw/draw_image.h"
#include "draw/draw_line.h" #include "engines/gfx/gfx_engine_manager.h"
#include "draw/draw_rect.h"
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
namespace OHOS { namespace OHOS {
...@@ -450,10 +448,10 @@ void UICanvas::DrawPath(const Paint& paint) ...@@ -450,10 +448,10 @@ void UICanvas::DrawPath(const Paint& paint)
Invalidate(); Invalidate();
} }
void UICanvas::OnDraw(const Rect& invalidatedArea) void UICanvas::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
Rect rect = GetOrigRect(); Rect rect = GetOrigRect();
DrawRect::Draw(rect, invalidatedArea, *style_, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, rect, invalidatedArea, *style_, opaScale_);
void* param = nullptr; void* param = nullptr;
ListNode<DrawCmd>* curDraw = drawCmdList_.Begin(); ListNode<DrawCmd>* curDraw = drawCmdList_.Begin();
...@@ -462,7 +460,7 @@ void UICanvas::OnDraw(const Rect& invalidatedArea) ...@@ -462,7 +460,7 @@ void UICanvas::OnDraw(const Rect& invalidatedArea)
if (trunc.Intersect(trunc, coords)) { if (trunc.Intersect(trunc, coords)) {
for (; curDraw != drawCmdList_.End(); curDraw = curDraw->next_) { for (; curDraw != drawCmdList_.End(); curDraw = curDraw->next_) {
param = curDraw->data_.param; param = curDraw->data_.param;
curDraw->data_.DrawGraphics(param, curDraw->data_.paint, rect, trunc, *style_); curDraw->data_.DrawGraphics(gfxDstBuffer, param, curDraw->data_.paint, rect, trunc, *style_);
} }
} }
} }
...@@ -473,7 +471,8 @@ void UICanvas::GetAbsolutePosition(const Point& prePoint, const Rect& rect, cons ...@@ -473,7 +471,8 @@ void UICanvas::GetAbsolutePosition(const Point& prePoint, const Rect& rect, cons
point.y = prePoint.y + rect.GetTop() + style.paddingTop_ + style.borderWidth_; point.y = prePoint.y + rect.GetTop() + style.paddingTop_ + style.borderWidth_;
} }
void UICanvas::DoDrawLine(void* param, void UICanvas::DoDrawLine(BufferInfo& gfxDstBuffer,
void* param,
const Paint& paint, const Paint& paint,
const Rect& rect, const Rect& rect,
const Rect& invalidatedArea, const Rect& invalidatedArea,
...@@ -488,10 +487,12 @@ void UICanvas::DoDrawLine(void* param, ...@@ -488,10 +487,12 @@ void UICanvas::DoDrawLine(void* param,
GetAbsolutePosition(lineParam->start, rect, style, start); GetAbsolutePosition(lineParam->start, rect, style, start);
GetAbsolutePosition(lineParam->end, rect, style, end); GetAbsolutePosition(lineParam->end, rect, style, end);
DrawLine::Draw(start, end, invalidatedArea, paint.GetStrokeWidth(), paint.GetStrokeColor(), paint.GetOpacity()); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, end, invalidatedArea, paint.GetStrokeWidth(),
paint.GetStrokeColor(), paint.GetOpacity());
} }
void UICanvas::DoDrawCurve(void* param, void UICanvas::DoDrawCurve(BufferInfo& gfxDstBuffer,
void* param,
const Paint& paint, const Paint& paint,
const Rect& rect, const Rect& rect,
const Rect& invalidatedArea, const Rect& invalidatedArea,
...@@ -510,11 +511,12 @@ void UICanvas::DoDrawCurve(void* param, ...@@ -510,11 +511,12 @@ void UICanvas::DoDrawCurve(void* param,
GetAbsolutePosition(curveParam->control1, rect, style, control1); GetAbsolutePosition(curveParam->control1, rect, style, control1);
GetAbsolutePosition(curveParam->control2, rect, style, control2); GetAbsolutePosition(curveParam->control2, rect, style, control2);
DrawCurve::DrawCubicBezier(start, control1, control2, end, invalidatedArea, paint.GetStrokeWidth(), BaseGfxEngine::GetInstance()->DrawCubicBezier(gfxDstBuffer, start, control1, control2, end, invalidatedArea,
paint.GetStrokeColor(), paint.GetOpacity()); paint.GetStrokeWidth(), paint.GetStrokeColor(), paint.GetOpacity());
} }
void UICanvas::DoDrawRect(void* param, void UICanvas::DoDrawRect(BufferInfo& gfxDstBuffer,
void* param,
const Paint& paint, const Paint& paint,
const Rect& rect, const Rect& rect,
const Rect& invalidatedArea, const Rect& invalidatedArea,
...@@ -540,32 +542,33 @@ void UICanvas::DoDrawRect(void* param, ...@@ -540,32 +542,33 @@ void UICanvas::DoDrawRect(void* param,
coords.SetPosition(x, y); coords.SetPosition(x, y);
coords.SetHeight(rectParam->height + lineWidth); coords.SetHeight(rectParam->height + lineWidth);
coords.SetWidth(rectParam->width + lineWidth); coords.SetWidth(rectParam->width + lineWidth);
DrawRect::Draw(coords, invalidatedArea, drawStyle, OPA_OPAQUE); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, coords, invalidatedArea, drawStyle, OPA_OPAQUE);
return; return;
} }
coords.SetPosition(x, y); coords.SetPosition(x, y);
coords.SetHeight(lineWidth); coords.SetHeight(lineWidth);
coords.SetWidth(rectParam->width); coords.SetWidth(rectParam->width);
DrawRect::Draw(coords, invalidatedArea, drawStyle, OPA_OPAQUE); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, coords, invalidatedArea, drawStyle, OPA_OPAQUE);
coords.SetPosition(x + rectParam->width, y); coords.SetPosition(x + rectParam->width, y);
coords.SetHeight(rectParam->height); coords.SetHeight(rectParam->height);
coords.SetWidth(lineWidth); coords.SetWidth(lineWidth);
DrawRect::Draw(coords, invalidatedArea, drawStyle, OPA_OPAQUE); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, coords, invalidatedArea, drawStyle, OPA_OPAQUE);
coords.SetPosition(x, y + lineWidth); coords.SetPosition(x, y + lineWidth);
coords.SetHeight(rectParam->height); coords.SetHeight(rectParam->height);
coords.SetWidth(lineWidth); coords.SetWidth(lineWidth);
DrawRect::Draw(coords, invalidatedArea, drawStyle, OPA_OPAQUE); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, coords, invalidatedArea, drawStyle, OPA_OPAQUE);
coords.SetPosition(x + lineWidth, y + rectParam->height); coords.SetPosition(x + lineWidth, y + rectParam->height);
coords.SetHeight(lineWidth); coords.SetHeight(lineWidth);
coords.SetWidth(rectParam->width); coords.SetWidth(rectParam->width);
DrawRect::Draw(coords, invalidatedArea, drawStyle, OPA_OPAQUE); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, coords, invalidatedArea, drawStyle, OPA_OPAQUE);
} }
void UICanvas::DoFillRect(void* param, void UICanvas::DoFillRect(BufferInfo& gfxDstBuffer,
void* param,
const Paint& paint, const Paint& paint,
const Rect& rect, const Rect& rect,
const Rect& invalidatedArea, const Rect& invalidatedArea,
...@@ -592,10 +595,11 @@ void UICanvas::DoFillRect(void* param, ...@@ -592,10 +595,11 @@ void UICanvas::DoFillRect(void* param,
drawStyle.bgColor_ = paint.GetFillColor(); drawStyle.bgColor_ = paint.GetFillColor();
drawStyle.bgOpa_ = paint.GetOpacity(); drawStyle.bgOpa_ = paint.GetOpacity();
drawStyle.borderRadius_ = 0; drawStyle.borderRadius_ = 0;
DrawRect::Draw(coords, invalidatedArea, drawStyle, OPA_OPAQUE); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, coords, invalidatedArea, drawStyle, OPA_OPAQUE);
} }
void UICanvas::DoDrawCircle(void* param, void UICanvas::DoDrawCircle(BufferInfo& gfxDstBuffer,
void* param,
const Paint& paint, const Paint& paint,
const Rect& rect, const Rect& rect,
const Rect& invalidatedArea, const Rect& invalidatedArea,
...@@ -620,18 +624,21 @@ void UICanvas::DoDrawCircle(void* param, ...@@ -620,18 +624,21 @@ void UICanvas::DoDrawCircle(void* param,
arcInfo.radius = circleParam->radius - halfLineWidth; arcInfo.radius = circleParam->radius - halfLineWidth;
drawStyle.lineWidth_ = arcInfo.radius; drawStyle.lineWidth_ = arcInfo.radius;
drawStyle.lineColor_ = paint.GetFillColor(); drawStyle.lineColor_ = paint.GetFillColor();
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, drawStyle, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, drawStyle, OPA_OPAQUE,
CapType::CAP_NONE);
} }
if (enableStroke) { if (enableStroke) {
arcInfo.radius = circleParam->radius + halfLineWidth - 1; arcInfo.radius = circleParam->radius + halfLineWidth - 1;
drawStyle.lineWidth_ = static_cast<int16_t>(paint.GetStrokeWidth()); drawStyle.lineWidth_ = static_cast<int16_t>(paint.GetStrokeWidth());
drawStyle.lineColor_ = paint.GetStrokeColor(); drawStyle.lineColor_ = paint.GetStrokeColor();
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, drawStyle, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, drawStyle, OPA_OPAQUE,
CapType::CAP_NONE);
} }
} }
void UICanvas::DoDrawArc(void* param, void UICanvas::DoDrawArc(BufferInfo& gfxDstBuffer,
void* param,
const Paint& paint, const Paint& paint,
const Rect& rect, const Rect& rect,
const Rect& invalidatedArea, const Rect& invalidatedArea,
...@@ -653,10 +660,12 @@ void UICanvas::DoDrawArc(void* param, ...@@ -653,10 +660,12 @@ void UICanvas::DoDrawArc(void* param,
arcInfo.radius = arcParam->radius + ((paint.GetStrokeWidth() + 1) >> 1); arcInfo.radius = arcParam->radius + ((paint.GetStrokeWidth() + 1) >> 1);
GetAbsolutePosition(arcParam->center, rect, style, arcInfo.center); GetAbsolutePosition(arcParam->center, rect, style, arcInfo.center);
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, drawStyle, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, drawStyle, OPA_OPAQUE,
CapType::CAP_NONE);
} }
void UICanvas::DoDrawImage(void* param, void UICanvas::DoDrawImage(BufferInfo& gfxDstBuffer,
void* param,
const Paint& paint, const Paint& paint,
const Rect& rect, const Rect& rect,
const Rect& invalidatedArea, const Rect& invalidatedArea,
...@@ -678,10 +687,12 @@ void UICanvas::DoDrawImage(void* param, ...@@ -678,10 +687,12 @@ void UICanvas::DoDrawImage(void* param,
cordsTmp.SetPosition(start.x, start.y); cordsTmp.SetPosition(start.x, start.y);
cordsTmp.SetHeight(imageParam->height); cordsTmp.SetHeight(imageParam->height);
cordsTmp.SetWidth(imageParam->width); cordsTmp.SetWidth(imageParam->width);
DrawImage::DrawCommon(cordsTmp, invalidatedArea, imageParam->image->GetPath(), style, paint.GetOpacity()); DrawImage::DrawCommon(gfxDstBuffer,cordsTmp, invalidatedArea,
imageParam->image->GetPath(), style, paint.GetOpacity());
} }
void UICanvas::DoDrawLabel(void* param, void UICanvas::DoDrawLabel(BufferInfo& gfxDstBuffer,
void* param,
const Paint& paint, const Paint& paint,
const Rect& rect, const Rect& rect,
const Rect& invalidatedArea, const Rect& invalidatedArea,
...@@ -695,11 +706,14 @@ void UICanvas::DoDrawLabel(void* param, ...@@ -695,11 +706,14 @@ void UICanvas::DoDrawLabel(void* param,
Point start; Point start;
GetAbsolutePosition({startPos.x, startPos.y}, rect, style, start); GetAbsolutePosition({startPos.x, startPos.y}, rect, style, start);
label->SetPosition(start.x, start.y); label->SetPosition(start.x, start.y);
label->OnDraw(invalidatedArea); label->OnDraw(gfxDstBuffer, invalidatedArea);
label->SetPosition(startPos.x, startPos.y); label->SetPosition(startPos.x, startPos.y);
} }
void UICanvas::DoDrawLineJoin(const Point& center, const Rect& invalidatedArea, const Paint& paint) void UICanvas::DoDrawLineJoin(BufferInfo& gfxDstBuffer,
const Point& center,
const Rect& invalidatedArea,
const Paint& paint)
{ {
ArcInfo arcinfo = {{0}}; ArcInfo arcinfo = {{0}};
arcinfo.center = center; arcinfo.center = center;
...@@ -712,10 +726,12 @@ void UICanvas::DoDrawLineJoin(const Point& center, const Rect& invalidatedArea, ...@@ -712,10 +726,12 @@ void UICanvas::DoDrawLineJoin(const Point& center, const Rect& invalidatedArea,
style.lineColor_ = paint.GetStrokeColor(); style.lineColor_ = paint.GetStrokeColor();
style.lineWidth_ = static_cast<int16_t>(paint.GetStrokeWidth()); style.lineWidth_ = static_cast<int16_t>(paint.GetStrokeWidth());
style.lineOpa_ = OPA_OPAQUE; style.lineOpa_ = OPA_OPAQUE;
DrawArc::GetInstance()->Draw(arcinfo, invalidatedArea, style, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcinfo, invalidatedArea, style, OPA_OPAQUE,
CapType::CAP_NONE);
} }
void UICanvas::DoDrawPath(void* param, void UICanvas::DoDrawPath(BufferInfo& gfxDstBuffer,
void* param,
const Paint& paint, const Paint& paint,
const Rect& rect, const Rect& rect,
const Rect& invalidatedArea, const Rect& invalidatedArea,
...@@ -750,9 +766,10 @@ void UICanvas::DoDrawPath(void* param, ...@@ -750,9 +766,10 @@ void UICanvas::DoDrawPath(void* param,
GetAbsolutePosition(start, rect, style, start); GetAbsolutePosition(start, rect, style, start);
GetAbsolutePosition(end, rect, style, end); GetAbsolutePosition(end, rect, style, end);
DrawLine::Draw(start, end, invalidatedArea, paint.GetStrokeWidth(), paint.GetStrokeColor(), OPA_OPAQUE); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, end, invalidatedArea,
paint.GetStrokeWidth(), paint.GetStrokeColor(), OPA_OPAQUE);
if ((pathEnd.x == start.x) && (pathEnd.y == start.y)) { if ((pathEnd.x == start.x) && (pathEnd.y == start.y)) {
DoDrawLineJoin(start, invalidatedArea, paint); DoDrawLineJoin(gfxDstBuffer, start, invalidatedArea, paint);
} }
pathEnd = end; pathEnd = end;
break; break;
...@@ -769,9 +786,10 @@ void UICanvas::DoDrawPath(void* param, ...@@ -769,9 +786,10 @@ void UICanvas::DoDrawPath(void* param,
arcInfo.radius = arcIter->data_.radius + ((paint.GetStrokeWidth() + 1) >> 1); arcInfo.radius = arcIter->data_.radius + ((paint.GetStrokeWidth() + 1) >> 1);
GetAbsolutePosition(arcIter->data_.center, rect, style, arcInfo.center); GetAbsolutePosition(arcIter->data_.center, rect, style, arcInfo.center);
DrawArc::GetInstance()->Draw(arcInfo, invalidatedArea, drawStyle, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfo, invalidatedArea, drawStyle, OPA_OPAQUE,
CapType::CAP_NONE);
if (pointIter != path->points_.Begin()) { if (pointIter != path->points_.Begin()) {
DoDrawLineJoin(pathEnd, invalidatedArea, paint); DoDrawLineJoin(gfxDstBuffer, pathEnd, invalidatedArea, paint);
} }
GetAbsolutePosition(pointIter->data_, rect, style, pathEnd); GetAbsolutePosition(pointIter->data_, rect, style, pathEnd);
...@@ -785,16 +803,16 @@ void UICanvas::DoDrawPath(void* param, ...@@ -785,16 +803,16 @@ void UICanvas::DoDrawPath(void* param,
GetAbsolutePosition(start, rect, style, start); GetAbsolutePosition(start, rect, style, start);
GetAbsolutePosition(end, rect, style, end); GetAbsolutePosition(end, rect, style, end);
if ((start.x != end.x) || (start.y != end.y)) { if ((start.x != end.x) || (start.y != end.y)) {
DrawLine::Draw(start, end, invalidatedArea, paint.GetStrokeWidth(), paint.GetStrokeColor(), BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, end, invalidatedArea,
OPA_OPAQUE); paint.GetStrokeWidth(), paint.GetStrokeColor(), OPA_OPAQUE);
if ((pathEnd.x == start.x) && (pathEnd.y == start.y)) { if ((pathEnd.x == start.x) && (pathEnd.y == start.y)) {
DoDrawLineJoin(start, invalidatedArea, paint); DoDrawLineJoin(gfxDstBuffer, start, invalidatedArea, paint);
} }
pathEnd = end; pathEnd = end;
} }
if ((pathEnd.x == end.x) && (pathEnd.y == end.y)) { if ((pathEnd.x == end.x) && (pathEnd.y == end.y)) {
DoDrawLineJoin(end, invalidatedArea, paint); DoDrawLineJoin(gfxDstBuffer, end, invalidatedArea, paint);
} }
pointIter = pointIter->next_; pointIter = pointIter->next_;
break; break;
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
*/ */
#include "components/ui_chart.h" #include "components/ui_chart.h"
#include "draw/draw_arc.h" #include "engines/gfx/gfx_engine_manager.h"
#include "draw/draw_line.h"
#include "securec.h" #include "securec.h"
namespace OHOS { namespace OHOS {
...@@ -56,10 +55,10 @@ void UIChart::SetWidth(int16_t width) ...@@ -56,10 +55,10 @@ void UIChart::SetWidth(int16_t width)
yAxis_.UpdateAxis(); yAxis_.UpdateAxis();
} }
void UIChart::OnDraw(const Rect& invalidatedArea) void UIChart::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
UIViewGroup::OnDraw(invalidatedArea); UIViewGroup::OnDraw(gfxDstBuffer, invalidatedArea);
DrawDataSerials(invalidatedArea); DrawDataSerials(gfxDstBuffer, invalidatedArea);
} }
bool UIChart::AddDataSerial(UIChartDataSerial* dataSerial) bool UIChart::AddDataSerial(UIChartDataSerial* dataSerial)
...@@ -328,7 +327,8 @@ void UIChartDataSerial::ClearData() ...@@ -328,7 +327,8 @@ void UIChartDataSerial::ClearData()
latestIndex_ = 0; latestIndex_ = 0;
} }
void UIChartDataSerial::DoDrawPoint(const Point& center, const PointStyle& style, const Rect& mask) void UIChartDataSerial::DoDrawPoint(BufferInfo& gfxDstBuffer, const Point& center,
const PointStyle& style, const Rect& mask)
{ {
Style drawStyle = StyleDefault::GetDefaultStyle(); Style drawStyle = StyleDefault::GetDefaultStyle();
drawStyle.lineOpa_ = OPA_OPAQUE; drawStyle.lineOpa_ = OPA_OPAQUE;
...@@ -343,37 +343,37 @@ void UIChartDataSerial::DoDrawPoint(const Point& center, const PointStyle& style ...@@ -343,37 +343,37 @@ void UIChartDataSerial::DoDrawPoint(const Point& center, const PointStyle& style
if (style.fillColor.full == style.strokeColor.full) { if (style.fillColor.full == style.strokeColor.full) {
drawStyle.lineWidth_ = style.radius + style.strokeWidth; drawStyle.lineWidth_ = style.radius + style.strokeWidth;
DrawArc::GetInstance()->Draw(arcinfo, mask, drawStyle, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcinfo, mask, drawStyle, OPA_OPAQUE, CapType::CAP_NONE);
return; return;
} }
drawStyle.lineWidth_ = style.radius; drawStyle.lineWidth_ = style.radius;
arcinfo.radius = style.radius; arcinfo.radius = style.radius;
DrawArc::GetInstance()->Draw(arcinfo, mask, drawStyle, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcinfo, mask, drawStyle, OPA_OPAQUE, CapType::CAP_NONE);
drawStyle.lineWidth_ = style.strokeWidth; drawStyle.lineWidth_ = style.strokeWidth;
drawStyle.lineColor_ = style.strokeColor; drawStyle.lineColor_ = style.strokeColor;
arcinfo.radius = style.radius + style.strokeWidth; arcinfo.radius = style.radius + style.strokeWidth;
DrawArc::GetInstance()->Draw(arcinfo, mask, drawStyle, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcinfo, mask, drawStyle, OPA_OPAQUE, CapType::CAP_NONE);
} }
void UIChartDataSerial::DrawPoint(const Rect& mask) void UIChartDataSerial::DrawPoint(BufferInfo& gfxDstBuffer, const Rect& mask)
{ {
Point center; Point center;
if (enableTopPoint_) { if (enableTopPoint_) {
if (GetPoint(peakPointIndex_, center)) { if (GetPoint(peakPointIndex_, center)) {
DoDrawPoint(center, topPointStyle_, mask); DoDrawPoint(gfxDstBuffer, center, topPointStyle_, mask);
} }
} }
if (enableBottomPoint_) { if (enableBottomPoint_) {
if (GetPoint(valleyPointIndex_, center)) { if (GetPoint(valleyPointIndex_, center)) {
DoDrawPoint(center, bottomPointStyle_, mask); DoDrawPoint(gfxDstBuffer, center, bottomPointStyle_, mask);
} }
} }
if (enableHeadPoint_) { if (enableHeadPoint_) {
if (GetPoint(latestIndex_, center)) { if (GetPoint(latestIndex_, center)) {
DoDrawPoint(center, headPointStyle_, mask); DoDrawPoint(gfxDstBuffer, center, headPointStyle_, mask);
lastPointIndex_ = latestIndex_; lastPointIndex_ = latestIndex_;
} }
} }
...@@ -427,7 +427,7 @@ void UIChartPillar::RefreshChart() ...@@ -427,7 +427,7 @@ void UIChartPillar::RefreshChart()
} }
} }
void UIChartPillar::DrawDataSerials(const Rect& invalidatedArea) void UIChartPillar::DrawDataSerials(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
xAxis_.UpdateAxisPoints(); xAxis_.UpdateAxisPoints();
yAxis_.UpdateAxisPoints(); yAxis_.UpdateAxisPoints();
...@@ -453,7 +453,8 @@ void UIChartPillar::DrawDataSerials(const Rect& invalidatedArea) ...@@ -453,7 +453,8 @@ void UIChartPillar::DrawDataSerials(const Rect& invalidatedArea)
} }
current.x += x; current.x += x;
xStart.x = current.x; xStart.x = current.x;
DrawLine::Draw(current, xStart, invalidatedArea, barWidth, data->GetFillColor(), style_->lineOpa_); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, current, xStart, invalidatedArea, barWidth,
data->GetFillColor(), style_->lineOpa_);
} }
dataSerialIndex++; dataSerialIndex++;
} }
...@@ -499,7 +500,7 @@ void UIChartPolyline::ReMeasure() ...@@ -499,7 +500,7 @@ void UIChartPolyline::ReMeasure()
} }
} }
void UIChartPolyline::DrawDataSerials(const Rect& invalidatedArea) void UIChartPolyline::DrawDataSerials(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
xAxis_.UpdateAxisPoints(); xAxis_.UpdateAxisPoints();
yAxis_.UpdateAxisPoints(); yAxis_.UpdateAxisPoints();
...@@ -511,21 +512,22 @@ void UIChartPolyline::DrawDataSerials(const Rect& invalidatedArea) ...@@ -511,21 +512,22 @@ void UIChartPolyline::DrawDataSerials(const Rect& invalidatedArea)
continue; continue;
} }
if (data->IsGradient()) { if (data->IsGradient()) {
GradientColor(invalidatedArea, data); GradientColor(gfxDstBuffer, invalidatedArea, data);
} }
if (data->GetHideCount() != 0) { if (data->GetHideCount() != 0) {
uint16_t hideIndex = data->GetHideIndex(); uint16_t hideIndex = data->GetHideIndex();
DrawPolyLine(0, hideIndex, invalidatedArea, data); DrawPolyLine(gfxDstBuffer, 0, hideIndex, invalidatedArea, data);
DrawPolyLine(hideIndex + data->GetHideCount(), dataCount - 1, invalidatedArea, data); DrawPolyLine(gfxDstBuffer, hideIndex + data->GetHideCount(), dataCount - 1, invalidatedArea, data);
} else { } else {
DrawPolyLine(0, dataCount - 1, invalidatedArea, data); DrawPolyLine(gfxDstBuffer, 0, dataCount - 1, invalidatedArea, data);
} }
data->DrawPoint(invalidatedArea); data->DrawPoint(gfxDstBuffer, invalidatedArea);
} }
} }
void UIChartPolyline::DrawSmoothPolyLine(uint16_t startIndex, void UIChartPolyline::DrawSmoothPolyLine(BufferInfo& gfxDstBuffer,
uint16_t startIndex,
uint16_t endIndex, uint16_t endIndex,
const Rect& invalidatedArea, const Rect& invalidatedArea,
UIChartDataSerial* data) UIChartDataSerial* data)
...@@ -567,7 +569,8 @@ void UIChartPolyline::DrawSmoothPolyLine(uint16_t startIndex, ...@@ -567,7 +569,8 @@ void UIChartPolyline::DrawSmoothPolyLine(uint16_t startIndex,
continue; continue;
} }
DrawLine::Draw(start, end, invalidatedArea, style_->lineWidth_, color, OPA_OPAQUE); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, end, invalidatedArea,
style_->lineWidth_, color, OPA_OPAQUE);
ArcInfo arcinfo = {{0}}; ArcInfo arcinfo = {{0}};
arcinfo.center = end; arcinfo.center = end;
arcinfo.imgPos = Point{0, 0}; arcinfo.imgPos = Point{0, 0};
...@@ -575,15 +578,18 @@ void UIChartPolyline::DrawSmoothPolyLine(uint16_t startIndex, ...@@ -575,15 +578,18 @@ void UIChartPolyline::DrawSmoothPolyLine(uint16_t startIndex,
arcinfo.startAngle = 0; arcinfo.startAngle = 0;
arcinfo.endAngle = CIRCLE_IN_DEGREE; arcinfo.endAngle = CIRCLE_IN_DEGREE;
DrawArc::GetInstance()->Draw(arcinfo, invalidatedArea, style, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcinfo, invalidatedArea,
style, OPA_OPAQUE, CapType::CAP_NONE);
start = end; start = end;
end = current; end = current;
} }
DrawLine::Draw(start, end, invalidatedArea, style_->lineWidth_, color, OPA_OPAQUE); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, end, invalidatedArea,
style_->lineWidth_, color, OPA_OPAQUE);
} }
void UIChartPolyline::DrawPolyLine(uint16_t startIndex, void UIChartPolyline::DrawPolyLine(BufferInfo& gfxDstBuffer,
uint16_t startIndex,
uint16_t endIndex, uint16_t endIndex,
const Rect& invalidatedArea, const Rect& invalidatedArea,
UIChartDataSerial* data) UIChartDataSerial* data)
...@@ -593,7 +599,7 @@ void UIChartPolyline::DrawPolyLine(uint16_t startIndex, ...@@ -593,7 +599,7 @@ void UIChartPolyline::DrawPolyLine(uint16_t startIndex,
} }
if (data->IsSmooth()) { if (data->IsSmooth()) {
DrawSmoothPolyLine(startIndex, endIndex, invalidatedArea, data); DrawSmoothPolyLine(gfxDstBuffer, startIndex, endIndex, invalidatedArea, data);
return; return;
} }
Point start; Point start;
...@@ -619,15 +625,18 @@ void UIChartPolyline::DrawPolyLine(uint16_t startIndex, ...@@ -619,15 +625,18 @@ void UIChartPolyline::DrawPolyLine(uint16_t startIndex,
continue; continue;
} }
DrawLine::Draw(start, end, invalidatedArea, style_->lineWidth_, color, OPA_OPAQUE); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, end, invalidatedArea,
style_->lineWidth_, color, OPA_OPAQUE);
if (style_->lineWidth_ >= LINE_JOIN_WIDTH) { if (style_->lineWidth_ >= LINE_JOIN_WIDTH) {
arcinfo.center = end; arcinfo.center = end;
DrawArc::GetInstance()->Draw(arcinfo, invalidatedArea, style, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcinfo, invalidatedArea,
style, OPA_OPAQUE, CapType::CAP_NONE);
} }
} }
data->GetPoint(endIndex - 1, start); data->GetPoint(endIndex - 1, start);
data->GetPoint(endIndex, end); data->GetPoint(endIndex, end);
DrawLine::Draw(start, end, invalidatedArea, style_->lineWidth_, color, OPA_OPAQUE); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, end, invalidatedArea,
style_->lineWidth_, color, OPA_OPAQUE);
} }
bool UIChartPolyline::GetLineCrossPoint(const Point& p1, bool UIChartPolyline::GetLineCrossPoint(const Point& p1,
...@@ -696,7 +705,8 @@ void UIChartPolyline::FindCrossPoints(const ChartLine& line, const ChartLine& po ...@@ -696,7 +705,8 @@ void UIChartPolyline::FindCrossPoints(const ChartLine& line, const ChartLine& po
} }
} }
void UIChartPolyline::DrawGradientColor(const Rect& invalidatedArea, void UIChartPolyline::DrawGradientColor(BufferInfo& gfxDstBuffer,
const Rect& invalidatedArea,
UIChartDataSerial* data, UIChartDataSerial* data,
const ChartLine& linePoints, const ChartLine& linePoints,
const ChartLine& limitPoints, const ChartLine& limitPoints,
...@@ -742,7 +752,8 @@ void UIChartPolyline::DrawGradientColor(const Rect& invalidatedArea, ...@@ -742,7 +752,8 @@ void UIChartPolyline::DrawGradientColor(const Rect& invalidatedArea,
if (cross.firstFind && cross.secondFind) { if (cross.firstFind && cross.secondFind) {
cross.first.y = enableReverse_ ? (cross.first.y + startY) : (startY - cross.first.y); cross.first.y = enableReverse_ ? (cross.first.y + startY) : (startY - cross.first.y);
cross.second.y = enableReverse_ ? (cross.second.y + startY) : (startY - cross.second.y); cross.second.y = enableReverse_ ? (cross.second.y + startY) : (startY - cross.second.y);
DrawLine::Draw(cross.first, cross.second, invalidatedArea, 1, data->GetFillColor(), mixData_[mixScale]); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, cross.first, cross.second,
invalidatedArea, 1, data->GetFillColor(), mixData_[mixScale]);
cross.firstFind = false; cross.firstFind = false;
cross.secondFind = false; cross.secondFind = false;
} }
...@@ -752,7 +763,8 @@ void UIChartPolyline::DrawGradientColor(const Rect& invalidatedArea, ...@@ -752,7 +763,8 @@ void UIChartPolyline::DrawGradientColor(const Rect& invalidatedArea,
cross.second.x = limitPoints.end.x; cross.second.x = limitPoints.end.x;
cross.second.y = y; cross.second.y = y;
cross.first.y = y; cross.first.y = y;
DrawLine::Draw(cross.first, cross.second, invalidatedArea, 1, data->GetFillColor(), mixData_[mixScale]); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, cross.first, cross.second,
invalidatedArea, 1, data->GetFillColor(), mixData_[mixScale]);
} }
} }
...@@ -775,7 +787,7 @@ void UIChartPolyline::CalcVerticalInfo(int16_t top, ...@@ -775,7 +787,7 @@ void UIChartPolyline::CalcVerticalInfo(int16_t top,
} }
} }
void UIChartPolyline::GradientColor(const Rect& invalidatedArea, UIChartDataSerial* data) void UIChartPolyline::GradientColor(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, UIChartDataSerial* data)
{ {
if (data == nullptr) { if (data == nullptr) {
return; return;
...@@ -811,7 +823,7 @@ void UIChartPolyline::GradientColor(const Rect& invalidatedArea, UIChartDataSeri ...@@ -811,7 +823,7 @@ void UIChartPolyline::GradientColor(const Rect& invalidatedArea, UIChartDataSeri
linePoints.end.y = linePoints.start.y; linePoints.end.y = linePoints.start.y;
if (y <= valleyY) { if (y <= valleyY) {
int16_t baseY = enableReverse_ ? endY : startY; int16_t baseY = enableReverse_ ? endY : startY;
DrawGradientColor(invalidatedArea, data, linePoints, limitPoints, baseY); DrawGradientColor(gfxDstBuffer, invalidatedArea, data, linePoints, limitPoints, baseY);
} else { } else {
int16_t mixScale = enableReverse_ ? (linePoints.start.y + endY - currentRect.GetTop()) : int16_t mixScale = enableReverse_ ? (linePoints.start.y + endY - currentRect.GetTop()) :
(currentRect.GetBottom() - (startY - linePoints.start.y)); (currentRect.GetBottom() - (startY - linePoints.start.y));
...@@ -821,9 +833,10 @@ void UIChartPolyline::GradientColor(const Rect& invalidatedArea, UIChartDataSeri ...@@ -821,9 +833,10 @@ void UIChartPolyline::GradientColor(const Rect& invalidatedArea, UIChartDataSeri
} }
Point start = {limitPoints.start.x, y}; Point start = {limitPoints.start.x, y};
Point end = {limitPoints.end.x, y}; Point end = {limitPoints.end.x, y};
DrawLine::Draw(start, end, invalidatedArea, 1, data->GetFillColor(), mixData_[mixScale]); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, end, invalidatedArea, 1,
data->GetFillColor(), mixData_[mixScale]);
} }
y--; y--;
} }
} }
} // namespace OHOS } // namespace OHOS
\ No newline at end of file
...@@ -15,10 +15,8 @@ ...@@ -15,10 +15,8 @@
#include "components/ui_checkbox.h" #include "components/ui_checkbox.h"
#include "default_resource/check_box_res.h" #include "default_resource/check_box_res.h"
#include "draw/draw_arc.h"
#include "draw/draw_image.h" #include "draw/draw_image.h"
#include "draw/draw_line.h" #include "engines/gfx/gfx_engine_manager.h"
#include "draw/draw_rect.h"
#include "imgdecode/cache_manager.h" #include "imgdecode/cache_manager.h"
namespace OHOS { namespace OHOS {
...@@ -120,7 +118,11 @@ void UICheckBox::CalculateSize() ...@@ -120,7 +118,11 @@ void UICheckBox::CalculateSize()
borderWidth_ = DEFAULT_BORDER_WIDTH * minValue / DEFAULT_HOT_WIDTH; borderWidth_ = DEFAULT_BORDER_WIDTH * minValue / DEFAULT_HOT_WIDTH;
} }
void UICheckBox::SelectedStateSoftwareDrawing(Rect rect, Rect trunc, int16_t borderRadius, int16_t rectLineWidth) void UICheckBox::SelectedStateSoftwareDrawing(BufferInfo& gfxDstBuffer,
Rect rect,
Rect trunc,
int16_t borderRadius,
int16_t rectLineWidth)
{ {
if (backgroundOpacity_ == 0) { if (backgroundOpacity_ == 0) {
return; return;
...@@ -129,7 +131,7 @@ void UICheckBox::SelectedStateSoftwareDrawing(Rect rect, Rect trunc, int16_t bor ...@@ -129,7 +131,7 @@ void UICheckBox::SelectedStateSoftwareDrawing(Rect rect, Rect trunc, int16_t bor
styleSelect.borderRadius_ = borderRadius; styleSelect.borderRadius_ = borderRadius;
styleSelect.bgColor_ = Color::GetColorFromRGB(DEFAULT_BG_RED, DEFAULT_BG_GREEN, DEFAULT_BG_BLUE); styleSelect.bgColor_ = Color::GetColorFromRGB(DEFAULT_BG_RED, DEFAULT_BG_GREEN, DEFAULT_BG_BLUE);
styleSelect.bgOpa_ = backgroundOpacity_; styleSelect.bgOpa_ = backgroundOpacity_;
DrawRect::Draw(rect, trunc, styleSelect, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, rect, trunc, styleSelect, opaScale_);
int16_t dx = borderWidth_ * DEFAULT_COEFFICIENT_START_DX; int16_t dx = borderWidth_ * DEFAULT_COEFFICIENT_START_DX;
int16_t dy = borderWidth_ * DEFAULT_COEFFICIENT_START_DY; int16_t dy = borderWidth_ * DEFAULT_COEFFICIENT_START_DY;
Point start = { static_cast<int16_t>(rect.GetX() + dx), static_cast<int16_t>(rect.GetY() + dy) }; Point start = { static_cast<int16_t>(rect.GetX() + dx), static_cast<int16_t>(rect.GetY() + dy) };
...@@ -153,14 +155,16 @@ void UICheckBox::SelectedStateSoftwareDrawing(Rect rect, Rect trunc, int16_t bor ...@@ -153,14 +155,16 @@ void UICheckBox::SelectedStateSoftwareDrawing(Rect rect, Rect trunc, int16_t bor
styleSelect.lineColor_ = Color::White(); styleSelect.lineColor_ = Color::White();
styleSelect.lineOpa_ = backgroundOpacity_; styleSelect.lineOpa_ = backgroundOpacity_;
uint8_t opa = DrawUtils::GetMixOpacity(opaScale_, backgroundOpacity_); uint8_t opa = DrawUtils::GetMixOpacity(opaScale_, backgroundOpacity_);
DrawArc::GetInstance()->Draw(arcInfoLeft, trunc, styleSelect, opaScale_, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfoLeft, trunc, styleSelect, opaScale_, CapType::CAP_NONE);
DrawLine::Draw(start, mid, trunc, rectLineWidth * 2, Color::White(), opa); // 2 : double BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, start, mid, trunc, rectLineWidth * 2, Color::White(),
DrawArc::GetInstance()->Draw(arcInfoMid, trunc, styleSelect, opaScale_, CapType::CAP_NONE); opa); // 2 : double
DrawLine::Draw(mid, end, trunc, rectLineWidth * 2, Color::White(), opa); // 2 : double BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfoMid, trunc, styleSelect, opaScale_, CapType::CAP_NONE);
DrawArc::GetInstance()->Draw(arcInfoRight, trunc, styleSelect, opaScale_, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, mid, end, trunc, rectLineWidth * 2, Color::White(),
opa); // 2 : double
BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfoRight, trunc, styleSelect, opaScale_, CapType::CAP_NONE);
} }
void UICheckBox::UnSelectedStateSoftwareDrawing(Rect rect, Rect trunc, int16_t borderRadius, int16_t rectLineWidth) void UICheckBox::UnSelectedStateSoftwareDrawing(BufferInfo& gfxDstBuffer, Rect rect, Rect trunc, int16_t borderRadius, int16_t rectLineWidth)
{ {
Rect contentRect = GetContentRect(); Rect contentRect = GetContentRect();
Style styleUnSelect = StyleDefault::GetBackgroundTransparentStyle(); Style styleUnSelect = StyleDefault::GetBackgroundTransparentStyle();
...@@ -168,7 +172,7 @@ void UICheckBox::UnSelectedStateSoftwareDrawing(Rect rect, Rect trunc, int16_t b ...@@ -168,7 +172,7 @@ void UICheckBox::UnSelectedStateSoftwareDrawing(Rect rect, Rect trunc, int16_t b
styleUnSelect.borderRadius_ = borderRadius; styleUnSelect.borderRadius_ = borderRadius;
styleUnSelect.borderColor_ = Color::White(); styleUnSelect.borderColor_ = Color::White();
styleUnSelect.borderOpa_ = DEFAULT_UNSELECT_BG_OPA; styleUnSelect.borderOpa_ = DEFAULT_UNSELECT_BG_OPA;
DrawRect::Draw(rect, trunc, styleUnSelect, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, rect, trunc, styleUnSelect, opaScale_);
} }
#if DEFAULT_ANIMATION #if DEFAULT_ANIMATION
...@@ -196,7 +200,7 @@ void UICheckBox::OnStop(UIView& view) ...@@ -196,7 +200,7 @@ void UICheckBox::OnStop(UIView& view)
} }
#endif #endif
void UICheckBox::OnDraw(const Rect& invalidatedArea) void UICheckBox::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
Rect trunc = invalidatedArea; Rect trunc = invalidatedArea;
if ((image_[SELECTED].GetSrcType() != IMG_SRC_UNKNOWN) && (image_[UNSELECTED].GetSrcType() != IMG_SRC_UNKNOWN)) { if ((image_[SELECTED].GetSrcType() != IMG_SRC_UNKNOWN) && (image_[UNSELECTED].GetSrcType() != IMG_SRC_UNKNOWN)) {
...@@ -207,13 +211,13 @@ void UICheckBox::OnDraw(const Rect& invalidatedArea) ...@@ -207,13 +211,13 @@ void UICheckBox::OnDraw(const Rect& invalidatedArea)
Rect coords = GetContentRect(); Rect coords = GetContentRect();
coords.SetWidth(imgWidth); coords.SetWidth(imgWidth);
coords.SetHeight(imgHeight); coords.SetHeight(imgHeight);
DrawRect::Draw(GetRect(), invalidatedArea, *style_, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, GetRect(), invalidatedArea, *style_, opaScale_);
int16_t offsetLeft = (GetWidth() - imgWidth) / 2; // 2 : half int16_t offsetLeft = (GetWidth() - imgWidth) / 2; // 2 : half
int16_t offsetTop = (GetHeight() - imgHeight) / 2; // 2 : half int16_t offsetTop = (GetHeight() - imgHeight) / 2; // 2 : half
coords.SetX(coords.GetX() + offsetLeft); coords.SetX(coords.GetX() + offsetLeft);
coords.SetY(coords.GetY() + offsetTop); coords.SetY(coords.GetY() + offsetTop);
if (trunc.Intersect(trunc, coords)) { if (trunc.Intersect(trunc, coords)) {
image_[state_].DrawImage(coords, trunc, *style_, opaScale_); image_[state_].DrawImage(gfxDstBuffer, coords, trunc, *style_, opaScale_);
} }
} else { } else {
Rect contentRect = GetContentRect(); Rect contentRect = GetContentRect();
...@@ -224,18 +228,18 @@ void UICheckBox::OnDraw(const Rect& invalidatedArea) ...@@ -224,18 +228,18 @@ void UICheckBox::OnDraw(const Rect& invalidatedArea)
CalculateSize(); CalculateSize();
int16_t rectLineWidth = borderWidth_ / DEFAULT_BORDER_WIDTH; int16_t rectLineWidth = borderWidth_ / DEFAULT_BORDER_WIDTH;
int16_t borderRadius = rectLineWidth * DEFAULT_RATIO_BORDER_RADIUS_LINE_WIDTH; int16_t borderRadius = rectLineWidth * DEFAULT_RATIO_BORDER_RADIUS_LINE_WIDTH;
DrawRect::Draw(GetRect(), invalidatedArea, *style_, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, GetRect(), invalidatedArea, *style_, opaScale_);
int16_t x = contentRect.GetX() + (width_ - borderWidth_) / 2; // 2: half int16_t x = contentRect.GetX() + (width_ - borderWidth_) / 2; // 2: half
int16_t y = contentRect.GetY() + (height_ - borderWidth_) / 2; // 2: half int16_t y = contentRect.GetY() + (height_ - borderWidth_) / 2; // 2: half
Rect rect(x, y, x + borderWidth_, y + borderWidth_); Rect rect(x, y, x + borderWidth_, y + borderWidth_);
#if DEFAULT_ANIMATION #if DEFAULT_ANIMATION
UnSelectedStateSoftwareDrawing(rect, trunc, borderRadius, rectLineWidth); UnSelectedStateSoftwareDrawing(gfxDstBuffer, rect, trunc, borderRadius, rectLineWidth);
SelectedStateSoftwareDrawing(rect, trunc, borderRadius, rectLineWidth); SelectedStateSoftwareDrawing(gfxDstBuffer, rect, trunc, borderRadius, rectLineWidth);
#else #else
if (state_ == SELECTED) { if (state_ == SELECTED) {
SelectedStateSoftwareDrawing(rect, trunc, borderRadius, rectLineWidth); SelectedStateSoftwareDrawing(gfxDstBuffer, rect, trunc, borderRadius, rectLineWidth);
} else { } else {
UnSelectedStateSoftwareDrawing(rect, trunc, borderRadius, rectLineWidth); UnSelectedStateSoftwareDrawing(gfxDstBuffer, rect, trunc, borderRadius, rectLineWidth);
} }
#endif #endif
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "components/ui_circle_progress.h" #include "components/ui_circle_progress.h"
#include "draw/draw_arc.h" #include "draw/draw_arc.h"
#include "draw/draw_line.h" #include "draw/draw_line.h"
#include "draw/draw_rect.h" #include "engines/gfx/gfx_engine_manager.h"
namespace OHOS { namespace OHOS {
UICircleProgress::UICircleProgress() UICircleProgress::UICircleProgress()
...@@ -82,7 +82,7 @@ void UICircleProgress::GetRedrawAngle(int16_t& start, int16_t& end) const ...@@ -82,7 +82,7 @@ void UICircleProgress::GetRedrawAngle(int16_t& start, int16_t& end) const
DrawArc::GetInstance()->GetDrawRange(start, end); DrawArc::GetInstance()->GetDrawRange(start, end);
} }
void UICircleProgress::DrawCommonCircle(const Rect& invalidatedArea) void UICircleProgress::DrawCommonCircle(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
ArcInfo arcinfo = {{0}}; ArcInfo arcinfo = {{0}};
arcinfo.radius = radius_; arcinfo.radius = radius_;
...@@ -103,8 +103,8 @@ void UICircleProgress::DrawCommonCircle(const Rect& invalidatedArea) ...@@ -103,8 +103,8 @@ void UICircleProgress::DrawCommonCircle(const Rect& invalidatedArea)
arcinfo.startAngle = start; arcinfo.startAngle = start;
arcinfo.endAngle = end; arcinfo.endAngle = end;
arcinfo.imgSrc = backgroundImage_; arcinfo.imgSrc = backgroundImage_;
DrawArc::GetInstance()->Draw(arcinfo, invalidatedArea, *backgroundStyle_, opaScale_, BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcinfo, invalidatedArea, *backgroundStyle_, opaScale_,
backgroundStyle_->lineCap_); backgroundStyle_->lineCap_);
} }
if ((startAngle != endAngle) || (foregroundStyle_->lineCap_ == CapType::CAP_ROUND)) { if ((startAngle != endAngle) || (foregroundStyle_->lineCap_ == CapType::CAP_ROUND)) {
...@@ -113,22 +113,22 @@ void UICircleProgress::DrawCommonCircle(const Rect& invalidatedArea) ...@@ -113,22 +113,22 @@ void UICircleProgress::DrawCommonCircle(const Rect& invalidatedArea)
arcinfo.startAngle = startAngle; arcinfo.startAngle = startAngle;
arcinfo.endAngle = endAngle; arcinfo.endAngle = endAngle;
arcinfo.imgSrc = foregroundImage_; arcinfo.imgSrc = foregroundImage_;
DrawArc::GetInstance()->Draw(arcinfo, invalidatedArea, *foregroundStyle_, opaScale_, BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcinfo, invalidatedArea, *foregroundStyle_, opaScale_,
foregroundStyle_->lineCap_); foregroundStyle_->lineCap_);
} }
} }
void UICircleProgress::OnDraw(const Rect& invalidatedArea) void UICircleProgress::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
if (GetRangeSize() == 0) { if (GetRangeSize() == 0) {
return; return;
} }
DrawRect::Draw(GetOrigRect(), invalidatedArea, *style_, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, GetOrigRect(), invalidatedArea, *style_, opaScale_);
Rect trunc(invalidatedArea); Rect trunc(invalidatedArea);
if (trunc.Intersect(trunc, GetOrigRect())) { if (trunc.Intersect(trunc, GetOrigRect())) {
DrawCommonCircle(trunc); DrawCommonCircle(gfxDstBuffer, trunc);
} }
} }
} // namespace OHOS } // namespace OHOS
\ No newline at end of file
...@@ -14,12 +14,11 @@ ...@@ -14,12 +14,11 @@
*/ */
#include "components/ui_image_view.h" #include "components/ui_image_view.h"
#include "common/image.h" #include "common/image.h"
#include "common/typed_text.h" #include "common/typed_text.h"
#include "draw/draw_image.h" #include "draw/draw_image.h"
#include "draw/draw_label.h" #include "draw/draw_label.h"
#include "draw/draw_rect.h" #include "engines/gfx/gfx_engine_manager.h"
#include "gfx_utils/file.h" #include "gfx_utils/file.h"
#include "gfx_utils/image_info.h" #include "gfx_utils/image_info.h"
#include "gfx_utils/mem_api.h" #include "gfx_utils/mem_api.h"
...@@ -261,10 +260,10 @@ bool UIImageView::OnPreDraw(Rect& invalidatedArea) const ...@@ -261,10 +260,10 @@ bool UIImageView::OnPreDraw(Rect& invalidatedArea) const
return false; return false;
} }
void UIImageView::OnDraw(const Rect& invalidatedArea) void UIImageView::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
OpacityType opa = GetMixOpaScale(); OpacityType opa = GetMixOpaScale();
DrawRect::Draw(GetRect(), invalidatedArea, *style_, opa); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, GetRect(), invalidatedArea, *style_, opa);
if ((imageHeight_ == 0) || (imageWidth_ == 0)) { if ((imageHeight_ == 0) || (imageWidth_ == 0)) {
return; return;
} }
...@@ -283,7 +282,7 @@ void UIImageView::OnDraw(const Rect& invalidatedArea) ...@@ -283,7 +282,7 @@ void UIImageView::OnDraw(const Rect& invalidatedArea)
cordsTmp.SetLeft(viewRect.GetX()); cordsTmp.SetLeft(viewRect.GetX());
cordsTmp.SetRight(viewRect.GetX() + imageWidth_ - 1); cordsTmp.SetRight(viewRect.GetX() + imageWidth_ - 1);
while (cordsTmp.GetLeft() <= viewRect.GetRight()) { while (cordsTmp.GetLeft() <= viewRect.GetRight()) {
image_.DrawImage(cordsTmp, trunc, *style_, opa); image_.DrawImage(gfxDstBuffer, cordsTmp, trunc, *style_, opa);
cordsTmp.SetLeft(cordsTmp.GetLeft() + imageWidth_); cordsTmp.SetLeft(cordsTmp.GetLeft() + imageWidth_);
cordsTmp.SetRight(cordsTmp.GetRight() + imageWidth_); cordsTmp.SetRight(cordsTmp.GetRight() + imageWidth_);
} }
...@@ -310,8 +309,8 @@ void UIImageView::OnDraw(const Rect& invalidatedArea) ...@@ -310,8 +309,8 @@ void UIImageView::OnDraw(const Rect& invalidatedArea)
Rect origRect = GetOrigRect(); Rect origRect = GetOrigRect();
transMap_->SetTransMapRect(origRect); transMap_->SetTransMapRect(origRect);
OpacityType opaScale = DrawUtils::GetMixOpacity(opa, style_->imageOpa_); OpacityType opaScale = DrawUtils::GetMixOpacity(opa, style_->imageOpa_);
DrawUtils::GetInstance()->DrawTransform(invalidatedArea, {0, 0}, Color::Black(), opaScale, *transMap_, BaseGfxEngine::GetInstance()->DrawTransform(gfxDstBuffer, invalidatedArea, {0, 0}, Color::Black(),
imageTranDataInfo); opaScale, *transMap_, imageTranDataInfo);
} }
} }
} }
......
...@@ -369,13 +369,14 @@ void UILabel::SetRollSpeed(uint16_t speed) ...@@ -369,13 +369,14 @@ void UILabel::SetRollSpeed(uint16_t speed)
} }
} }
void UILabel::OnDraw(const Rect& invalidatedArea) void UILabel::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
InitLabelText(); InitLabelText();
UIView::OnDraw(invalidatedArea); UIView::OnDraw(gfxDstBuffer, invalidatedArea);
Style style = GetStyleConst(); Style style = GetStyleConst();
style.textColor_ = GetTextColor(); style.textColor_ = GetTextColor();
OpacityType opa = GetMixOpaScale(); OpacityType opa = GetMixOpaScale();
labelText_->OnDraw(invalidatedArea, GetOrigRect(), GetContentRect(), offsetX_, style, ellipsisIndex_, opa); labelText_->OnDraw(gfxDstBuffer, invalidatedArea, GetOrigRect(),
GetContentRect(), offsetX_, style, ellipsisIndex_, opa);
} }
} // namespace OHOS } // namespace OHOS
\ No newline at end of file
...@@ -24,9 +24,9 @@ UILabelButton::UILabelButton() : labelButtonText_(nullptr), offset_({ 0, 0 }) ...@@ -24,9 +24,9 @@ UILabelButton::UILabelButton() : labelButtonText_(nullptr), offset_({ 0, 0 })
labelStyle_ = StyleDefault::GetDefaultStyle(); labelStyle_ = StyleDefault::GetDefaultStyle();
} }
void UILabelButton::OnDraw(const Rect& invalidatedArea) void UILabelButton::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
UIButton::OnDraw(invalidatedArea); UIButton::OnDraw(gfxDstBuffer, invalidatedArea);
Rect textRect = GetContentRect(); Rect textRect = GetContentRect();
textRect.SetLeft(textRect.GetLeft() + offset_.x); textRect.SetLeft(textRect.GetLeft() + offset_.x);
...@@ -35,7 +35,8 @@ void UILabelButton::OnDraw(const Rect& invalidatedArea) ...@@ -35,7 +35,8 @@ void UILabelButton::OnDraw(const Rect& invalidatedArea)
labelButtonText_->ReMeasureTextSize(textRect, labelStyle_); labelButtonText_->ReMeasureTextSize(textRect, labelStyle_);
OpacityType opa = GetMixOpaScale(); OpacityType opa = GetMixOpaScale();
uint16_t ellipsisIndex = labelButtonText_->GetEllipsisIndex(textRect, labelStyle_); uint16_t ellipsisIndex = labelButtonText_->GetEllipsisIndex(textRect, labelStyle_);
labelButtonText_->OnDraw(invalidatedArea, GetOrigRect(), textRect, 0, labelStyle_, ellipsisIndex, opa); labelButtonText_->OnDraw(gfxDstBuffer, invalidatedArea, GetOrigRect(), textRect, 0,
labelStyle_, ellipsisIndex, opa);
} }
UILabelButton::~UILabelButton() UILabelButton::~UILabelButton()
......
...@@ -17,9 +17,8 @@ ...@@ -17,9 +17,8 @@
#include "common/image.h" #include "common/image.h"
#include "components/root_view.h" #include "components/root_view.h"
#include "components/ui_view_group.h" #include "components/ui_view_group.h"
#include "draw/draw_arc.h"
#include "draw/draw_image.h" #include "draw/draw_image.h"
#include "draw/draw_rect.h" #include "engines/gfx/gfx_engine_manager.h"
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
#include "imgdecode/cache_manager.h" #include "imgdecode/cache_manager.h"
#include "securec.h" #include "securec.h"
...@@ -71,13 +70,13 @@ void UIRadioButton::CalculateSize() ...@@ -71,13 +70,13 @@ void UIRadioButton::CalculateSize()
} }
} }
void UIRadioButton::OnDraw(const Rect& invalidatedArea) void UIRadioButton::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
if ((image_[SELECTED].GetSrcType() != IMG_SRC_UNKNOWN) && (image_[UNSELECTED].GetSrcType() != IMG_SRC_UNKNOWN)) { if ((image_[SELECTED].GetSrcType() != IMG_SRC_UNKNOWN) && (image_[UNSELECTED].GetSrcType() != IMG_SRC_UNKNOWN)) {
UICheckBox::OnDraw(invalidatedArea); UICheckBox::OnDraw(gfxDstBuffer, invalidatedArea);
} else { } else {
CalculateSize(); CalculateSize();
DrawRect::Draw(GetRect(), invalidatedArea, *style_, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, GetRect(), invalidatedArea, *style_, opaScale_);
Rect contentRect = GetContentRect(); Rect contentRect = GetContentRect();
int16_t dx = width_ >> 1; int16_t dx = width_ >> 1;
int16_t dy = height_ >> 1; int16_t dy = height_ >> 1;
...@@ -93,12 +92,14 @@ void UIRadioButton::OnDraw(const Rect& invalidatedArea) ...@@ -93,12 +92,14 @@ void UIRadioButton::OnDraw(const Rect& invalidatedArea)
styleSelect.lineWidth_ = arcInfoBig.radius; styleSelect.lineWidth_ = arcInfoBig.radius;
styleSelect.lineColor_ = Color::GetColorFromRGB(0x1F, 0x71, 0xFF); styleSelect.lineColor_ = Color::GetColorFromRGB(0x1F, 0x71, 0xFF);
if (isIntersect) { if (isIntersect) {
DrawArc::GetInstance()->Draw(arcInfoBig, trunc, styleSelect, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfoBig, trunc, styleSelect,
OPA_OPAQUE, CapType::CAP_NONE);
} }
styleSelect.lineWidth_ = arcInfoSmall.radius; styleSelect.lineWidth_ = arcInfoSmall.radius;
styleSelect.lineColor_ = Color::White(); styleSelect.lineColor_ = Color::White();
if (isIntersect) { if (isIntersect) {
DrawArc::GetInstance()->Draw(arcInfoSmall, trunc, styleSelect, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfoSmall, trunc, styleSelect,
OPA_OPAQUE, CapType::CAP_NONE);
} }
break; break;
} }
...@@ -108,7 +109,8 @@ void UIRadioButton::OnDraw(const Rect& invalidatedArea) ...@@ -108,7 +109,8 @@ void UIRadioButton::OnDraw(const Rect& invalidatedArea)
styleUnSelect.lineWidth_ = lineWidth_; styleUnSelect.lineWidth_ = lineWidth_;
if (isIntersect) { if (isIntersect) {
// 0xa8 : opacity of drawing unselected button arc edge. // 0xa8 : opacity of drawing unselected button arc edge.
DrawArc::GetInstance()->Draw(arcInfoBig, trunc, styleUnSelect, 0xa8, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfoBig, trunc, styleUnSelect,
0xa8, CapType::CAP_NONE);
} }
break; break;
} }
......
...@@ -25,9 +25,9 @@ UIRepeatButton::UIRepeatButton() : ticksInterval_(200), event_({ 0, 0 }), ...@@ -25,9 +25,9 @@ UIRepeatButton::UIRepeatButton() : ticksInterval_(200), event_({ 0, 0 }),
UIRepeatButton::~UIRepeatButton() {} UIRepeatButton::~UIRepeatButton() {}
void UIRepeatButton::OnDraw(const Rect& invalidatedArea) void UIRepeatButton::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
UIButton::OnDraw(invalidatedArea); UIButton::OnDraw(gfxDstBuffer, invalidatedArea);
} }
bool UIRepeatButton::OnReleaseEvent(const ReleaseEvent& event) bool UIRepeatButton::OnReleaseEvent(const ReleaseEvent& event)
......
...@@ -42,7 +42,7 @@ UIScrollView::UIScrollView() ...@@ -42,7 +42,7 @@ UIScrollView::UIScrollView()
ySlider_.SetStyle(StyleDefault::GetBrightStyle()); ySlider_.SetStyle(StyleDefault::GetBrightStyle());
} }
void UIScrollView::OnPostDraw(const Rect& invalidatedArea) void UIScrollView::OnPostDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
if (!xSlider_.IsVisible() && !ySlider_.IsVisible()) { if (!xSlider_.IsVisible() && !ySlider_.IsVisible()) {
return; return;
...@@ -50,11 +50,11 @@ void UIScrollView::OnPostDraw(const Rect& invalidatedArea) ...@@ -50,11 +50,11 @@ void UIScrollView::OnPostDraw(const Rect& invalidatedArea)
Rect scrollRect = GetRect(); Rect scrollRect = GetRect();
if (xSlider_.IsVisible()) { if (xSlider_.IsVisible()) {
xSlider_.SetPosition(scrollRect.GetX() + xSliderPos_.x, scrollRect.GetY() + xSliderPos_.y); xSlider_.SetPosition(scrollRect.GetX() + xSliderPos_.x, scrollRect.GetY() + xSliderPos_.y);
xSlider_.OnDraw(invalidatedArea); xSlider_.OnDraw(gfxDstBuffer, invalidatedArea);
} }
if (ySlider_.IsVisible()) { if (ySlider_.IsVisible()) {
ySlider_.SetPosition(scrollRect.GetX() + ySliderPos_.x, scrollRect.GetY() + ySliderPos_.y); ySlider_.SetPosition(scrollRect.GetX() + ySliderPos_.x, scrollRect.GetY() + ySliderPos_.y);
ySlider_.OnDraw(invalidatedArea); ySlider_.OnDraw(gfxDstBuffer, invalidatedArea);
} }
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "dock/focus_manager.h" #include "dock/focus_manager.h"
#include "dock/vibrator_manager.h" #include "dock/vibrator_manager.h"
#include "draw/draw_image.h" #include "draw/draw_image.h"
#include "draw/draw_rect.h" #include "engines/gfx/gfx_engine_manager.h"
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
#include "imgdecode/cache_manager.h" #include "imgdecode/cache_manager.h"
#include "themes/theme_manager.h" #include "themes/theme_manager.h"
...@@ -125,7 +125,7 @@ void UISlider::SetImage(const char* backgroundImage, const char* foregroundImage ...@@ -125,7 +125,7 @@ void UISlider::SetImage(const char* backgroundImage, const char* foregroundImage
} }
#if ENABLE_SLIDER_KNOB #if ENABLE_SLIDER_KNOB
void UISlider::DrawKnob(const Rect& invalidatedArea, const Rect& foregroundRect) void UISlider::DrawKnob(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, const Rect& foregroundRect)
{ {
int16_t halfKnobWidth = GetKnobWidth() >> 1; int16_t halfKnobWidth = GetKnobWidth() >> 1;
int16_t offset; int16_t offset;
...@@ -159,7 +159,7 @@ void UISlider::DrawKnob(const Rect& invalidatedArea, const Rect& foregroundRect) ...@@ -159,7 +159,7 @@ void UISlider::DrawKnob(const Rect& invalidatedArea, const Rect& foregroundRect)
GRAPHIC_LOGW("UISlider::DrawKnob Direction error!\n"); GRAPHIC_LOGW("UISlider::DrawKnob Direction error!\n");
} }
} }
DrawValidRect(knobImage_, knobBar, invalidatedArea, *knobStyle_, 0); DrawValidRect(gfxDstBuffer, knobImage_, knobBar, invalidatedArea, *knobStyle_, 0);
} }
bool UISlider::InitImage() bool UISlider::InitImage()
...@@ -203,7 +203,7 @@ bool UISlider::InitImage() ...@@ -203,7 +203,7 @@ bool UISlider::InitImage()
return true; return true;
} }
void UISlider::DrawForeground(const Rect& invalidatedArea, Rect& coords) void UISlider::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, Rect& coords)
{ {
Point startPoint; Point startPoint;
int16_t progressWidth; int16_t progressWidth;
...@@ -266,22 +266,22 @@ void UISlider::DrawForeground(const Rect& invalidatedArea, Rect& coords) ...@@ -266,22 +266,22 @@ void UISlider::DrawForeground(const Rect& invalidatedArea, Rect& coords)
} }
if (rect.Intersect(rect, invalidatedArea)) { if (rect.Intersect(rect, invalidatedArea)) {
DrawValidRect(foregroundImage_, coords, rect, *foregroundStyle_, radius); DrawValidRect(gfxDstBuffer, foregroundImage_, coords, rect, *foregroundStyle_, radius);
} }
} }
#endif #endif
void UISlider::OnDraw(const Rect& invalidatedArea) void UISlider::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
DrawRect::Draw(GetOrigRect(), invalidatedArea, *style_, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, GetOrigRect(), invalidatedArea, *style_, opaScale_);
Rect trunc(invalidatedArea); Rect trunc(invalidatedArea);
if (trunc.Intersect(trunc, GetOrigRect())) { if (trunc.Intersect(trunc, GetOrigRect())) {
DrawBackground(trunc); DrawBackground(gfxDstBuffer, trunc);
Rect foregroundRect; Rect foregroundRect;
DrawForeground(trunc, foregroundRect); DrawForeground(gfxDstBuffer, trunc, foregroundRect);
#if ENABLE_SLIDER_KNOB #if ENABLE_SLIDER_KNOB
DrawKnob(trunc, foregroundRect); DrawKnob(gfxDstBuffer, trunc, foregroundRect);
#endif #endif
} }
} }
......
...@@ -135,23 +135,23 @@ bool UISurfaceView::OnPreDraw(Rect& invalidatedArea) const ...@@ -135,23 +135,23 @@ bool UISurfaceView::OnPreDraw(Rect& invalidatedArea) const
return false; return false;
} }
void UISurfaceView::OnDraw(const Rect& invalidatedArea) void UISurfaceView::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
Draw(invalidatedArea); Draw(gfxDstBuffer, invalidatedArea);
} }
void UISurfaceView::Draw(const Rect& invalidatedArea) void UISurfaceView::Draw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
SurfaceBuffer* acquireBuffer = (surface_ != nullptr) ? surface_->AcquireBuffer() : nullptr; SurfaceBuffer* acquireBuffer = (surface_ != nullptr) ? surface_->AcquireBuffer() : nullptr;
if (acquireBuffer != nullptr) { if (acquireBuffer != nullptr) {
GRAPHIC_LOGE("UISurfaceView::Draw acquireBufferVirAddr=%p \n", acquireBuffer->GetVirAddr()); GRAPHIC_LOGE("UISurfaceView::Draw acquireBufferVirAddr=%p \n", acquireBuffer->GetVirAddr());
// fill with buffer // fill with buffer
DrawUtils::GetInstance()->DrawWithBuffer(GetRect(), invalidatedArea, DrawUtils::GetInstance()->DrawWithBuffer(gfxDstBuffer, GetRect(), invalidatedArea,
reinterpret_cast<const ColorType*>(acquireBuffer->GetVirAddr())); reinterpret_cast<const ColorType*>(acquireBuffer->GetVirAddr()));
surface_->ReleaseBuffer(acquireBuffer); surface_->ReleaseBuffer(acquireBuffer);
} else { } else {
// fill with transpant color // fill with transpant color
DrawUtils::GetInstance()->DrawTranspantArea(GetRect(), invalidatedArea); DrawUtils::GetInstance()->DrawTranspantArea(gfxDstBuffer, GetRect(), invalidatedArea);
} }
} }
} // namespace OHOS } // namespace OHOS
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
#include "components/ui_toggle_button.h" #include "components/ui_toggle_button.h"
#include "common/image.h" #include "common/image.h"
#include "draw/draw_arc.h" #include "engines/gfx/gfx_engine_manager.h"
#include "draw/draw_rect.h"
#include "imgdecode/cache_manager.h" #include "imgdecode/cache_manager.h"
namespace OHOS { namespace OHOS {
...@@ -54,13 +53,13 @@ void UIToggleButton::CalculateSize() ...@@ -54,13 +53,13 @@ void UIToggleButton::CalculateSize()
rectWidth_ = DEFAULT_WIDTH * minValue / DEFAULT_HOT_WIDTH; rectWidth_ = DEFAULT_WIDTH * minValue / DEFAULT_HOT_WIDTH;
} }
void UIToggleButton::OnDraw(const Rect& invalidatedArea) void UIToggleButton::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
if ((image_[SELECTED].GetSrcType() != IMG_SRC_UNKNOWN) && (image_[UNSELECTED].GetSrcType() != IMG_SRC_UNKNOWN)) { if ((image_[SELECTED].GetSrcType() != IMG_SRC_UNKNOWN) && (image_[UNSELECTED].GetSrcType() != IMG_SRC_UNKNOWN)) {
UICheckBox::OnDraw(invalidatedArea); UICheckBox::OnDraw(gfxDstBuffer, invalidatedArea);
} else { } else {
CalculateSize(); CalculateSize();
DrawRect::Draw(GetRect(), invalidatedArea, *style_, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, GetRect(), invalidatedArea, *style_, opaScale_);
Rect contentRect = GetContentRect(); Rect contentRect = GetContentRect();
int16_t dx = (width_ - rectWidth_) >> 1; int16_t dx = (width_ - rectWidth_) >> 1;
int16_t dy = (height_ >> 1) - corner_; int16_t dy = (height_ >> 1) - corner_;
...@@ -77,7 +76,7 @@ void UIToggleButton::OnDraw(const Rect& invalidatedArea) ...@@ -77,7 +76,7 @@ void UIToggleButton::OnDraw(const Rect& invalidatedArea)
styleSelect.bgColor_ = Color::GetColorFromRGB(DEFAULT_BG_RED, DEFAULT_BG_GREEN, DEFAULT_BG_BLUE); styleSelect.bgColor_ = Color::GetColorFromRGB(DEFAULT_BG_RED, DEFAULT_BG_GREEN, DEFAULT_BG_BLUE);
styleSelect.bgOpa_ = OPA_OPAQUE; styleSelect.bgOpa_ = OPA_OPAQUE;
if (isIntersect) { if (isIntersect) {
DrawRect::Draw(rectMid, trunc, styleSelect, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, rectMid, trunc, styleSelect, opaScale_);
} }
ArcInfo arcInfoRight = { ArcInfo arcInfoRight = {
{ static_cast<int16_t>(x + rectWidth_ - corner_), static_cast<int16_t>(y + corner_) }, { 0 }, { static_cast<int16_t>(x + rectWidth_ - corner_), static_cast<int16_t>(y + corner_) }, { 0 },
...@@ -87,7 +86,8 @@ void UIToggleButton::OnDraw(const Rect& invalidatedArea) ...@@ -87,7 +86,8 @@ void UIToggleButton::OnDraw(const Rect& invalidatedArea)
styleSelect.lineWidth_ = radius_; styleSelect.lineWidth_ = radius_;
styleSelect.lineColor_ = Color::White(); styleSelect.lineColor_ = Color::White();
if (isIntersect) { if (isIntersect) {
DrawArc::GetInstance()->Draw(arcInfoRight, trunc, styleSelect, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfoRight, trunc,
styleSelect, OPA_OPAQUE, CapType::CAP_NONE);
} }
break; break;
} }
...@@ -97,7 +97,7 @@ void UIToggleButton::OnDraw(const Rect& invalidatedArea) ...@@ -97,7 +97,7 @@ void UIToggleButton::OnDraw(const Rect& invalidatedArea)
styleUnSelect.bgOpa_ = DEFAULT_UNSELECTED_OPA; styleUnSelect.bgOpa_ = DEFAULT_UNSELECTED_OPA;
styleUnSelect.borderRadius_ = corner_; styleUnSelect.borderRadius_ = corner_;
if (isIntersect) { if (isIntersect) {
DrawRect::Draw(rectMid, trunc, styleUnSelect, opaScale_); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, rectMid, trunc, styleUnSelect, opaScale_);
} }
ArcInfo arcInfoLeft = { ArcInfo arcInfoLeft = {
{ static_cast<int16_t>(x + corner_), static_cast<int16_t>(y + corner_) }, { 0 }, radius_, 0, { static_cast<int16_t>(x + corner_), static_cast<int16_t>(y + corner_) }, { 0 }, radius_, 0,
...@@ -106,7 +106,8 @@ void UIToggleButton::OnDraw(const Rect& invalidatedArea) ...@@ -106,7 +106,8 @@ void UIToggleButton::OnDraw(const Rect& invalidatedArea)
styleUnSelect.lineColor_ = Color::White(); styleUnSelect.lineColor_ = Color::White();
styleUnSelect.lineWidth_ = radius_; styleUnSelect.lineWidth_ = radius_;
if (isIntersect) { if (isIntersect) {
DrawArc::GetInstance()->Draw(arcInfoLeft, trunc, styleUnSelect, OPA_OPAQUE, CapType::CAP_NONE); BaseGfxEngine::GetInstance()->DrawArc(gfxDstBuffer, arcInfoLeft, trunc,
styleUnSelect, OPA_OPAQUE, CapType::CAP_NONE);
} }
break; break;
} }
......
...@@ -17,9 +17,8 @@ ...@@ -17,9 +17,8 @@
#include "components/root_view.h" #include "components/root_view.h"
#include "core/render_manager.h" #include "core/render_manager.h"
#include "dock/focus_manager.h" #include "dock/focus_manager.h"
#include "dock/screen_device_proxy.h"
#include "draw/draw_rect.h"
#include "draw/draw_utils.h" #include "draw/draw_utils.h"
#include "engines/gfx/gfx_engine_manager.h"
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
#include "gfx_utils/mem_api.h" #include "gfx_utils/mem_api.h"
#include "securec.h" #include "securec.h"
...@@ -100,10 +99,10 @@ bool UIView::OnPreDraw(Rect& invalidatedArea) const ...@@ -100,10 +99,10 @@ bool UIView::OnPreDraw(Rect& invalidatedArea) const
return false; return false;
} }
void UIView::OnDraw(const Rect& invalidatedArea) void UIView::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{ {
uint8_t opa = GetMixOpaScale(); uint8_t opa = GetMixOpaScale();
DrawRect::Draw(GetOrigRect(), invalidatedArea, *style_, opa); BaseGfxEngine::GetInstance()->DrawRect(gfxDstBuffer, GetOrigRect(), invalidatedArea, *style_, opa);
} }
void UIView::SetupThemeStyles() void UIView::SetupThemeStyles()
...@@ -820,15 +819,19 @@ bool UIView::GetBitmap(ImageInfo& bitmap) ...@@ -820,15 +819,19 @@ bool UIView::GetBitmap(ImageInfo& bitmap)
nextSibling_ = nullptr; nextSibling_ = nullptr;
parent_ = nullptr; parent_ = nullptr;
int16_t screenWidth = ScreenDeviceProxy::GetInstance()->GetScreenWidth(); BufferInfo* bufferInfo = BaseGfxEngine::GetInstance()->GetBufferInfo();
int16_t screenHeight = ScreenDeviceProxy::GetInstance()->GetScreenHeight(); if (bufferInfo == nullptr) {
return false;
}
int16_t screenWidth = bufferInfo->width;
int16_t screenHeight = bufferInfo->height;
Rect screenRect(0, 0, screenWidth, screenHeight); Rect screenRect(0, 0, screenWidth, screenHeight);
rect_.SetPosition(0, 0); rect_.SetPosition(0, 0);
Rect mask = GetRect(); Rect mask = GetRect();
mask.Intersect(mask, screenRect); mask.Intersect(mask, screenRect);
uint16_t bufferWidth = static_cast<uint16_t>(mask.GetWidth()); uint16_t bufferWidth = static_cast<uint16_t>(mask.GetWidth());
uint16_t bufferHeight = static_cast<uint16_t>(mask.GetHeight()); uint16_t bufferHeight = static_cast<uint16_t>(mask.GetHeight());
bitmap.header.colorMode = ScreenDeviceProxy::GetInstance()->GetBufferMode(); bitmap.header.colorMode = bufferInfo->mode;
bitmap.dataSize = bufferWidth * bufferHeight * DrawUtils::GetByteSizeByColorMode(bitmap.header.colorMode); bitmap.dataSize = bufferWidth * bufferHeight * DrawUtils::GetByteSizeByColorMode(bitmap.header.colorMode);
bitmap.header.width = bufferWidth; bitmap.header.width = bufferWidth;
bitmap.header.height = bufferHeight; bitmap.header.height = bufferHeight;
...@@ -841,18 +844,23 @@ bool UIView::GetBitmap(ImageInfo& bitmap) ...@@ -841,18 +844,23 @@ bool UIView::GetBitmap(ImageInfo& bitmap)
rect_.SetPosition(tempX, tempY); rect_.SetPosition(tempX, tempY);
return false; return false;
} }
if (memset_s(viewBitmapBuffer, bitmap.dataSize, 0, bitmap.dataSize) != EOK) {
ImageCacheFree(bitmap); BufferInfo newBufferInfo;
return false; newBufferInfo.virAddr = static_cast<void*>(viewBitmapBuffer);
} newBufferInfo.phyAddr = newBufferInfo.virAddr;
ScreenDeviceProxy::GetInstance()->EnableBitmapBuffer(viewBitmapBuffer); newBufferInfo.rect = mask;
ScreenDeviceProxy::GetInstance()->SetViewBitmapBufferWidth(bufferWidth); newBufferInfo.width = bufferWidth;
newBufferInfo.height = bufferHeight;
newBufferInfo.mode = bufferInfo->mode;
RootView::GetInstance()->SaveDrawContext();
RootView::GetInstance()->UpdateBufferInfo(&newBufferInfo);
RootView::GetInstance()->DrawTop(this, mask); RootView::GetInstance()->DrawTop(this, mask);
bitmap.data = viewBitmapBuffer; bitmap.data = viewBitmapBuffer;
ScreenDeviceProxy::GetInstance()->DisableBitmapBuffer(); RootView::GetInstance()->RestoreDrawContext();
nextSibling_ = tempSibling; nextSibling_ = tempSibling;
parent_ = tempParent; parent_ = tempParent;
rect_.SetPosition(tempX, tempY); rect_.SetPosition(tempX, tempY);
return true; return true;
} }
} // namespace OHOS } // namespace OHOS
\ No newline at end of file
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "core/render_manager.h" #include "core/render_manager.h"
#include "components/root_view.h" #include "components/root_view.h"
#include "dock/screen_device_proxy.h"
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
#include "hal_tick.h" #include "hal_tick.h"
#include "securec.h" #include "securec.h"
......
...@@ -36,9 +36,12 @@ struct AllocationInfo { ...@@ -36,9 +36,12 @@ struct AllocationInfo {
}; };
#endif #endif
#ifndef TRANSFORMOPTION
#define TRANSFORMOPTION
struct TransformOption { struct TransformOption {
TransformAlgorithm algorithm; TransformAlgorithm algorithm;
}; };
#endif
/** @brief A semaphore for display buffer flushing. */ /** @brief A semaphore for display buffer flushing. */
class FlushSem : public HeapBase { class FlushSem : public HeapBase {
......
...@@ -49,8 +49,10 @@ void ScreenDeviceProxy::DrawAnimatorBuffer(const Rect& invalidatedArea) ...@@ -49,8 +49,10 @@ void ScreenDeviceProxy::DrawAnimatorBuffer(const Rect& invalidatedArea)
uint8_t pxSize = DrawUtils::GetPxSizeByColorMode(animatorImageInfo_.header.colorMode); uint8_t pxSize = DrawUtils::GetPxSizeByColorMode(animatorImageInfo_.header.colorMode);
TransformDataInfo imageTranDataInfo = {animatorImageInfo_.header, animatorImageInfo_.data, pxSize, LEVEL0, TransformDataInfo imageTranDataInfo = {animatorImageInfo_.header, animatorImageInfo_.data, pxSize, LEVEL0,
BILINEAR}; BILINEAR};
#if 0 // to do delete
DrawUtils::GetInstance()->DrawTransform(invalidRect, {0, 0}, Color::Black(), OPA_OPAQUE, transMap_, DrawUtils::GetInstance()->DrawTransform(invalidRect, {0, 0}, Color::Black(), OPA_OPAQUE, transMap_,
imageTranDataInfo); imageTranDataInfo);
#endif
} }
} }
......
...@@ -25,7 +25,8 @@ DrawArc* DrawArc::GetInstance() ...@@ -25,7 +25,8 @@ DrawArc* DrawArc::GetInstance()
return &drawArc; return &drawArc;
} }
void DrawArc::DrawImg(const Point& imgPos, void DrawArc::DrawImg(BufferInfo& gfxDstBuffer,
const Point& imgPos,
Rect& area, Rect& area,
const Rect& invalidatedArea, const Rect& invalidatedArea,
const Style& style, const Style& style,
...@@ -43,11 +44,12 @@ void DrawArc::DrawImg(const Point& imgPos, ...@@ -43,11 +44,12 @@ void DrawArc::DrawImg(const Point& imgPos,
cordsTmp.SetHeight(header.height); cordsTmp.SetHeight(header.height);
cordsTmp.SetWidth(header.width); cordsTmp.SetWidth(header.width);
if (area.Intersect(area, invalidatedArea)) { if (area.Intersect(area, invalidatedArea)) {
image->DrawImage(cordsTmp, area, style, opaScale); image->DrawImage(gfxDstBuffer, cordsTmp, area, style, opaScale);
} }
} }
void DrawArc::DrawVerLine(const Point& begin, void DrawArc::DrawVerLine(BufferInfo& gfxDstBuffer,
const Point& begin,
const Point& imgPos, const Point& imgPos,
const Rect& mask, const Rect& mask,
int16_t len, int16_t len,
...@@ -57,13 +59,14 @@ void DrawArc::DrawVerLine(const Point& begin, ...@@ -57,13 +59,14 @@ void DrawArc::DrawVerLine(const Point& begin,
{ {
Rect rect(begin.x, begin.y, begin.x, begin.y + len); Rect rect(begin.x, begin.y, begin.x, begin.y + len);
if ((image != nullptr) && (image->GetSrcType() != IMG_SRC_UNKNOWN)) { if ((image != nullptr) && (image->GetSrcType() != IMG_SRC_UNKNOWN)) {
DrawImg(imgPos, rect, mask, style, opaScale, image); DrawImg(gfxDstBuffer, imgPos, rect, mask, style, opaScale, image);
} else { } else {
DrawUtils::GetInstance()->DrawColorArea(rect, mask, style.lineColor_, opaScale); DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rect, mask, style.lineColor_, opaScale);
} }
} }
void DrawArc::DrawHorLine(const Point& begin, void DrawArc::DrawHorLine(BufferInfo& gfxDstBuffer,
const Point& begin,
const Point& imgPos, const Point& imgPos,
const Rect& mask, const Rect& mask,
int16_t len, int16_t len,
...@@ -73,13 +76,13 @@ void DrawArc::DrawHorLine(const Point& begin, ...@@ -73,13 +76,13 @@ void DrawArc::DrawHorLine(const Point& begin,
{ {
if ((image != nullptr) && (image->GetSrcType() != IMG_SRC_UNKNOWN)) { if ((image != nullptr) && (image->GetSrcType() != IMG_SRC_UNKNOWN)) {
Rect rect(begin.x, begin.y, begin.x + len, begin.y); Rect rect(begin.x, begin.y, begin.x + len, begin.y);
DrawImg(imgPos, rect, mask, style, opaScale, image); DrawImg(gfxDstBuffer, imgPos, rect, mask, style, opaScale, image);
} else { } else {
if (len == 0) { if (len == 0) {
DrawUtils::GetInstance()->DrawPixel(begin.x, begin.y, mask, style.lineColor_, opaScale); DrawUtils::GetInstance()->DrawPixel(gfxDstBuffer, begin.x, begin.y, mask, style.lineColor_, opaScale);
} else { } else {
Rect rect(begin.x, begin.y, begin.x + len, begin.y); Rect rect(begin.x, begin.y, begin.x + len, begin.y);
DrawUtils::GetInstance()->DrawColorArea(rect, mask, style.lineColor_, opaScale); DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rect, mask, style.lineColor_, opaScale);
} }
} }
} }
...@@ -122,9 +125,14 @@ uint16_t DrawArc::CalculateTanDegree(uint16_t x, uint16_t y) ...@@ -122,9 +125,14 @@ uint16_t DrawArc::CalculateTanDegree(uint16_t x, uint16_t y)
return degree; return degree;
} }
void DrawArc::DrawCircleNoEndpoint(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa, bool anti) void DrawArc::DrawCircleNoEndpoint(BufferInfo& gfxDstBuffer,
ArcInfo& arcInfo,
const Rect& mask,
const Style& style,
uint8_t opa,
bool anti)
{ {
DrawAxisLine(arcInfo, mask, style, opa); DrawAxisLine(gfxDstBuffer, arcInfo, mask, style, opa);
int16_t yStart = mask.GetTop() - arcInfo.center.y; int16_t yStart = mask.GetTop() - arcInfo.center.y;
int16_t yEnd = mask.GetBottom() - arcInfo.center.y; int16_t yEnd = mask.GetBottom() - arcInfo.center.y;
...@@ -176,52 +184,53 @@ void DrawArc::DrawCircleNoEndpoint(ArcInfo& arcInfo, const Rect& mask, const Sty ...@@ -176,52 +184,53 @@ void DrawArc::DrawCircleNoEndpoint(ArcInfo& arcInfo, const Rect& mask, const Sty
} }
#if ENABLE_ANTIALIAS #if ENABLE_ANTIALIAS
if (anti) { if (anti) {
DrawLineAnti(arcInfo, mask, style, opa); DrawLineAnti(gfxDstBuffer, arcInfo, mask, style, opa);
} }
#endif #endif
DrawLineWithDegree(arcInfo, -lineEnd_, -lineStart_, y_, mask, style, opa, ARC_QUADRANT_ONE); DrawLineWithDegree(gfxDstBuffer, arcInfo, -lineEnd_, -lineStart_, y_, mask, style, opa, ARC_QUADRANT_ONE);
DrawLineWithDegree(arcInfo, -lineEnd_, -lineStart_, -y_, mask, style, opa, ARC_QUADRANT_TWO); DrawLineWithDegree(gfxDstBuffer, arcInfo, -lineEnd_, -lineStart_, -y_, mask, style, opa, ARC_QUADRANT_TWO);
DrawLineWithDegree(arcInfo, lineStart_, lineEnd_, -y_, mask, style, opa, ARC_QUADRANT_THREE); DrawLineWithDegree(gfxDstBuffer, arcInfo, lineStart_, lineEnd_, -y_, mask, style, opa, ARC_QUADRANT_THREE);
DrawLineWithDegree(arcInfo, lineStart_, lineEnd_, y_, mask, style, opa, ARC_QUADRANT_FOUR); DrawLineWithDegree(gfxDstBuffer, arcInfo, lineStart_, lineEnd_, y_, mask, style, opa, ARC_QUADRANT_FOUR);
} }
} }
void DrawArc::DrawAxisLine(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa) void DrawArc::DrawAxisLine(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa)
{ {
int16_t lineWidth = 0; int16_t lineWidth = 0;
int16_t outRadius = outRadius_ - 1; int16_t outRadius = outRadius_ - 1;
int16_t inRadius = inRadius_; int16_t inRadius = inRadius_;
if (inRadius <= 0) { if (inRadius <= 0) {
inRadius = 1; inRadius = 1;
DrawHorLine(arcInfo.center, arcInfo.imgPos, mask, 0, style, opa, arcInfo.imgSrc); DrawHorLine(gfxDstBuffer, arcInfo.center, arcInfo.imgPos, mask, 0, style, opa, arcInfo.imgSrc);
} }
lineWidth = outRadius - inRadius; lineWidth = outRadius - inRadius;
if (isCircle_ || (IS_IN_DEGREERANE(THREE_QUARTER_IN_DEGREE, arcInfo.startAngle, arcInfo.endAngle))) { if (isCircle_ || (IS_IN_DEGREERANE(THREE_QUARTER_IN_DEGREE, arcInfo.startAngle, arcInfo.endAngle))) {
DrawHorLine(Point{static_cast<int16_t>(arcInfo.center.x - outRadius), arcInfo.center.y}, arcInfo.imgPos, mask, DrawHorLine(gfxDstBuffer, Point{static_cast<int16_t>(arcInfo.center.x - outRadius), arcInfo.center.y},
lineWidth, style, opa, arcInfo.imgSrc); arcInfo.imgPos, mask, lineWidth, style, opa, arcInfo.imgSrc);
} }
if (isCircle_ || (IS_IN_DEGREERANE(QUARTER_IN_DEGREE, arcInfo.startAngle, arcInfo.endAngle))) { if (isCircle_ || (IS_IN_DEGREERANE(QUARTER_IN_DEGREE, arcInfo.startAngle, arcInfo.endAngle))) {
DrawHorLine(Point{static_cast<int16_t>(arcInfo.center.x + inRadius), arcInfo.center.y}, arcInfo.imgPos, mask, DrawHorLine(gfxDstBuffer, Point{static_cast<int16_t>(arcInfo.center.x + inRadius), arcInfo.center.y},
lineWidth, style, opa, arcInfo.imgSrc); arcInfo.imgPos, mask, lineWidth, style, opa, arcInfo.imgSrc);
} }
if (isCircle_ || (IS_IN_DEGREERANE(0, arcInfo.startAngle, arcInfo.endAngle))) { if (isCircle_ || (IS_IN_DEGREERANE(0, arcInfo.startAngle, arcInfo.endAngle))) {
DrawVerLine(Point{arcInfo.center.x, static_cast<int16_t>(arcInfo.center.y - outRadius)}, arcInfo.imgPos, mask, DrawVerLine(gfxDstBuffer, Point{arcInfo.center.x, static_cast<int16_t>(arcInfo.center.y - outRadius)},
lineWidth, style, opa, arcInfo.imgSrc); arcInfo.imgPos, mask, lineWidth, style, opa, arcInfo.imgSrc);
} }
if (isCircle_ || (IS_IN_DEGREERANE(SEMICIRCLE_IN_DEGREE, arcInfo.startAngle, arcInfo.endAngle))) { if (isCircle_ || (IS_IN_DEGREERANE(SEMICIRCLE_IN_DEGREE, arcInfo.startAngle, arcInfo.endAngle))) {
DrawVerLine(Point{arcInfo.center.x, static_cast<int16_t>(arcInfo.center.y + inRadius)}, arcInfo.imgPos, mask, DrawVerLine(gfxDstBuffer, Point{arcInfo.center.x, static_cast<int16_t>(arcInfo.center.y + inRadius)},
lineWidth, style, opa, arcInfo.imgSrc); arcInfo.imgPos, mask, lineWidth, style, opa, arcInfo.imgSrc);
} }
} }
void DrawArc::DrawLineWithDegree(ArcInfo& arcInfo, void DrawArc::DrawLineWithDegree(BufferInfo& gfxDstBuffer,
ArcInfo& arcInfo,
int16_t start, int16_t start,
int16_t end, int16_t end,
int16_t y, int16_t y,
...@@ -231,8 +240,9 @@ void DrawArc::DrawLineWithDegree(ArcInfo& arcInfo, ...@@ -231,8 +240,9 @@ void DrawArc::DrawLineWithDegree(ArcInfo& arcInfo,
uint8_t quadrant) uint8_t quadrant)
{ {
if (isCircle_) { if (isCircle_) {
DrawHorLine(Point{static_cast<int16_t>(arcInfo.center.x + start), static_cast<int16_t>(arcInfo.center.y + y)}, DrawHorLine(gfxDstBuffer, Point{static_cast<int16_t>(arcInfo.center.x + start),
arcInfo.imgPos, mask, end - start, style, opaScale, arcInfo.imgSrc); static_cast<int16_t>(arcInfo.center.y + y)}, arcInfo.imgPos,
mask, end - start, style, opaScale, arcInfo.imgSrc);
return; return;
} }
uint16_t degreeStart = GetDegreeInQuadrant(CalculateTanDegree(MATH_ABS(start), MATH_ABS(y)), quadrant); uint16_t degreeStart = GetDegreeInQuadrant(CalculateTanDegree(MATH_ABS(start), MATH_ABS(y)), quadrant);
...@@ -249,23 +259,24 @@ void DrawArc::DrawLineWithDegree(ArcInfo& arcInfo, ...@@ -249,23 +259,24 @@ void DrawArc::DrawLineWithDegree(ArcInfo& arcInfo,
case OUT_DEGREE_RANG: case OUT_DEGREE_RANG:
return; return;
case IN_DEGREE_RANG: case IN_DEGREE_RANG:
DrawHorLine( DrawHorLine(gfxDstBuffer,
Point{static_cast<int16_t>(arcInfo.center.x + start), static_cast<int16_t>(arcInfo.center.y + y)}, Point{static_cast<int16_t>(arcInfo.center.x + start), static_cast<int16_t>(arcInfo.center.y + y)},
arcInfo.imgPos, mask, end - start, style, opaScale, arcInfo.imgSrc); arcInfo.imgPos, mask, end - start, style, opaScale, arcInfo.imgSrc);
return; return;
case INTERSECT: case INTERSECT:
DrawLineWithDegreeInner(arcInfo, start, end, y, mask, style, opaScale, quadrant); DrawLineWithDegreeInner(gfxDstBuffer, arcInfo, start, end, y, mask, style, opaScale, quadrant);
return; return;
case DOUBLE_INTERSECT: case DOUBLE_INTERSECT:
drawEnd = DrawLineWithDegreeInner(arcInfo, start, end, y, mask, style, opaScale, quadrant); drawEnd = DrawLineWithDegreeInner(gfxDstBuffer, arcInfo, start, end, y, mask, style, opaScale, quadrant);
DrawLineWithDegreeInner(arcInfo, drawEnd + 1, end, y, mask, style, opaScale, quadrant); DrawLineWithDegreeInner(gfxDstBuffer, arcInfo, drawEnd + 1, end, y, mask, style, opaScale, quadrant);
return; return;
default: default:
return; return;
} }
} }
int16_t DrawArc::DrawLineWithDegreeInner(ArcInfo& arcInfo, int16_t DrawArc::DrawLineWithDegreeInner(BufferInfo& gfxDstBuffer,
ArcInfo& arcInfo,
int16_t start, int16_t start,
int16_t end, int16_t end,
int16_t y, int16_t y,
...@@ -294,7 +305,7 @@ int16_t DrawArc::DrawLineWithDegreeInner(ArcInfo& arcInfo, ...@@ -294,7 +305,7 @@ int16_t DrawArc::DrawLineWithDegreeInner(ArcInfo& arcInfo,
drawEnd = end; drawEnd = end;
} }
if ((drawStart != COORD_MIN) && (drawEnd != COORD_MIN)) { if ((drawStart != COORD_MIN) && (drawEnd != COORD_MIN)) {
DrawHorLine( DrawHorLine(gfxDstBuffer,
Point{static_cast<int16_t>(arcInfo.center.x + drawStart), static_cast<int16_t>(arcInfo.center.y + y)}, Point{static_cast<int16_t>(arcInfo.center.x + drawStart), static_cast<int16_t>(arcInfo.center.y + y)},
arcInfo.imgPos, mask, drawEnd - drawStart, style, opaScale, arcInfo.imgSrc); arcInfo.imgPos, mask, drawEnd - drawStart, style, opaScale, arcInfo.imgSrc);
} }
...@@ -302,7 +313,8 @@ int16_t DrawArc::DrawLineWithDegreeInner(ArcInfo& arcInfo, ...@@ -302,7 +313,8 @@ int16_t DrawArc::DrawLineWithDegreeInner(ArcInfo& arcInfo,
} }
#if ENABLE_ANTIALIAS #if ENABLE_ANTIALIAS
void DrawArc::DrawLineAnti(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa) void DrawArc::DrawLineAnti(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, const Rect& mask,
const Style& style, uint8_t opa)
{ {
outAntiStart_ = lineStart_; outAntiStart_ = lineStart_;
outAntiEnd_ = lineStart_; outAntiEnd_ = lineStart_;
...@@ -332,7 +344,7 @@ void DrawArc::DrawLineAnti(ArcInfo& arcInfo, const Rect& mask, const Style& styl ...@@ -332,7 +344,7 @@ void DrawArc::DrawLineAnti(ArcInfo& arcInfo, const Rect& mask, const Style& styl
(((static_cast<uint64_t>(outRadius_) << 1) - 1 - (currentSqr - antiOutRadiusSqr_)) * OPA_OPAQUE) / (((static_cast<uint64_t>(outRadius_) << 1) - 1 - (currentSqr - antiOutRadiusSqr_)) * OPA_OPAQUE) /
((outRadius_ << 1) - 1); ((outRadius_ << 1) - 1);
antiOpa = (opa == OPA_OPAQUE) ? antiOpa : (static_cast<uint16_t>(antiOpa) * opa) >> SHIFT_8; antiOpa = (opa == OPA_OPAQUE) ? antiOpa : (static_cast<uint16_t>(antiOpa) * opa) >> SHIFT_8;
DrawPointAnti(arcInfo, xAnti, mask, style, antiOpa); DrawPointAnti(gfxDstBuffer, arcInfo, xAnti, mask, style, antiOpa);
} }
for (int16_t xAnti = inAntiStart_; xAnti <= inAntiEnd_; xAnti++) { for (int16_t xAnti = inAntiStart_; xAnti <= inAntiEnd_; xAnti++) {
...@@ -342,11 +354,12 @@ void DrawArc::DrawLineAnti(ArcInfo& arcInfo, const Rect& mask, const Style& styl ...@@ -342,11 +354,12 @@ void DrawArc::DrawLineAnti(ArcInfo& arcInfo, const Rect& mask, const Style& styl
} }
uint8_t antiOpa = (static_cast<uint64_t>(currentSqr - antiInRadiusSqr_) * OPA_OPAQUE) / ((inRadius_ << 1) - 1); uint8_t antiOpa = (static_cast<uint64_t>(currentSqr - antiInRadiusSqr_) * OPA_OPAQUE) / ((inRadius_ << 1) - 1);
antiOpa = (opa == OPA_OPAQUE) ? antiOpa : (static_cast<uint16_t>(antiOpa) * opa) >> SHIFT_8; antiOpa = (opa == OPA_OPAQUE) ? antiOpa : (static_cast<uint16_t>(antiOpa) * opa) >> SHIFT_8;
DrawPointAnti(arcInfo, xAnti, mask, style, antiOpa); DrawPointAnti(gfxDstBuffer, arcInfo, xAnti, mask, style, antiOpa);
} }
} }
void DrawArc::DrawPointAnti(ArcInfo& arcInfo, int16_t x, const Rect& mask, const Style& style, uint8_t antiOpa) void DrawArc::DrawPointAnti(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, int16_t x, const Rect& mask,
const Style& style, uint8_t antiOpa)
{ {
int16_t startX; int16_t startX;
int16_t starty; int16_t starty;
...@@ -354,22 +367,22 @@ void DrawArc::DrawPointAnti(ArcInfo& arcInfo, int16_t x, const Rect& mask, const ...@@ -354,22 +367,22 @@ void DrawArc::DrawPointAnti(ArcInfo& arcInfo, int16_t x, const Rect& mask, const
if (isCircle_ || (IS_IN_DEGREERANE(CIRCLE_IN_DEGREE - degreeBase, arcInfo.startAngle, arcInfo.endAngle))) { if (isCircle_ || (IS_IN_DEGREERANE(CIRCLE_IN_DEGREE - degreeBase, arcInfo.startAngle, arcInfo.endAngle))) {
startX = arcInfo.center.x + x; startX = arcInfo.center.x + x;
starty = arcInfo.center.y + y_; starty = arcInfo.center.y + y_;
DrawHorLine(Point{startX, starty}, arcInfo.imgPos, mask, 0, style, antiOpa, arcInfo.imgSrc); DrawHorLine(gfxDstBuffer, Point{startX, starty}, arcInfo.imgPos, mask, 0, style, antiOpa, arcInfo.imgSrc);
} }
if (isCircle_ || (IS_IN_DEGREERANE(SEMICIRCLE_IN_DEGREE + degreeBase, arcInfo.startAngle, arcInfo.endAngle))) { if (isCircle_ || (IS_IN_DEGREERANE(SEMICIRCLE_IN_DEGREE + degreeBase, arcInfo.startAngle, arcInfo.endAngle))) {
startX = arcInfo.center.x + x; startX = arcInfo.center.x + x;
starty = arcInfo.center.y - y_; starty = arcInfo.center.y - y_;
DrawHorLine(Point{startX, starty}, arcInfo.imgPos, mask, 0, style, antiOpa, arcInfo.imgSrc); DrawHorLine(gfxDstBuffer, Point{startX, starty}, arcInfo.imgPos, mask, 0, style, antiOpa, arcInfo.imgSrc);
} }
if (isCircle_ || (IS_IN_DEGREERANE(degreeBase, arcInfo.startAngle, arcInfo.endAngle))) { if (isCircle_ || (IS_IN_DEGREERANE(degreeBase, arcInfo.startAngle, arcInfo.endAngle))) {
startX = arcInfo.center.x - x; startX = arcInfo.center.x - x;
starty = arcInfo.center.y + y_; starty = arcInfo.center.y + y_;
DrawHorLine(Point{startX, starty}, arcInfo.imgPos, mask, 0, style, antiOpa, arcInfo.imgSrc); DrawHorLine(gfxDstBuffer, Point{startX, starty}, arcInfo.imgPos, mask, 0, style, antiOpa, arcInfo.imgSrc);
} }
if (isCircle_ || (IS_IN_DEGREERANE(SEMICIRCLE_IN_DEGREE - degreeBase, arcInfo.startAngle, arcInfo.endAngle))) { if (isCircle_ || (IS_IN_DEGREERANE(SEMICIRCLE_IN_DEGREE - degreeBase, arcInfo.startAngle, arcInfo.endAngle))) {
startX = arcInfo.center.x - x; startX = arcInfo.center.x - x;
starty = arcInfo.center.y - y_; starty = arcInfo.center.y - y_;
DrawHorLine(Point{startX, starty}, arcInfo.imgPos, mask, 0, style, antiOpa, arcInfo.imgSrc); DrawHorLine(gfxDstBuffer, Point{startX, starty}, arcInfo.imgPos, mask, 0, style, antiOpa, arcInfo.imgSrc);
} }
} }
#endif #endif
...@@ -390,7 +403,8 @@ uint16_t DrawArc::GetDegreeInQuadrant(uint16_t degree, uint8_t quadrant) ...@@ -390,7 +403,8 @@ uint16_t DrawArc::GetDegreeInQuadrant(uint16_t degree, uint8_t quadrant)
} }
} }
void DrawArc::Draw(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opaScale, uint8_t cap) void DrawArc::Draw(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, const Rect& mask,
const Style& style, uint8_t opaScale, uint8_t cap)
{ {
OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.lineOpa_); OpacityType opa = DrawUtils::GetMixOpacity(opaScale, style.lineOpa_);
if ((opa == OPA_TRANSPARENT) || (style.lineWidth_ < 1)) { if ((opa == OPA_TRANSPARENT) || (style.lineWidth_ < 1)) {
...@@ -400,9 +414,9 @@ void DrawArc::Draw(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8 ...@@ -400,9 +414,9 @@ void DrawArc::Draw(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8
SetArcInfo(arcInfo, style); SetArcInfo(arcInfo, style);
if (arcInfo.startAngle != arcInfo.endAngle) { if (arcInfo.startAngle != arcInfo.endAngle) {
if ((arcInfo.imgSrc != nullptr) && (arcInfo.imgSrc->GetSrcType() != IMG_SRC_UNKNOWN)) { if ((arcInfo.imgSrc != nullptr) && (arcInfo.imgSrc->GetSrcType() != IMG_SRC_UNKNOWN)) {
DrawCircleNoEndpoint(arcInfo, mask, style, opa, false); DrawCircleNoEndpoint(gfxDstBuffer, arcInfo, mask, style, opa, false);
} else { } else {
DrawCircleNoEndpoint(arcInfo, mask, style, opa, true); DrawCircleNoEndpoint(gfxDstBuffer, arcInfo, mask, style, opa, true);
} }
} }
...@@ -431,7 +445,7 @@ void DrawArc::Draw(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8 ...@@ -431,7 +445,7 @@ void DrawArc::Draw(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8
endArcInfo.center.x += startCapX; endArcInfo.center.x += startCapX;
endArcInfo.center.y -= startCapY; endArcInfo.center.y -= startCapY;
SetArcInfo(endArcInfo, style); SetArcInfo(endArcInfo, style);
DrawCircleNoEndpoint(endArcInfo, mask, style, opa, true); DrawCircleNoEndpoint(gfxDstBuffer, endArcInfo, mask, style, opa, true);
temp = (outRadius - endArcInfo.radius + 1) * Sin(arcInfo.endAngle); temp = (outRadius - endArcInfo.radius + 1) * Sin(arcInfo.endAngle);
int16_t endCapX = static_cast<int16_t>((temp > 0) ? (temp + 0.5f) : (temp - 0.5f)); int16_t endCapX = static_cast<int16_t>((temp > 0) ? (temp + 0.5f) : (temp - 0.5f));
...@@ -443,7 +457,7 @@ void DrawArc::Draw(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8 ...@@ -443,7 +457,7 @@ void DrawArc::Draw(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8
endArcInfo.center.x += endCapX; endArcInfo.center.x += endCapX;
endArcInfo.center.y -= endCapY; endArcInfo.center.y -= endCapY;
SetArcInfo(endArcInfo, style); SetArcInfo(endArcInfo, style);
DrawCircleNoEndpoint(endArcInfo, mask, style, opa, true); DrawCircleNoEndpoint(gfxDstBuffer, endArcInfo, mask, style, opa, true);
} }
} }
......
...@@ -24,22 +24,14 @@ ...@@ -24,22 +24,14 @@
#include "gfx_utils/style.h" #include "gfx_utils/style.h"
namespace OHOS { namespace OHOS {
struct ArcInfo {
Point center;
Point imgPos;
uint16_t radius;
int16_t startAngle;
int16_t endAngle;
const Image* imgSrc;
};
class DrawArc : public HeapBase { class DrawArc : public HeapBase {
public: public:
static DrawArc* GetInstance(); static DrawArc* GetInstance();
void GetDrawRange(int16_t& start, int16_t& end); void GetDrawRange(int16_t& start, int16_t& end);
void Draw(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opaScale, uint8_t cap); void Draw(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, const Rect& mask,
const Style& style, uint8_t opaScale, uint8_t cap);
private: private:
static constexpr uint8_t DRAW_ARC_QUADRANT_NUM = 4; static constexpr uint8_t DRAW_ARC_QUADRANT_NUM = 4;
...@@ -86,8 +78,11 @@ private: ...@@ -86,8 +78,11 @@ private:
antiInRadiusSqr_(0) antiInRadiusSqr_(0)
{ {
} }
~DrawArc() {} ~DrawArc() {}
void DrawVerLine(const Point& begin,
void DrawVerLine(BufferInfo& gfxDstBuffer,
const Point& begin,
const Point& imgPos, const Point& imgPos,
const Rect& mask, const Rect& mask,
int16_t len, int16_t len,
...@@ -95,7 +90,8 @@ private: ...@@ -95,7 +90,8 @@ private:
uint8_t opaScale, uint8_t opaScale,
const Image* imgSrc); const Image* imgSrc);
void DrawHorLine(const Point& begin, void DrawHorLine(BufferInfo& gfxDstBuffer,
const Point& begin,
const Point& imgPos, const Point& imgPos,
const Rect& mask, const Rect& mask,
int16_t len, int16_t len,
...@@ -103,7 +99,8 @@ private: ...@@ -103,7 +99,8 @@ private:
uint8_t opaScale, uint8_t opaScale,
const Image* imgSrc); const Image* imgSrc);
void DrawImg(const Point& imgPos, void DrawImg(BufferInfo& gfxDstBuffer,
const Point& imgPos,
Rect& area, Rect& area,
const Rect& invalidatedArea, const Rect& invalidatedArea,
const Style& style, const Style& style,
...@@ -111,11 +108,17 @@ private: ...@@ -111,11 +108,17 @@ private:
const Image* imgSrc); const Image* imgSrc);
int16_t GetDegreeRangeIntersectState(uint16_t degreeStart, uint16_t degreeEnd, uint16_t start, uint16_t end); int16_t GetDegreeRangeIntersectState(uint16_t degreeStart, uint16_t degreeEnd, uint16_t start, uint16_t end);
uint16_t CalculateTanDegree(uint16_t x, uint16_t y); uint16_t CalculateTanDegree(uint16_t x, uint16_t y);
int16_t GetDrawAngle(int16_t angle); int16_t GetDrawAngle(int16_t angle);
void DrawCircleNoEndpoint(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa, bool anti);
void DrawAxisLine(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa); void DrawCircleNoEndpoint(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa, bool anti);
void DrawLineWithDegree(ArcInfo& arcInfo,
void DrawAxisLine(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa);
void DrawLineWithDegree(BufferInfo& gfxDstBuffer,
ArcInfo& arcInfo,
int16_t start, int16_t start,
int16_t end, int16_t end,
int16_t y, int16_t y,
...@@ -123,7 +126,9 @@ private: ...@@ -123,7 +126,9 @@ private:
const Style& style, const Style& style,
uint8_t opaScale, uint8_t opaScale,
uint8_t quadrant); uint8_t quadrant);
int16_t DrawLineWithDegreeInner(ArcInfo& arcInfo,
int16_t DrawLineWithDegreeInner(BufferInfo& gfxDstBuffer,
ArcInfo& arcInfo,
int16_t start, int16_t start,
int16_t end, int16_t end,
int16_t y, int16_t y,
...@@ -132,8 +137,13 @@ private: ...@@ -132,8 +137,13 @@ private:
uint8_t opaScale, uint8_t opaScale,
uint8_t quadrant); uint8_t quadrant);
#if ENABLE_ANTIALIAS #if ENABLE_ANTIALIAS
void DrawLineAnti(ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa); void DrawLineAnti(BufferInfo& gfxDstBuffer, ArcInfo& arcInfo, const Rect& mask, const Style& style, uint8_t opa);
void DrawPointAnti(ArcInfo& arcInfo, int16_t x, const Rect& mask, const Style& style, uint8_t antiOpa); void DrawPointAnti(BufferInfo& gfxDstBuffer,
ArcInfo& arcInfo,
int16_t x,
const Rect& mask,
const Style& style,
uint8_t antiOpa);
#endif #endif
uint16_t GetDegreeInQuadrant(uint16_t degree, uint8_t quadrant); uint16_t GetDegreeInQuadrant(uint16_t degree, uint8_t quadrant);
void SetArcInfo(ArcInfo& arcInfo, const Style& style); void SetArcInfo(ArcInfo& arcInfo, const Style& style);
......
...@@ -15,11 +15,12 @@ ...@@ -15,11 +15,12 @@
#include "draw/draw_curve.h" #include "draw/draw_curve.h"
#include "animator/interpolation.h" #include "animator/interpolation.h"
#include "draw/draw_line.h" #include "engines/gfx/gfx_engine_manager.h"
namespace OHOS { namespace OHOS {
void DrawCurve::DrawCubicBezier(const Point& start, const Point& control1, const Point& control2, const Point& end, void DrawCurve::DrawCubicBezier(BufferInfo& gfxDstBuffer, const Point& start, const Point& control1,
const Rect& mask, int16_t width, const ColorType& color, OpacityType opacity) const Point& control2, const Point& end, const Rect& mask,
int16_t width, const ColorType& color, OpacityType opacity)
{ {
if ((width == 0) || (opacity == OPA_TRANSPARENT)) { if ((width == 0) || (opacity == OPA_TRANSPARENT)) {
return; return;
...@@ -33,7 +34,7 @@ void DrawCurve::DrawCubicBezier(const Point& start, const Point& control1, const ...@@ -33,7 +34,7 @@ void DrawCurve::DrawCubicBezier(const Point& start, const Point& control1, const
if ((prePoint.x == point.x) && (prePoint.y == point.y)) { if ((prePoint.x == point.x) && (prePoint.y == point.y)) {
continue; continue;
} }
DrawLine::Draw(prePoint, point, mask, width, color, opacity); BaseGfxEngine::GetInstance()->DrawLine(gfxDstBuffer, prePoint, point, mask, width, color, opacity);
prePoint = point; prePoint = point;
} }
} }
......
...@@ -18,12 +18,14 @@ ...@@ -18,12 +18,14 @@
#include "gfx_utils/color.h" #include "gfx_utils/color.h"
#include "gfx_utils/geometry2d.h" #include "gfx_utils/geometry2d.h"
#include "gfx_utils/graphic_buffer.h"
namespace OHOS { namespace OHOS {
class DrawCurve : public HeapBase { class DrawCurve : public HeapBase {
public: public:
static void DrawCubicBezier(const Point& start, const Point& control1, const Point& control2, const Point& end, static void DrawCubicBezier(BufferInfo& gfxDstBuffer, const Point& start, const Point& control1,
const Rect& mask, int16_t width, const ColorType& color, OpacityType opacity); const Point& control2, const Point& end, const Rect& mask,
int16_t width, const ColorType& color, OpacityType opacity);
private: private:
static constexpr uint16_t INTERPOLATION_RANGE = 1024; static constexpr uint16_t INTERPOLATION_RANGE = 1024;
}; };
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "imgdecode/cache_manager.h" #include "imgdecode/cache_manager.h"
namespace OHOS { namespace OHOS {
void DrawImage::DrawCommon(const Rect& coords, const Rect& mask, void DrawImage::DrawCommon(BufferInfo& gfxDstBuffer, const Rect& coords, const Rect& mask,
const ImageInfo* img, const Style& style, uint8_t opaScale) const ImageInfo* img, const Style& style, uint8_t opaScale)
{ {
if (img == nullptr) { if (img == nullptr) {
...@@ -52,11 +52,11 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask, ...@@ -52,11 +52,11 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask,
break; break;
} }
lutColorMode = DrawUtils::GetLutColorModeBySize(size); lutColorMode = DrawUtils::GetLutColorModeBySize(size);
DrawUtils::GetInstance()->DrawImage(coords, mask, img->data, opa, pxBitSize, DrawUtils::GetInstance()->DrawImage(gfxDstBuffer, coords, mask, img->data, opa, pxBitSize,
static_cast<ColorMode>(img->header.colorMode), lutColorMode); static_cast<ColorMode>(img->header.colorMode), lutColorMode);
} }
void DrawImage::DrawCommon(const Rect& coords, const Rect& mask, void DrawImage::DrawCommon(BufferInfo& gfxDstBuffer, const Rect& coords, const Rect& mask,
const char* path, const Style& style, uint8_t opaScale) const char* path, const Style& style, uint8_t opaScale)
{ {
if (path == nullptr) { if (path == nullptr) {
...@@ -71,7 +71,7 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask, ...@@ -71,7 +71,7 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask,
uint8_t pxBitSize = DrawUtils::GetPxSizeByColorMode(entry.GetImageInfo().header.colorMode); uint8_t pxBitSize = DrawUtils::GetPxSizeByColorMode(entry.GetImageInfo().header.colorMode);
if (entry.InCache()) { if (entry.InCache()) {
DrawUtils::GetInstance()->DrawImage(coords, mask, entry.GetImgData(), opa, pxBitSize, DrawUtils::GetInstance()->DrawImage(gfxDstBuffer, coords, mask, entry.GetImgData(), opa, pxBitSize,
static_cast<ColorMode>(entry.GetImageInfo().header.colorMode)); static_cast<ColorMode>(entry.GetImageInfo().header.colorMode));
} else { } else {
Rect valid = coords; Rect valid = coords;
...@@ -100,7 +100,7 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask, ...@@ -100,7 +100,7 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask,
UIFree(buf); UIFree(buf);
return; return;
} }
DrawUtils::GetInstance()->DrawImage(line, mask, buf, opa, pxBitSize, DrawUtils::GetInstance()->DrawImage(gfxDstBuffer, line, mask, buf, opa, pxBitSize,
static_cast<ColorMode>(entry.GetImageInfo().header.colorMode)); 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);
......
...@@ -30,10 +30,10 @@ public: ...@@ -30,10 +30,10 @@ public:
DrawImage() {} DrawImage() {}
~DrawImage() {} ~DrawImage() {}
static void DrawCommon(const Rect& coords, const Rect& mask, static void DrawCommon(BufferInfo& gfxDstBuffer, const Rect& coords, const Rect& mask,
const ImageInfo* img, const Style& style, uint8_t opaScale); const ImageInfo* img, const Style& style, uint8_t opaScale);
static void DrawCommon(const Rect& coords, const Rect& mask, static void DrawCommon(BufferInfo& gfxDstBuffer, const Rect& coords, const Rect& mask,
const char* path, const Style& style, uint8_t opaScale); const char* path, const Style& style, uint8_t opaScale);
}; };
} // namespace OHOS } // namespace OHOS
......
...@@ -17,12 +17,13 @@ ...@@ -17,12 +17,13 @@
#include <cstdio> #include <cstdio>
#include "common/typed_text.h" #include "common/typed_text.h"
#include "draw/draw_utils.h" #include "draw/draw_utils.h"
#include "engines/gfx/gfx_engine_manager.h"
#include "font/ui_font.h" #include "font/ui_font.h"
#include "font/ui_font_header.h" #include "font/ui_font_header.h"
#include "gfx_utils/graphic_log.h" #include "gfx_utils/graphic_log.h"
namespace OHOS { namespace OHOS {
void DrawLabel::DrawTextOneLine(const LabelLineInfo& labelLine) void DrawLabel::DrawTextOneLine(BufferInfo& gfxDstBuffer, const LabelLineInfo& labelLine)
{ {
UIFont* fontEngine = UIFont::GetInstance(); UIFont* fontEngine = UIFont::GetInstance();
if (labelLine.direct == TEXT_DIRECT_RTL) { if (labelLine.direct == TEXT_DIRECT_RTL) {
...@@ -48,7 +49,7 @@ void DrawLabel::DrawTextOneLine(const LabelLineInfo& labelLine) ...@@ -48,7 +49,7 @@ void DrawLabel::DrawTextOneLine(const LabelLineInfo& labelLine)
labelLine.fontId, labelLine.fontId,
0, 0,
labelLine.fontSize}; labelLine.fontSize};
DrawUtils::GetInstance()->DrawLetter(letterInfo); DrawUtils::GetInstance()->DrawLetter(gfxDstBuffer, letterInfo);
letterWidth = fontEngine->GetWidth(letter, 0); letterWidth = fontEngine->GetWidth(letter, 0);
if (labelLine.direct == TEXT_DIRECT_RTL) { if (labelLine.direct == TEXT_DIRECT_RTL) {
labelLine.pos.x -= (letterWidth + labelLine.style.letterSpace_); labelLine.pos.x -= (letterWidth + labelLine.style.letterSpace_);
...@@ -58,7 +59,8 @@ void DrawLabel::DrawTextOneLine(const LabelLineInfo& labelLine) ...@@ -58,7 +59,8 @@ void DrawLabel::DrawTextOneLine(const LabelLineInfo& labelLine)
} }
} }
void DrawLabel::DrawArcText(const Rect& mask, void DrawLabel::DrawArcText(BufferInfo& gfxDstBuffer,
const Rect& mask,
const char* text, const char* text,
const Point& arcCenter, const Point& arcCenter,
uint8_t fontId, uint8_t fontId,
...@@ -113,12 +115,13 @@ void DrawLabel::DrawArcText(const Rect& mask, ...@@ -113,12 +115,13 @@ void DrawLabel::DrawArcText(const Rect& mask,
TypedText::GetArcLetterPos(arcCenter, arcTextInfo.radius, angle, posX, posY); TypedText::GetArcLetterPos(arcCenter, arcTextInfo.radius, angle, posX, posY);
angle += incrementAngle; angle += incrementAngle;
DrawLetterWithRotate(mask, fontId, letter, Point{MATH_ROUND(posX), MATH_ROUND(posY)}, DrawLetterWithRotate(gfxDstBuffer, mask, fontId, letter, Point{MATH_ROUND(posX), MATH_ROUND(posY)},
static_cast<int16_t>(rotateAngle), style.textColor_, opaScale); static_cast<int16_t>(rotateAngle), style.textColor_, opaScale);
} }
} }
void DrawLabel::DrawLetterWithRotate(const Rect& mask, void DrawLabel::DrawLetterWithRotate(BufferInfo& gfxDstBuffer,
const Rect& mask,
uint8_t fontId, uint8_t fontId,
uint32_t letter, uint32_t letter,
const Point& pos, const Point& pos,
...@@ -162,6 +165,7 @@ void DrawLabel::DrawLetterWithRotate(const Rect& mask, ...@@ -162,6 +165,7 @@ void DrawLabel::DrawLetterWithRotate(const Rect& mask,
transMap.Rotate(rotateAngle, Vector2<float>(-node.left, node.top - head.ascender)); transMap.Rotate(rotateAngle, Vector2<float>(-node.left, node.top - head.ascender));
TransformDataInfo letterTranDataInfo = {ImageHeader{colorMode, 0, 0, 0, node.cols, node.rows}, fontMap, fontWeight, TransformDataInfo letterTranDataInfo = {ImageHeader{colorMode, 0, 0, 0, node.cols, node.rows}, fontMap, fontWeight,
BlurLevel::LEVEL0}; BlurLevel::LEVEL0};
DrawUtils::GetInstance()->DrawTransform(mask, Point{0, 0}, color, opaScale, transMap, letterTranDataInfo); BaseGfxEngine::GetInstance()->DrawTransform(gfxDstBuffer, mask, Point{0, 0}, color, opaScale, transMap,
letterTranDataInfo);
} }
} // namespace OHOS } // namespace OHOS
...@@ -25,14 +25,20 @@ ...@@ -25,14 +25,20 @@
namespace OHOS { namespace OHOS {
class DrawLabel : public HeapBase { class DrawLabel : public HeapBase {
public: public:
static void DrawTextOneLine(const LabelLineInfo& labelLine); static void DrawTextOneLine(BufferInfo& gfxDstBuffer, const LabelLineInfo& labelLine);
static void DrawArcText(const Rect& mask, const char* text, const Point& arcCenter, uint8_t fontId, static void DrawArcText(BufferInfo& gfxDstBuffer, const Rect& mask, const char* text,
const UIArcLabel::ArcTextInfo arcTextInfo, UIArcLabel::TextOrientation orientation, const Style& style, const Point& arcCenter, uint8_t fontId, const UIArcLabel::ArcTextInfo arcTextInfo,
uint8_t opaScale); UIArcLabel::TextOrientation orientation, const Style& style, uint8_t opaScale);
static void DrawLetterWithRotate(const Rect& mask, uint8_t fontId, uint32_t letter, const Point& pos, static void DrawLetterWithRotate(BufferInfo& gfxDstBuffer,
int16_t rotateAngle, const ColorType& color, OpacityType opaScale); const Rect& mask,
uint8_t fontId,
uint32_t letter,
const Point& pos,
int16_t rotateAngle,
const ColorType& color,
OpacityType opaScale);
}; };
} // namespace OHOS } // namespace OHOS
#endif // GRAPHIC_LITE_DRAW_LABEL_H #endif // GRAPHIC_LITE_DRAW_LABEL_H
...@@ -56,7 +56,8 @@ namespace OHOS { ...@@ -56,7 +56,8 @@ namespace OHOS {
SWAP_POINTS((x1), (x2), (y1), (y2)); \ SWAP_POINTS((x1), (x2), (y1), (y2)); \
} }
void DrawLine::Draw(const Point& start, void DrawLine::Draw(BufferInfo& gfxDstBuffer,
const Point& start,
const Point& end, const Point& end,
const Rect& mask, const Rect& mask,
int16_t width, int16_t width,
...@@ -83,15 +84,16 @@ void DrawLine::Draw(const Point& start, ...@@ -83,15 +84,16 @@ void DrawLine::Draw(const Point& start,
} }
if (start.y == end.y) { if (start.y == end.y) {
DrawHorizontalLine(start, end, mask, width, color, opacity); DrawHorizontalLine(gfxDstBuffer, start, end, mask, width, color, opacity);
} else if (start.x == end.x) { } else if (start.x == end.x) {
DrawVerticalLine(start, end, mask, width, color, opacity); DrawVerticalLine(gfxDstBuffer, start, end, mask, width, color, opacity);
} else { } else {
DrawWuLine(start, end, mask, width, color, opacity); DrawWuLine(gfxDstBuffer, start, end, mask, width, color, opacity);
} }
} }
void DrawLine::DrawVerticalLine(const Point& start, void DrawLine::DrawVerticalLine(BufferInfo& gfxDstBuffer,
const Point& start,
const Point& end, const Point& end,
const Rect& mask, const Rect& mask,
int16_t width, int16_t width,
...@@ -112,10 +114,10 @@ void DrawLine::DrawVerticalLine(const Point& start, ...@@ -112,10 +114,10 @@ void DrawLine::DrawVerticalLine(const Point& start,
rect.SetHeight(start.y - end.y + 1); rect.SetHeight(start.y - end.y + 1);
} }
DrawUtils::GetInstance()->DrawColorArea(rect, mask, color, opacity); DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rect, mask, color, opacity);
} }
void DrawLine::DrawHorizontalLine(const Point& start, void DrawLine::DrawHorizontalLine(BufferInfo& gfxDstBuffer, const Point& start,
const Point& end, const Point& end,
const Rect& mask, const Rect& mask,
int16_t width, int16_t width,
...@@ -136,14 +138,14 @@ void DrawLine::DrawHorizontalLine(const Point& start, ...@@ -136,14 +138,14 @@ void DrawLine::DrawHorizontalLine(const Point& start,
rect.SetHeight(width); rect.SetHeight(width);
} }
DrawUtils::GetInstance()->DrawColorArea(rect, mask, color, opacity); DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rect, mask, color, opacity);
} }
void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask, void DrawLine::DrawWuLine(BufferInfo& gfxDstBuffer, const Point& start, const Point& end,
int16_t width, const ColorType& color, OpacityType opacity) const Rect& mask, int16_t width, const ColorType& color, OpacityType opacity)
{ {
if (width <= 2) { // 2 : thin line width if (width <= 2) { // 2 : thin line width
DrawThinWuLine(start, end, mask, width, color, opacity); DrawThinWuLine(gfxDstBuffer, start, end, mask, width, color, opacity);
return; return;
} }
...@@ -179,7 +181,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -179,7 +181,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
// width is longer than distance between start point and end point, need swap direction of line. // width is longer than distance between start point and end point, need swap direction of line.
if (dx * dx + dy * dy < width * width) { if (dx * dx + dy * dy < width * width) {
if ((dx == 1) && (dy == 1)) { if ((dx == 1) && (dy == 1)) {
DrawThinWuLine({ x0Int, y0Int }, { x3Int, y3Int }, mask, 2, color, opacity); // 2 : width of line DrawThinWuLine(gfxDstBuffer, { x0Int, y0Int }, { x3Int, y3Int }, mask, 2, color, opacity); // 2 : width of line
return; return;
} }
dx = MATH_ABS(x0Int - x1Int); dx = MATH_ABS(x0Int - x1Int);
...@@ -245,7 +247,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -245,7 +247,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
dx = MATH_ABS(x1Int - x0Int); dx = MATH_ABS(x1Int - x0Int);
sx = x0Int; sx = x0Int;
sy = y0Int; sy = y0Int;
DrawUtils::GetInstance()->DrawPixel(x0Int, y0Int, mask, color, opacity); DrawUtils::GetInstance()->DrawPixel(gfxDstBuffer, x0Int, y0Int, mask, color, opacity);
while (--dx) { while (--dx) {
accTemp1 = acc1; accTemp1 = acc1;
acc1 += adj1; acc1 += adj1;
...@@ -256,7 +258,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -256,7 +258,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
sy++; sy++;
} }
sx -= dir; sx -= dir;
DrawUtils::GetInstance()->DrawPixelInLine(sx, sy, mask, color, opacity, DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sx, sy, mask, color, opacity,
(acc1 >> SHIFT_8) ^ OPA_OPAQUE); (acc1 >> SHIFT_8) ^ OPA_OPAQUE);
} }
if (sy - y0Int < MAX_LINE_WIDTH) { if (sy - y0Int < MAX_LINE_WIDTH) {
...@@ -268,7 +270,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -268,7 +270,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
dx = MATH_ABS(x3Int - x2Int); dx = MATH_ABS(x3Int - x2Int);
sy = y3Int; sy = y3Int;
sx = x3Int; sx = x3Int;
DrawUtils::GetInstance()->DrawPixel(x3Int, y3Int, mask, color, opacity); DrawUtils::GetInstance()->DrawPixel(gfxDstBuffer, x3Int, y3Int, mask, color, opacity);
while (--dx) { while (--dx) {
accTemp1 = acc1; accTemp1 = acc1;
acc1 += adj1; acc1 += adj1;
...@@ -279,7 +281,8 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -279,7 +281,8 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
sy--; sy--;
} }
sx += dir; sx += dir;
DrawUtils::GetInstance()->DrawPixelInLine(sx, sy, mask, color, opacity, (acc1 >> SHIFT_8) ^ OPA_OPAQUE); DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sx, sy, mask, color, opacity,
(acc1 >> SHIFT_8) ^ OPA_OPAQUE);
} }
if (temp1 < MAX_LINE_WIDTH) { if (temp1 < MAX_LINE_WIDTH) {
endPoints1[temp1++] = sx + dir; endPoints1[temp1++] = sx + dir;
...@@ -287,9 +290,9 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -287,9 +290,9 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
} else { } else {
/* If y0 is equal to y1, draw two horizontal lines as the top line and bottom line. */ /* If y0 is equal to y1, draw two horizontal lines as the top line and bottom line. */
rect.SetRect(MATH_MIN(x0Int, x1Int), y0Int, MATH_MAX(x0Int, x1Int), y1Int); rect.SetRect(MATH_MIN(x0Int, x1Int), y0Int, MATH_MAX(x0Int, x1Int), y1Int);
DrawUtils::GetInstance()->DrawColorArea(rect, mask, color, opacity); DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rect, mask, color, opacity);
rect.SetRect(MATH_MIN(x2Int, x3Int), y3Int, MATH_MAX(x2Int, x3Int), y2Int); rect.SetRect(MATH_MIN(x2Int, x3Int), y3Int, MATH_MAX(x2Int, x3Int), y2Int);
DrawUtils::GetInstance()->DrawColorArea(rect, mask, color, opacity); DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rect, mask, color, opacity);
} }
sx = x0Int; sx = x0Int;
...@@ -302,7 +305,8 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -302,7 +305,8 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
while (--dy) { while (--dy) {
if (sy <= y1Int) { if (sy <= y1Int) {
INCREASE_ACC(acc0, accTemp0, adj0, sx, dir); INCREASE_ACC(acc0, accTemp0, adj0, sx, dir);
DrawUtils::GetInstance()->DrawPixelInLine(sx + dir, sy, mask, color, opacity, acc0 >> SHIFT_8); DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sx + dir, sy, mask,
color, opacity, acc0 >> SHIFT_8);
if (temp0 < MAX_LINE_WIDTH) { if (temp0 < MAX_LINE_WIDTH) {
edge0 = endPoints0[temp0++]; edge0 = endPoints0[temp0++];
} }
...@@ -310,15 +314,16 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -310,15 +314,16 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
} else if (sy < y2Int) { } else if (sy < y2Int) {
INCREASE_ACC(acc0, accTemp0, adj0, sx, dir); INCREASE_ACC(acc0, accTemp0, adj0, sx, dir);
INCREASE_ACC(acc2, accTemp2, adj0, sxTemp, dir); INCREASE_ACC(acc2, accTemp2, adj0, sxTemp, dir);
DrawUtils::GetInstance()->DrawPixelInLine(sx + dir, sy, mask, color, opacity, acc0 >> SHIFT_8); DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sx + dir, sy, mask,
DrawUtils::GetInstance()->DrawPixelInLine(sxTemp, sy, mask, color, opacity, color, opacity, acc0 >> SHIFT_8);
(acc2 >> SHIFT_8) ^ OPA_OPAQUE); DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sxTemp, sy, mask, color, opacity,
(acc2 >> SHIFT_8) ^ OPA_OPAQUE);
edge0 = sxTemp + dir; edge0 = sxTemp + dir;
edge1 = sx; edge1 = sx;
} else if (sy < y3Int) { } else if (sy < y3Int) {
INCREASE_ACC(acc2, accTemp2, adj0, sxTemp, dir); INCREASE_ACC(acc2, accTemp2, adj0, sxTemp, dir);
DrawUtils::GetInstance()->DrawPixelInLine(sxTemp, sy, mask, color, opacity, DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sxTemp, sy, mask, color, opacity,
(acc2 >> SHIFT_8) ^ OPA_OPAQUE); (acc2 >> SHIFT_8) ^ OPA_OPAQUE);
edge0 = sxTemp + dir; edge0 = sxTemp + dir;
if (temp1 > 0) { if (temp1 > 0) {
edge1 = endPoints1[--temp1]; edge1 = endPoints1[--temp1];
...@@ -328,7 +333,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -328,7 +333,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
SWAP_INT16(edge0, edge1); SWAP_INT16(edge0, edge1);
} }
rect.SetRect(edge0, sy, edge1, sy); rect.SetRect(edge0, sy, edge1, sy);
DrawUtils::GetInstance()->DrawColorArea(rect, mask, color, opacity); DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rect, mask, color, opacity);
sy++; sy++;
} }
} else { } else {
...@@ -340,7 +345,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -340,7 +345,7 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
dy = MATH_ABS(y1Int - y0Int); dy = MATH_ABS(y1Int - y0Int);
sx = x0Int; sx = x0Int;
sy = y0Int; sy = y0Int;
DrawUtils::GetInstance()->DrawPixel(sx, sy, mask, color, opacity); DrawUtils::GetInstance()->DrawPixel(gfxDstBuffer, sx, sy, mask, color, opacity);
while (--dy) { while (--dy) {
accTemp1 = acc1; accTemp1 = acc1;
acc1 += adj1; acc1 += adj1;
...@@ -351,8 +356,8 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -351,8 +356,8 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
sx--; sx--;
} }
sy -= dir; sy -= dir;
DrawUtils::GetInstance()->DrawPixelInLine(sx, sy, mask, color, opacity, DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sx, sy, mask, color, opacity,
(acc1 >> SHIFT_8) ^ OPA_OPAQUE); (acc1 >> SHIFT_8) ^ OPA_OPAQUE);
} }
if (x0Int - sx < MAX_LINE_WIDTH) { if (x0Int - sx < MAX_LINE_WIDTH) {
endPoints0[x0Int - sx] = sy - dir; endPoints0[x0Int - sx] = sy - dir;
...@@ -373,18 +378,19 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -373,18 +378,19 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
sx++; sx++;
} }
sy += dir; sy += dir;
DrawUtils::GetInstance()->DrawPixelInLine(sx, sy, mask, color, opacity, (acc1 >> SHIFT_8) ^ OPA_OPAQUE); DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sx, sy, mask, color, opacity,
(acc1 >> SHIFT_8) ^ OPA_OPAQUE);
} }
DrawUtils::GetInstance()->DrawPixel(x3Int, y3Int, mask, color, opacity); DrawUtils::GetInstance()->DrawPixel(gfxDstBuffer, x3Int, y3Int, mask, color, opacity);
if (temp1 < MAX_LINE_WIDTH) { if (temp1 < MAX_LINE_WIDTH) {
endPoints1[temp1++] = sy + dir; endPoints1[temp1++] = sy + dir;
} }
} else { } else {
/* If x0 is equal to x1, draw two vertical lines as the top line and bottom line. */ /* If x0 is equal to x1, draw two vertical lines as the top line and bottom line. */
rect.SetRect(x1Int, MATH_MIN(y0Int, y1Int), x0Int, MATH_MAX(y0Int, y1Int)); rect.SetRect(x1Int, MATH_MIN(y0Int, y1Int), x0Int, MATH_MAX(y0Int, y1Int));
DrawUtils::GetInstance()->DrawColorArea(rect, mask, color, opacity); DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rect, mask, color, opacity);
rect.SetRect(x3Int, MATH_MIN(y2Int, y3Int), x2Int, MATH_MAX(y2Int, y3Int)); rect.SetRect(x3Int, MATH_MIN(y2Int, y3Int), x2Int, MATH_MAX(y2Int, y3Int));
DrawUtils::GetInstance()->DrawColorArea(rect, mask, color, opacity); DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rect, mask, color, opacity);
} }
sx = x0Int - 1; sx = x0Int - 1;
...@@ -397,7 +403,8 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -397,7 +403,8 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
while (--dx) { while (--dx) {
if (sx >= x1Int) { if (sx >= x1Int) {
INCREASE_ACC(acc0, accTemp0, adj0, sy, dir); INCREASE_ACC(acc0, accTemp0, adj0, sy, dir);
DrawUtils::GetInstance()->DrawPixelInLine(sx, sy + dir, mask, color, opacity, acc0 >> SHIFT_8); DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sx, sy + dir, mask,
color, opacity, acc0 >> SHIFT_8);
if (temp0 < MAX_LINE_WIDTH) { if (temp0 < MAX_LINE_WIDTH) {
edge0 = endPoints0[temp0++]; edge0 = endPoints0[temp0++];
} }
...@@ -405,15 +412,16 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -405,15 +412,16 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
} else if (sx > x2Int) { } else if (sx > x2Int) {
INCREASE_ACC(acc0, accTemp0, adj0, sy, dir); INCREASE_ACC(acc0, accTemp0, adj0, sy, dir);
INCREASE_ACC(acc2, accTemp2, adj0, syTemp, dir); INCREASE_ACC(acc2, accTemp2, adj0, syTemp, dir);
DrawUtils::GetInstance()->DrawPixelInLine(sx, sy + dir, mask, color, opacity, acc0 >> SHIFT_8); DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sx, sy + dir, mask,
DrawUtils::GetInstance()->DrawPixelInLine(sx, syTemp, mask, color, opacity, color, opacity, acc0 >> SHIFT_8);
(acc2 >> SHIFT_8) ^ OPA_OPAQUE); DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sx, syTemp, mask, color,
opacity, (acc2 >> SHIFT_8) ^ OPA_OPAQUE);
edge0 = syTemp + dir; edge0 = syTemp + dir;
edge1 = sy; edge1 = sy;
} else if (sx > x3Int) { } else if (sx > x3Int) {
INCREASE_ACC(acc2, accTemp2, adj0, syTemp, dir); INCREASE_ACC(acc2, accTemp2, adj0, syTemp, dir);
DrawUtils::GetInstance()->DrawPixelInLine(sx, syTemp, mask, color, opacity, DrawUtils::GetInstance()->DrawPixelInLine(gfxDstBuffer, sx, syTemp, mask, color, opacity,
(acc2 >> SHIFT_8) ^ OPA_OPAQUE); (acc2 >> SHIFT_8) ^ OPA_OPAQUE);
edge0 = syTemp + dir; edge0 = syTemp + dir;
if (temp1 > 0) { if (temp1 > 0) {
edge1 = endPoints1[--temp1]; edge1 = endPoints1[--temp1];
...@@ -423,14 +431,14 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask ...@@ -423,14 +431,14 @@ void DrawLine::DrawWuLine(const Point& start, const Point& end, const Rect& mask
SWAP_INT16(edge0, edge1); SWAP_INT16(edge0, edge1);
} }
rect.SetRect(sx, edge0, sx, edge1); rect.SetRect(sx, edge0, sx, edge1);
DrawUtils::GetInstance()->DrawColorArea(rect, mask, color, opacity); DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, rect, mask, color, opacity);
sx--; sx--;
} }
} }
} }
void DrawLine::DrawThinWuLine(const Point& start, const Point& end, const Rect& mask, void DrawLine::DrawThinWuLine(BufferInfo& gfxDstBuffer, const Point& start, const Point& end,
int16_t width, const ColorType& color, OpacityType opacity) const Rect& mask, int16_t width, const ColorType& color, OpacityType opacity)
{ {
int16_t sx = start.x; int16_t sx = start.x;
int16_t sy = start.y; int16_t sy = start.y;
...@@ -449,10 +457,11 @@ void DrawLine::DrawThinWuLine(const Point& start, const Point& end, const Rect& ...@@ -449,10 +457,11 @@ void DrawLine::DrawThinWuLine(const Point& start, const Point& end, const Rect&
INCREASE_ACC(acc, accTemp, adj, sx, dir); INCREASE_ACC(acc, accTemp, adj, sx, dir);
sy++; sy++;
if (width == 1) { if (width == 1) {
DrawUtils::GetInstance()->DrawAdjPixelInLine(sx, sy, sx + dir, sy, mask, color, opacity, DrawUtils::GetInstance()->DrawAdjPixelInLine(gfxDstBuffer, sx, sy, sx + dir, sy, mask,
acc >> SHIFT_8); color, opacity, acc >> SHIFT_8);
} else { } else {
DrawUtils::GetInstance()->DrawVerPixelInLine(sx, sy, dir, mask, color, opacity, acc >> SHIFT_8); DrawUtils::GetInstance()->DrawVerPixelInLine(gfxDstBuffer, sx, sy, dir, mask,
color, opacity, acc >> SHIFT_8);
} }
} }
} else { } else {
...@@ -461,10 +470,11 @@ void DrawLine::DrawThinWuLine(const Point& start, const Point& end, const Rect& ...@@ -461,10 +470,11 @@ void DrawLine::DrawThinWuLine(const Point& start, const Point& end, const Rect&
INCREASE_ACC(acc, accTemp, adj, sy, dir); INCREASE_ACC(acc, accTemp, adj, sy, dir);
sx--; sx--;
if (width == 1) { if (width == 1) {
DrawUtils::GetInstance()->DrawAdjPixelInLine(sx, sy, sx, sy + dir, mask, color, opacity, DrawUtils::GetInstance()->DrawAdjPixelInLine(gfxDstBuffer, sx, sy, sx, sy + dir, mask,
acc >> SHIFT_8); color, opacity, acc >> SHIFT_8);
} else { } else {
DrawUtils::GetInstance()->DrawHorPixelInLine(sx, sy, dir, mask, color, opacity, acc >> SHIFT_8); DrawUtils::GetInstance()->DrawHorPixelInLine(gfxDstBuffer, sx, sy, dir, mask,
color, opacity, acc >> SHIFT_8);
} }
} }
} }
......
...@@ -18,21 +18,25 @@ ...@@ -18,21 +18,25 @@
#include "gfx_utils/color.h" #include "gfx_utils/color.h"
#include "gfx_utils/geometry2d.h" #include "gfx_utils/geometry2d.h"
#include "gfx_utils/graphic_buffer.h"
namespace OHOS { namespace OHOS {
class DrawLine : public HeapBase { class DrawLine : public HeapBase {
public: public:
static void Draw(const Point& start, const Point& end, const Rect& mask, static void Draw(BufferInfo& gfxDstBuffer, const Point& start, const Point& end, const Rect& mask,
int16_t width, const ColorType& color, OpacityType opacity); int16_t width, const ColorType& color, OpacityType opacity);
private: private:
static void DrawVerticalLine(const Point& start, const Point& end, const Rect& mask, static void DrawVerticalLine(BufferInfo& gfxDstBuffer, const Point& start, const Point& end,
int16_t width, const ColorType& color, OpacityType opacity); const Rect& mask, int16_t width, const ColorType& color, OpacityType opacity);
static void DrawHorizontalLine(const Point& start, const Point& end, const Rect& mask,
int16_t width, const ColorType& color, OpacityType opacity); static void DrawHorizontalLine(BufferInfo& gfxDstBuffer, const Point& start, const Point& end,
static void DrawWuLine(const Point& start, const Point& end, const Rect& mask, const Rect& mask, int16_t width, const ColorType& color, OpacityType opacity);
int16_t width, const ColorType& color, OpacityType opacity);
static void DrawThinWuLine(const Point& start, const Point& end, const Rect& mask, static void DrawWuLine(BufferInfo& gfxDstBuffer, const Point& start, const Point& end,
const Rect& mask, int16_t width, const ColorType& color, OpacityType opacity);
static void DrawThinWuLine(BufferInfo& gfxDstBuffer, const Point& start, const Point& end, const Rect& mask,
int16_t width, const ColorType& color, OpacityType opacity); int16_t width, const ColorType& color, OpacityType opacity);
}; };
} // namespace OHOS } // namespace OHOS
......
此差异已折叠。
...@@ -16,7 +16,11 @@ ...@@ -16,7 +16,11 @@
#ifndef GRAPHIC_LITE_DRAW_RECT_H #ifndef GRAPHIC_LITE_DRAW_RECT_H
#define GRAPHIC_LITE_DRAW_RECT_H #define GRAPHIC_LITE_DRAW_RECT_H
#include "components/ui_view.h" #include "gfx_utils/heap_base.h"
#include "gfx_utils/rect.h"
#include "gfx_utils/style.h"
#include "gfx_utils/color.h"
#include "gfx_utils/graphic_buffer.h"
namespace OHOS { namespace OHOS {
/** @brief Class for drawing rectangle. */ /** @brief Class for drawing rectangle. */
...@@ -25,37 +29,48 @@ public: ...@@ -25,37 +29,48 @@ public:
DrawRect() {}; DrawRect() {};
~DrawRect() {}; ~DrawRect() {};
static void Draw(const Rect& rect, const Rect& dirtyRect, const Style& style, OpacityType opaScale); static void Draw(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
const Style& style, OpacityType opaScale);
private: private:
static void DrawRectRadiusWithoutBorder(const Rect& rect, const Rect& dirtyRect, const Style& style, static void DrawRectRadiusWithoutBorder(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
OpacityType opaScale); const Style& style, OpacityType opaScale);
static void DrawRectBorderWithoutRadius(const Rect& rect, const Rect& dirtyRect, const Style& style,
OpacityType opaScale); static void DrawRectBorderWithoutRadius(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
static void DrawRectRadiusEqualBorder(const Rect& rect, const Rect& dirtyRect, const Style& style, const Style& style, OpacityType opaScale);
OpacityType opaScale);
static void DrawRectRadiusSmallThanBorder(const Rect& rect, const Rect& dirtyRect, const Style& style, static void DrawRectRadiusEqualBorder(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
OpacityType opaScale); const Style& style, OpacityType opaScale);
static void DrawRectRadiusBiggerThanBorder(const Rect& rect, const Rect& dirtyRect, const Style& style,
OpacityType opaScale); static void DrawRectRadiusSmallThanBorder(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
const Style& style, OpacityType opaScale);
static void DrawRectRadiusWithoutBorderCon1(const Rect& rect, const Rect& dirtyRect, const Style& style,
OpacityType opaScale); static void DrawRectRadiusBiggerThanBorder(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
static void DrawRectRadiusWithoutBorderCon2(const Rect& rect, const Rect& dirtyRect, const Style& style, const Style& style, OpacityType opaScale);
OpacityType opaScale);
static void DrawRectRadiusWithoutBorderCon3(const Rect& rect, const Rect& dirtyRect, const Style& style, static void DrawRectRadiusWithoutBorderCon1(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
OpacityType opaScale); const Style& style, OpacityType opaScale);
static void DrawRectRadiusWithoutBorderCon4(const Rect& rect, const Rect& dirtyRect, const Style& style,
OpacityType opaScale); static void DrawRectRadiusWithoutBorderCon2(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
const Style& style, OpacityType opaScale);
static void DrawRectRadiusBiggerThanBorderCon1(const Rect& rect, const Rect& dirtyRect, const Style& style,
OpacityType opaScale); static void DrawRectRadiusWithoutBorderCon3(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
static void DrawRectRadiusBiggerThanBorderCon2(const Rect& rect, const Rect& dirtyRect, const Style& style, const Style& style, OpacityType opaScale);
OpacityType opaScale);
static void DrawRectRadiusBiggerThanBorderCon3(const Rect& rect, const Rect& dirtyRect, const Style& style, static void DrawRectRadiusWithoutBorderCon4(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
OpacityType opaScale); const Style& style, OpacityType opaScale);
static void DrawRectRadiusBiggerThanBorderCon4(const Rect& rect, const Rect& dirtyRect, const Style& style,
OpacityType opaScale); static void DrawRectRadiusBiggerThanBorderCon1(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
const Style& style, OpacityType opaScale);
static void DrawRectRadiusBiggerThanBorderCon2(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
const Style& style, OpacityType opaScale);
static void DrawRectRadiusBiggerThanBorderCon3(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
const Style& style, OpacityType opaScale);
static void DrawRectRadiusBiggerThanBorderCon4(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& dirtyRect,
const Style& style, OpacityType opaScale);
}; };
} // namespace OHOS } // namespace OHOS
#endif // GRAPHIC_LITE_DRAW_RECT_H #endif // GRAPHIC_LITE_DRAW_RECT_H
...@@ -17,7 +17,12 @@ ...@@ -17,7 +17,12 @@
#include "draw/draw_utils.h" #include "draw/draw_utils.h"
namespace OHOS { namespace OHOS {
void DrawTriangle::Draw(const Point* points, uint8_t count, const Rect& mask, const ColorType& color, OpacityType opa) void DrawTriangle::Draw(BufferInfo& gfxDstBuffer,
const Point* points,
uint8_t count,
const Rect& mask,
const ColorType& color,
OpacityType opa)
{ {
if ((points == nullptr) || (count != VERTEX_NUM)) { if ((points == nullptr) || (count != VERTEX_NUM)) {
return; return;
...@@ -55,7 +60,7 @@ void DrawTriangle::Draw(const Point* points, uint8_t count, const Rect& mask, co ...@@ -55,7 +60,7 @@ void DrawTriangle::Draw(const Point* points, uint8_t count, const Rect& mask, co
area.SetRight(MATH_MAX(edge1.curPoint.x, edge2.curPoint.x)); area.SetRight(MATH_MAX(edge1.curPoint.x, edge2.curPoint.x));
area.SetTop(MATH_MIN(edge1.curPoint.y, edge2.curPoint.y)); area.SetTop(MATH_MIN(edge1.curPoint.y, edge2.curPoint.y));
area.SetBottom(MATH_MAX(edge1.curPoint.y, edge2.curPoint.y)); area.SetBottom(MATH_MAX(edge1.curPoint.y, edge2.curPoint.y));
DrawUtils::GetInstance()->DrawColorArea(area, mask, color, opa); DrawUtils::GetInstance()->DrawColorArea(gfxDstBuffer, area, mask, color, opa);
while (edge1.curPoint.y == lastY) { while (edge1.curPoint.y == lastY) {
// use Bresenham algorithm to get next point on edge1 // use Bresenham algorithm to get next point on edge1
......
...@@ -18,11 +18,13 @@ ...@@ -18,11 +18,13 @@
#include "gfx_utils/color.h" #include "gfx_utils/color.h"
#include "gfx_utils/geometry2d.h" #include "gfx_utils/geometry2d.h"
#include "gfx_utils/graphic_buffer.h"
namespace OHOS { namespace OHOS {
class DrawTriangle : public HeapBase { class DrawTriangle : public HeapBase {
public: public:
static void Draw(const Point* points, uint8_t count, const Rect& mask, const ColorType& color, OpacityType opa); static void Draw(BufferInfo& gfxDstBuffer, const Point* points, uint8_t count,
const Rect& mask, const ColorType& color, OpacityType opa);
struct Edge { struct Edge {
Point curPoint; Point curPoint;
......
此差异已折叠。
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#define GRAPHIC_LITE_DRAW_UTILS_H #define GRAPHIC_LITE_DRAW_UTILS_H
#include "gfx_utils/color.h" #include "gfx_utils/color.h"
#include "dock/screen_device_proxy.h"
#include "common/text.h" #include "common/text.h"
#include "gfx_utils/geometry2d.h" #include "gfx_utils/geometry2d.h"
#include "gfx_utils/graphic_buffer.h"
#include "gfx_utils/graphic_types.h" #include "gfx_utils/graphic_types.h"
#include "gfx_utils/style.h" #include "gfx_utils/style.h"
#include "gfx_utils/transform.h" #include "gfx_utils/transform.h"
...@@ -109,13 +109,6 @@ struct TriangleEdge { ...@@ -109,13 +109,6 @@ struct TriangleEdge {
int32_t dv = 0; int32_t dv = 0;
// parameters above are Q15 fixed-point number // parameters above are Q15 fixed-point number
}; };
struct TransformDataInfo {
ImageHeader header;
const uint8_t* data;
uint8_t pxSize;
BlurLevel blurLevel;
TransformAlgorithm algorithm;
};
struct TriangleTransformDataInfo { struct TriangleTransformDataInfo {
const TransformDataInfo& info; const TransformDataInfo& info;
...@@ -170,16 +163,20 @@ class DrawUtils : public HeapBase { ...@@ -170,16 +163,20 @@ class DrawUtils : public HeapBase {
public: public:
static DrawUtils* GetInstance(); static DrawUtils* GetInstance();
void DrawColorArea(const Rect& area, const Rect& mask, const ColorType& color, OpacityType opa) const; void DrawColorArea(BufferInfo& gfxDstBuffer, const Rect& area, const Rect& mask,
const ColorType& color, OpacityType opa) const;
void DrawColorAreaBySides(const Rect& mask, const ColorType& color, OpacityType opa, const EdgeSides& sides) const; void DrawColorAreaBySides(BufferInfo& gfxDstBuffer, const Rect& mask, const ColorType& color,
OpacityType opa, const EdgeSides& sides) const;
void DrawPixel(int16_t x, int16_t y, const Rect& mask, const ColorType& color, OpacityType opa) const; void DrawPixel(BufferInfo& gfxDstBuffer, int16_t x, int16_t y, const Rect& mask,
const ColorType& color, OpacityType opa) const;
void DrawLetter(const LabelLetterInfo& letterInfo) const; void DrawLetter(BufferInfo& gfxDstBuffer, const LabelLetterInfo& letterInfo) const;
void DrawImage(const Rect& area, const Rect& mask, const uint8_t* image, OpacityType opa, uint8_t pxBitSize, void DrawImage(BufferInfo& gfxDstBuffer, const Rect& area, const Rect& mask,
ColorMode colorMode, LutColorMode lutColorMode = LUT_UNKNOW) const; 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);
...@@ -189,23 +186,25 @@ public: ...@@ -189,23 +186,25 @@ public:
const Rect& trans, const Rect& trans,
TransformInitState& init); TransformInitState& init);
static void DrawTriangleTransform(const Rect& mask, static void DrawTriangleTransform(BufferInfo& gfxDstBuffer,
const Rect& mask,
const Point& position, const Point& position,
const ColorType& color, const ColorType& color,
OpacityType opaScale, OpacityType opaScale,
const TransformMap& transMap, const TransformMap& transMap,
const TriangleTransformDataInfo& dataInfo); const TriangleTransformDataInfo& dataInfo);
void DrawTransform(const Rect& mask, void DrawTransform(BufferInfo& gfxDstBuffer,
const Rect& mask,
const Point& position, const Point& position,
const ColorType& color, const ColorType& color,
OpacityType opaScale, OpacityType opaScale,
const TransformMap& transMap, const TransformMap& transMap,
const TransformDataInfo& dataInfo) const; const TransformDataInfo& dataInfo) const;
void DrawTranspantArea(const Rect& rect, const Rect& mask); void DrawTranspantArea(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& mask);
void DrawWithBuffer(const Rect& rect, const Rect& mask, const ColorType* colorBuf); void DrawWithBuffer(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& mask, const ColorType* colorBuf);
static uint8_t GetPxSizeByColorMode(uint8_t colorMode); static uint8_t GetPxSizeByColorMode(uint8_t colorMode);
...@@ -220,7 +219,8 @@ public: ...@@ -220,7 +219,8 @@ public:
return opaMix; return opaMix;
} }
void DrawAdjPixelInLine(int16_t x1, void DrawAdjPixelInLine(BufferInfo& gfxDstBuffer,
int16_t x1,
int16_t y1, int16_t y1,
int16_t x2, int16_t x2,
int16_t y2, int16_t y2,
...@@ -229,10 +229,11 @@ public: ...@@ -229,10 +229,11 @@ public:
OpacityType opa, OpacityType opa,
uint16_t w) const; uint16_t w) const;
void DrawPixelInLine(int16_t x, int16_t y, const Rect& mask, const ColorType& color, OpacityType opa, uint16_t w) void DrawPixelInLine(BufferInfo& gfxDstBuffer, int16_t x, int16_t y, const Rect& mask,
const; const ColorType& color, OpacityType opa, uint16_t w) const;
void DrawVerPixelInLine(int16_t x, void DrawVerPixelInLine(BufferInfo& gfxDstBuffer,
int16_t x,
int16_t y, int16_t y,
int8_t dir, int8_t dir,
const Rect& mask, const Rect& mask,
...@@ -240,7 +241,8 @@ public: ...@@ -240,7 +241,8 @@ public:
OpacityType opa, OpacityType opa,
uint16_t weight) const; uint16_t weight) const;
void DrawHorPixelInLine(int16_t x, void DrawHorPixelInLine(BufferInfo& gfxDstBuffer,
int16_t x,
int16_t y, int16_t y,
int8_t dir, int8_t dir,
const Rect& mask, const Rect& mask,
...@@ -248,47 +250,44 @@ public: ...@@ -248,47 +250,44 @@ public:
OpacityType opa, OpacityType opa,
uint16_t weight) const; uint16_t weight) const;
private: void BlendWithSoftWare(const uint8_t* src1,
#if ENABLE_GFX_ENGINES const Rect& srcRect,
bool FillAreaWithHardware(const Rect& fillArea, const ColorType& color, const OpacityType& opa) const;
#endif
void FillAreaWithSoftWare(const Rect& fillArea,
uint8_t* mem,
ColorMode mode,
uint8_t destByteSize,
int16_t bufWidth,
const ColorType& color,
const OpacityType& opa) const;
void BlendWithSoftWare(const uint8_t* src,
uint32_t srcStride, uint32_t srcStride,
uint32_t srcLineNumber,
ColorMode srcMode, ColorMode srcMode,
uint8_t* dest, uint32_t color,
OpacityType opa,
uint8_t* dst,
uint32_t destStride, uint32_t destStride,
ColorMode destMode, ColorMode destMode,
uint32_t width, uint32_t x,
uint32_t height, uint32_t y) const;
OpacityType opa) const;
using DrawTriangleTransformFuc = void (*)(const TriangleScanInfo& triangle); void FillAreaWithSoftWare(BufferInfo& gfxDstBuffer,
const Rect& fillArea,
const ColorType& color,
const OpacityType& opa) const;
private:
using DrawTriangleTransformFuc = void (*)(const TriangleScanInfo& triangle, const ColorMode bufferMode);
static void DrawTriangleTrueColorNearest(const TriangleScanInfo& triangle); static void DrawTriangleTrueColorNearest(const TriangleScanInfo& triangle, const ColorMode bufferMode);
static void DrawTriangleAlphaBilinear(const TriangleScanInfo& triangle); static void DrawTriangleAlphaBilinear(const TriangleScanInfo& triangle, const ColorMode bufferMode);
static void DrawTriangleTrueColorBilinear565(const TriangleScanInfo& triangle); static void DrawTriangleTrueColorBilinear565(const TriangleScanInfo& triangle, const ColorMode bufferMode);
static void DrawTriangleTrueColorBilinear888(const TriangleScanInfo& triangle); static void DrawTriangleTrueColorBilinear888(const TriangleScanInfo& triangle, const ColorMode bufferMode);
static void DrawTriangleTrueColorBilinear8888(const TriangleScanInfo& triangle); static void DrawTriangleTrueColorBilinear8888(const TriangleScanInfo& triangle, const ColorMode bufferMode);
inline static void StepToNextLine(TriangleEdge& edg1, TriangleEdge& edg2); inline static void StepToNextLine(TriangleEdge& edg1, TriangleEdge& edg2);
static void DrawTriangleTransformPart(const TrianglePartInfo& part); static void DrawTriangleTransformPart(BufferInfo& gfxDstBuffer, const TrianglePartInfo& part);
static OpacityType GetPxAlphaForAlphaImg(const TransformDataInfo& dataInfo, const Point& point); static OpacityType GetPxAlphaForAlphaImg(const TransformDataInfo& dataInfo, const Point& point);
void FillArea(const Rect& rect, const Rect& mask, bool isTransparent, const ColorType* colorBuf); void FillArea(BufferInfo& gfxDstBuffer, const Rect& rect, const Rect& mask,
bool isTransparent, const ColorType* colorBuf);
}; };
} // namespace OHOS } // namespace OHOS
#endif // GRAPHIC_LITE_DRAW_UTILS_H #endif // GRAPHIC_LITE_DRAW_UTILS_H
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "engines/gfx/gfx_engine_manager.h"
#include "draw/draw_arc.h"
#include "draw/draw_curve.h"
#include "draw/draw_line.h"
#include "draw/draw_rect.h"
namespace OHOS {
BaseGfxEngine* BaseGfxEngine::baseEngine_ = nullptr;
void BaseGfxEngine::DrawArc(BufferInfo& dst,
ArcInfo& arcInfo,
const Rect& mask,
const Style& style,
OpacityType opacity,
uint8_t cap)
{
DrawArc::GetInstance()->Draw(dst, arcInfo, mask, style, opacity, cap);
}
void BaseGfxEngine::DrawLine(BufferInfo& dst,
const Point& start,
const Point& end,
const Rect& mask,
int16_t width,
ColorType color,
OpacityType opacity)
{
DrawLine::Draw(dst, start, end, mask, width, color, opacity);
}
void BaseGfxEngine::DrawCubicBezier(BufferInfo& dst,
const Point& start,
const Point& control1,
const Point& control2,
const Point& end,
const Rect& mask,
int16_t width,
ColorType color,
OpacityType opacity)
{
DrawCurve::DrawCubicBezier(dst, start, control1, control2, end, mask, width, color, opacity);
}
void BaseGfxEngine::DrawRect(BufferInfo& dst,
const Rect& rect,
const Rect& dirtyRect,
const Style& style,
OpacityType opacity)
{
DrawRect::Draw(dst, rect, dirtyRect, style, opacity);
}
void BaseGfxEngine::DrawTransform(BufferInfo& dst,
const Rect& mask,
const Point& position,
ColorType color,
OpacityType opacity,
const TransformMap& transMap,
const TransformDataInfo& dataInfo)
{
DrawUtils::GetInstance()->DrawTransform(dst, mask, position, color,
opacity, transMap, dataInfo);
}
void BaseGfxEngine::Blit(BufferInfo& dst,
const Point& dstPos,
const BufferInfo& src,
const Rect& subRect,
const BlendOption& blendOption)
{
DrawUtils::GetInstance()->BlendWithSoftWare(static_cast<uint8_t*>(src.virAddr), src.rect, src.stride,
src.rect.GetHeight(), src.mode, src.color, blendOption.opacity, static_cast<uint8_t*>(dst.virAddr),
dst.stride, dst.mode, subRect.GetX(), subRect.GetY());
}
void BaseGfxEngine::Fill(BufferInfo& dst, const Rect& fillArea, const ColorType color, const OpacityType opacity)
{
uint8_t bufferPxSize = DrawUtils::GetByteSizeByColorMode(dst.mode);
DrawUtils::GetInstance()->FillAreaWithSoftWare(dst, fillArea, color, opacity);
}
uint8_t* BaseGfxEngine::AllocBuffer(uint32_t size, uint32_t usage)
{
return static_cast<uint8_t *>(malloc(size));
}
void BaseGfxEngine::FreeBuffer(uint8_t* buffer)
{
free(buffer);
}
}
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "engines/gfx/hi3516/hi3516_engine.h"
#include "draw/draw_utils.h"
#include "hals/gfx_engines.h"
#include "lite_wm_type.h"
namespace OHOS {
const int16_t HARDWARE_ACC_SIZE_LIMIT = 50 * 50;
__attribute__((constructor)) void RegisterHi3516GfxEngine()
{
BaseGfxEngine::InitGfxEngine(new Hi3516GfxEngine());
}
void Hi3516GfxEngine::Fill(BufferInfo& dst,
const Rect& fillArea,
const ColorType color,
const OpacityType opacity)
{
#if ENABLE_GFX_ENGINES
if ((opacity != OPA_OPAQUE) && (fillArea.GetSize() >= HARDWARE_ACC_SIZE_LIMIT)) {
LiteSurfaceData data;
data.phyAddr = static_cast<uint8_t *>(dst.phyAddr);
data.width = dst.width;
data.height = dst.height;
data.stride = dst.stride;
data.pixelFormat = IMAGE_PIXEL_FORMAT_ARGB8888;
if (GfxEngines::GetInstance()->GfxFillArea(data, fillArea, color, opacity)) {
return;
}
}
#endif
BaseGfxEngine::Fill(dst, fillArea, color, opacity);
}
}
/* /*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at. * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "font/ui_font.h" #ifndef GRAPHIC_LITE_HI3516_ENGINE_H
#include "font/ui_font_header.h" #define GRAPHIC_LITE_HI3516_ENGINE_H
namespace OHOS { #include "engines/gfx/gfx_engine_manager.h"
UITextLanguageFontParam* GetTextLangFontsTable(uint8_t langFontId)
{ namespace OHOS {
// Need to be implemented class Hi3516GfxEngine : public BaseGfxEngine {
return nullptr; public:
} void Fill(BufferInfo& dst,
const Rect& fillArea,
uint8_t GetTotalLangId() const ColorType color,
{ const OpacityType opacity) override;
// Need to be implemented };
return 0; }
}
#endif
uint8_t GetBitmapFontIdMax()
{
// Need to be implemented
return 0;
}
uint8_t GetTotalFontId()
{
// Need to be implemented
return 0xFF;
}
uint16_t GetTotalTextId()
{
// Need to be implemented
return 0;
}
LangTextParam* GetLangTextDefaultParamTable()
{
// Need to be implemented
return nullptr;
}
} // namespace OHOS
\ No newline at end of file
...@@ -49,11 +49,11 @@ void BaseFont::SetPsramMemory(uintptr_t psramAddr, uint32_t psramLen) ...@@ -49,11 +49,11 @@ void BaseFont::SetPsramMemory(uintptr_t psramAddr, uint32_t psramLen)
int8_t BaseFont::GetDefaultParamByLangId(uint8_t langId, LangTextParam** pParam) const int8_t BaseFont::GetDefaultParamByLangId(uint8_t langId, LangTextParam** pParam) const
{ {
if ((langId >= GetTotalLangId()) || (pParam == nullptr)) { if ((langId >= UIFontBuilder::GetInstance()->GetTotalLangId()) || (pParam == nullptr)) {
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
LangTextParam *pTable = GetLangTextDefaultParamTable(); LangTextParam *pTable = UIFontBuilder::GetInstance()->GetLangTextDefaultParamTable();
if (pTable == nullptr) { if (pTable == nullptr) {
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
#include "font/glyphs_manager.h" #include "font/glyphs_manager.h"
#include "font/ui_font_builder.h"
#include "gfx_utils/file.h" #include "gfx_utils/file.h"
#include "securec.h" #include "securec.h"
...@@ -43,7 +44,7 @@ GlyphsManager::GlyphsManager() ...@@ -43,7 +44,7 @@ GlyphsManager::GlyphsManager()
isFileSet_(false), isFileSet_(false),
isFontIdSet_(false) isFontIdSet_(false)
{ {
fontId_ = GetBitmapFontIdMax(); fontId_ = UIFontBuilder::GetInstance()->GetBitmapFontIdMax();
} }
GlyphsManager::~GlyphsManager() {} GlyphsManager::~GlyphsManager() {}
...@@ -179,7 +180,7 @@ int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start) ...@@ -179,7 +180,7 @@ int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start)
if (strncmp(binHeader_.fontMagic, FONT_MAGIC_NUMBER, FONT_MAGIC_NUM_LEN) != 0) { if (strncmp(binHeader_.fontMagic, FONT_MAGIC_NUMBER, FONT_MAGIC_NUM_LEN) != 0) {
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (binHeader_.fontNum > GetBitmapFontIdMax()) { if (binHeader_.fontNum > UIFontBuilder::GetInstance()->GetBitmapFontIdMax()) {
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
...@@ -211,7 +212,7 @@ int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start) ...@@ -211,7 +212,7 @@ int8_t GlyphsManager::SetFile(int32_t fp, uint32_t start)
isFileSet_ = true; isFileSet_ = true;
} }
fontId_ = GetBitmapFontIdMax(); fontId_ = UIFontBuilder::GetInstance()->GetBitmapFontIdMax();
return ret; return ret;
} }
...@@ -221,7 +222,7 @@ int8_t GlyphsManager::SetCurrentFontId(uint8_t fontId) ...@@ -221,7 +222,7 @@ int8_t GlyphsManager::SetCurrentFontId(uint8_t fontId)
if (!isFileSet_) { if (!isFileSet_) {
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (fontId > GetBitmapFontIdMax()) { if (fontId > UIFontBuilder::GetInstance()->GetBitmapFontIdMax()) {
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
if (fontId_ == fontId) { if (fontId_ == fontId) {
...@@ -247,7 +248,7 @@ int8_t GlyphsManager::SetCurrentFontId(uint8_t fontId) ...@@ -247,7 +248,7 @@ int8_t GlyphsManager::SetCurrentFontId(uint8_t fontId)
if (!found) { if (!found) {
isFontIdSet_ = false; isFontIdSet_ = false;
curFontHeader_ = nullptr; curFontHeader_ = nullptr;
fontId_ = GetBitmapFontIdMax(); fontId_ = UIFontBuilder::GetInstance()->GetBitmapFontIdMax();
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
......
...@@ -18,7 +18,9 @@ ...@@ -18,7 +18,9 @@
#include "font/ui_font_cache.h" #include "font/ui_font_cache.h"
#if ENABLE_VECTOR_FONT #if ENABLE_VECTOR_FONT
#include "font/ui_font_vector.h" #include "font/ui_font_vector.h"
#endif // ENABLE_VECTOR_FONT #else
#include "font/ui_font_bitmap.h"
#endif
#include "graphic_config.h" #include "graphic_config.h"
#if ENABLE_MULTI_FONT #if ENABLE_MULTI_FONT
#include "font/ui_multi_font_manager.h" #include "font/ui_multi_font_manager.h"
...@@ -37,6 +39,11 @@ UIFont* UIFont::GetInstance() ...@@ -37,6 +39,11 @@ UIFont* UIFont::GetInstance()
instance.defaultInstance_ = new UIFontVector(); instance.defaultInstance_ = new UIFontVector();
instance.instance_ = instance.defaultInstance_; instance.instance_ = instance.defaultInstance_;
} }
#else
if (instance.instance_ == nullptr) {
instance.defaultInstance_ = new UIFontBitmap();
instance.instance_ = instance.defaultInstance_;
}
#endif #endif
return &instance; return &instance;
} }
......
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "font/ui_font_bitmap.h"
#include "font/ui_font_adaptor.h"
#include "font/ui_font_builder.h"
#include "gfx_utils/file.h"
#include "graphic_config.h"
#if ENABLE_MULTI_FONT
#include "font/ui_multi_font_manager.h"
#endif
#if ENABLE_SHAPING
#include "font/ui_text_shaping.h"
#endif
namespace OHOS {
UIFontBitmap::UIFontBitmap() : dynamicFont_(), dynamicFontRamUsed_(0), dynamicFontFd_(-1)
{
SetBaseFontId(UIFontBuilder::GetInstance()->GetBitmapFontIdMax());
bitmapCache_ = nullptr;
bitmapRamUsed_ = FONT_BITMAP_CACHE_SIZE;
}
UIFontBitmap:: ~UIFontBitmap()
{
if (dynamicFontFd_ >= 0) {
close(dynamicFontFd_);
}
if (bitmapCache_ != nullptr) {
delete bitmapCache_;
bitmapCache_ = nullptr;
}
}
bool UIFontBitmap::IsVectorFont() const
{
return false;
}
uint8_t UIFontBitmap::GetShapingFontId(char* text, uint8_t& ttfId, uint32_t& script, uint8_t fontId, uint8_t size) const
{
#if ENABLE_MULTI_FONT
return UIMultiFontManager::GetInstance()->GetShapingFontId(text, fontId, ttfId, script);
#else
UITextLanguageFontParam* fontParam = UIFontBuilder::GetInstance()->GetTextLangFontsTable(fontId);
if (fontParam == nullptr) {
return 0;
}
ttfId = fontParam->ttfId;
return fontParam->shaping;
#endif
}
uint8_t UIFontBitmap::GetFontWeight(uint8_t fontId)
{
UITextLanguageFontParam* fontParam = UIFontBuilder::GetInstance()->GetTextLangFontsTable(fontId);
if (fontParam == nullptr) {
return 0;
}
return fontParam->fontWeight;
}
int8_t UIFontBitmap::SetFontPath(const char* dpath, const char* spath)
{
if (dpath == nullptr) {
return INVALID_RET_VALUE;
}
#ifdef _WIN32
dynamicFontFd_ = open(dpath, O_RDONLY | O_BINARY);
#else
dynamicFontFd_ = open(dpath, O_RDONLY);
#endif
if (dynamicFontFd_ < 0) {
return INVALID_RET_VALUE;
}
dynamicFont_.SetRamBuffer(GetRamAddr());
uint32_t start = 0;
int32_t ret = dynamicFont_.SetFile(dynamicFontFd_, start);
if (ret == INVALID_RET_VALUE) {
close(dynamicFontFd_);
dynamicFontFd_ = -1;
return ret;
}
dynamicFontRamUsed_ = dynamicFont_.GetRamUsedLen();
return RET_VALUE_OK;
}
int8_t UIFontBitmap::SetCurrentFontId(uint8_t fontId, uint8_t size)
{
int8_t ret = SetDynamicFontId(fontId);
if (ret == RET_VALUE_OK) {
SetBaseFontId(fontId);
}
return ret;
}
uint16_t UIFontBitmap::GetHeight()
{
int16_t ret = dynamicFont_.SetCurrentFontId(GetBaseFontId());
if (ret == INVALID_RET_VALUE) {
return ret;
}
return dynamicFont_.GetFontHeight();
}
uint8_t UIFontBitmap::GetFontId(const char* ttfName, uint8_t size) const
{
if (ttfName == nullptr) {
return UIFontBuilder::GetInstance()->GetBitmapFontIdMax();
}
uint8_t id;
for (id = 0; id < UIFontBuilder::GetInstance()->GetBitmapFontIdMax(); ++id) {
UITextLanguageFontParam* fontParam = UIFontBuilder::GetInstance()->GetTextLangFontsTable(id);
if (fontParam != nullptr) {
if ((fontParam->size == size) && (strncmp(fontParam->ttfName, ttfName, TTF_NAME_LEN_MAX) == 0)) {
break;
}
}
}
return id;
}
int16_t UIFontBitmap::GetWidth(uint32_t unicode, uint8_t fontId)
{
return GetWidthInFontId(unicode, fontId);
}
uint8_t* UIFontBitmap::GetBitmap(uint32_t unicode, GlyphNode& glyphNode, uint8_t fontId)
{
return SearchInFont(unicode, glyphNode, fontId);
}
int8_t UIFontBitmap::GetCurrentFontHeader(FontHeader& fontHeader)
{
int8_t ret = dynamicFont_.SetCurrentFontId(GetBaseFontId());
if (ret == INVALID_RET_VALUE) {
return ret;
}
const FontHeader* header = dynamicFont_.GetCurrentFontHeader();
if (header != nullptr) {
fontHeader = *header;
return RET_VALUE_OK;
}
return INVALID_RET_VALUE;
}
int8_t UIFontBitmap::GetGlyphNode(uint32_t unicode, GlyphNode& glyphNode)
{
int8_t ret = dynamicFont_.SetCurrentFontId(GetBaseFontId());
if (ret == INVALID_RET_VALUE) {
return ret;
}
const GlyphNode* node = dynamicFont_.GetGlyphNode(unicode);
if (node != nullptr) {
glyphNode = *node;
return RET_VALUE_OK;
}
return INVALID_RET_VALUE;
}
int8_t UIFontBitmap::GetFontVersion(char* dVersion, uint8_t dLen, char* sVersion, uint8_t sLen) const
{
return dynamicFont_.GetFontVersion(dVersion, dLen);
}
int8_t UIFontBitmap::SetCurrentLangId(uint8_t langId)
{
if (bitmapCache_ == nullptr) {
uint8_t* bitmapCacheAddr = reinterpret_cast<uint8_t*>(GetRamAddr() + dynamicFontRamUsed_);
bitmapCache_ = new UIFontCache(bitmapCacheAddr, bitmapRamUsed_);
}
uint32_t total = dynamicFontRamUsed_ + bitmapRamUsed_;
return (total <= GetRamLen()) ? RET_VALUE_OK : INVALID_RET_VALUE;
}
UITextLanguageFontParam* UIFontBitmap::GetFontInfo(uint8_t fontId) const
{
return UIFontBuilder::GetInstance()->GetTextLangFontsTable(fontId);
}
uint32_t UIFontBitmap::GetBitmapRamUsed()
{
return bitmapRamUsed_;
}
uint32_t UIFontBitmap::GetDynamicFontRamUsed()
{
return dynamicFontRamUsed_;
}
uint32_t UIFontBitmap::GetRamUsedLen(uint32_t textManagerRamUsed, uint32_t langFontRamUsed)
{
if (bitmapCache_ == nullptr) {
uint8_t* bitmapCacheAddr = reinterpret_cast<uint8_t*>(GetRamAddr() + dynamicFontRamUsed_ + textManagerRamUsed);
bitmapCache_ = new UIFontCache(bitmapCacheAddr, bitmapRamUsed_);
}
return dynamicFontRamUsed_ + textManagerRamUsed + bitmapRamUsed_ + langFontRamUsed;
}
int8_t UIFontBitmap::GetDynamicFotBitmap(uint32_t unicode, uint8_t* bitmap)
{
return dynamicFont_.GetBitmap(unicode, bitmap);
}
uint8_t* UIFontBitmap::GetCacheBitmap(uint8_t fontId, uint32_t unicode)
{
if (bitmapCache_ != nullptr) {
return bitmapCache_->GetBitmap(fontId, unicode);
}
return nullptr;
}
uint8_t* UIFontBitmap::GetCacheSpace(uint8_t fontId, uint32_t unicode, uint32_t size)
{
if (bitmapCache_ != nullptr) {
return bitmapCache_->GetSpace(fontId, unicode, size);
}
return nullptr;
}
void UIFontBitmap::PutCacheSpace(uint8_t* addr)
{
if (bitmapCache_ != nullptr) {
bitmapCache_->PutSpace(addr);
}
}
int8_t UIFontBitmap::SetDynamicFontId(uint8_t fontId)
{
return dynamicFont_.SetCurrentFontId(fontId);
}
int16_t UIFontBitmap::GetDynamicFontWidth(uint32_t unicode, uint8_t fontId)
{
int16_t ret = dynamicFont_.SetCurrentFontId(fontId);
if (ret == INVALID_RET_VALUE) {
return ret;
}
return dynamicFont_.GetFontWidth(unicode);
}
uint8_t* UIFontBitmap::SearchInFont(uint32_t unicode, GlyphNode& glyphNode, uint8_t fontId)
{
if (!UIFontAdaptor::IsSameTTFId(fontId, unicode)) {
return nullptr;
}
if (fontId != GetBaseFontId()) {
SetCurrentFontId(fontId);
}
if (bitmapCache_ == nullptr) {
return nullptr;
}
uint8_t* bitmap = bitmapCache_->GetBitmap(GetBaseFontId(), unicode);
if (bitmap != nullptr) {
GetGlyphNode(unicode, glyphNode);
return bitmap;
}
int8_t ret = GetGlyphNode(unicode, glyphNode);
if (ret != RET_VALUE_OK) {
return nullptr;
}
if (glyphNode.kernOff <= glyphNode.dataOff) {
return nullptr;
}
uint32_t bitmapSize = glyphNode.kernOff - glyphNode.dataOff;
bitmap = bitmapCache_->GetSpace(GetBaseFontId(), unicode, bitmapSize);
ret = dynamicFont_.GetBitmap(unicode, bitmap);
if (ret == RET_VALUE_OK) {
return bitmap;
}
bitmapCache_->PutSpace(bitmap);
return nullptr;
}
int16_t UIFontBitmap::GetWidthInFontId(uint32_t unicode, uint8_t fontId)
{
if (!UIFontAdaptor::IsSameTTFId(fontId, unicode)) {
return INVALID_RET_VALUE;
}
if (fontId != GetBaseFontId()) {
SetCurrentFontId(fontId);
}
return GetDynamicFontWidth(unicode, GetBaseFontId());
}
} // namespace
此差异已折叠。
...@@ -65,7 +65,7 @@ uint16_t UILineBreakEngine::GetNextBreakPos(UILineBreakProxy& record) ...@@ -65,7 +65,7 @@ uint16_t UILineBreakEngine::GetNextBreakPos(UILineBreakProxy& record)
category &= ~0x4000; category &= ~0x4000;
} }
state = row->fNextState[category]; state = row->fNextState[category];
row = reinterpret_cast<const RBBIStateTableRow*>( rbbStateTable->fTableData + rbbStateTable->fRowLen * state); row = reinterpret_cast<const RBBIStateTableRow*>(rbbStateTable->fTableData + rbbStateTable->fRowLen * state);
int16_t completedRule = row->fAccepting; int16_t completedRule = row->fAccepting;
if ((completedRule > 0) || (state == LINE_BREAK_STATE_STOP)) { if ((completedRule > 0) || (state == LINE_BREAK_STATE_STOP)) {
return index; return index;
......
...@@ -30,7 +30,7 @@ UIMultiFontManager::UIMultiFontManager() ...@@ -30,7 +30,7 @@ UIMultiFontManager::UIMultiFontManager()
bengaliTtfId_(0), topIndex_(0) bengaliTtfId_(0), topIndex_(0)
{ {
const UITextLanguageFontParam* fontParam = nullptr; const UITextLanguageFontParam* fontParam = nullptr;
uint8_t totalFontId = GetTotalFontId(); uint8_t totalFontId = UIFontBuilder::GetInstance()->GetTotalFontId();
for (uint8_t i = 0; i < totalFontId; i++) { for (uint8_t i = 0; i < totalFontId; i++) {
fontParam = UIFont::GetInstance()->GetFontInfo(i); fontParam = UIFont::GetInstance()->GetFontInfo(i);
if (fontParam == nullptr) { if (fontParam == nullptr) {
...@@ -127,7 +127,7 @@ UIMultiFontManager* UIMultiFontManager::GetInstance() ...@@ -127,7 +127,7 @@ UIMultiFontManager* UIMultiFontManager::GetInstance()
void UIMultiFontManager::ClearSearchFontList() void UIMultiFontManager::ClearSearchFontList()
{ {
uint8_t totalFontId = GetTotalFontId(); uint8_t totalFontId = UIFontBuilder::GetInstance()->GetTotalFontId();
for (uint8_t index = 0; index < totalFontId; index++) { for (uint8_t index = 0; index < totalFontId; index++) {
fontIdIndex_[index] = MAX_LIST_NUM; fontIdIndex_[index] = MAX_LIST_NUM;
} }
...@@ -142,7 +142,7 @@ void UIMultiFontManager::ClearSearchFontList() ...@@ -142,7 +142,7 @@ void UIMultiFontManager::ClearSearchFontList()
int8_t UIMultiFontManager::SetSearchFontList(uint8_t fontListId, uint8_t *fontIds, uint8_t size) int8_t UIMultiFontManager::SetSearchFontList(uint8_t fontListId, uint8_t *fontIds, uint8_t size)
{ {
if ((fontListId >= GetTotalFontId()) || (fontIds == nullptr) || (size == 0) || if ((fontListId >= UIFontBuilder::GetInstance()->GetTotalFontId()) || (fontIds == nullptr) || (size == 0) ||
(fontIdIndex_ == nullptr) || (topIndex_ >= MAX_LIST_NUM)) { (fontIdIndex_ == nullptr) || (topIndex_ >= MAX_LIST_NUM)) {
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
...@@ -152,7 +152,7 @@ int8_t UIMultiFontManager::SetSearchFontList(uint8_t fontListId, uint8_t *fontId ...@@ -152,7 +152,7 @@ int8_t UIMultiFontManager::SetSearchFontList(uint8_t fontListId, uint8_t *fontId
int8_t UIMultiFontManager::GetSearchFontList(uint8_t fontListId, uint8_t **fontIds) int8_t UIMultiFontManager::GetSearchFontList(uint8_t fontListId, uint8_t **fontIds)
{ {
if ((fontListId >= GetTotalFontId()) || (fontIds == nullptr) || if ((fontListId >= UIFontBuilder::GetInstance()->GetTotalFontId()) || (fontIds == nullptr) ||
(fontIdIndex_ == nullptr) || (fontIdIndex_[fontListId] >= MAX_LIST_NUM)) { (fontIdIndex_ == nullptr) || (fontIdIndex_[fontListId] >= MAX_LIST_NUM)) {
return INVALID_RET_VALUE; return INVALID_RET_VALUE;
} }
......
此差异已折叠。
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
#ifndef GRAPHIC_LITE_WINDOW_IMPL_H #ifndef GRAPHIC_LITE_WINDOW_IMPL_H
#define GRAPHIC_LITE_WINDOW_IMPL_H #define GRAPHIC_LITE_WINDOW_IMPL_H
#include "iwindow.h"
#include "components/root_view.h" #include "components/root_view.h"
#include "engines/gfx/gfx_engine_manager.h"
#include "iwindow.h"
#include "window/window.h" #include "window/window.h"
#include "dock/screen_device.h"
namespace OHOS { namespace OHOS {
class WindowImpl : public Window { class WindowImpl : public Window {
...@@ -49,9 +49,18 @@ public: ...@@ -49,9 +49,18 @@ public:
void AddToDisplay(); void AddToDisplay();
void RemoveFromDisplay(); void RemoveFromDisplay();
BufferInfo* GetBufferInfo();
private: private:
void UpdateHalDisplayBuffer(); void UpdateHalDisplayBuffer();
struct AllocationInfo {
uint8_t* virAddr;
uint8_t* phyAddr;
uint16_t width;
uint16_t height;
uint32_t stride;
ImagePixelFormat pixelFormat;
};
RootView* rootView_; RootView* rootView_;
IWindow* iWindow_; IWindow* iWindow_;
WindowConfig config_; WindowConfig config_;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册