mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-05 21:57:20 +00:00
Merge branch '1.0'
Conflicts: src/app/commands/cmd_preview.cpp src/app/thumbnail_generator.cpp src/app/ui/editor/editor.h src/app/util/render.h src/raster/image_buffer.h
This commit is contained in:
commit
adf08ac7df
@ -193,7 +193,8 @@ protected:
|
||||
m_render.reset(
|
||||
renderEngine.renderSprite(
|
||||
0, 0, m_sprite->width(), m_sprite->height(),
|
||||
m_editor->frame(), Zoom(1, 1), false, false));
|
||||
m_editor->frame(), Zoom(1, 1), false, false,
|
||||
Editor::getRenderImageBuffer()));
|
||||
}
|
||||
|
||||
int x, y, w, h, u, v;
|
||||
|
@ -83,9 +83,11 @@ private:
|
||||
RenderEngine renderEngine(m_fop->document,
|
||||
sprite, NULL, FrameNumber(0));
|
||||
|
||||
doc::ImageBufferPtr thumbnail_buffer(new doc::ImageBuffer);
|
||||
base::UniquePtr<Image> image(renderEngine.renderSprite(
|
||||
0, 0, sprite->width(), sprite->height(),
|
||||
FrameNumber(0), Zoom(1, 1), true, false));
|
||||
FrameNumber(0), Zoom(1, 1), true, false,
|
||||
thumbnail_buffer));
|
||||
|
||||
// Calculate the thumbnail size
|
||||
int thumb_w = MAX_THUMBNAIL_SIZE * image->width() / MAX(image->width(), image->height());
|
||||
|
@ -137,6 +137,8 @@ private:
|
||||
Graphics* m_g;
|
||||
};
|
||||
|
||||
static doc::ImageBufferPtr render_buffer;
|
||||
|
||||
Editor::Editor(Document* document, EditorFlags flags)
|
||||
: Widget(editor_type())
|
||||
, m_state(new StandbyState())
|
||||
@ -387,12 +389,16 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& rc, in
|
||||
RenderEngine renderEngine(m_document, m_sprite, m_layer, m_frame);
|
||||
|
||||
// Generate the rendered image
|
||||
if (!render_buffer)
|
||||
render_buffer.reset(new doc::ImageBuffer());
|
||||
|
||||
base::UniquePtr<Image> rendered(NULL);
|
||||
try {
|
||||
rendered.reset(renderEngine.renderSprite(
|
||||
source_x, source_y, width, height,
|
||||
m_frame, m_zoom, true,
|
||||
((m_flags & kShowOnionskin) == kShowOnionskin)));
|
||||
((m_flags & kShowOnionskin) == kShowOnionskin),
|
||||
render_buffer));
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
Console::showException(e);
|
||||
@ -1455,6 +1461,12 @@ void Editor::notifyScrollChanged()
|
||||
m_observers.notifyScrollChanged(this);
|
||||
}
|
||||
|
||||
// static
|
||||
ImageBufferPtr Editor::getRenderImageBuffer()
|
||||
{
|
||||
return render_buffer;
|
||||
}
|
||||
|
||||
void Editor::onSetTiledMode(filters::TiledMode mode)
|
||||
{
|
||||
invalidate();
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "app/zoom.h"
|
||||
#include "base/connection.h"
|
||||
#include "doc/frame_number.h"
|
||||
#include "doc/image_buffer.h"
|
||||
#include "gfx/fwd.h"
|
||||
#include "ui/base.h"
|
||||
#include "ui/timer.h"
|
||||
@ -196,6 +197,10 @@ namespace app {
|
||||
// position.
|
||||
void notifyScrollChanged();
|
||||
|
||||
// Returns the buffer used to render editor viewports.
|
||||
// E.g. It can be re-used by PreviewCommand
|
||||
static ImageBufferPtr getRenderImageBuffer();
|
||||
|
||||
// in cursor.cpp
|
||||
|
||||
static app::Color get_cursor_color();
|
||||
|
@ -486,7 +486,8 @@ Image* RenderEngine::renderSprite(int source_x, int source_y,
|
||||
int width, int height,
|
||||
FrameNumber frame, Zoom zoom,
|
||||
bool draw_tiled_bg,
|
||||
bool enable_onionskin)
|
||||
bool enable_onionskin,
|
||||
ImageBufferPtr& buffer)
|
||||
{
|
||||
void (*zoomed_func)(Image*, const Image*, const Palette*, int, int, int, int, Zoom);
|
||||
const LayerImage* background = m_sprite->backgroundLayer();
|
||||
@ -515,7 +516,7 @@ Image* RenderEngine::renderSprite(int source_x, int source_y,
|
||||
}
|
||||
|
||||
// Create a temporary RGB bitmap to draw all to it
|
||||
image = Image::create(IMAGE_RGB, width, height);
|
||||
image = Image::create(IMAGE_RGB, width, height, buffer);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "app/color.h"
|
||||
#include "app/zoom.h"
|
||||
#include "doc/frame_number.h"
|
||||
#include "doc/image_buffer.h"
|
||||
|
||||
namespace doc {
|
||||
class Image;
|
||||
@ -73,7 +74,8 @@ namespace app {
|
||||
int width, int height,
|
||||
FrameNumber frame, Zoom zoom,
|
||||
bool draw_tiled_bg,
|
||||
bool enable_onionskin);
|
||||
bool enable_onionskin,
|
||||
ImageBufferPtr& buffer);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Extra functions
|
||||
|
@ -16,7 +16,7 @@ namespace doc {
|
||||
|
||||
class ImageBuffer {
|
||||
public:
|
||||
ImageBuffer(size_t size) : m_buffer(size) {
|
||||
ImageBuffer(size_t size = 1) : m_buffer(size) {
|
||||
}
|
||||
|
||||
size_t size() const { return m_buffer.size(); }
|
||||
|
Loading…
Reference in New Issue
Block a user