mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Add she::LockedSurface::scrollTo() so we can specialize it in the Skia port
This commit is contained in:
parent
237549b818
commit
da3b3de6c1
@ -349,6 +349,13 @@ namespace she {
|
||||
width, height);
|
||||
}
|
||||
|
||||
void scrollTo(const gfx::Rect& rc, int dx, int dy) override {
|
||||
blit(m_bmp, m_bmp,
|
||||
rc.x, rc.y,
|
||||
rc.x+dx, rc.y+dy,
|
||||
rc.w, rc.h);
|
||||
}
|
||||
|
||||
void drawSurface(const LockedSurface* src, int dstx, int dsty) override {
|
||||
draw_sprite(m_bmp, static_cast<const Alleg4Surface*>(src)->m_bmp, dstx, dsty);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ namespace she {
|
||||
virtual void fillRect(gfx::Color color, const gfx::Rect& rc) = 0;
|
||||
|
||||
virtual void blitTo(LockedSurface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const = 0;
|
||||
virtual void scrollTo(const gfx::Rect& rc, int dx, int dy) = 0;
|
||||
virtual void drawSurface(const LockedSurface* src, int dstx, int dsty) = 0;
|
||||
virtual void drawRgbaSurface(const LockedSurface* src, int dstx, int dsty) = 0;
|
||||
virtual void drawColoredRgbaSurface(const LockedSurface* src, gfx::Color fg, gfx::Color bg, const gfx::Clip& clip) = 0;
|
||||
|
@ -258,6 +258,39 @@ public:
|
||||
((SkiaSurface*)dest)->m_canvas->drawBitmapRectToRect(m_bitmap, &srcRect, dstRect, &paint);
|
||||
}
|
||||
|
||||
void scrollTo(const gfx::Rect& rc, int dx, int dy) override {
|
||||
int w = m_bitmap.width();
|
||||
int h = m_bitmap.height();
|
||||
gfx::Clip clip(rc.x+dx, rc.y+dy, rc);
|
||||
if (!clip.clip(w, h, w, h))
|
||||
return;
|
||||
|
||||
int bytesPerPixel = m_bitmap.bytesPerPixel();
|
||||
int rowBytes = (int)m_bitmap.rowBytes();
|
||||
int rowDelta;
|
||||
|
||||
if (dy > 0) {
|
||||
clip.src.y += clip.size.h-1;
|
||||
clip.dst.y += clip.size.h-1;
|
||||
rowDelta = -rowBytes;
|
||||
}
|
||||
else
|
||||
rowDelta = rowBytes;
|
||||
|
||||
char* dst = (char*)m_bitmap.getPixels();
|
||||
const char* src = dst;
|
||||
dst += rowBytes*clip.dst.y + bytesPerPixel*clip.dst.x;
|
||||
src += rowBytes*clip.src.y + bytesPerPixel*clip.src.x;
|
||||
w = bytesPerPixel*clip.size.w;
|
||||
h = clip.size.h;
|
||||
|
||||
while (--h >= 0) {
|
||||
memmove(dst, src, w);
|
||||
dst += rowDelta;
|
||||
src += rowDelta;
|
||||
}
|
||||
}
|
||||
|
||||
void drawSurface(const LockedSurface* src, int dstx, int dsty) override {
|
||||
gfx::Clip clip(dstx, dsty, 0, 0,
|
||||
((SkiaSurface*)src)->m_bitmap.width(),
|
||||
|
@ -22,12 +22,8 @@ namespace ui {
|
||||
|
||||
using namespace gfx;
|
||||
|
||||
void move_region(const Region& region, int dx, int dy)
|
||||
void move_region(Manager* manager, const Region& region, int dx, int dy)
|
||||
{
|
||||
ASSERT(Manager::getDefault());
|
||||
if (!Manager::getDefault())
|
||||
return;
|
||||
|
||||
she::System* system = she::instance();
|
||||
she::Display* display = Manager::getDefault()->getDisplay();
|
||||
ASSERT(display);
|
||||
@ -40,7 +36,7 @@ void move_region(const Region& region, int dx, int dy)
|
||||
// Blit directly screen to screen.
|
||||
if (nrects == 1) {
|
||||
Rect rc = region[0];
|
||||
lock->blitTo(lock, rc.x, rc.y, rc.x+dx, rc.y+dy, rc.w, rc.h);
|
||||
lock->scrollTo(rc, dx, dy);
|
||||
}
|
||||
// Blit saving areas and copy them.
|
||||
else if (nrects > 1) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2014 David Capello
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -10,9 +10,11 @@
|
||||
|
||||
#include "gfx/region.h"
|
||||
|
||||
namespace ui { // TODO all these functions are deprecated and must be replaced by Graphics methods.
|
||||
namespace ui {
|
||||
|
||||
void move_region(const gfx::Region& region, int dx, int dy);
|
||||
class Manager;
|
||||
|
||||
void move_region(Manager* manager, const gfx::Region& region, int dx, int dy);
|
||||
|
||||
} // namespace ui
|
||||
|
||||
|
@ -1068,7 +1068,7 @@ void Widget::scrollRegion(const Region& region, const Point& delta)
|
||||
reg2.offset(-delta);
|
||||
|
||||
// Move screen pixels
|
||||
ui::move_region(reg2, delta.x, delta.y);
|
||||
ui::move_region(getManager(), reg2, delta.x, delta.y);
|
||||
|
||||
reg2.offset(delta);
|
||||
|
||||
|
@ -577,7 +577,7 @@ void Window::moveWindow(const gfx::Rect& rect, bool use_blit)
|
||||
{
|
||||
IntersectClip clip(&g, man_pos);
|
||||
if (clip) {
|
||||
ui::move_region(moveableRegion, dx, dy);
|
||||
ui::move_region(manager, moveableRegion, dx, dy);
|
||||
}
|
||||
}
|
||||
show_mouse_cursor();
|
||||
|
Loading…
x
Reference in New Issue
Block a user