Skip to content

Commit

Permalink
Fix mipmaps options when downsampling (fix aseprite#4317)
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Jun 19, 2024
1 parent 649f444 commit 3d50a85
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion laf
10 changes: 8 additions & 2 deletions src/app/ui/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,11 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
}

if (rendered && rendered->nativeHandle()) {
os::Paint p;
if (newEngine) {
os::Sampling sampling;
p.srcEdges(os::Paint::SrcEdges::Fast); // Enable mipmaps if possible

if (m_proj.scaleX() < 1.0) {
switch (pref.editor.downsampling()) {
case gen::Downsampling::NEAREST:
Expand All @@ -775,7 +778,6 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
}
}

os::Paint p;
if (renderProperties.requiresRgbaBackbuffer)
p.blendMode(os::BlendMode::SrcOver);
else
Expand All @@ -788,7 +790,11 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
&p);
}
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);
}
}

Expand Down
11 changes: 1 addition & 10 deletions src/ui/graphics.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 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
//
// This file is released under the terms of the MIT license.
Expand Down Expand Up @@ -329,15 +329,6 @@ void Graphics::drawSurfaceNine(os::Surface* surface,
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)
{
m_font = font;
Expand Down
4 changes: 1 addition & 3 deletions src/ui/graphics.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 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
//
// This file is released under the terms of the MIT license.
Expand Down Expand Up @@ -96,8 +96,6 @@ namespace ui {
const bool drawCenter,
const Paint* paint = nullptr);

void blit(os::Surface* src, int srcx, int srcy, int dstx, int dsty, int w, int h);

// ======================================================================
// FONT & TEXT
// ======================================================================
Expand Down

0 comments on commit 3d50a85

Please sign in to comment.