You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #109358 from zenorbi/styleboxflat-antialiasing-adjust-for-oversampling
Adjust StyleBoxFlat antialiasing to account for Viewport oversampling
This commit is contained in:
@@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "style_box_flat.h"
|
#include "style_box_flat.h"
|
||||||
|
|
||||||
#include "scene/main/scene_tree.h"
|
#include "scene/main/canvas_item.h"
|
||||||
#include "scene/main/window.h"
|
#include "scene/main/viewport.h"
|
||||||
#include "servers/rendering/rendering_server.h"
|
#include "servers/rendering/rendering_server.h"
|
||||||
|
|
||||||
float StyleBoxFlat::get_style_margin(Side p_side) const {
|
float StyleBoxFlat::get_style_margin(Side p_side) const {
|
||||||
@@ -497,17 +497,18 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
|
|||||||
real_t aa_size_scaled = 1.0f;
|
real_t aa_size_scaled = 1.0f;
|
||||||
if (aa_on) {
|
if (aa_on) {
|
||||||
real_t scale_factor = 1.0f;
|
real_t scale_factor = 1.0f;
|
||||||
const SceneTree *tree = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
|
CanvasItem *ci = CanvasItem::get_current_item_drawn();
|
||||||
if (tree) {
|
if (ci) {
|
||||||
const Window *window = tree->get_root();
|
Viewport *vp = ci->get_viewport();
|
||||||
const Vector2 stretch_scale = window->get_stretch_transform().get_scale();
|
if (vp) {
|
||||||
scale_factor = MIN(stretch_scale.x, stretch_scale.y);
|
scale_factor = vp->get_oversampling();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust AA feather size to account for the 2D scale factor, so that
|
// Adjust AA feather size to account for the 2D scale factor, so that
|
||||||
// antialiasing doesn't become blurry at viewport resolutions higher
|
// antialiasing doesn't become blurry at viewport resolutions higher
|
||||||
// than the default when using the `canvas_items` stretch mode
|
// than the default when using the `canvas_items` stretch mode
|
||||||
// (or when using `content_scale_factor` values different than `1.0`).
|
// (or when using `oversampling` values different than `1.0`).
|
||||||
aa_size_scaled = aa_size / scale_factor;
|
aa_size_scaled = aa_size / scale_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user