提交 6fa6f77b 编写于 作者: O openharmony_ci 提交者: Gitee

!512 渲染脏区域简单切分

Merge pull request !512 from pssea/master
...@@ -31,6 +31,7 @@ const constexpr uint8_t MAX_SPLIT_NUM = 32; // split at most 32 parts ...@@ -31,6 +31,7 @@ const constexpr uint8_t MAX_SPLIT_NUM = 32; // split at most 32 parts
const constexpr uint8_t VIEW_STACK_DEPTH = COMPONENT_NESTING_DEPTH * 2; const constexpr uint8_t VIEW_STACK_DEPTH = COMPONENT_NESTING_DEPTH * 2;
#else #else
const constexpr uint8_t VIEW_STACK_DEPTH = COMPONENT_NESTING_DEPTH; const constexpr uint8_t VIEW_STACK_DEPTH = COMPONENT_NESTING_DEPTH;
const constexpr uint8_t MAX_INVALIDATE_SIZE = 24;
#endif #endif
static Rect g_maskStack[COMPONENT_NESTING_DEPTH]; static Rect g_maskStack[COMPONENT_NESTING_DEPTH];
static UIView* g_viewStack[VIEW_STACK_DEPTH]; static UIView* g_viewStack[VIEW_STACK_DEPTH];
...@@ -353,6 +354,7 @@ void RootView::OptimizeInvalidMap() ...@@ -353,6 +354,7 @@ void RootView::OptimizeInvalidMap()
} }
curview = g_viewStack[--stackCount]; curview = g_viewStack[--stackCount];
Rect rect;
if (!curview->IsVisible() || !rect.Intersect(curview->GetRect(), GetScreenRect())) { if (!curview->IsVisible() || !rect.Intersect(curview->GetRect(), GetScreenRect())) {
curview = nullptr; curview = nullptr;
continue; continue;
...@@ -396,6 +398,52 @@ void RootView::DrawInvalidMap(const Rect& buffRect) ...@@ -396,6 +398,52 @@ void RootView::DrawInvalidMap(const Rect& buffRect)
} }
} }
} }
#else
void RootView::OptimizeAddRect(Rect& rect)
{
Rect joinRect;
for (ListNode<Rect>* iter = invalidateRects_.Begin(); iter != invalidateRects_.End(); iter = iter->next_) {
if (iter->data_.IsContains(rect)) {
return;
}
if (iter->data_.IsIntersect(rect)) {
joinRect.Join(iter->data_, rect);
if (joinRect.GetSize() < iter->data_.GetSize() + rect.GetSize()) {
iter->data_ = joinRect;
return;
}
}
}
if (invalidateRects_.Size() < MAX_INVALIDATE_SIZE) {
invalidateRects_.PushBack(rect);
} else {
invalidateRects_.Clear();
invalidateRects_.PushBack(GetScreenRect());
}
}
void RootView::OptimizeInvalidateRects()
{
Rect joinRect;
for (ListNode<Rect>* iter1 = invalidateRects_.Begin(); iter1 != invalidateRects_.End(); iter1 = iter1->next_) {
for (ListNode<Rect>* iter2 = invalidateRects_.Begin(); iter2 != invalidateRects_.End(); iter2 = iter2->next_) {
if (iter1 == iter2) {
continue;
}
if (iter2->data_.IsIntersect(iter1->data_)) {
joinRect.Join(iter1->data_, iter2->data_);
if (joinRect.GetSize() < (iter1->data_.GetSize() + iter2->data_.GetSize())) {
iter2->data_ = joinRect;
iter1 = invalidateRects_.Remove(iter1)->prev_;
break;
}
}
}
}
}
#endif #endif
void RootView::AddInvalidateRect(Rect& rect, UIView* view) void RootView::AddInvalidateRect(Rect& rect, UIView* view)
...@@ -410,12 +458,7 @@ void RootView::AddInvalidateRect(Rect& rect, UIView* view) ...@@ -410,12 +458,7 @@ void RootView::AddInvalidateRect(Rect& rect, UIView* view)
invalidRects[0].Join(invalidRects[0], commonRect); invalidRects[0].Join(invalidRects[0], commonRect);
} }
#else #else
if (!renderFlag_) { OptimizeAddRect(commonRect);
invalidRect_ = commonRect;
renderFlag_ = true;
} else {
invalidRect_.Join(invalidRect_, commonRect);
}
#endif #endif
} }
} }
...@@ -440,7 +483,7 @@ void RootView::Measure() ...@@ -440,7 +483,7 @@ void RootView::Measure()
MeasureView(childrenHead_); MeasureView(childrenHead_);
} }
#else #else
if (renderFlag_) { if (invalidateRects_.Size() > 0) {
MeasureView(childrenHead_); MeasureView(childrenHead_);
} }
#endif #endif
...@@ -473,10 +516,9 @@ void RootView::Render() ...@@ -473,10 +516,9 @@ void RootView::Render()
#if defined __linux__ || defined __LITEOS__ || defined __APPLE__ #if defined __linux__ || defined __LITEOS__ || defined __APPLE__
pthread_mutex_lock(&lock_); pthread_mutex_lock(&lock_);
#endif #endif
Rect invalidRectTmp = invalidRect_; #if !LOCAL_RENDER
invalidRect_ = {0, 0, 0, 0}; OptimizeInvalidateRects();
bool renderFlagTmp = renderFlag_; #endif
renderFlag_ = false;
#if defined __linux__ || defined __LITEOS__ || defined __APPLE__ #if defined __linux__ || defined __LITEOS__ || defined __APPLE__
pthread_mutex_unlock(&lock_); pthread_mutex_unlock(&lock_);
#endif #endif
...@@ -486,8 +528,11 @@ void RootView::Render() ...@@ -486,8 +528,11 @@ void RootView::Render()
RenderManager::RenderRect(GetRect(), this); RenderManager::RenderRect(GetRect(), this);
invalidateMap_.clear(); invalidateMap_.clear();
#else #else
if (renderFlagTmp) { if ( invalidateRects_.Size() > 0) {
RenderManager::RenderRect(invalidRectTmp, this); for (ListNode<Rect>* iter = invalidateRects_.Begin(); iter != invalidateRects_.End(); iter = iter->next_) {
RenderManager::RenderRect(iter->data_, this);
}
invalidateRects_.Clear();
#endif #endif
#if ENABLE_WINDOW #if ENABLE_WINDOW
......
...@@ -324,9 +324,11 @@ private: ...@@ -324,9 +324,11 @@ private:
std::map<UIView*, Graphic::Vector<Rect>> invalidateMap_; std::map<UIView*, Graphic::Vector<Rect>> invalidateMap_;
#else #else
bool renderFlag_ = false; void OptimizeAddRect(Rect& rect);
Rect invalidRect_; void OptimizeInvalidateRects();
List<Rect> invalidateRects_;
#endif #endif
OnKeyActListener* onKeyActListener_ {nullptr}; OnKeyActListener* onKeyActListener_ {nullptr};
OnVirtualDeviceEventListener* onVirtualEventListener_ {nullptr}; OnVirtualDeviceEventListener* onVirtualEventListener_ {nullptr};
#if defined __linux__ || defined __LITEOS__ || defined __APPLE__ #if defined __linux__ || defined __LITEOS__ || defined __APPLE__
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册