Skip to content

Commit

Permalink
GUI: Fix ThemeItemTextData's dirty rectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
Tkachov authored and sev- committed Jul 3, 2016
1 parent b946ef8 commit 425d963
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
10 changes: 5 additions & 5 deletions graphics/VectorRendererSpec.cpp
Expand Up @@ -2382,18 +2382,18 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) {
if (y + ystart < _clippingArea.top || y + ystart > _clippingArea.bottom) continue;

if (((1 << x) & hb) == 0) {
blendFillClip(xstart + r + x, ptr_tl - y - px, ptr_tr + y - px, color, (uint8)alpha);
blendFill(ptr_tl - y - px, ptr_tr + y - px, color, (uint8)alpha);

// Will create a dark line of pixles if left out
if (hb > 0) {
blendFillClip(x, ptr_bl - y + px, ptr_br + y + px, color, (uint8)alpha);
blendFill(ptr_bl - y + px, ptr_br + y + px, color, (uint8)alpha);
}
hb |= (1 << x);
}

if (((1 << y) & hb) == 0) {
blendFillClip(x, ptr_tl - x - py, ptr_tr + x - py, color, (uint8)alpha);
blendFillClip(x, ptr_bl - x + py, ptr_br + x + py, color, (uint8)alpha);
blendFill(ptr_tl - x - py, ptr_tr + x - py, color, (uint8)alpha);
blendFill(ptr_bl - x + py, ptr_br + x + py, color, (uint8)alpha);
hb |= (1 << y);
}
}
Expand All @@ -2402,7 +2402,7 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) {
int realy = ystart;
while (short_h--) {
if (realy >= _clippingArea.top && realy <= _clippingArea.bottom)
blendFillClip(xstart+x, ptr_fill, ptr_fill + width + 1, color, (uint8)alpha);
blendFill(ptr_fill, ptr_fill + width + 1, color, (uint8)alpha);
ptr_fill += pitch;
++realy;
}
Expand Down
10 changes: 0 additions & 10 deletions graphics/VectorRendererSpec.h
Expand Up @@ -252,16 +252,6 @@ class VectorRendererSpec : public VectorRenderer {
}
}

inline void blendFillClip(int x, PixelType *first, PixelType *last, PixelType color, uint8 alpha) {
while (first != last) {
if (x >= _clippingArea.left && x <= _clippingArea.right)
blendPixelPtr(first++, color, alpha);
else
++first;
++x;
}
}

void darkenFill(PixelType *first, PixelType *last);

const PixelFormat _format;
Expand Down
12 changes: 8 additions & 4 deletions gui/ThemeEngine.cpp
Expand Up @@ -276,15 +276,19 @@ void ThemeItemDrawDataClip::drawSelf(bool draw, bool restore) {
}

void ThemeItemTextData::drawSelf(bool draw, bool restore) {
Common::Rect dirty = _textDrawableArea;
if (dirty.isEmpty()) dirty = _area;
else dirty.clip(_area);

if (_restoreBg || restore)
_engine->restoreBackground(_area);
_engine->restoreBackground(dirty);

if (draw) {
_engine->renderer()->setFgColor(_color->r, _color->g, _color->b);
_engine->renderer()->drawString(_data->_fontPtr, _text, _area, _alignH, _alignV, _deltax, _ellipsis, _textDrawableArea);
}

_engine->addDirtyRect(_area);
_engine->addDirtyRect(dirty);
}

void ThemeItemBitmap::drawSelf(bool draw, bool restore) {
Expand Down Expand Up @@ -1414,12 +1418,12 @@ void ThemeEngine::drawTextClip(const Common::Rect &r, const Common::Rect &clippi

switch (inverted) {
case kTextInversion:
queueDD(kDDTextSelectionBackground, r);
queueDDClip(kDDTextSelectionBackground, r, clippingArea);
restore = false;
break;

case kTextInversionFocus:
queueDD(kDDTextSelectionFocusBackground, r);
queueDDClip(kDDTextSelectionFocusBackground, r, clippingArea);
restore = false;
break;

Expand Down

0 comments on commit 425d963

Please sign in to comment.