mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 03:39:51 +00:00
Added 'extras' to Sprite to draw extra-stuff that is not in the Sprite (it will be useful to draw preview of the brush).
This commit is contained in:
parent
e7b99eda29
commit
156e3adeb3
@ -60,6 +60,7 @@ Sprite::Sprite(int imgtype, int w, int h)
|
||||
this->undo = undo_new(this);
|
||||
this->repository.paths = jlist_new();
|
||||
this->repository.masks = jlist_new();
|
||||
this->m_extras = NULL;
|
||||
|
||||
/* boundary stuff */
|
||||
this->bound.nseg = 0;
|
||||
@ -140,6 +141,7 @@ Sprite::~Sprite()
|
||||
// destroy undo, mask, etc.
|
||||
delete this->undo;
|
||||
delete this->mask;
|
||||
delete this->m_extras; // image
|
||||
if (this->frlens) jfree(this->frlens);
|
||||
if (this->bound.seg) jfree(this->bound.seg);
|
||||
|
||||
@ -384,6 +386,18 @@ void Sprite::unlock()
|
||||
}
|
||||
}
|
||||
|
||||
void Sprite::prepare_extra()
|
||||
{
|
||||
if (!m_extras ||
|
||||
m_extras->imgtype != imgtype ||
|
||||
m_extras->w != w ||
|
||||
m_extras->h != h) {
|
||||
delete m_extras; // image
|
||||
m_extras = image_new(imgtype, w, h);
|
||||
image_clear(m_extras, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Palette* sprite_get_palette(const Sprite* sprite, int frame)
|
||||
{
|
||||
Palette* found = NULL;
|
||||
|
@ -78,6 +78,9 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
Image* m_extras; // Image with the sprite size to draw some extra stuff (e.g. editor's cursor)
|
||||
int m_extras_opacity; // Opacity to be used to draw the extra image
|
||||
|
||||
// Mutex to modify the 'locked' flag.
|
||||
JMutex m_mutex;
|
||||
|
||||
@ -101,6 +104,11 @@ public:
|
||||
void unlock();
|
||||
|
||||
LayerFolder* get_folder() const { return m_folder; }
|
||||
|
||||
void prepare_extra();
|
||||
Image* get_extras() { return m_extras; }
|
||||
int get_extras_opacity() const { return m_extras_opacity; }
|
||||
void set_extras_opacity(int opacity) { m_extras_opacity = opacity; }
|
||||
};
|
||||
|
||||
Sprite* sprite_new(int imgtype, int w, int h);
|
||||
|
@ -468,4 +468,22 @@ void RenderEngine::renderLayer(Sprite *sprite, Layer *layer, Image *image,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Draw extras
|
||||
if (layer == sprite->layer && sprite->get_extras() != NULL) {
|
||||
int opacity = sprite->get_extras_opacity();
|
||||
|
||||
if (zoom == 0) {
|
||||
image_merge(image, sprite->get_extras(),
|
||||
-source_x,
|
||||
-source_y,
|
||||
opacity, BLEND_MODE_NORMAL);
|
||||
}
|
||||
else {
|
||||
(*zoomed_func)(image, sprite->get_extras(),
|
||||
-source_x,
|
||||
-source_y,
|
||||
opacity, BLEND_MODE_NORMAL, zoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user