From 8d3f86c77ff46405fefb578a868beaafa578ff93 Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Fri, 31 Jan 2020 17:18:58 +0100 Subject: [PATCH] [kandinsky/context] getPixel only if in the clipping rect Fixes the redrawing of RoundCursorView when its frame overlaps the clipping rect. --- kandinsky/include/kandinsky/context.h | 2 +- kandinsky/src/context_pixel.cpp | 9 +++------ python/port/mod/kandinsky/modkandinsky.cpp | 3 ++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/kandinsky/include/kandinsky/context.h b/kandinsky/include/kandinsky/context.h index 27bd7bbc0..fbcc6bf4f 100644 --- a/kandinsky/include/kandinsky/context.h +++ b/kandinsky/include/kandinsky/context.h @@ -12,7 +12,7 @@ public: // Pixel manipulation void setPixel(KDPoint p, KDColor c); - KDColor getPixel(KDPoint p); + void getPixel(KDPoint p, KDColor * pixel); void getPixels(KDRect r, KDColor * pixels); // Text diff --git a/kandinsky/src/context_pixel.cpp b/kandinsky/src/context_pixel.cpp index dceb85ff9..ea577d682 100644 --- a/kandinsky/src/context_pixel.cpp +++ b/kandinsky/src/context_pixel.cpp @@ -7,14 +7,11 @@ void KDContext::setPixel(KDPoint p, KDColor c) { } } -KDColor KDContext::getPixel(KDPoint p) { +void KDContext::getPixel(KDPoint p, KDColor * pixel) { KDPoint absolutePoint = p.translatedBy(m_origin); if (m_clippingRect.contains(absolutePoint)) { - KDColor result = KDColorBlack; - pullRect(KDRect(absolutePoint, 1, 1), &result); - return result; + pullRect(KDRect(absolutePoint, 1, 1), pixel); } - return KDColorBlack; } void KDContext::getPixels(KDRect r, KDColor * pixels) { @@ -28,7 +25,7 @@ void KDContext::getPixels(KDRect r, KDColor * pixels) { KDCoordinate xMax = r.x()+r.width(); for (int y = r.y(); y < yMax; y++) { for (int x = r.x(); x < xMax; x++) { - pixels[i++] = getPixel(KDPoint(x, y)); + getPixel(KDPoint(x, y), pixels + (i++)); } } } diff --git a/python/port/mod/kandinsky/modkandinsky.cpp b/python/port/mod/kandinsky/modkandinsky.cpp index dafb14114..c9579236b 100644 --- a/python/port/mod/kandinsky/modkandinsky.cpp +++ b/python/port/mod/kandinsky/modkandinsky.cpp @@ -51,7 +51,8 @@ mp_obj_t modkandinsky_color(mp_obj_t red, mp_obj_t green, mp_obj_t blue) { mp_obj_t modkandinsky_get_pixel(mp_obj_t x, mp_obj_t y) { KDPoint point(mp_obj_get_int(x), mp_obj_get_int(y)); - KDColor c = KDIonContext::sharedContext()->getPixel(point); + KDColor c; + KDIonContext::sharedContext()->getPixel(point, &c); return TupleForRGB(c.red(), c.green(), c.blue()); }