mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 12:37:45 +01:00
Fix check for empty clipping array (#4421)
This commit is contained in:
parent
8cf26d6f3c
commit
310355a00b
@ -16,11 +16,11 @@ const Color COLOR_OFF(0, 0, 0, 0);
|
|||||||
const Color COLOR_ON(255, 255, 255, 255);
|
const Color COLOR_ON(255, 255, 255, 255);
|
||||||
|
|
||||||
void Rect::expand(int16_t horizontal, int16_t vertical) {
|
void Rect::expand(int16_t horizontal, int16_t vertical) {
|
||||||
if ((*this).is_set() && ((*this).w >= (-2 * horizontal)) && ((*this).h >= (-2 * vertical))) {
|
if (this->is_set() && (this->w >= (-2 * horizontal)) && (this->h >= (-2 * vertical))) {
|
||||||
(*this).x = (*this).x - horizontal;
|
this->x = this->x - horizontal;
|
||||||
(*this).y = (*this).y - vertical;
|
this->y = this->y - vertical;
|
||||||
(*this).w = (*this).w + (2 * horizontal);
|
this->w = this->w + (2 * horizontal);
|
||||||
(*this).h = (*this).h + (2 * vertical);
|
this->h = this->h + (2 * vertical);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,60 +400,48 @@ class DisplayBuffer {
|
|||||||
*/
|
*/
|
||||||
virtual DisplayType get_display_type() = 0;
|
virtual DisplayType get_display_type() = 0;
|
||||||
|
|
||||||
///
|
/** Set the clipping rectangle for further drawing
|
||||||
/// Set the clipping rectangle for further drawing
|
*
|
||||||
///
|
* @param[in] rect: Pointer to Rect for clipping (or NULL for entire screen)
|
||||||
/// \param[in] rect: Pointer to Rect for clipping (or NULL for entire screen)
|
*
|
||||||
///
|
* return true if success, false if error
|
||||||
/// \return true if success, false if error
|
*/
|
||||||
///
|
|
||||||
void start_clipping(Rect rect);
|
void start_clipping(Rect rect);
|
||||||
void start_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom) {
|
void start_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom) {
|
||||||
start_clipping(Rect(left, top, right - left, bottom - top));
|
start_clipping(Rect(left, top, right - left, bottom - top));
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
/** Add a rectangular region to the invalidation region
|
||||||
/// Add a rectangular region to the invalidation region
|
* - This is usually called when an element has been modified
|
||||||
/// - This is usually called when an element has been modified
|
*
|
||||||
///
|
* @param[in] rect: Rectangle to add to the invalidation region
|
||||||
/// \param[in] rect: Rectangle to add to the invalidation region
|
*/
|
||||||
///
|
|
||||||
/// \return none
|
|
||||||
///
|
|
||||||
void extend_clipping(Rect rect);
|
void extend_clipping(Rect rect);
|
||||||
void extend_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom) {
|
void extend_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom) {
|
||||||
this->extend_clipping(Rect(left, top, right - left, bottom - top));
|
this->extend_clipping(Rect(left, top, right - left, bottom - top));
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
/** substract a rectangular region to the invalidation region
|
||||||
/// substract a rectangular region to the invalidation region
|
* - This is usually called when an element has been modified
|
||||||
/// - This is usually called when an element has been modified
|
*
|
||||||
///
|
* @param[in] rect: Rectangle to add to the invalidation region
|
||||||
/// \param[in] rect: Rectangle to add to the invalidation region
|
*/
|
||||||
///
|
|
||||||
/// \return none
|
|
||||||
///
|
|
||||||
void shrink_clipping(Rect rect);
|
void shrink_clipping(Rect rect);
|
||||||
void shrink_clipping(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
|
void shrink_clipping(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
|
||||||
this->shrink_clipping(Rect(left, top, right - left, bottom - top));
|
this->shrink_clipping(Rect(left, top, right - left, bottom - top));
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
/** Reset the invalidation region
|
||||||
/// Reset the invalidation region
|
*/
|
||||||
///
|
|
||||||
/// \return none
|
|
||||||
///
|
|
||||||
void end_clipping();
|
void end_clipping();
|
||||||
|
|
||||||
///
|
/** Get the current the clipping rectangle
|
||||||
/// Get the current the clipping rectangle
|
*
|
||||||
///
|
* return rect for active clipping region
|
||||||
///
|
*/
|
||||||
/// \return rect for active clipping region
|
|
||||||
///
|
|
||||||
Rect get_clipping();
|
Rect get_clipping();
|
||||||
|
|
||||||
bool is_clipping() const { return this->clipping_rectangle_.empty(); }
|
bool is_clipping() const { return !this->clipping_rectangle_.empty(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void vprintf_(int x, int y, Font *font, Color color, TextAlign align, const char *format, va_list arg);
|
void vprintf_(int x, int y, Font *font, Color color, TextAlign align, const char *format, va_list arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user