Removed surface_restorer class
This was only used in the GUI1 widget base class and isn't something we'll need with accelerated rendering.
This commit is contained in:
parent
3be39a98fe
commit
c7367344b1
4 changed files with 2 additions and 98 deletions
|
@ -37,67 +37,6 @@ void surface::free_surface()
|
|||
}
|
||||
}
|
||||
|
||||
surface_restorer::surface_restorer()
|
||||
: target_(nullptr)
|
||||
, rect_(sdl::empty_rect)
|
||||
, surface_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
surface_restorer::surface_restorer(CVideo* target, const SDL_Rect& rect)
|
||||
: target_(target)
|
||||
, rect_(rect)
|
||||
, surface_(nullptr)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
surface_restorer::~surface_restorer()
|
||||
{
|
||||
restore();
|
||||
}
|
||||
|
||||
void surface_restorer::restore(const SDL_Rect& dst) const
|
||||
{
|
||||
if(surface_.null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_Rect dst2 = sdl::intersect_rects(dst, rect_);
|
||||
if(dst2.w == 0 || dst2.h == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_Rect src = dst2;
|
||||
src.x -= rect_.x;
|
||||
src.y -= rect_.y;
|
||||
sdl_blit(surface_, &src, target_->getSurface(), &dst2);
|
||||
}
|
||||
|
||||
void surface_restorer::restore() const
|
||||
{
|
||||
if(surface_.null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_Rect dst = rect_;
|
||||
sdl_blit(surface_, nullptr, target_->getSurface(), &dst);
|
||||
}
|
||||
|
||||
void surface_restorer::update()
|
||||
{
|
||||
if(rect_.w <= 0 || rect_.h <= 0) {
|
||||
surface_.assign(nullptr);
|
||||
} else {
|
||||
surface_.assign(::get_surface_portion(target_->getSurface(),rect_));
|
||||
}
|
||||
}
|
||||
|
||||
void surface_restorer::cancel()
|
||||
{
|
||||
surface_.assign(nullptr);
|
||||
}
|
||||
|
||||
bool operator<(const surface& a, const surface& b)
|
||||
{
|
||||
return a.get() < b.get();
|
||||
|
|
|
@ -100,25 +100,6 @@ private:
|
|||
|
||||
bool operator<(const surface& a, const surface& b);
|
||||
|
||||
struct surface_restorer
|
||||
{
|
||||
surface_restorer();
|
||||
surface_restorer(class CVideo* target, const SDL_Rect& rect);
|
||||
~surface_restorer();
|
||||
|
||||
void restore() const;
|
||||
void restore(const SDL_Rect& dst) const;
|
||||
void update();
|
||||
void cancel();
|
||||
|
||||
const SDL_Rect& area() const { return rect_; }
|
||||
|
||||
private:
|
||||
class CVideo* target_;
|
||||
SDL_Rect rect_;
|
||||
surface surface_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper class for pinning SDL surfaces into memory.
|
||||
* @note This class should be used only with neutral surfaces, so that
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace gui {
|
|||
bool widget::mouse_lock_ = false;
|
||||
|
||||
widget::widget(const widget &o)
|
||||
: events::sdl_handler(), focus_(o.focus_), video_(o.video_), restorer_(o.restorer_), rect_(o.rect_),
|
||||
: events::sdl_handler(), focus_(o.focus_), video_(o.video_), rect_(o.rect_),
|
||||
needs_restore_(o.needs_restore_), state_(o.state_), hidden_override_(o.hidden_override_),
|
||||
enabled_(o.enabled_), clip_(o.clip_), clip_rect_(o.clip_rect_), volatile_(o.volatile_),
|
||||
help_text_(o.help_text_), tooltip_text_(o.tooltip_text_), help_string_(o.help_string_), id_(o.id_), mouse_lock_local_(o.mouse_lock_local_)
|
||||
|
@ -74,10 +74,6 @@ bool widget::mouse_locked() const
|
|||
|
||||
void widget::bg_cancel()
|
||||
{
|
||||
for(std::vector< surface_restorer >::iterator i = restorer_.begin(),
|
||||
i_end = restorer_.end(); i != i_end; ++i)
|
||||
i->cancel();
|
||||
restorer_.clear();
|
||||
}
|
||||
|
||||
void widget::set_location(const SDL_Rect& rect)
|
||||
|
@ -104,9 +100,8 @@ const SDL_Rect* widget::clip_rect() const
|
|||
return clip_ ? &clip_rect_ : nullptr;
|
||||
}
|
||||
|
||||
void widget::bg_register(const SDL_Rect& rect)
|
||||
void widget::bg_register(const SDL_Rect& /*rect*/)
|
||||
{
|
||||
restorer_.emplace_back(&video(), rect);
|
||||
}
|
||||
|
||||
void widget::set_location(int x, int y)
|
||||
|
@ -241,9 +236,6 @@ void widget::set_id(const std::string& id)
|
|||
|
||||
void widget::bg_update()
|
||||
{
|
||||
for(std::vector< surface_restorer >::iterator i = restorer_.begin(),
|
||||
i_end = restorer_.end(); i != i_end; ++i)
|
||||
i->update();
|
||||
}
|
||||
|
||||
void widget::bg_restore() const
|
||||
|
@ -251,9 +243,6 @@ void widget::bg_restore() const
|
|||
clip_rect_setter clipper(video().getSurface(), &clip_rect_, clip_);
|
||||
|
||||
if (needs_restore_) {
|
||||
for(std::vector< surface_restorer >::const_iterator i = restorer_.begin(),
|
||||
i_end = restorer_.end(); i != i_end; ++i)
|
||||
i->restore();
|
||||
needs_restore_ = false;
|
||||
}
|
||||
}
|
||||
|
@ -261,10 +250,6 @@ void widget::bg_restore() const
|
|||
void widget::bg_restore(const SDL_Rect& rect) const
|
||||
{
|
||||
clip_rect_setter clipper(video().getSurface(), &clip_rect_, clip_);
|
||||
|
||||
for(std::vector< surface_restorer >::const_iterator i = restorer_.begin(),
|
||||
i_end = restorer_.end(); i != i_end; ++i)
|
||||
i->restore(rect);
|
||||
}
|
||||
|
||||
void widget::set_volatile(bool val)
|
||||
|
|
|
@ -107,7 +107,6 @@ private:
|
|||
void hide_override(bool value = true);
|
||||
|
||||
CVideo* video_;
|
||||
std::vector< surface_restorer > restorer_;
|
||||
SDL_Rect rect_;
|
||||
mutable bool needs_restore_; // Have we drawn ourselves, so that if moved, we need to restore the background?
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue