mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher] Avoid holding a working buffer for all chevron view
Change-Id: Ib8c5f085b57dd0417215d7e8689833dfee138699
This commit is contained in:
@@ -9,13 +9,12 @@ public:
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void setHighlighted(bool highlight);
|
||||
KDSize minimalSizeForOptimalDisplay() override;
|
||||
private:
|
||||
/* k_chevronHeight and k_chevronWidth are the dimensions of the chevron. */
|
||||
constexpr static KDCoordinate k_chevronHeight = 16;
|
||||
constexpr static KDCoordinate k_chevronWidth = 8;
|
||||
private:
|
||||
constexpr static KDCoordinate k_chevronRightMargin = 20;
|
||||
bool m_highlighted;
|
||||
KDColor m_workingBuffer[k_chevronWidth*k_chevronHeight];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -49,6 +49,8 @@ void ChevronView::setHighlighted(bool highlight) {
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
KDColor s_workingBuffer[ChevronView::k_chevronWidth*ChevronView::k_chevronHeight];
|
||||
|
||||
void ChevronView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
/* Draw the chevron aligned on the right of the view and vertically centered.
|
||||
* The heightCenter is the coordinate of the vertical middle of the view. That
|
||||
@@ -58,9 +60,9 @@ void ChevronView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
KDCoordinate chevronHalfHeight = k_chevronHeight/2;
|
||||
KDRect frame(width - k_chevronRightMargin, heightCenter -chevronHalfHeight, k_chevronWidth, k_chevronHeight);
|
||||
if (m_highlighted) {
|
||||
ctx->fillRectWithPixels(frame, highlightedChevronPixel, (KDColor *)m_workingBuffer);
|
||||
ctx->fillRectWithPixels(frame, highlightedChevronPixel, (KDColor *)s_workingBuffer);
|
||||
} else {
|
||||
ctx->fillRectWithPixels(frame, chevronPixel, (KDColor *)m_workingBuffer);
|
||||
ctx->fillRectWithPixels(frame, chevronPixel, (KDColor *)s_workingBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user