Fix preview of transformations (PixelsMovement)

This commit is contained in:
David Capello 2015-06-25 14:54:06 -03:00
parent f571e4ceb2
commit 710e640174
4 changed files with 21 additions and 12 deletions

View File

@ -1471,7 +1471,6 @@ void Editor::pasteImage(const Image* image, const gfx::Point& pos)
}
Sprite* sprite = this->sprite();
int opacity = 255;
// Check bounds where the image will be pasted.
int x = pos.x;
@ -1493,7 +1492,7 @@ void Editor::pasteImage(const Image* image, const gfx::Point& pos)
PixelsMovementPtr pixelsMovement(
new PixelsMovement(UIContext::instance(),
getSite(), image, gfx::Point(x, y), opacity, "Paste"));
getSite(), image, gfx::Point(x, y), "Paste"));
// Select the pasted image so the user can move it and transform it.
pixelsMovement->maskImage(image);

View File

@ -30,6 +30,7 @@
#include "doc/algorithm/flip_image.h"
#include "doc/algorithm/rotate.h"
#include "doc/algorithm/rotsprite.h"
#include "doc/blend_internals.h"
#include "doc/cel.h"
#include "doc/image.h"
#include "doc/layer.h"
@ -48,7 +49,7 @@ static inline const base::Vector2d<double> point2Vector(const gfx::PointT<T>& pt
PixelsMovement::PixelsMovement(Context* context,
Site site,
const Image* moveThis, const gfx::Point& initialPos, int opacity,
const Image* moveThis, const gfx::Point& initialPos,
const char* operationName)
: m_reader(context)
, m_site(site)
@ -71,9 +72,13 @@ PixelsMovement::PixelsMovement(Context* context,
// and its owner could destroy our new "extra cel".
ASSERT(!m_document->getExtraCel());
int t, opacity = static_cast<LayerImage*>(m_layer)->opacity();
Cel* cel = m_site.cel();
if (cel) opacity = MUL_UN8(opacity, cel->opacity(), t);
ContextWriter writer(m_reader, 500);
m_document->prepareExtraCel(m_sprite->bounds(), opacity);
m_document->setExtraCelType(render::ExtraType::COMPOSITE);
m_document->setExtraCelType(render::ExtraType::PATCH);
m_document->setExtraCelBlendMode(
static_cast<LayerImage*>(m_layer)->blendMode());
@ -462,11 +467,11 @@ void PixelsMovement::stampImage()
gfx::Region modifiedRegion(expand.getDestCanvas()->bounds());
expand.validateDestCanvas(modifiedRegion);
render::composite_image(
expand.getDestCanvas(), image,
-expand.getCel()->x(),
-expand.getCel()->y(),
cel->opacity(), BlendMode::NORMAL);
expand.getDestCanvas()->copy(
image, gfx::Clip(
-expand.getCel()->x(),
-expand.getCel()->y(),
image->bounds()));
expand.commit();
}
@ -616,6 +621,11 @@ void PixelsMovement::drawImage(doc::Image* dst, const gfx::Point& pt)
dst->setMaskColor(m_sprite->transparentColor());
clear_image(dst, dst->maskColor());
render::Render().renderLayer(
dst, m_layer, m_site.frame(),
gfx::Clip(0, 0, dst->bounds()),
BlendMode::SRC);
m_originalImage->setMaskColor(m_maskColor);
drawParallelogram(dst, m_originalImage, corners, pt);
}

View File

@ -50,7 +50,7 @@ namespace app {
PixelsMovement(Context* context,
Site site,
const Image* moveThis,
const gfx::Point& initialPos, int opacity,
const gfx::Point& initialPos,
const char* operationName);
~PixelsMovement();

View File

@ -417,11 +417,11 @@ void StandbyState::transformSelection(Editor* editor, MouseMessage* msg, HandleT
Document* document = editor->document();
base::UniquePtr<Image> tmpImage(new_image_from_mask(editor->getSite()));
gfx::Point origin = document->mask()->bounds().getOrigin();
int opacity = 255;
PixelsMovementPtr pixelsMovement(
new PixelsMovement(UIContext::instance(),
editor->getSite(),
tmpImage, origin, opacity,
tmpImage, origin,
"Transformation"));
// If the Ctrl key is pressed start dragging a copy of the selection