mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 12:44:53 +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
|
// Aseprite
|
||||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -32,6 +32,10 @@
|
|||||||
#include "os/surface.h"
|
#include "os/surface.h"
|
||||||
#include "os/system.h"
|
#include "os/system.h"
|
||||||
|
|
||||||
|
#if LAF_SKIA
|
||||||
|
#include "os/skia/skia_surface.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@ -182,6 +186,19 @@ protected:
|
|||||||
if (m_render == nullptr) {
|
if (m_render == nullptr) {
|
||||||
m_render = os::instance()->makeRgbaSurface(m_sprite->width(),
|
m_render = os::instance()->makeRgbaSurface(m_sprite->width(),
|
||||||
m_sprite->height());
|
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;
|
m_repaint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +227,10 @@ protected:
|
|||||||
render.renderCheckeredBackground(
|
render.renderCheckeredBackground(
|
||||||
g->getInternalSurface(), m_sprite,
|
g->getInternalSurface(), m_sprite,
|
||||||
gfx::Clip(g->getInternalDeltaX(),
|
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
|
// Invalidate the whole Graphics (as we've just modified its
|
||||||
// internal os::Surface directly).
|
// internal os::Surface directly).
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2022 Igara Studio S.A.
|
// Copyright (C) 2022-2023 Igara Studio S.A.
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -38,6 +38,10 @@ namespace app {
|
|||||||
// composite the background already painted on the screen with
|
// composite the background already painted on the screen with
|
||||||
// the sprite painted in the backbuffer.
|
// the sprite painted in the backbuffer.
|
||||||
bool requiresRgbaBackbuffer = false;
|
bool requiresRgbaBackbuffer = false;
|
||||||
|
|
||||||
|
// True if renderSprite() composite an unpremultiplied RGBA
|
||||||
|
// surface when we draw on a transparent background.
|
||||||
|
bool outputsUnpremultiplied = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~Renderer() { }
|
virtual ~Renderer() { }
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2022 Igara Studio S.A.
|
// Copyright (C) 2022-2023 Igara Studio S.A.
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -17,6 +17,11 @@ namespace app {
|
|||||||
|
|
||||||
using namespace doc;
|
using namespace doc;
|
||||||
|
|
||||||
|
SimpleRenderer::SimpleRenderer()
|
||||||
|
{
|
||||||
|
m_properties.outputsUnpremultiplied = true;
|
||||||
|
}
|
||||||
|
|
||||||
void SimpleRenderer::setRefLayersVisiblity(const bool visible)
|
void SimpleRenderer::setRefLayersVisiblity(const bool visible)
|
||||||
{
|
{
|
||||||
m_render.setRefLayersVisiblity(visible);
|
m_render.setRefLayersVisiblity(visible);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2022 Igara Studio S.A.
|
// Copyright (C) 2022-2023 Igara Studio S.A.
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -17,6 +17,8 @@ namespace app {
|
|||||||
// CPU-only.
|
// CPU-only.
|
||||||
class SimpleRenderer : public Renderer {
|
class SimpleRenderer : public Renderer {
|
||||||
public:
|
public:
|
||||||
|
SimpleRenderer();
|
||||||
|
|
||||||
const Properties& properties() const override { return m_properties; }
|
const Properties& properties() const override { return m_properties; }
|
||||||
|
|
||||||
void setRefLayersVisiblity(const bool visible) override;
|
void setRefLayersVisiblity(const bool visible) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user