aboutsummaryrefslogtreecommitdiff
path: root/graphics/nine_patch.cpp
diff options
context:
space:
mode:
authorAlexander Tkachev2016-06-30 23:34:25 +0600
committerEugene Sandulenko2016-07-03 12:23:57 +0200
commit4b87563792163d5fd538092b340500bccd20aa7b (patch)
treebc64bedf5aef5686c82a1d16cf870b0fc7a1bc35 /graphics/nine_patch.cpp
parent916c86e68941cb1a752566ac9c0346263970b366 (diff)
downloadscummvm-rg350-4b87563792163d5fd538092b340500bccd20aa7b.tar.gz
scummvm-rg350-4b87563792163d5fd538092b340500bccd20aa7b.tar.bz2
scummvm-rg350-4b87563792163d5fd538092b340500bccd20aa7b.zip
GUI: Add blipClip()
Diffstat (limited to 'graphics/nine_patch.cpp')
-rw-r--r--graphics/nine_patch.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index a193200208..8ac6977eed 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -236,6 +236,41 @@ void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, in
}
}
+void NinePatchBitmap::blitClip(Graphics::Surface &target, Common::Rect clip, int dx, int dy, int dw, int dh) {
+ /* don't draw bitmaps that are smaller than the fixed area */
+ if (dw < _h._fix || dh < _v._fix)
+ return;
+
+ /* if the bitmap is the same size as the origin, then draw it as-is */
+ if (dw == _width && dh == _height) {
+ Common::Rect r(1, 1, dw, dh);
+
+ _bmp->blitClip(target, clip, dx, dy, Graphics::FLIP_NONE, &r);
+ return;
+ }
+
+ /* only recalculate the offsets if they have changed since the last draw */
+ if (_cached_dw != dw || _cached_dh != dh) {
+ _h.calcOffsets(dw);
+ _v.calcOffsets(dh);
+
+ _cached_dw = dw;
+ _cached_dh = dh;
+ }
+
+ /* draw each region */
+ for (uint i = 0; i < _v._m.size(); ++i) {
+ for (uint j = 0; j < _h._m.size(); ++j) {
+ Common::Rect r(_h._m[j]->offset, _v._m[i]->offset,
+ _h._m[j]->offset + _h._m[j]->length, _v._m[i]->offset + _v._m[i]->length);
+
+ _bmp->blitClip(target, clip, dx + _h._m[j]->dest_offset, dy + _v._m[i]->dest_offset,
+ Graphics::FLIP_NONE, &r, TS_ARGB(255, 255, 255, 255),
+ _h._m[j]->dest_length, _v._m[i]->dest_length);
+ }
+ }
+}
+
NinePatchBitmap::~NinePatchBitmap() {
if (_destroy_bmp)
delete _bmp;