GRAPHICS: Vector renderer clipping rect related cleanups

Selecting whether a clipping variant of a draw call needs to be used is
no longer the responsibility to the caller. The clipping rect is now
part of the state of the renderer.

Also fix some of the draw calls to better apply the clipping rect.
This commit is contained in:
Bastien Bouclet 2019-08-27 08:07:14 +02:00
parent b87ebdce21
commit 1d764bd787
8 changed files with 149 additions and 582 deletions

View File

@ -32,34 +32,7 @@ namespace Graphics {
/********************************************************************
* DRAWSTEP handling functions
********************************************************************/
void VectorRenderer::drawStep(const Common::Rect &area, const DrawStep &step, uint32 extra) {
if (step.bgColor.set)
setBgColor(step.bgColor.r, step.bgColor.g, step.bgColor.b);
if (step.fgColor.set)
setFgColor(step.fgColor.r, step.fgColor.g, step.fgColor.b);
if (step.bevelColor.set)
setBevelColor(step.bevelColor.r, step.bevelColor.g, step.bevelColor.b);
if (step.gradColor1.set && step.gradColor2.set)
setGradientColors(step.gradColor1.r, step.gradColor1.g, step.gradColor1.b,
step.gradColor2.r, step.gradColor2.g, step.gradColor2.b);
setShadowOffset(_disableShadows ? 0 : step.shadow);
setBevel(step.bevel);
setGradientFactor(step.factor);
setStrokeWidth(step.stroke);
setFillMode((FillMode)step.fillMode);
_dynamicData = extra;
Common::Rect noClip = Common::Rect(0, 0, 0, 0);
(this->*(step.drawingCall))(area, step, noClip);
}
void VectorRenderer::drawStepClip(const Common::Rect &area, const Common::Rect &clip, const DrawStep &step, uint32 extra) {
void VectorRenderer::drawStep(const Common::Rect &area, const Common::Rect &clip, const DrawStep &step, uint32 extra) {
if (step.bgColor.set)
setBgColor(step.bgColor.r, step.bgColor.g, step.bgColor.b);
@ -79,10 +52,11 @@ void VectorRenderer::drawStepClip(const Common::Rect &area, const Common::Rect &
setGradientFactor(step.factor);
setStrokeWidth(step.stroke);
setFillMode((FillMode)step.fillMode);
setClippingRect(clip);
_dynamicData = extra;
(this->*(step.drawingCall))(area, step, clip);
(this->*(step.drawingCall))(area, step);
}
int VectorRenderer::stepGetRadius(const DrawStep &step, const Common::Rect &area) {

View File

@ -39,7 +39,7 @@ class VectorRenderer;
struct DrawStep;
typedef void (VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const Graphics::DrawStep &, const Common::Rect &);
typedef void (VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const Graphics::DrawStep &);
struct DrawStep {
@ -165,7 +165,6 @@ public:
* @param y2 Vertical (Y) coordinate for the line end
*/
virtual void drawLine(int x1, int y1, int x2, int y2) = 0;
virtual void drawLineClip(int x1, int y1, int x2, int y2, Common::Rect clipping) = 0;
/**
* Draws a circle centered at (x,y) with radius r.
@ -175,7 +174,6 @@ public:
* @param r Radius of the circle.
*/
virtual void drawCircle(int x, int y, int r) = 0;
virtual void drawCircleClip(int x, int y, int r, Common::Rect clipping) = 0;
/**
* Draws a square starting at (x,y) with the given width and height.
@ -186,7 +184,6 @@ public:
* @param h Height of the square
*/
virtual void drawSquare(int x, int y, int w, int h) = 0;
virtual void drawSquareClip(int x, int y, int w, int h, Common::Rect clipping) = 0;
/**
* Draws a rounded square starting at (x,y) with the given width and height.
@ -199,7 +196,6 @@ public:
* @param r Radius of the corners.
*/
virtual void drawRoundedSquare(int x, int y, int r, int w, int h) = 0;
virtual void drawRoundedSquareClip(int x, int y, int r, int w, int h, Common::Rect clipping) = 0;
/**
* Draws a triangle starting at (x,y) with the given base and height.
@ -213,7 +209,6 @@ public:
* @param orient Orientation of the triangle.
*/
virtual void drawTriangle(int x, int y, int base, int height, TriangleOrientation orient) = 0;
virtual void drawTriangleClip(int x, int y, int base, int height, TriangleOrientation orient, Common::Rect clipping) = 0;
/**
* Draws a beveled square like the ones in the Classic GUI themes.
@ -226,8 +221,7 @@ public:
* @param h Height of the square
* @param bevel Amount of bevel. Must be positive.
*/
virtual void drawBeveledSquare(int x, int y, int w, int h, int bevel) = 0;
virtual void drawBeveledSquareClip(int x, int y, int w, int h, int bevel, Common::Rect clipping) = 0;
virtual void drawBeveledSquare(int x, int y, int w, int h) = 0;
/**
* Draws a tab-like shape, specially thought for the Tab widget.
@ -241,8 +235,6 @@ public:
* @param r Radius of the corners of the tab (0 for squared tabs).
*/
virtual void drawTab(int x, int y, int r, int w, int h) = 0;
virtual void drawTabClip(int x, int y, int r, int w, int h, Common::Rect clipping) = 0;
/**
* Simple helper function to draw a cross.
@ -252,11 +244,6 @@ public:
drawLine(x + w, y, x, y + h);
}
virtual void drawCrossClip(int x, int y, int w, int h, Common::Rect clipping) {
drawLineClip(x, y, x + w, y + w, clipping);
drawLineClip(x + w, y, x, y + h, clipping);
}
/**
* Set the active foreground painting color for the renderer.
* All the foreground drawing from then on will be done with that color, unless
@ -320,7 +307,6 @@ public:
* Defaults to using the active Foreground color for filling.
*/
virtual void fillSurface() = 0;
virtual void fillSurfaceClip(Common::Rect clipping) = 0;
/**
* Clears the active surface.
@ -383,6 +369,16 @@ public:
_gradientFactor = factor;
}
/**
* Sets the clipping rectangle to be used by draw calls.
*
* Draw calls are restricted to pixels that are inside of the clipping
* rectangle. Pixels outside the clipping rectangle are not modified.
* To disable the clipping rectangle, call this method with a rectangle
* the same size as the target surface.
*/
virtual void setClippingRect(const Common::Rect &clippingArea) = 0;
/**
* Translates the position data inside a DrawStep into actual
* screen drawing positions.
@ -398,74 +394,74 @@ public:
/**
* DrawStep callback functions for each drawing feature
*/
void drawCallback_CIRCLE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
void drawCallback_CIRCLE(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h, radius;
radius = stepGetRadius(step, area);
stepGetPositions(step, area, x, y, w, h);
drawCircleClip(x + radius, y + radius, radius, clip);
drawCircle(x + radius, y + radius, radius);
}
void drawCallback_SQUARE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
void drawCallback_SQUARE(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawSquareClip(x, y, w, h, clip);
drawSquare(x, y, w, h);
}
void drawCallback_LINE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
void drawCallback_LINE(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawLineClip(x, y, x + w, y + w, clip);
drawLine(x, y, x + w, y + w);
}
void drawCallback_ROUNDSQ(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
void drawCallback_ROUNDSQ(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawRoundedSquareClip(x, y, stepGetRadius(step, area), w, h, clip);
drawRoundedSquare(x, y, stepGetRadius(step, area), w, h);
}
void drawCallback_FILLSURFACE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
fillSurfaceClip(clip);
void drawCallback_FILLSURFACE(const Common::Rect &area, const DrawStep &step) {
fillSurface();
}
void drawCallback_TRIANGLE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
void drawCallback_TRIANGLE(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawTriangleClip(x, y, w, h, (TriangleOrientation)step.extraData, clip);
drawTriangle(x, y, w, h, (TriangleOrientation)step.extraData);
}
void drawCallback_BEVELSQ(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
void drawCallback_BEVELSQ(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawBeveledSquareClip(x, y, w, h, _bevel, clip);
drawBeveledSquare(x, y, w, h);
}
void drawCallback_TAB(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
void drawCallback_TAB(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawTabClip(x, y, stepGetRadius(step, area), w, h, clip);
drawTab(x, y, stepGetRadius(step, area), w, h);
}
void drawCallback_BITMAP(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
void drawCallback_BITMAP(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
blitKeyBitmapClip(step.blitSrc, Common::Rect(x, y, x + w, y + h), clip);
blitKeyBitmap(step.blitSrc, Common::Point(x, y));
}
void drawCallback_ALPHABITMAP(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
void drawCallback_ALPHABITMAP(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
blitAlphaBitmap(step.blitAlphaSrc, Common::Rect(x, y, x + w, y + h), step.autoscale, step.xAlign, step.yAlign); // TODO
}
void drawCallback_CROSS(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
void drawCallback_CROSS(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h);
drawCrossClip(x, y, w, h, clip);
drawCross(x, y, w, h);
}
void drawCallback_VOID(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {}
void drawCallback_VOID(const Common::Rect &area, const DrawStep &step) {}
/**
* Draws the specified draw step on the screen.
@ -474,8 +470,7 @@ public:
* @param area Zone to paint on
* @param step Pointer to a DrawStep struct.
*/
virtual void drawStep(const Common::Rect &area, const DrawStep &step, uint32 extra = 0);
virtual void drawStepClip(const Common::Rect &area, const Common::Rect &clip, const DrawStep &step, uint32 extra = 0);
virtual void drawStep(const Common::Rect &area, const Common::Rect &clip, const DrawStep &step, uint32 extra = 0);
/**
* Copies the part of the current frame to the system overlay.
@ -509,17 +504,11 @@ public:
virtual void blitSurface(const Graphics::Surface *source, const Common::Rect &r) = 0;
/**
* Blits a given graphics surface into a small area of the current drawing surface.
*
* Note that the given surface is expected to be smaller than the
* active drawing surface, hence the WHOLE source surface will be
* blitted into the active surface, at the position specified by "r".
* Blits a given graphics surface at the specified position of the current drawing surface.
*/
virtual void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) = 0;
virtual void blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) = 0;
virtual void blitSubSurface(const Graphics::Surface *source, const Common::Point &p) = 0;
virtual void blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r) = 0;
virtual void blitKeyBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) = 0;
virtual void blitKeyBitmap(const Graphics::Surface *source, const Common::Point &p) = 0;
virtual void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r,
GUI::ThemeEngine::AutoScaleMode autoscale = GUI::ThemeEngine::kAutoScaleNone,

View File

@ -689,46 +689,23 @@ gradientFillClip(PixelType *ptr, int width, int x, int y, int realX, int realY)
template<typename PixelType>
void VectorRendererSpec<PixelType>::
fillSurface() {
byte *ptr = (byte *)_activeSurface->getPixels();
Common::Rect drawRect(0, 0, _activeSurface->w, _activeSurface->h);
drawRect.clip(_clippingArea);
int h = _activeSurface->h;
int pitch = _activeSurface->pitch;
if (Base::_fillMode == kFillBackground) {
colorFill<PixelType>((PixelType *)ptr, (PixelType *)(ptr + pitch * h), _bgColor);
} else if (Base::_fillMode == kFillForeground) {
colorFill<PixelType>((PixelType *)ptr, (PixelType *)(ptr + pitch * h), _fgColor);
} else if (Base::_fillMode == kFillGradient) {
precalcGradient(h);
for (int i = 0; i < h; i++) {
gradientFill((PixelType *)ptr, _activeSurface->w, 0, i);
ptr += pitch;
}
}
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
fillSurfaceClip(Common::Rect clipping) {
int w = _activeSurface->w;
int h = _activeSurface->h;
if (clipping.isEmpty() || (clipping.left == 0 && clipping.top == 0 && clipping.right == w && clipping.bottom == h)) {
fillSurface();
if (drawRect.isEmpty()) {
return;
}
byte *ptr = (byte *)_activeSurface->getPixels();
int pitch = _activeSurface->pitch;
int h = _activeSurface->h;
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(0, drawRect.top);
if (Base::_fillMode == kFillBackground || Base::_fillMode == kFillForeground) {
PixelType color = (Base::_fillMode == kFillBackground ? _bgColor : _fgColor);
byte *ptrLeft = (ptr + _clippingArea.left), *ptrRight = ptr + _clippingArea.right;
for (int i = 0; i < h; i++) {
if (_clippingArea.top <= i && i < _clippingArea.bottom) {
colorFill<PixelType>((PixelType *)ptrLeft, (PixelType *)ptrRight, color);
}
PixelType *ptrLeft = (ptr + drawRect.left), *ptrRight = ptr + drawRect.right;
for (int i = drawRect.top; i < drawRect.bottom; i++) {
colorFill<PixelType>(ptrLeft, ptrRight, color);
ptrLeft += pitch;
ptrRight += pitch;
@ -737,10 +714,8 @@ fillSurfaceClip(Common::Rect clipping) {
} else if (Base::_fillMode == kFillGradient) {
precalcGradient(h);
for (int i = 0; i < h; i++) {
if (_clippingArea.top <= i && i < _clippingArea.bottom) {
gradientFill((PixelType *)ptr + _clippingArea.left, _clippingArea.width(), 0, i);
}
for (int i = drawRect.top; i < drawRect.bottom; i++) {
gradientFill(ptr + drawRect.left, drawRect.width(), 0, i);
ptr += pitch;
}
@ -781,67 +756,25 @@ blitSurface(const Graphics::Surface *source, const Common::Rect &r) {
template<typename PixelType>
void VectorRendererSpec<PixelType>::
blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) {
byte *dst_ptr = (byte *)_activeSurface->getBasePtr(r.left, r.top);
const byte *src_ptr = (const byte *)source->getPixels();
blitSubSurface(const Graphics::Surface *source, const Common::Point &p) {
Common::Rect drawRect(p.x, p.y, p.x + source->w, p.y + source->h);
drawRect.clip(_clippingArea);
const int dst_pitch = _activeSurface->pitch;
const int src_pitch = source->pitch;
int h = r.height();
const int w = r.width() * sizeof(PixelType);
while (h--) {
memcpy(dst_ptr, src_ptr, w);
dst_ptr += dst_pitch;
src_ptr += src_pitch;
}
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) {
if (clipping.isEmpty() || clipping.contains(r)) {
blitSubSurface(source, r);
if (drawRect.isEmpty()) {
return;
}
int16 x = r.left;
int16 y = r.top;
int sourceOffsetX = drawRect.left - p.x;
int sourceOffsetY = drawRect.top - p.y;
if (r.width() > source->w)
x = x + (r.width() >> 1) - (source->w >> 1);
if (r.height() > source->h)
y = y + (r.height() >> 1) - (source->h >> 1);
int w = source->w, h = source->h;
int usedW = w, usedH = h;
int offsetX = 0, offsetY = 0;
if (x > clipping.right || x + w < clipping.left) return;
if (y > clipping.bottom || y + h < clipping.top) return;
if (x < clipping.left) {
offsetX = clipping.left - x;
usedW -= offsetX;
x = clipping.left;
}
if (y < clipping.top) {
offsetY = clipping.top - y;
usedH -= offsetY;
y = clipping.top;
}
if (usedW > clipping.width()) usedW = clipping.width();
if (usedH > clipping.height()) usedH = clipping.height();
byte *dst_ptr = (byte *)_activeSurface->getBasePtr(x, y);
const byte *src_ptr = (const byte *)source->getBasePtr(offsetX, offsetY);
byte *dst_ptr = (byte *)_activeSurface->getBasePtr(drawRect.left, drawRect.top);
const byte *src_ptr = (const byte *)source->getBasePtr(sourceOffsetX, sourceOffsetY);
const int dst_pitch = _activeSurface->pitch;
const int src_pitch = source->pitch;
int lines = usedH;
const int sz = usedW * sizeof(PixelType);
int lines = drawRect.height();
const int sz = drawRect.width() * sizeof(PixelType);
while (lines--) {
memcpy(dst_ptr, src_ptr, sz);
@ -852,26 +785,27 @@ blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const
template<typename PixelType>
void VectorRendererSpec<PixelType>::
blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r) {
int16 x = r.left;
int16 y = r.top;
blitKeyBitmap(const Graphics::Surface *source, const Common::Point &p) {
Common::Rect drawRect(p.x, p.y, p.x + source->w, p.y + source->h);
drawRect.clip(_clippingArea);
if (r.width() > source->w)
x = x + (r.width() >> 1) - (source->w >> 1);
if (drawRect.isEmpty()) {
return;
}
if (r.height() > source->h)
y = y + (r.height() >> 1) - (source->h >> 1);
int sourceOffsetX = drawRect.left - p.x;
int sourceOffsetY = drawRect.top - p.y;
PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(x, y);
const PixelType *src_ptr = (const PixelType *)source->getPixels();
PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(drawRect.left, drawRect.top);
const PixelType *src_ptr = (const PixelType *)source->getBasePtr(sourceOffsetX, sourceOffsetY);
int dst_pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int src_pitch = source->pitch / source->format.bytesPerPixel;
int w, h = source->h;
int w, h = drawRect.height();
while (h--) {
w = source->w;
w = drawRect.width();
while (w--) {
if (*src_ptr != _bitmapAlphaColor)
@ -881,8 +815,8 @@ blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r) {
src_ptr++;
}
dst_ptr = dst_ptr - source->w + dst_pitch;
src_ptr = src_ptr - source->w + src_pitch;
dst_ptr = dst_ptr - drawRect.width() + dst_pitch;
src_ptr = src_ptr - drawRect.width() + src_pitch;
}
}
@ -920,57 +854,6 @@ blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, GUI
}
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
blitKeyBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) {
if (clipping.isEmpty() || clipping.contains(r)) {
blitKeyBitmap(source, r);
return;
}
int16 x = r.left;
int16 y = r.top;
if (r.width() > source->w)
x = x + (r.width() >> 1) - (source->w >> 1);
if (r.height() > source->h)
y = y + (r.height() >> 1) - (source->h >> 1);
Common::Rect drawRect(x, y, x + source->w, y + source->h);
drawRect.clip(clipping);
if (drawRect.isEmpty()) {
return;
}
int sourceOffsetX = drawRect.left - x;
int sourceOffsetY = drawRect.top - y;
PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(drawRect.left, drawRect.top);
const PixelType *src_ptr = (const PixelType *)source->getBasePtr(sourceOffsetX, sourceOffsetY);
int dst_pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int src_pitch = source->pitch / source->format.bytesPerPixel;
int w, h = drawRect.height();
while (h--) {
w = drawRect.width();
while (w--) {
if (*src_ptr != _bitmapAlphaColor)
*dst_ptr = *src_ptr;
dst_ptr++;
src_ptr++;
}
dst_ptr = dst_ptr - drawRect.width() + dst_pitch;
src_ptr = src_ptr - drawRect.width() + src_pitch;
}
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle) {
@ -1179,7 +1062,6 @@ drawString(const Graphics::Font *font, const Common::String &text, const Common:
}
}
/** LINES **/
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawLine(int x1, int y1, int x2, int y2) {
@ -1208,87 +1090,35 @@ drawLine(int x1, int y1, int x2, int y2) {
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int st = Base::_strokeWidth >> 1;
if (dy == 0) { // horizontal lines
// these can be filled really fast with a single memset.
colorFill<PixelType>(ptr, ptr + dx + 1, (PixelType)_fgColor);
for (int i = 0, p = pitch; i < st; ++i, p += pitch) {
colorFill<PixelType>(ptr + p, ptr + dx + 1 + p, (PixelType)_fgColor);
colorFill<PixelType>(ptr - p, ptr + dx + 1 - p, (PixelType)_fgColor);
}
} else if (dx == 0) { // vertical lines
// these ones use a static pitch increase.
while (y1++ <= y2) {
colorFill<PixelType>(ptr - st, ptr + st, (PixelType)_fgColor);
ptr += pitch;
}
} else if (dx == dy) { // diagonal lines
// these ones also use a fixed pitch increase
pitch += (x2 > x1) ? 1 : -1;
while (dy--) {
colorFill<PixelType>(ptr - st, ptr + st, (PixelType)_fgColor);
ptr += pitch;
}
} else { // generic lines, use the standard algorithm...
drawLineAlg(x1, y1, x2, y2, dx, dy, (PixelType)_fgColor);
}
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawLineClip(int x1, int y1, int x2, int y2, Common::Rect clipping) {
x1 = CLIP(x1, 0, (int)Base::_activeSurface->w);
x2 = CLIP(x2, 0, (int)Base::_activeSurface->w);
y1 = CLIP(y1, 0, (int)Base::_activeSurface->h);
y2 = CLIP(y2, 0, (int)Base::_activeSurface->h);
// we draw from top to bottom
if (y2 < y1) {
SWAP(x1, x2);
SWAP(y1, y2);
}
uint dx = ABS(x2 - x1);
uint dy = ABS(y2 - y1);
// this is a point, not a line. stoopid.
if (dy == 0 && dx == 0)
return;
if (Base::_strokeWidth == 0)
return;
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x1, y1);
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int st = Base::_strokeWidth >> 1;
Common::Rect backup = _clippingArea;
_clippingArea = clipping;
bool needsClipping = !_clippingArea.isEmpty() && (!_clippingArea.contains(x1, y1) || !_clippingArea.contains(x2, y2));
if (!needsClipping) {
drawLine(x1, y1, x2, y2);
_clippingArea = backup;
return;
}
bool useClippingVersions = !_clippingArea.contains(x1, y1) || !_clippingArea.contains(x2, y2);
int ptr_x = x1, ptr_y = y1;
if (dy == 0) { // horizontal lines
colorFillClip<PixelType>(ptr, ptr + dx + 1, (PixelType)_fgColor, x1, y1, _clippingArea);
if (useClippingVersions) {
colorFillClip<PixelType>(ptr, ptr + dx + 1, (PixelType)_fgColor, x1, y1, _clippingArea);
} else {
colorFill<PixelType>(ptr, ptr + dx + 1, (PixelType)_fgColor);
}
for (int i = 0, p = pitch; i < st; ++i, p += pitch) {
colorFillClip<PixelType>(ptr + p, ptr + dx + 1 + p, (PixelType)_fgColor, x1, y1 + p/pitch, _clippingArea);
colorFillClip<PixelType>(ptr - p, ptr + dx + 1 - p, (PixelType)_fgColor, x1, y1 - p/pitch, _clippingArea);
if (useClippingVersions) {
colorFillClip<PixelType>(ptr + p, ptr + dx + 1 + p, (PixelType)_fgColor, x1, y1 + p/pitch, _clippingArea);
colorFillClip<PixelType>(ptr - p, ptr + dx + 1 - p, (PixelType)_fgColor, x1, y1 - p/pitch, _clippingArea);
} else {
colorFill<PixelType>(ptr + p, ptr + dx + 1 + p, (PixelType)_fgColor);
colorFill<PixelType>(ptr - p, ptr + dx + 1 - p, (PixelType)_fgColor);
}
}
} else if (dx == 0) { // vertical lines
// these ones use a static pitch increase.
while (y1++ <= y2) {
colorFillClip<PixelType>(ptr - st, ptr + st, (PixelType)_fgColor, x1 - st, ptr_y, _clippingArea);
if (useClippingVersions) {
colorFillClip<PixelType>(ptr - st, ptr + st, (PixelType)_fgColor, x1 - st, ptr_y, _clippingArea);
} else {
colorFill<PixelType>(ptr - st, ptr + st, (PixelType)_fgColor);
}
ptr += pitch;
++ptr_y;
}
@ -1298,14 +1128,22 @@ drawLineClip(int x1, int y1, int x2, int y2, Common::Rect clipping) {
pitch += (x2 > x1) ? 1 : -1;
while (dy--) {
colorFillClip<PixelType>(ptr - st, ptr + st, (PixelType)_fgColor, ptr_x - st, ptr_y, _clippingArea);
if (useClippingVersions) {
colorFillClip<PixelType>(ptr - st, ptr + st, (PixelType)_fgColor, ptr_x - st, ptr_y, _clippingArea);
} else {
colorFill<PixelType>(ptr - st, ptr + st, (PixelType)_fgColor);
}
ptr += pitch;
++ptr_y;
if (x2 > x1) ++ptr_x; else --ptr_x;
}
} else { // generic lines, use the standard algorithm...
drawLineAlgClip(x1, y1, x2, y2, dx, dy, (PixelType)_fgColor);
if (useClippingVersions) {
drawLineAlgClip(x1, y1, x2, y2, dx, dy, (PixelType)_fgColor);
} else {
drawLineAlg(x1, y1, x2, y2, dx, dy, (PixelType)_fgColor);
}
}
}
@ -1317,47 +1155,7 @@ drawCircle(int x, int y, int r) {
x - r < 0 || y - r < 0 || x == 0 || y == 0 || r <= 0)
return;
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
&& x + r + Base::_shadowOffset < Base::_activeSurface->w
&& y + r + Base::_shadowOffset < Base::_activeSurface->h) {
drawCircleAlg(x + Base::_shadowOffset + 1, y + Base::_shadowOffset + 1, r, 0, kFillForeground);
}
switch (Base::_fillMode) {
case kFillDisabled:
if (Base::_strokeWidth)
drawCircleAlg(x, y, r, _fgColor, kFillDisabled);
break;
case kFillForeground:
drawCircleAlg(x, y, r, _fgColor, kFillForeground);
break;
case kFillBackground:
if (Base::_strokeWidth > 1) {
drawCircleAlg(x, y, r, _fgColor, kFillForeground);
drawCircleAlg(x, y, r - Base::_strokeWidth, _bgColor, kFillBackground);
} else {
drawCircleAlg(x, y, r, _bgColor, kFillBackground);
drawCircleAlg(x, y, r, _fgColor, kFillDisabled);
}
break;
case kFillGradient:
break;
}
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawCircleClip(int x, int y, int r, Common::Rect clipping) {
if (x + r > Base::_activeSurface->w || y + r > Base::_activeSurface->h ||
x - r < 0 || y - r < 0 || x == 0 || y == 0 || r <= 0)
return;
Common::Rect backup = _clippingArea;
_clippingArea = clipping;
bool useClippingVersions = !(_clippingArea.isEmpty() || _clippingArea.contains(Common::Rect(x - r, y - r, x + r, y + r)));
bool useClippingVersions = !_clippingArea.contains(Common::Rect(x - r, y - r, x + r, y + r));
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
&& x + r + Base::_shadowOffset < Base::_activeSurface->w
@ -1408,8 +1206,6 @@ drawCircleClip(int x, int y, int r, Common::Rect clipping) {
case kFillGradient:
break;
}
_clippingArea = backup;
}
/** SQUARES **/
@ -1420,45 +1216,7 @@ drawSquare(int x, int y, int w, int h) {
w <= 0 || h <= 0 || x < 0 || y < 0)
return;
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
&& x + w + Base::_shadowOffset < Base::_activeSurface->w
&& y + h + Base::_shadowOffset < Base::_activeSurface->h) {
drawSquareShadow(x, y, w, h, Base::_shadowOffset);
}
switch (Base::_fillMode) {
case kFillDisabled:
if (Base::_strokeWidth)
drawSquareAlg(x, y, w, h, _fgColor, kFillDisabled);
break;
case kFillForeground:
drawSquareAlg(x, y, w, h, _fgColor, kFillForeground);
break;
case kFillBackground:
drawSquareAlg(x, y, w, h, _bgColor, kFillBackground);
drawSquareAlg(x, y, w, h, _fgColor, kFillDisabled);
break;
case kFillGradient:
VectorRendererSpec::drawSquareAlg(x, y, w, h, 0, kFillGradient);
if (Base::_strokeWidth)
drawSquareAlg(x, y, w, h, _fgColor, kFillDisabled);
break;
}
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawSquareClip(int x, int y, int w, int h, Common::Rect clipping) {
if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h ||
w <= 0 || h <= 0 || x < 0 || y < 0)
return;
Common::Rect backup = _clippingArea;
_clippingArea = clipping;
bool useClippingVersions = !(_clippingArea.isEmpty() || _clippingArea.contains(Common::Rect(x, y, x + w, y + h)));
bool useClippingVersions = !_clippingArea.contains(Common::Rect(x, y, x + w, y + h));
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
&& x + w + Base::_shadowOffset < Base::_activeSurface->w
@ -1506,8 +1264,6 @@ drawSquareClip(int x, int y, int w, int h, Common::Rect clipping) {
}
break;
}
_clippingArea = backup;
}
/** ROUNDED SQUARES **/
@ -1518,38 +1274,13 @@ drawRoundedSquare(int x, int y, int r, int w, int h) {
w <= 0 || h <= 0 || x < 0 || y < 0 || r <= 0)
return;
if ((r * 2) > w || (r * 2) > h)
r = MIN(w /2, h / 2);
if (r <= 0)
return;
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
&& x + w + Base::_shadowOffset + 1 < Base::_activeSurface->w
&& y + h + Base::_shadowOffset + 1 < Base::_activeSurface->h
&& h > (Base::_shadowOffset + 1) * 2) {
drawRoundedSquareShadow(x, y, r, w, h, Base::_shadowOffset);
}
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, Base::_fillMode);
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawRoundedSquareClip(int x, int y, int r, int w, int h, Common::Rect clipping) {
if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h ||
w <= 0 || h <= 0 || x < 0 || y < 0 || r <= 0)
return;
if ((r * 2) > w || (r * 2) > h)
r = MIN(w / 2, h / 2);
if (r <= 0)
return;
Common::Rect backup = _clippingArea;
_clippingArea = clipping;
bool useOriginal = (_clippingArea.isEmpty() || _clippingArea.contains(Common::Rect(x, y, x + w, y + h)));
bool useOriginal = _clippingArea.contains(Common::Rect(x, y, x + w, y + h));
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
&& x + w + Base::_shadowOffset + 1 < Base::_activeSurface->w
@ -1567,8 +1298,6 @@ drawRoundedSquareClip(int x, int y, int r, int w, int h, Common::Rect clipping)
} else {
drawRoundedSquareAlgClip(x, y, r, w, h, _fgColor, Base::_fillMode);
}
_clippingArea = backup;
}
template<typename PixelType>
@ -1578,64 +1307,23 @@ drawTab(int x, int y, int r, int w, int h) {
w <= 0 || h <= 0 || x < 0 || y < 0 || r > w || r > h)
return;
if (r == 0 && Base::_bevel > 0) {
drawBevelTabAlg(x, y, w, h, Base::_bevel, _bevelColor, _fgColor, (Base::_dynamicData >> 16), (Base::_dynamicData & 0xFFFF));
return;
}
if (r == 0) return;
switch (Base::_fillMode) {
case kFillDisabled:
// FIXME: Implement this
return;
case kFillGradient:
case kFillBackground:
// FIXME: This is broken for the AA renderer.
// See the rounded rect alg for how to fix it. (The border should
// be drawn before the interior, both inside drawTabAlg.)
drawTabShadow(x, y, w - 2, h, r);
drawTabAlg(x, y, w - 2, h, r, _bgColor, Base::_fillMode);
if (Base::_strokeWidth)
drawTabAlg(x, y, w, h, r, _fgColor, kFillDisabled, (Base::_dynamicData >> 16), (Base::_dynamicData & 0xFFFF));
break;
case kFillForeground:
drawTabAlg(x, y, w, h, r, _fgColor, Base::_fillMode);
break;
}
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawTabClip(int x, int y, int r, int w, int h, Common::Rect clipping) {
if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h ||
w <= 0 || h <= 0 || x < 0 || y < 0 || r > w || r > h)
return;
Common::Rect backup = _clippingArea;
_clippingArea = clipping;
bool useClippingVersions = !(_clippingArea.isEmpty() || _clippingArea.contains(Common::Rect(x, y, x + w, y + h)));
bool useClippingVersions = !_clippingArea.contains(Common::Rect(x, y, x + w, y + h));
if (r == 0 && Base::_bevel > 0) {
if (useClippingVersions)
drawBevelTabAlgClip(x, y, w, h, Base::_bevel, _bevelColor, _fgColor, (Base::_dynamicData >> 16), (Base::_dynamicData & 0xFFFF));
else
drawBevelTabAlg(x, y, w, h, Base::_bevel, _bevelColor, _fgColor, (Base::_dynamicData >> 16), (Base::_dynamicData & 0xFFFF));
_clippingArea = backup;
return;
}
if (r == 0) {
_clippingArea = backup;
return;
}
switch (Base::_fillMode) {
case kFillDisabled:
// FIXME: Implement this
_clippingArea = backup;
return;
case kFillGradient:
@ -1663,14 +1351,11 @@ drawTabClip(int x, int y, int r, int w, int h, Common::Rect clipping) {
drawTabAlg(x, y, w, h, r, _fgColor, Base::_fillMode);
break;
}
_clippingArea = backup;
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawTriangle(int x, int y, int w, int h, TriangleOrientation orient) {
if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
return;
@ -1690,76 +1375,7 @@ drawTriangle(int x, int y, int w, int h, TriangleOrientation orient) {
if (Base::_dynamicData != 0)
orient = (TriangleOrientation)Base::_dynamicData;
if (w == h) {
int newW = w;
switch (orient) {
case kTriangleUp:
case kTriangleDown:
//drawTriangleFast(x, y, newW, (orient == kTriangleDown), color, Base::_fillMode);
drawTriangleVertAlg(x, y, newW, newW, (orient == kTriangleDown), color, Base::_fillMode);
break;
case kTriangleLeft:
case kTriangleRight:
case kTriangleAuto:
break;
}
if (Base::_strokeWidth > 0)
if (Base::_fillMode == kFillBackground || Base::_fillMode == kFillGradient) {
//drawTriangleFast(x, y, newW, (orient == kTriangleDown), _fgColor, kFillDisabled);
drawTriangleVertAlg(x, y, newW, newW, (orient == kTriangleDown), color, Base::_fillMode);
}
} else {
int newW = w;
int newH = h;
switch (orient) {
case kTriangleUp:
case kTriangleDown:
drawTriangleVertAlg(x, y, newW, newH, (orient == kTriangleDown), color, Base::_fillMode);
break;
case kTriangleLeft:
case kTriangleRight:
case kTriangleAuto:
break;
}
if (Base::_strokeWidth > 0) {
if (Base::_fillMode == kFillBackground || Base::_fillMode == kFillGradient) {
drawTriangleVertAlg(x, y, newW, newH, (orient == kTriangleDown), _fgColor, kFillDisabled);
}
}
}
}
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawTriangleClip(int x, int y, int w, int h, TriangleOrientation orient, Common::Rect clipping) {
if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
return;
PixelType color = 0;
if (Base::_strokeWidth <= 1) {
if (Base::_fillMode == kFillForeground)
color = _fgColor;
else if (Base::_fillMode == kFillBackground)
color = _bgColor;
} else {
if (Base::_fillMode == kFillDisabled)
return;
color = _fgColor;
}
if (Base::_dynamicData != 0)
orient = (TriangleOrientation)Base::_dynamicData;
Common::Rect backup = _clippingArea;
_clippingArea = clipping;
bool useClippingVersions = !(_clippingArea.isEmpty() || _clippingArea.contains(Common::Rect(x, y, x + w, y + h)));
bool useClippingVersions = !_clippingArea.contains(Common::Rect(x, y, x + w, y + h));
if (w == h) {
int newW = w;
@ -1814,8 +1430,6 @@ drawTriangleClip(int x, int y, int w, int h, TriangleOrientation orient, Common:
}
}
}
_clippingArea = backup;
}
@ -2345,7 +1959,7 @@ drawSquareAlgClip(int x, int y, int w, int h, PixelType color, VectorRenderer::F
/** SQUARE ALGORITHM **/
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawBevelSquareAlg(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color, bool fill) {
drawBevelSquareAlg(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color) {
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int i, j;
PixelType *ptr_left;
@ -2405,7 +2019,7 @@ drawBevelSquareAlg(int x, int y, int w, int h, int bevel, PixelType top_color, P
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawBevelSquareAlgClip(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color, bool fill) {
drawBevelSquareAlgClip(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color) {
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int i, j;
PixelType *ptr_left;

View File

@ -51,29 +51,18 @@ public:
VectorRendererSpec(PixelFormat format);
void drawLine(int x1, int y1, int x2, int y2);
void drawLineClip(int x1, int y1, int x2, int y2, Common::Rect clipping);
void drawCircle(int x, int y, int r);
void drawCircleClip(int x, int y, int r, Common::Rect clipping);
void drawSquare(int x, int y, int w, int h);
void drawSquareClip(int x, int y, int w, int h, Common::Rect clipping);
void drawRoundedSquare(int x, int y, int r, int w, int h);
void drawRoundedSquareClip(int x, int y, int r, int w, int h, Common::Rect clipping);
void drawTriangle(int x, int y, int base, int height, TriangleOrientation orient);
void drawTriangleClip(int x, int y, int base, int height, TriangleOrientation orient, Common::Rect clipping);
void drawTab(int x, int y, int r, int w, int h);
void drawTabClip(int x, int y, int r, int w, int h, Common::Rect clipping);
void drawBeveledSquare(int x, int y, int w, int h, int bevel) {
drawBevelSquareAlg(x, y, w, h, bevel, _bevelColor, _fgColor, Base::_fillMode != kFillDisabled);
}
void drawBeveledSquareClip(int x, int y, int w, int h, int bevel, Common::Rect clipping) {
bool useClippingVersions = !(clipping.isEmpty() || clipping.contains(Common::Rect(x, y, x + w, y + h)));
void drawBeveledSquare(int x, int y, int w, int h) {
bool useClippingVersions = !_clippingArea.contains(Common::Rect(x, y, x + w, y + h));
if (useClippingVersions) {
Common::Rect backup = _clippingArea;
_clippingArea = clipping;
drawBevelSquareAlgClip(x, y, w, h, bevel, _bevelColor, _fgColor, Base::_fillMode != kFillDisabled);
_clippingArea = backup;
drawBevelSquareAlgClip(x, y, w, h, _bevel, _bevelColor, _fgColor);
} else {
drawBevelSquareAlg(x, y, w, h, bevel, _bevelColor, _fgColor, Base::_fillMode != kFillDisabled);
drawBevelSquareAlg(x, y, w, h, _bevel, _bevelColor, _fgColor);
}
}
void drawString(const Graphics::Font *font, const Common::String &text,
@ -84,17 +73,15 @@ public:
void setBgColor(uint8 r, uint8 g, uint8 b) { _bgColor = _format.RGBToColor(r, g, b); }
void setBevelColor(uint8 r, uint8 g, uint8 b) { _bevelColor = _format.RGBToColor(r, g, b); }
void setGradientColors(uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2);
void setClippingRect(const Common::Rect &clippingArea) override { _clippingArea = clippingArea; }
void copyFrame(OSystem *sys, const Common::Rect &r);
void copyWholeFrame(OSystem *sys) { copyFrame(sys, Common::Rect(0, 0, _activeSurface->w, _activeSurface->h)); }
void fillSurface();
void fillSurfaceClip(Common::Rect clipping);
void blitSurface(const Graphics::Surface *source, const Common::Rect &r);
void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r);
void blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping);
void blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r);
void blitKeyBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping);
void blitSubSurface(const Graphics::Surface *source, const Common::Point &p);
void blitKeyBitmap(const Graphics::Surface *source, const Common::Point &p);
void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r,
GUI::ThemeEngine::AutoScaleMode autoscale = GUI::ThemeEngine::kAutoScaleNone,
Graphics::DrawStep::VectorAlignment xAlign = Graphics::DrawStep::kVectorAlignManual,
@ -223,10 +210,10 @@ protected:
bool inverted, PixelType color, FillMode fill_m);
virtual void drawBevelSquareAlg(int x, int y, int w, int h,
int bevel, PixelType top_color, PixelType bottom_color, bool fill);
int bevel, PixelType top_color, PixelType bottom_color);
virtual void drawBevelSquareAlgClip(int x, int y, int w, int h,
int bevel, PixelType top_color, PixelType bottom_color, bool fill);
int bevel, PixelType top_color, PixelType bottom_color);
virtual void drawTabAlg(int x, int y, int w, int h, int r,
PixelType color, VectorRenderer::FillMode fill_m,

View File

@ -875,7 +875,7 @@ void ThemeEngine::drawDD(DrawData type, const Common::Rect &r, uint32 dynamic, b
if (drawData->_layer == _layerToDraw) {
Common::List<Graphics::DrawStep>::const_iterator step;
for (step = drawData->_steps.begin(); step != drawData->_steps.end(); ++step) {
_vectorRenderer->drawStepClip(area, _clip, *step, dynamic);
_vectorRenderer->drawStep(area, _clip, *step, dynamic);
}
addDirtyRect(extendedRect);
@ -912,23 +912,6 @@ void ThemeEngine::drawDDText(TextData type, TextColor color, const Common::Rect
addDirtyRect(dirty);
}
void ThemeEngine::drawBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha) {
if (_layerToDraw == kDrawLayerBackground)
return;
Common::Rect area = r;
area.clip(_screen.w, _screen.h);
if (alpha)
_vectorRenderer->blitKeyBitmapClip(bitmap, area, _clip);
else
_vectorRenderer->blitSubSurfaceClip(bitmap, area, _clip);
Common::Rect dirtyRect = area;
dirtyRect.clip(_clip);
addDirtyRect(dirtyRect);
}
/**********************************************************
* Widget drawing functions
*********************************************************/
@ -1123,11 +1106,22 @@ void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &s
}
}
void ThemeEngine::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, bool themeTrans) {
void ThemeEngine::drawSurface(const Common::Point &p, const Graphics::Surface &surface, bool themeTrans) {
if (!ready())
return;
drawBitmap(&surface, r, themeTrans);
if (_layerToDraw == kDrawLayerBackground)
return;
_vectorRenderer->setClippingRect(_clip);
if (themeTrans)
_vectorRenderer->blitKeyBitmap(&surface, p);
else
_vectorRenderer->blitSubSurface(&surface, p);
Common::Rect dirtyRect = Common::Rect(p.x, p.y, p.x + surface.w, p.y + surface.h);
dirtyRect.clip(_clip);
addDirtyRect(dirtyRect);
}
void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background) {
@ -1911,4 +1905,8 @@ Common::Rect ThemeEngine::swapClipRect(const Common::Rect &newRect) {
return oldRect;
}
void ThemeEngine::disableClipRect() {
_clip = Common::Rect(_screen.w, _screen.h);
}
} // End of namespace GUI.

View File

@ -387,6 +387,11 @@ public:
*/
Common::Rect swapClipRect(const Common::Rect &newRect);
/**
* Set the clipping rect to allow rendering on the whole surface.
*/
void disableClipRect();
/** @name WIDGET DRAWING METHODS */
//@{
@ -395,7 +400,7 @@ public:
void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled,
uint16 hints = 0);
void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, bool themeTrans = false);
void drawSurface(const Common::Point &p, const Graphics::Surface &surface, bool themeTrans = false);
void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled);
@ -633,7 +638,6 @@ protected:
bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft,
TextAlignVertical alignV = kTextAlignVTop, int deltax = 0,
const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0));
void drawBitmap(const Graphics::Surface *bitmap, const Common::Rect &clippingRect, bool alpha);
/**
* DEBUG: Draws a white square and writes some text next to it.

View File

@ -163,6 +163,7 @@ void Dialog::drawDialog(DrawLayer layerToDraw) {
if (!isVisible())
return;
g_gui.theme()->disableClipRect();
g_gui.theme()->_layerToDraw = layerToDraw;
g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _backgroundType);

View File

@ -482,7 +482,7 @@ void PicButtonWidget::drawWidget() {
const int x = _x + (_w - gfx->w) / 2;
const int y = _y + (_h - gfx->h) / 2;
g_gui.theme()->drawSurface(Common::Rect(x, y, x + gfx->w, y + gfx->h), *gfx, _transparency);
g_gui.theme()->drawSurface(Common::Point(x, y), *gfx, _transparency);
}
}
@ -733,7 +733,7 @@ void GraphicsWidget::drawWidget() {
const int x = _x + (_w - _gfx.w) / 2;
const int y = _y + (_h - _gfx.h) / 2;
g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), _gfx, _transparency);
g_gui.theme()->drawSurface(Common::Point(x, y), _gfx, _transparency);
}
}