Skip to content

Commit

Permalink
[poincare] Remove statically-allocated buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
boricj authored and EmilieNumworks committed Apr 8, 2020
1 parent 2768ac2 commit 2f61b82
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion poincare/include/poincare/parenthesis_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class ParenthesisLayoutNode : public BracketLayoutNode {
#endif

protected:
static KDColor s_parenthesisWorkingBuffer[k_parenthesisCurveHeight*k_parenthesisCurveWidth];
KDSize computeSize() override {
return KDSize(ParenthesisWidth(), HeightGivenChildHeight(childHeight()));
}
Expand Down
5 changes: 3 additions & 2 deletions poincare/src/left_parenthesis_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@ const uint8_t bottomLeftCurve[ParenthesisLayoutNode::k_parenthesisCurveHeight][P
};

void LeftParenthesisLayoutNode::RenderWithChildHeight(KDCoordinate childHeight, KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
KDColor parenthesisWorkingBuffer[k_parenthesisCurveHeight*k_parenthesisCurveWidth];
KDCoordinate parenthesisHeight = ParenthesisLayoutNode::HeightGivenChildHeight(childHeight);
KDRect frame(p.x()+ParenthesisLayoutNode::k_externWidthMargin,
p.y()+ParenthesisLayoutNode::k_externHeightMargin,
ParenthesisLayoutNode::k_parenthesisCurveWidth,
ParenthesisLayoutNode::k_parenthesisCurveHeight);

ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topLeftCurve, (KDColor *)(ParenthesisLayoutNode::s_parenthesisWorkingBuffer));
ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topLeftCurve, parenthesisWorkingBuffer);

frame = KDRect(p.x()+ParenthesisLayoutNode::k_externWidthMargin,
p.y() + parenthesisHeight - ParenthesisLayoutNode::k_parenthesisCurveHeight - ParenthesisLayoutNode::k_externHeightMargin,
ParenthesisLayoutNode::k_parenthesisCurveWidth,
ParenthesisLayoutNode::k_parenthesisCurveHeight);

ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomLeftCurve, (KDColor *)(ParenthesisLayoutNode::s_parenthesisWorkingBuffer));
ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomLeftCurve, parenthesisWorkingBuffer);

ctx->fillRect(KDRect(p.x()+ParenthesisLayoutNode::k_externWidthMargin,
p.y()+ParenthesisLayoutNode::k_parenthesisCurveHeight+ParenthesisLayoutNode::k_externHeightMargin,
Expand Down
2 changes: 0 additions & 2 deletions poincare/src/parenthesis_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Poincare {

KDColor ParenthesisLayoutNode::s_parenthesisWorkingBuffer[];

}
5 changes: 3 additions & 2 deletions poincare/src/right_parenthesis_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@ const uint8_t bottomRightCurve[ParenthesisLayoutNode::k_parenthesisCurveHeight][
};

void RightParenthesisLayoutNode::RenderWithChildHeight(KDCoordinate childHeight, KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
KDColor parenthesisWorkingBuffer[k_parenthesisCurveHeight*k_parenthesisCurveWidth];
KDCoordinate parenthesisHeight = ParenthesisLayoutNode::HeightGivenChildHeight(childHeight);
KDRect frame = KDRect(p.x() + ParenthesisLayoutNode::k_widthMargin + ParenthesisLayoutNode::k_lineThickness - ParenthesisLayoutNode::k_parenthesisCurveWidth,
p.y() + ParenthesisLayoutNode::k_externHeightMargin,
ParenthesisLayoutNode::k_parenthesisCurveWidth,
ParenthesisLayoutNode::k_parenthesisCurveHeight);

ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topRightCurve, (KDColor *)(ParenthesisLayoutNode::s_parenthesisWorkingBuffer));
ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topRightCurve, parenthesisWorkingBuffer);

frame = KDRect(p.x() + ParenthesisLayoutNode::k_widthMargin + ParenthesisLayoutNode::k_lineThickness - ParenthesisLayoutNode::k_parenthesisCurveWidth,
p.y() + parenthesisHeight - ParenthesisLayoutNode::k_parenthesisCurveHeight - ParenthesisLayoutNode::k_externHeightMargin,
ParenthesisLayoutNode::k_parenthesisCurveWidth,
ParenthesisLayoutNode::k_parenthesisCurveHeight);

ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomRightCurve, (KDColor *)(ParenthesisLayoutNode::s_parenthesisWorkingBuffer));
ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomRightCurve, parenthesisWorkingBuffer);

ctx->fillRect(KDRect(p.x()+ParenthesisLayoutNode::k_widthMargin,
p.y()+ParenthesisLayoutNode::k_parenthesisCurveHeight+2,
Expand Down
4 changes: 2 additions & 2 deletions poincare/src/trigonometry_cheat_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Expression TrigonometryCheatTable::simplify(const Expression e, ExpressionNode::
* For instance, when simplfy a Cosine, we always compute the value for an angle
* in the top right trigonometric quadrant. */
const TrigonometryCheatTable * TrigonometryCheatTable::Table() {
static Row sTableRows[] = {
static const Row sTableRows[] = {
Row(Row::Pair("-90", -90.0f),
Row::Pair("π*(-2)^(-1)", -1.5707963267948966f),
Row::Pair("-100", -100.0f),
Expand Down Expand Up @@ -306,7 +306,7 @@ const TrigonometryCheatTable * TrigonometryCheatTable::Table() {
Row::Pair("0",0.0f),
Row::Pair("0",0.0f))
};
static TrigonometryCheatTable sTable(sTableRows);
static const TrigonometryCheatTable sTable(sTableRows);
return &sTable;
}

Expand Down

0 comments on commit 2f61b82

Please sign in to comment.