mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-18 12:04:03 -04:00
1. Implement partial refresh. 2. Implement refresh canceling mechanism. 3. Refactor some parts of the gui and display code. ad 1. - Detect parts of the screen changed since last update and merge them into bigger regions. These regions defines parts of the context sent to the display. - Refresh the region covering all of the parts since this is the most time consuming part and the size of the refreshed region doesn't change the time much. - Refresh the whole screen if deep refresh is requested and previously fast refresh was used. This is needed to prevent unwanted artifacts in some cases. ad 2. - Separate display update and refresh logic. - Divide image display message handling into two handlers, one updating and other one refreshing the screen. - Add cancel refresh message and use it to cancel refresh during update. - Store sum of refresh regions gathered during updates to refresh them all at once at the end.
54 lines
1.8 KiB
C++
54 lines
1.8 KiB
C++
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include "Axes.hpp"
|
|
#include "gui/Common.hpp"
|
|
#include <cstdint>
|
|
#include <limits>
|
|
#include <string>
|
|
|
|
namespace gui
|
|
{
|
|
|
|
/// defines both: size & position
|
|
/// size is always in: { zero_size < max_size }
|
|
/// position is always in: { min_position < zero_position < max_position }
|
|
class BoundingBox
|
|
{
|
|
public:
|
|
static constexpr Length zero_size = 0;
|
|
static constexpr Length max_size = std::numeric_limits<Length>().max();
|
|
static constexpr Length min_size = std::numeric_limits<Length>().min();
|
|
|
|
static constexpr Position zero_position = 0;
|
|
static constexpr Position max_position = std::numeric_limits<Position>().max();
|
|
static constexpr Position min_position = std::numeric_limits<Position>().min();
|
|
|
|
struct
|
|
{
|
|
Position x = zero_position, y = zero_position;
|
|
Length w = zero_size, h = zero_size;
|
|
};
|
|
BoundingBox() = default;
|
|
BoundingBox(Position x, Position y, Length w, Length h);
|
|
|
|
static bool intersect(const BoundingBox &box1, const BoundingBox &box2, BoundingBox &result);
|
|
|
|
/// set x,y,w,h to zero
|
|
void clear();
|
|
/// get size in axis - in x get width in y get height
|
|
Length size(gui::Axis axis) const;
|
|
/// get position in axis - in x get x, in y get y
|
|
Position pos(gui::Axis axis) const;
|
|
std::string str() const;
|
|
/// assign width and/or height of bigger bounding box
|
|
void expandSize(const BoundingBox &box);
|
|
|
|
bool operator==(const BoundingBox &box) const;
|
|
bool operator!=(const BoundingBox &box) const;
|
|
};
|
|
|
|
} /* namespace gui */
|