1// Aseprite
2// Copyright (C) 2019-2022 Igara Studio S.A.
3// Copyright (C) 2018 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifndef APP_UI_EDITOR_RENDER_H_INCLUDED
9#define APP_UI_EDITOR_RENDER_H_INCLUDED
10#pragma once
11
12#include "doc/blend_mode.h"
13#include "doc/color.h"
14#include "doc/frame.h"
15#include "doc/image_buffer.h"
16#include "doc/pixel_format.h"
17#include "gfx/clip.h"
18#include "gfx/point.h"
19#include "render/extra_type.h"
20#include "render/onionskin_options.h"
21#include "render/projection.h"
22
23namespace doc {
24 class Cel;
25 class Image;
26 class Layer;
27 class Palette;
28 class Sprite;
29 class Tileset;
30}
31
32namespace app {
33 class Doc;
34 class Renderer;
35
36 class EditorRender {
37 public:
38 EditorRender();
39 ~EditorRender();
40
41 void setRefLayersVisiblity(const bool visible);
42 void setNonactiveLayersOpacity(const int opacity);
43 void setNewBlendMethod(const bool newBlend);
44
45 void setProjection(const render::Projection& projection);
46
47 void setupBackground(Doc* doc, doc::PixelFormat pixelFormat);
48 void setTransparentBackground();
49
50 void setSelectedLayer(const doc::Layer* layer);
51
52 void setPreviewImage(const doc::Layer* layer,
53 const doc::frame_t frame,
54 const doc::Image* image,
55 const doc::Tileset* tileset,
56 const gfx::Point& pos,
57 const doc::BlendMode blendMode);
58 void removePreviewImage();
59
60 void setExtraImage(
61 render::ExtraType type,
62 const doc::Cel* cel,
63 const doc::Image* image,
64 doc::BlendMode blendMode,
65 const doc::Layer* currentLayer,
66 doc::frame_t currentFrame);
67 void removeExtraImage();
68
69 void setOnionskin(const render::OnionskinOptions& options);
70 void disableOnionskin();
71
72 void renderSprite(
73 doc::Image* dstImage,
74 const doc::Sprite* sprite,
75 doc::frame_t frame);
76 void renderSprite(
77 doc::Image* dstImage,
78 const doc::Sprite* sprite,
79 doc::frame_t frame,
80 const gfx::ClipF& area);
81 void renderCheckeredBackground(
82 doc::Image* image,
83 const gfx::Clip& area);
84 void renderImage(
85 doc::Image* dst_image,
86 const doc::Image* src_image,
87 const doc::Palette* pal,
88 const int x,
89 const int y,
90 const int opacity,
91 const doc::BlendMode blendMode);
92
93 doc::ImageBufferPtr getRenderImageBuffer();
94
95 private:
96 std::unique_ptr<Renderer> m_renderer;
97 };
98
99} // namespace app
100
101#endif
102