mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Make kittest's predictable texture filtering honor TextureOptions::NEAREST (#8441)
This commit is contained in:
@@ -1,6 +1,41 @@
|
||||
use egui::{Color32, accesskit::Role};
|
||||
use egui_kittest::{Harness, kittest::Queryable as _};
|
||||
|
||||
/// Textures with [`egui::TextureOptions::NEAREST`] should render crisp,
|
||||
/// also with kittest's predictable texture filtering.
|
||||
#[test]
|
||||
fn test_nearest_texture_filtering() {
|
||||
let mut texture: Option<egui::TextureHandle> = None;
|
||||
let mut harness = Harness::builder()
|
||||
.with_size(egui::Vec2::new(80.0, 48.0))
|
||||
.build_ui(move |ui| {
|
||||
let texture = texture.get_or_insert_with(|| {
|
||||
let pixels = [
|
||||
Color32::BLACK,
|
||||
Color32::WHITE,
|
||||
Color32::BLACK,
|
||||
Color32::WHITE,
|
||||
Color32::WHITE,
|
||||
Color32::BLACK,
|
||||
Color32::WHITE,
|
||||
Color32::BLACK,
|
||||
];
|
||||
let image = egui::ColorImage::new([4, 2], pixels.to_vec());
|
||||
ui.ctx()
|
||||
.load_texture("checkerboard", image, egui::TextureOptions::NEAREST)
|
||||
});
|
||||
|
||||
let rect = egui::Rect::from_min_size(egui::pos2(8.0, 8.0), egui::vec2(64.0, 32.0));
|
||||
let uv = egui::Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0));
|
||||
ui.painter().add(
|
||||
egui::epaint::RectShape::filled(rect, 0, Color32::WHITE)
|
||||
.with_texture(texture.id(), uv),
|
||||
);
|
||||
});
|
||||
harness.run();
|
||||
harness.snapshot("nearest_texture_filtering");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_kerning() {
|
||||
let mut results = egui_kittest::SnapshotResults::new();
|
||||
|
||||
Reference in New Issue
Block a user