diff options
author | truelight <truelight@openttd.org> | 2007-06-18 20:08:21 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2007-06-18 20:08:21 +0000 |
commit | 26e9b5ca5f0eafae421a640ea4e4753d6ac7ec0e (patch) | |
tree | 50524cab6a4a5052a93115c2d41248a6b3bf2528 /src/blitter/32bpp_base.cpp | |
parent | 49220cc6f1e3570dc1b9001c40af2a8a4e35b649 (diff) | |
download | openttd-26e9b5ca5f0eafae421a640ea4e4753d6ac7ec0e.tar.xz |
(svn r10206) -Codechange: more moving things to blitter-layer: ScrollBuffer
Diffstat (limited to 'src/blitter/32bpp_base.cpp')
-rw-r--r-- | src/blitter/32bpp_base.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/blitter/32bpp_base.cpp b/src/blitter/32bpp_base.cpp index adfc0fbef..f788b56a7 100644 --- a/src/blitter/32bpp_base.cpp +++ b/src/blitter/32bpp_base.cpp @@ -121,6 +121,58 @@ void Blitter_32bppBase::MoveBuffer(void *video_dst, const void *video_src, int w } } +void Blitter_32bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) +{ + const uint32 *src; + uint32 *dst; + + if (scroll_y > 0) { + /*Calculate pointers */ + dst = (uint32 *)video + left + (top + height - 1) * _screen.pitch; + src = dst - scroll_y * _screen.pitch; + + /* Decrease height and increase top */ + top += scroll_y; + height -= scroll_y; + assert(height > 0); + + /* Adjust left & width */ + if (scroll_x >= 0) { + dst += scroll_x; + left += scroll_x; + width -= scroll_x; + } else { + src -= scroll_x; + width += scroll_x; + } + + /* Negative height as we want to copy from bottom to top */ + this->CopyFromBuffer(dst, src, width, -height, _screen.pitch); + } else { + /* Calculate pointers */ + dst = (uint32 *)video + left + top * _screen.pitch; + src = dst - scroll_y * _screen.pitch; + + /* Decrese height. (scroll_y is <=0). */ + height += scroll_y; + assert(height > 0); + + /* Adjust left & width */ + if (scroll_x >= 0) { + dst += scroll_x; + left += scroll_x; + width -= scroll_x; + } else { + src -= scroll_x; + width += scroll_x; + } + + /* the y-displacement may be 0 therefore we have to use memmove, + * because source and destination may overlap */ + this->MoveBuffer(dst, src, width, height); + } +} + int Blitter_32bppBase::BufferSize(int width, int height) { return width * height * sizeof(uint32); |