mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Fix FullscreenPreview for SimpleRenderer
The SimpleRenderer outputs unpremultiplied RGB values when we render in a transparent background, we have to indicate that to Skia now that we're compositing os::Surfaces (SkiaSurfaces) directly in this FullscreenPreview command.
This commit is contained in:
parent
7b6187ada3
commit
da9f334214
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -32,6 +32,10 @@
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
|
||||
#if LAF_SKIA
|
||||
#include "os/skia/skia_surface.h"
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
@ -182,6 +186,19 @@ protected:
|
||||
if (m_render == nullptr) {
|
||||
m_render = os::instance()->makeRgbaSurface(m_sprite->width(),
|
||||
m_sprite->height());
|
||||
|
||||
#if LAF_SKIA
|
||||
// The SimpleRenderer renders unpremultiplied surfaces when
|
||||
// rendering on transparent background (this is the only place
|
||||
// where this happens).
|
||||
if (render.properties().outputsUnpremultiplied) {
|
||||
// We use a little tricky with Skia indicating that the alpha
|
||||
// is unpremultiplied
|
||||
((os::SkiaSurface*)m_render.get())
|
||||
->bitmap().setAlphaType(kUnpremul_SkAlphaType);
|
||||
}
|
||||
#endif
|
||||
|
||||
m_repaint = true;
|
||||
}
|
||||
|
||||
@ -210,7 +227,10 @@ protected:
|
||||
render.renderCheckeredBackground(
|
||||
g->getInternalSurface(), m_sprite,
|
||||
gfx::Clip(g->getInternalDeltaX(),
|
||||
g->getInternalDeltaY(), clientBounds()));
|
||||
g->getInternalDeltaY(),
|
||||
-m_pos.x, -m_pos.y,
|
||||
2*g->getInternalSurface()->width(),
|
||||
2*g->getInternalSurface()->height()));
|
||||
|
||||
// Invalidate the whole Graphics (as we've just modified its
|
||||
// internal os::Surface directly).
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2022 Igara Studio S.A.
|
||||
// Copyright (C) 2022-2023 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -38,6 +38,10 @@ namespace app {
|
||||
// composite the background already painted on the screen with
|
||||
// the sprite painted in the backbuffer.
|
||||
bool requiresRgbaBackbuffer = false;
|
||||
|
||||
// True if renderSprite() composite an unpremultiplied RGBA
|
||||
// surface when we draw on a transparent background.
|
||||
bool outputsUnpremultiplied = false;
|
||||
};
|
||||
|
||||
virtual ~Renderer() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2022 Igara Studio S.A.
|
||||
// Copyright (C) 2022-2023 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -17,6 +17,11 @@ namespace app {
|
||||
|
||||
using namespace doc;
|
||||
|
||||
SimpleRenderer::SimpleRenderer()
|
||||
{
|
||||
m_properties.outputsUnpremultiplied = true;
|
||||
}
|
||||
|
||||
void SimpleRenderer::setRefLayersVisiblity(const bool visible)
|
||||
{
|
||||
m_render.setRefLayersVisiblity(visible);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2022 Igara Studio S.A.
|
||||
// Copyright (C) 2022-2023 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -17,6 +17,8 @@ namespace app {
|
||||
// CPU-only.
|
||||
class SimpleRenderer : public Renderer {
|
||||
public:
|
||||
SimpleRenderer();
|
||||
|
||||
const Properties& properties() const override { return m_properties; }
|
||||
|
||||
void setRefLayersVisiblity(const bool visible) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user