mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 01:20:17 +00:00
Fix flashing selected layer for tilemaps
We've also removed the necessity to create a temporary image for the flashing effect, so it uses less memory.
This commit is contained in:
parent
472861ddd9
commit
615fa33188
@ -63,6 +63,7 @@
|
||||
#include "os/display.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
#include "render/rasterize.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -1304,15 +1305,9 @@ void Editor::flashCurrentLayer()
|
||||
m_renderEngine->removePreviewImage();
|
||||
|
||||
ExtraCelRef extraCel(new ExtraCel);
|
||||
extraCel->create(m_sprite, src_cel->bounds(), m_frame, 255);
|
||||
extraCel->setType(render::ExtraType::COMPOSITE);
|
||||
extraCel->setType(render::ExtraType::OVER_COMPOSITE);
|
||||
extraCel->setBlendMode(BlendMode::NEG_BW);
|
||||
|
||||
Image* flash_image = extraCel->image();
|
||||
clear_image(flash_image, flash_image->maskColor());
|
||||
copy_image(flash_image, src_cel->image(), 0, 0);
|
||||
|
||||
ExtraCelRef oldExtraCel = m_document->extraCel();
|
||||
m_document->setExtraCel(extraCel);
|
||||
m_flashing = Flashing::WithFlashExtraCel;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Aseprite Render Library
|
||||
// Copyright (c) 2001-2015 David Capello
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -20,6 +21,10 @@ namespace render {
|
||||
// The extra cel indicates an extra composition for the current
|
||||
// layer/frame.
|
||||
COMPOSITE,
|
||||
|
||||
// Composite the current cel two times (don't use the extral cel),
|
||||
// but the second time using the extral blend mode.
|
||||
OVER_COMPOSITE,
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
|
@ -528,11 +528,11 @@ Render::Render()
|
||||
: m_flags(0)
|
||||
, m_nonactiveLayersOpacity(255)
|
||||
, m_sprite(nullptr)
|
||||
, m_currentLayer(NULL)
|
||||
, m_currentLayer(nullptr)
|
||||
, m_currentFrame(0)
|
||||
, m_extraType(ExtraType::NONE)
|
||||
, m_extraCel(NULL)
|
||||
, m_extraImage(NULL)
|
||||
, m_extraCel(nullptr)
|
||||
, m_extraImage(nullptr)
|
||||
, m_newBlendMethod(true)
|
||||
, m_bgType(BgType::TRANSPARENT)
|
||||
, m_bgCheckedSize(16, 16)
|
||||
@ -634,7 +634,7 @@ void Render::removePreviewImage()
|
||||
void Render::removeExtraImage()
|
||||
{
|
||||
m_extraType = ExtraType::NONE;
|
||||
m_extraCel = NULL;
|
||||
m_extraCel = nullptr;
|
||||
}
|
||||
|
||||
void Render::setOnionskin(const OnionskinOptions& options)
|
||||
@ -1101,7 +1101,7 @@ void Render::renderLayer(
|
||||
|
||||
if (celImage) {
|
||||
const LayerImage* imgLayer = static_cast<const LayerImage*>(layer);
|
||||
const BlendMode layerBlendMode =
|
||||
BlendMode layerBlendMode =
|
||||
(blendMode == BlendMode::UNSPECIFIED ?
|
||||
imgLayer->blendMode():
|
||||
blendMode);
|
||||
@ -1119,26 +1119,39 @@ void Render::renderLayer(
|
||||
if (!isSelected && m_nonactiveLayersOpacity != 255)
|
||||
opacity = MUL_UN8(opacity, m_nonactiveLayersOpacity, t);
|
||||
|
||||
// Draw parts outside the "m_extraCel" area
|
||||
if (drawExtra && m_extraType == ExtraType::PATCH) {
|
||||
gfx::Region originalAreas(area.srcBounds());
|
||||
originalAreas.createSubtraction(
|
||||
originalAreas, gfx::Region(extraArea));
|
||||
// Generally this is just one pass, but if we are using
|
||||
// OVER_COMPOSITE extra cel, this will be two passes.
|
||||
for (int pass=0; pass<2; ++pass) {
|
||||
// Draw parts outside the "m_extraCel" area
|
||||
if (drawExtra && m_extraType == ExtraType::PATCH) {
|
||||
gfx::Region originalAreas(area.srcBounds());
|
||||
originalAreas.createSubtraction(
|
||||
originalAreas, gfx::Region(extraArea));
|
||||
|
||||
for (auto rc : originalAreas) {
|
||||
renderCel(
|
||||
image, celImage, layer, pal, celBounds,
|
||||
gfx::Clip(area.dst.x+rc.x-area.src.x,
|
||||
area.dst.y+rc.y-area.src.y, rc),
|
||||
compositeImage, opacity, layerBlendMode);
|
||||
for (auto rc : originalAreas) {
|
||||
renderCel(
|
||||
image, celImage, layer, pal, celBounds,
|
||||
gfx::Clip(area.dst.x+rc.x-area.src.x,
|
||||
area.dst.y+rc.y-area.src.y, rc),
|
||||
compositeImage, opacity, layerBlendMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Draw the whole cel
|
||||
else {
|
||||
renderCel(
|
||||
image, celImage, layer, pal,
|
||||
celBounds, area, compositeImage,
|
||||
opacity, layerBlendMode);
|
||||
// Draw the whole cel
|
||||
else {
|
||||
renderCel(
|
||||
image, celImage, layer, pal,
|
||||
celBounds, area, compositeImage,
|
||||
opacity, layerBlendMode);
|
||||
}
|
||||
|
||||
if (m_extraType == ExtraType::OVER_COMPOSITE &&
|
||||
layer == m_currentLayer &&
|
||||
pass == 0) {
|
||||
// Go for second pass with the extra blend mode...
|
||||
layerBlendMode = m_extraBlendMode;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user