Fixes blur rendering with RTSurface on hidpi screen

Other fixes:
- Fixes splash image not rendered
- Cleans commented code
- Replaces deprecated librsvg functions
- Updates Makefile librsvg required minimum version
- Correctly uses RTSurface getWidth / getHeight functions
- Improves lwbutton aspect

Known issues:
- Blur rendering with RTPixbuf on hidpi screen
This commit is contained in:
Pandagrapher
2022-08-21 15:45:07 +02:00
parent 7ee6fd795b
commit 36222d14a2
7 changed files with 95 additions and 46 deletions

View File

@@ -90,7 +90,7 @@ int RTSurface::getWidth()
{
return
surface
? surface->get_width()
? (surface->get_width() / RTScalable::getScale())
: -1;
}
@@ -98,7 +98,7 @@ int RTSurface::getHeight()
{
return
surface
? surface->get_height()
? (surface->get_height() / RTScalable::getScale())
: -1;
}
@@ -152,8 +152,22 @@ RTPixbuf::RTPixbuf(const Glib::ustring &icon_name, const Gtk::IconSize iconSize)
const Cairo::RefPtr<Cairo::ImageSurface> surface = RTScalable::loadSurfaceFromIcon(icon_name, iconSize);
if (surface) {
// Downscale surface before creating pixbuf
const Cairo::RefPtr<Cairo::Surface> _surface = Cairo::Surface::create(surface,
Cairo::CONTENT_COLOR_ALPHA,
surface->get_width() / RTScalable::getScale(),
surface->get_height() / RTScalable::getScale());
const auto c = Cairo::Context::create(_surface);
c->scale(1. / static_cast<double>(RTScalable::getScale()), 1. / static_cast<double>(RTScalable::getScale()));
c->set_source(surface, 0., 0.);
c->paint();
// Create pixbuf from surface
pixbuf = Gdk::Pixbuf::create(surface, 0, 0, surface->get_width(), surface->get_height());
pixbuf = Gdk::Pixbuf::create(_surface,
0,
0,
surface->get_width() / RTScalable::getScale(),
surface->get_height() / RTScalable::getScale());
// Save private parameters
type = RTPixbuf::IconType;
@@ -177,8 +191,22 @@ RTPixbuf::RTPixbuf(const Glib::ustring &fname) :
const Cairo::RefPtr<Cairo::ImageSurface> surface = RTScalable::loadSurfaceFromPNG(fname);
if (surface) {
// Downscale surface before creating pixbuf
const Cairo::RefPtr<Cairo::Surface> _surface = Cairo::Surface::create(surface,
Cairo::CONTENT_COLOR_ALPHA,
surface->get_width() / RTScalable::getScale(),
surface->get_height() / RTScalable::getScale());
const auto c = Cairo::Context::create(_surface);
c->scale(1. / static_cast<double>(RTScalable::getScale()), 1. / static_cast<double>(RTScalable::getScale()));
c->set_source(surface, 0., 0.);
c->paint();
// Create pixbuf from surface
pixbuf = Gdk::Pixbuf::create(surface, 0, 0, surface->get_width(), surface->get_height());
pixbuf = Gdk::Pixbuf::create(_surface,
0,
0,
surface->get_width() / RTScalable::getScale(),
surface->get_height() / RTScalable::getScale());
// Save private parameter
type = RTPixbuf::PNGType;
@@ -192,8 +220,22 @@ RTPixbuf::RTPixbuf(const Glib::ustring &fname) :
const Cairo::RefPtr<Cairo::ImageSurface> surface = RTScalable::loadSurfaceFromSVG(fname);
if (surface) {
// Downscale surface before creating pixbuf
const Cairo::RefPtr<Cairo::Surface> _surface = Cairo::Surface::create(surface,
Cairo::CONTENT_COLOR_ALPHA,
surface->get_width() / RTScalable::getScale(),
surface->get_height() / RTScalable::getScale());
const auto c = Cairo::Context::create(_surface);
c->scale(1. / static_cast<double>(RTScalable::getScale()), 1. / static_cast<double>(RTScalable::getScale()));
c->set_source(surface, 0., 0.);
c->paint();
// Create pixbuf from surface
pixbuf = Gdk::Pixbuf::create(surface, 0, 0, surface->get_width(), surface->get_height());
pixbuf = Gdk::Pixbuf::create(_surface,
0,
0,
surface->get_width() / RTScalable::getScale(),
surface->get_height() / RTScalable::getScale());
// Save private parameter
type = RTPixbuf::SVGType;