1// Aseprite
2// Copyright (C) 2001-2015 David Capello
3//
4// This program is distributed under the terms of
5// the End-User License Agreement for Aseprite.
6
7#ifdef HAVE_CONFIG_H
8#include "config.h"
9#endif
10
11#include "app/cmd/clear_image.h"
12
13#include "app/doc.h"
14#include "doc/image.h"
15#include "doc/primitives.h"
16
17namespace app {
18namespace cmd {
19
20using namespace doc;
21
22ClearImage::ClearImage(Image* image, color_t color)
23 : WithImage(image)
24 , m_color(color)
25{
26}
27
28void ClearImage::onExecute()
29{
30 Image* image = this->image();
31
32 ASSERT(!m_copy);
33 m_copy.reset(Image::createCopy(image));
34 clear_image(image, m_color);
35
36 image->incrementVersion();
37}
38
39void ClearImage::onUndo()
40{
41 Image* image = this->image();
42
43 copy_image(image, m_copy.get());
44 m_copy.reset();
45
46 image->incrementVersion();
47}
48
49} // namespace cmd
50} // namespace app
51