mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Remove statically-allocated buffers
This commit is contained in:
committed by
M4x1m3
parent
c7f675a621
commit
739bd31d10
@@ -14,8 +14,6 @@ const uint8_t chevronMask[ChevronView::k_chevronHeight][ChevronView::k_chevronWi
|
||||
{0x0C, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
|
||||
};
|
||||
|
||||
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
|
||||
@@ -24,7 +22,8 @@ void ChevronView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
KDCoordinate heightCenter = bounds().height()/2;
|
||||
KDCoordinate chevronHalfHeight = k_chevronHeight/2;
|
||||
KDRect frame(width - k_chevronWidth, heightCenter -chevronHalfHeight, k_chevronWidth, k_chevronHeight);
|
||||
ctx->blendRectWithMask(frame, Palette::Control, (const uint8_t *)chevronMask, s_workingBuffer);
|
||||
KDColor workingBuffer[ChevronView::k_chevronWidth*ChevronView::k_chevronHeight];
|
||||
ctx->blendRectWithMask(frame, Palette::Control, (const uint8_t *)chevronMask, workingBuffer);
|
||||
}
|
||||
|
||||
KDSize ChevronView::minimalSizeForOptimalDisplay() const {
|
||||
|
||||
@@ -8,8 +8,6 @@ const uint8_t ellipsisMask[EllipsisView::k_ellipsisHeight][EllipsisView::k_ellip
|
||||
{0xFF, 0xD1, 0xA1, 0xC1, 0xFF, 0xFF, 0xFF, 0xD1, 0xA1, 0xC1, 0xFF, 0xFF, 0xFF, 0xD1, 0xA1, 0xC1, 0xFF},
|
||||
};
|
||||
|
||||
KDColor s_ellipsisWorkingBuffer[EllipsisView::k_ellipsisWidth*EllipsisView::k_ellipsisHeight];
|
||||
|
||||
void EllipsisView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
/* Draw the ellipsis vertically and horizontally centered in the view.
|
||||
* The heightCenter is the coordinate of the vertical middle of the view. That
|
||||
@@ -19,7 +17,8 @@ void EllipsisView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
KDCoordinate heightCenter = bounds().height()/2;
|
||||
KDCoordinate ellipsisHalfHeight = k_ellipsisHeight/2;
|
||||
KDRect frame(widthCenter - ellipsisHalfWidth, heightCenter - ellipsisHalfHeight, k_ellipsisWidth, k_ellipsisHeight);
|
||||
ctx->blendRectWithMask(frame, Palette::PrimaryText, (const uint8_t *)ellipsisMask, s_ellipsisWorkingBuffer);
|
||||
KDColor ellipsisWorkingBuffer[EllipsisView::k_ellipsisWidth*EllipsisView::k_ellipsisHeight];
|
||||
ctx->blendRectWithMask(frame, Palette::PrimaryText, (const uint8_t *)ellipsisMask, ellipsisWorkingBuffer);
|
||||
}
|
||||
|
||||
KDSize EllipsisView::minimalSizeForOptimalDisplay() const {
|
||||
|
||||
@@ -40,18 +40,17 @@ void GaugeView::setBackgroundColor(KDColor color) {
|
||||
}
|
||||
}
|
||||
|
||||
KDColor s_gaugeIndicatorWorkingBuffer[GaugeView::k_indicatorDiameter*GaugeView::k_indicatorDiameter];
|
||||
|
||||
void GaugeView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(bounds(), m_backgroundColor);
|
||||
/* Draw the gauge centered vertically on all the width available */
|
||||
KDCoordinate width = bounds().width()-k_indicatorDiameter;
|
||||
KDCoordinate height = bounds().height();
|
||||
KDColor gaugeIndicatorWorkingBuffer[GaugeView::k_indicatorDiameter*GaugeView::k_indicatorDiameter];
|
||||
|
||||
ctx->fillRect(KDRect(k_indicatorDiameter/2, (height-k_thickness)/2, width*m_level, k_thickness), Palette::ControlEnabled);
|
||||
ctx->fillRect(KDRect(k_indicatorDiameter/2+width*m_level, (height-k_thickness)/2, width*(1.0f-m_level), k_thickness), Palette::ControlDisabled);
|
||||
KDRect frame(width*m_level, (height-k_indicatorDiameter)/2, k_indicatorDiameter, k_indicatorDiameter);
|
||||
ctx->blendRectWithMask(frame, Palette::Control, (const uint8_t *)gaugeIndicatorMask, s_gaugeIndicatorWorkingBuffer);
|
||||
ctx->blendRectWithMask(frame, Palette::Control, (const uint8_t *)gaugeIndicatorMask, gaugeIndicatorWorkingBuffer);
|
||||
}
|
||||
|
||||
KDSize GaugeView::minimalSizeForOptimalDisplay() const {
|
||||
|
||||
@@ -77,14 +77,13 @@ void KeyView::setType(Type type) {
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
KDColor s_keyWorkingBuffer[KeyView::k_keySize*KeyView::k_keySize];
|
||||
|
||||
void KeyView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
/* Draw the key centered on the view. */
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate height = bounds().height();
|
||||
KDRect frame((width - k_keySize)/2, (height - k_keySize)/2, k_keySize, k_keySize);
|
||||
ctx->blendRectWithMask(frame, Palette::PrimaryText, mask(), s_keyWorkingBuffer);
|
||||
KDColor keyWorkingBuffer[KeyView::k_keySize*KeyView::k_keySize];
|
||||
ctx->blendRectWithMask(frame, Palette::PrimaryText, mask(), keyWorkingBuffer);
|
||||
}
|
||||
|
||||
KDSize KeyView::minimalSizeForOptimalDisplay() const {
|
||||
|
||||
@@ -46,8 +46,6 @@ void SwitchView::setState(bool state) {
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
KDColor s_switchWorkingBuffer[SwitchView::k_switchWidth*SwitchView::k_switchHeight];
|
||||
|
||||
void SwitchView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
/* Draw the switch aligned on the right of the view and vertically centered.
|
||||
* The heightCenter is the coordinate of the vertical middle of the view. That
|
||||
@@ -55,13 +53,14 @@ void SwitchView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate heightCenter = bounds().height()/2;
|
||||
KDCoordinate switchHalfHeight = k_switchHeight/2;
|
||||
KDColor switchWorkingBuffer[SwitchView::k_switchWidth*SwitchView::k_switchHeight];
|
||||
|
||||
KDColor mainColor = m_state ? Palette::Control : Palette::ControlDisabled;
|
||||
KDRect frame(width - k_switchWidth, heightCenter -switchHalfHeight, k_switchWidth, k_switchHeight);
|
||||
ctx->blendRectWithMask(frame, mainColor, (const uint8_t *)switchMask, s_switchWorkingBuffer);
|
||||
ctx->blendRectWithMask(frame, mainColor, (const uint8_t *)switchMask, switchWorkingBuffer);
|
||||
KDCoordinate onOffX = width - (m_state ? k_onOffSize : k_switchWidth);
|
||||
KDRect onOffFrame(onOffX, heightCenter -switchHalfHeight, k_onOffSize, k_onOffSize);
|
||||
ctx->blendRectWithMask(onOffFrame, Palette::ListCellBackground, (const uint8_t *)onOffMask, s_switchWorkingBuffer);
|
||||
ctx->blendRectWithMask(onOffFrame, Palette::ListCellBackground, (const uint8_t *)onOffMask, switchWorkingBuffer);
|
||||
}
|
||||
|
||||
KDSize SwitchView::minimalSizeForOptimalDisplay() const {
|
||||
|
||||
Reference in New Issue
Block a user