Fix mipmaps options when downsampling (fix #4317)

This commit is contained in:
David Capello 2024-06-19 20:51:02 -03:00
parent 649f444f05
commit 3d50a85d14
4 changed files with 11 additions and 16 deletions

2
laf

@ -1 +1 @@
Subproject commit 8059af40be3b96a470fdd2f5a3631ad219d522aa Subproject commit 5f9189c337bfc34bd5da4797734f53598cff3dc4

View File

@ -754,8 +754,11 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
} }
if (rendered && rendered->nativeHandle()) { if (rendered && rendered->nativeHandle()) {
os::Paint p;
if (newEngine) { if (newEngine) {
os::Sampling sampling; os::Sampling sampling;
p.srcEdges(os::Paint::SrcEdges::Fast); // Enable mipmaps if possible
if (m_proj.scaleX() < 1.0) { if (m_proj.scaleX() < 1.0) {
switch (pref.editor.downsampling()) { switch (pref.editor.downsampling()) {
case gen::Downsampling::NEAREST: case gen::Downsampling::NEAREST:
@ -775,7 +778,6 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
} }
} }
os::Paint p;
if (renderProperties.requiresRgbaBackbuffer) if (renderProperties.requiresRgbaBackbuffer)
p.blendMode(os::BlendMode::SrcOver); p.blendMode(os::BlendMode::SrcOver);
else else
@ -788,7 +790,11 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
&p); &p);
} }
else { else {
g->blit(rendered.get(), 0, 0, dest.x, dest.y, dest.w, dest.h); g->drawSurface(rendered.get(),
gfx::Rect(0, 0, dest.w, dest.h),
gfx::Rect(dest.x, dest.y, dest.w, dest.h),
os::Sampling(os::Sampling::Filter::Nearest),
&p);
} }
} }

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2019-2022 Igara Studio S.A. // Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
@ -329,15 +329,6 @@ void Graphics::drawSurfaceNine(os::Surface* surface,
m_surface->drawSurfaceNine(surface, src, center, displacedDst, drawCenter, paint); m_surface->drawSurfaceNine(surface, src, center, displacedDst, drawCenter, paint);
} }
void Graphics::blit(os::Surface* srcSurface, int srcx, int srcy, int dstx, int dsty, int w, int h)
{
dirty(gfx::Rect(m_dx+dstx, m_dy+dsty, w, h));
os::SurfaceLock lockSrc(srcSurface);
os::SurfaceLock lockDst(m_surface.get());
srcSurface->blitTo(m_surface.get(), srcx, srcy, m_dx+dstx, m_dy+dsty, w, h);
}
void Graphics::setFont(const os::FontRef& font) void Graphics::setFont(const os::FontRef& font)
{ {
m_font = font; m_font = font;

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2019-2022 Igara Studio S.A. // Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
@ -96,8 +96,6 @@ namespace ui {
const bool drawCenter, const bool drawCenter,
const Paint* paint = nullptr); const Paint* paint = nullptr);
void blit(os::Surface* src, int srcx, int srcy, int dstx, int dsty, int w, int h);
// ====================================================================== // ======================================================================
// FONT & TEXT // FONT & TEXT
// ====================================================================== // ======================================================================