diff --git a/apps/shared/round_cursor_view.cpp b/apps/shared/round_cursor_view.cpp index 7722b85d3..f09544b88 100644 --- a/apps/shared/round_cursor_view.cpp +++ b/apps/shared/round_cursor_view.cpp @@ -6,8 +6,10 @@ static KDColor s_cursorWorkingBuffer[Dots::LargeDotDiameter*Dots::LargeDotDiamet void RoundCursorView::drawRect(KDContext * ctx, KDRect rect) const { KDRect r = bounds(); +#ifdef GRAPH_CURSOR_SPEEDUP ctx->getPixels(r, m_underneathPixelBuffer); m_underneathPixelBufferLoaded = true; +#endif ctx->blendRectWithMask(r, m_color, (const uint8_t *)Dots::LargeDotMask, s_cursorWorkingBuffer); } @@ -17,12 +19,14 @@ KDSize RoundCursorView::minimalSizeForOptimalDisplay() const { void RoundCursorView::setColor(KDColor color) { m_color = color; +#ifdef GRAPH_CURSOR_SPEEDUP eraseCursorIfPossible(); +#endif markRectAsDirty(bounds()); } void RoundCursorView::setCursorFrame(KDRect f, bool force) { -#if GRAPH_CURSOR_SPEEDUP +#ifdef GRAPH_CURSOR_SPEEDUP /* TODO This is quite dirty (we are out of the dirty tracking and we assume * the cursor is the upmost view) but it works well. */ if (m_frame == f && !force) { diff --git a/apps/shared/round_cursor_view.h b/apps/shared/round_cursor_view.h index 25539702a..001113406 100644 --- a/apps/shared/round_cursor_view.h +++ b/apps/shared/round_cursor_view.h @@ -6,11 +6,16 @@ namespace Shared { -#define GRAPH_CURSOR_SPEEDUP 1 +#define GRAPH_CURSOR_SPEEDUP class RoundCursorView : public CursorView { public: - RoundCursorView(KDColor color = KDColorBlack) : m_color(color), m_underneathPixelBufferLoaded(false) {} + RoundCursorView(KDColor color = KDColorBlack) : + m_color(color) +#ifdef GRAPH_CURSOR_SPEEDUP + , m_underneathPixelBufferLoaded(false) +#endif + {} void drawRect(KDContext * ctx, KDRect rect) const override; KDSize minimalSizeForOptimalDisplay() const override; void setColor(KDColor color); @@ -23,9 +28,11 @@ private: bool eraseCursorIfPossible(); #endif constexpr static int k_cursorSize = Dots::LargeDotDiameter; - mutable KDColor m_underneathPixelBuffer[k_cursorSize*k_cursorSize]; KDColor m_color; +#ifdef GRAPH_CURSOR_SPEEDUP + mutable KDColor m_underneathPixelBuffer[k_cursorSize*k_cursorSize]; mutable bool m_underneathPixelBufferLoaded; +#endif }; }