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:
parent
b87ebdce21
commit
1d764bd787
8 changed files with 149 additions and 582 deletions
|
@ -32,34 +32,7 @@ namespace Graphics {
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
* DRAWSTEP handling functions
|
* DRAWSTEP handling functions
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
void VectorRenderer::drawStep(const Common::Rect &area, 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);
|
|
||||||
|
|
||||||
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) {
|
|
||||||
|
|
||||||
if (step.bgColor.set)
|
if (step.bgColor.set)
|
||||||
setBgColor(step.bgColor.r, step.bgColor.g, step.bgColor.b);
|
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);
|
setGradientFactor(step.factor);
|
||||||
setStrokeWidth(step.stroke);
|
setStrokeWidth(step.stroke);
|
||||||
setFillMode((FillMode)step.fillMode);
|
setFillMode((FillMode)step.fillMode);
|
||||||
|
setClippingRect(clip);
|
||||||
|
|
||||||
_dynamicData = extra;
|
_dynamicData = extra;
|
||||||
|
|
||||||
(this->*(step.drawingCall))(area, step, clip);
|
(this->*(step.drawingCall))(area, step);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VectorRenderer::stepGetRadius(const DrawStep &step, const Common::Rect &area) {
|
int VectorRenderer::stepGetRadius(const DrawStep &step, const Common::Rect &area) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ class VectorRenderer;
|
||||||
struct DrawStep;
|
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 {
|
struct DrawStep {
|
||||||
|
@ -165,7 +165,6 @@ public:
|
||||||
* @param y2 Vertical (Y) coordinate for the line end
|
* @param y2 Vertical (Y) coordinate for the line end
|
||||||
*/
|
*/
|
||||||
virtual void drawLine(int x1, int y1, int x2, int y2) = 0;
|
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.
|
* Draws a circle centered at (x,y) with radius r.
|
||||||
|
@ -175,7 +174,6 @@ public:
|
||||||
* @param r Radius of the circle.
|
* @param r Radius of the circle.
|
||||||
*/
|
*/
|
||||||
virtual void drawCircle(int x, int y, int r) = 0;
|
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.
|
* Draws a square starting at (x,y) with the given width and height.
|
||||||
|
@ -186,7 +184,6 @@ public:
|
||||||
* @param h Height of the square
|
* @param h Height of the square
|
||||||
*/
|
*/
|
||||||
virtual void drawSquare(int x, int y, int w, int h) = 0;
|
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.
|
* 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.
|
* @param r Radius of the corners.
|
||||||
*/
|
*/
|
||||||
virtual void drawRoundedSquare(int x, int y, int r, int w, int h) = 0;
|
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.
|
* Draws a triangle starting at (x,y) with the given base and height.
|
||||||
|
@ -213,7 +209,6 @@ public:
|
||||||
* @param orient Orientation of the triangle.
|
* @param orient Orientation of the triangle.
|
||||||
*/
|
*/
|
||||||
virtual void drawTriangle(int x, int y, int base, int height, TriangleOrientation orient) = 0;
|
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.
|
* Draws a beveled square like the ones in the Classic GUI themes.
|
||||||
|
@ -226,8 +221,7 @@ public:
|
||||||
* @param h Height of the square
|
* @param h Height of the square
|
||||||
* @param bevel Amount of bevel. Must be positive.
|
* @param bevel Amount of bevel. Must be positive.
|
||||||
*/
|
*/
|
||||||
virtual void drawBeveledSquare(int x, int y, int w, int h, int bevel) = 0;
|
virtual void drawBeveledSquare(int x, int y, int w, int h) = 0;
|
||||||
virtual void drawBeveledSquareClip(int x, int y, int w, int h, int bevel, Common::Rect clipping) = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a tab-like shape, specially thought for the Tab widget.
|
* 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).
|
* @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 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.
|
* Simple helper function to draw a cross.
|
||||||
|
@ -252,11 +244,6 @@ public:
|
||||||
drawLine(x + w, y, x, y + h);
|
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.
|
* Set the active foreground painting color for the renderer.
|
||||||
* All the foreground drawing from then on will be done with that color, unless
|
* 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.
|
* Defaults to using the active Foreground color for filling.
|
||||||
*/
|
*/
|
||||||
virtual void fillSurface() = 0;
|
virtual void fillSurface() = 0;
|
||||||
virtual void fillSurfaceClip(Common::Rect clipping) = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the active surface.
|
* Clears the active surface.
|
||||||
|
@ -383,6 +369,16 @@ public:
|
||||||
_gradientFactor = factor;
|
_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
|
* Translates the position data inside a DrawStep into actual
|
||||||
* screen drawing positions.
|
* screen drawing positions.
|
||||||
|
@ -398,74 +394,74 @@ public:
|
||||||
/**
|
/**
|
||||||
* DrawStep callback functions for each drawing feature
|
* 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;
|
uint16 x, y, w, h, radius;
|
||||||
|
|
||||||
radius = stepGetRadius(step, area);
|
radius = stepGetRadius(step, area);
|
||||||
stepGetPositions(step, area, x, y, w, h);
|
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;
|
uint16 x, y, w, h;
|
||||||
stepGetPositions(step, area, 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;
|
uint16 x, y, w, h;
|
||||||
stepGetPositions(step, area, 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;
|
uint16 x, y, w, h;
|
||||||
stepGetPositions(step, area, 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) {
|
void drawCallback_FILLSURFACE(const Common::Rect &area, const DrawStep &step) {
|
||||||
fillSurfaceClip(clip);
|
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;
|
uint16 x, y, w, h;
|
||||||
stepGetPositions(step, area, 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;
|
uint16 x, y, w, h;
|
||||||
stepGetPositions(step, area, 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;
|
uint16 x, y, w, h;
|
||||||
stepGetPositions(step, area, 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;
|
uint16 x, y, w, h;
|
||||||
stepGetPositions(step, area, 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;
|
uint16 x, y, w, h;
|
||||||
stepGetPositions(step, area, 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
|
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;
|
uint16 x, y, w, h;
|
||||||
stepGetPositions(step, area, 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.
|
* Draws the specified draw step on the screen.
|
||||||
|
@ -474,8 +470,7 @@ public:
|
||||||
* @param area Zone to paint on
|
* @param area Zone to paint on
|
||||||
* @param step Pointer to a DrawStep struct.
|
* @param step Pointer to a DrawStep struct.
|
||||||
*/
|
*/
|
||||||
virtual void drawStep(const Common::Rect &area, const DrawStep &step, uint32 extra = 0);
|
virtual void drawStep(const Common::Rect &area, const Common::Rect &clip, const DrawStep &step, uint32 extra = 0);
|
||||||
virtual void drawStepClip(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.
|
* 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;
|
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.
|
* Blits a given graphics surface at the specified position 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".
|
|
||||||
*/
|
*/
|
||||||
virtual void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) = 0;
|
virtual void blitSubSurface(const Graphics::Surface *source, const Common::Point &p) = 0;
|
||||||
virtual void blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) = 0;
|
|
||||||
|
|
||||||
virtual void blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r) = 0;
|
virtual void blitKeyBitmap(const Graphics::Surface *source, const Common::Point &p) = 0;
|
||||||
virtual void blitKeyBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) = 0;
|
|
||||||
|
|
||||||
virtual void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r,
|
virtual void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r,
|
||||||
GUI::ThemeEngine::AutoScaleMode autoscale = GUI::ThemeEngine::kAutoScaleNone,
|
GUI::ThemeEngine::AutoScaleMode autoscale = GUI::ThemeEngine::kAutoScaleNone,
|
||||||
|
|
|
@ -689,46 +689,23 @@ gradientFillClip(PixelType *ptr, int width, int x, int y, int realX, int realY)
|
||||||
template<typename PixelType>
|
template<typename PixelType>
|
||||||
void VectorRendererSpec<PixelType>::
|
void VectorRendererSpec<PixelType>::
|
||||||
fillSurface() {
|
fillSurface() {
|
||||||
byte *ptr = (byte *)_activeSurface->getPixels();
|
Common::Rect drawRect(0, 0, _activeSurface->w, _activeSurface->h);
|
||||||
|
drawRect.clip(_clippingArea);
|
||||||
|
|
||||||
int h = _activeSurface->h;
|
if (drawRect.isEmpty()) {
|
||||||
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();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte *ptr = (byte *)_activeSurface->getPixels();
|
int h = _activeSurface->h;
|
||||||
int pitch = _activeSurface->pitch;
|
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
|
||||||
|
|
||||||
|
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(0, drawRect.top);
|
||||||
|
|
||||||
if (Base::_fillMode == kFillBackground || Base::_fillMode == kFillForeground) {
|
if (Base::_fillMode == kFillBackground || Base::_fillMode == kFillForeground) {
|
||||||
PixelType color = (Base::_fillMode == kFillBackground ? _bgColor : _fgColor);
|
PixelType color = (Base::_fillMode == kFillBackground ? _bgColor : _fgColor);
|
||||||
byte *ptrLeft = (ptr + _clippingArea.left), *ptrRight = ptr + _clippingArea.right;
|
PixelType *ptrLeft = (ptr + drawRect.left), *ptrRight = ptr + drawRect.right;
|
||||||
for (int i = 0; i < h; i++) {
|
for (int i = drawRect.top; i < drawRect.bottom; i++) {
|
||||||
if (_clippingArea.top <= i && i < _clippingArea.bottom) {
|
colorFill<PixelType>(ptrLeft, ptrRight, color);
|
||||||
colorFill<PixelType>((PixelType *)ptrLeft, (PixelType *)ptrRight, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
ptrLeft += pitch;
|
ptrLeft += pitch;
|
||||||
ptrRight += pitch;
|
ptrRight += pitch;
|
||||||
|
@ -737,10 +714,8 @@ fillSurfaceClip(Common::Rect clipping) {
|
||||||
} else if (Base::_fillMode == kFillGradient) {
|
} else if (Base::_fillMode == kFillGradient) {
|
||||||
precalcGradient(h);
|
precalcGradient(h);
|
||||||
|
|
||||||
for (int i = 0; i < h; i++) {
|
for (int i = drawRect.top; i < drawRect.bottom; i++) {
|
||||||
if (_clippingArea.top <= i && i < _clippingArea.bottom) {
|
gradientFill(ptr + drawRect.left, drawRect.width(), 0, i);
|
||||||
gradientFill((PixelType *)ptr + _clippingArea.left, _clippingArea.width(), 0, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr += pitch;
|
ptr += pitch;
|
||||||
}
|
}
|
||||||
|
@ -781,67 +756,25 @@ blitSurface(const Graphics::Surface *source, const Common::Rect &r) {
|
||||||
|
|
||||||
template<typename PixelType>
|
template<typename PixelType>
|
||||||
void VectorRendererSpec<PixelType>::
|
void VectorRendererSpec<PixelType>::
|
||||||
blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) {
|
blitSubSurface(const Graphics::Surface *source, const Common::Point &p) {
|
||||||
byte *dst_ptr = (byte *)_activeSurface->getBasePtr(r.left, r.top);
|
Common::Rect drawRect(p.x, p.y, p.x + source->w, p.y + source->h);
|
||||||
const byte *src_ptr = (const byte *)source->getPixels();
|
drawRect.clip(_clippingArea);
|
||||||
|
|
||||||
const int dst_pitch = _activeSurface->pitch;
|
if (drawRect.isEmpty()) {
|
||||||
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);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16 x = r.left;
|
int sourceOffsetX = drawRect.left - p.x;
|
||||||
int16 y = r.top;
|
int sourceOffsetY = drawRect.top - p.y;
|
||||||
|
|
||||||
if (r.width() > source->w)
|
byte *dst_ptr = (byte *)_activeSurface->getBasePtr(drawRect.left, drawRect.top);
|
||||||
x = x + (r.width() >> 1) - (source->w >> 1);
|
const byte *src_ptr = (const byte *)source->getBasePtr(sourceOffsetX, sourceOffsetY);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
const int dst_pitch = _activeSurface->pitch;
|
const int dst_pitch = _activeSurface->pitch;
|
||||||
const int src_pitch = source->pitch;
|
const int src_pitch = source->pitch;
|
||||||
|
|
||||||
int lines = usedH;
|
int lines = drawRect.height();
|
||||||
const int sz = usedW * sizeof(PixelType);
|
const int sz = drawRect.width() * sizeof(PixelType);
|
||||||
|
|
||||||
while (lines--) {
|
while (lines--) {
|
||||||
memcpy(dst_ptr, src_ptr, sz);
|
memcpy(dst_ptr, src_ptr, sz);
|
||||||
|
@ -852,26 +785,27 @@ blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const
|
||||||
|
|
||||||
template<typename PixelType>
|
template<typename PixelType>
|
||||||
void VectorRendererSpec<PixelType>::
|
void VectorRendererSpec<PixelType>::
|
||||||
blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r) {
|
blitKeyBitmap(const Graphics::Surface *source, const Common::Point &p) {
|
||||||
int16 x = r.left;
|
Common::Rect drawRect(p.x, p.y, p.x + source->w, p.y + source->h);
|
||||||
int16 y = r.top;
|
drawRect.clip(_clippingArea);
|
||||||
|
|
||||||
if (r.width() > source->w)
|
if (drawRect.isEmpty()) {
|
||||||
x = x + (r.width() >> 1) - (source->w >> 1);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (r.height() > source->h)
|
int sourceOffsetX = drawRect.left - p.x;
|
||||||
y = y + (r.height() >> 1) - (source->h >> 1);
|
int sourceOffsetY = drawRect.top - p.y;
|
||||||
|
|
||||||
PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(x, y);
|
PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(drawRect.left, drawRect.top);
|
||||||
const PixelType *src_ptr = (const PixelType *)source->getPixels();
|
const PixelType *src_ptr = (const PixelType *)source->getBasePtr(sourceOffsetX, sourceOffsetY);
|
||||||
|
|
||||||
int dst_pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
|
int dst_pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
|
||||||
int src_pitch = source->pitch / source->format.bytesPerPixel;
|
int src_pitch = source->pitch / source->format.bytesPerPixel;
|
||||||
|
|
||||||
int w, h = source->h;
|
int w, h = drawRect.height();
|
||||||
|
|
||||||
while (h--) {
|
while (h--) {
|
||||||
w = source->w;
|
w = drawRect.width();
|
||||||
|
|
||||||
while (w--) {
|
while (w--) {
|
||||||
if (*src_ptr != _bitmapAlphaColor)
|
if (*src_ptr != _bitmapAlphaColor)
|
||||||
|
@ -881,8 +815,8 @@ blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r) {
|
||||||
src_ptr++;
|
src_ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
dst_ptr = dst_ptr - source->w + dst_pitch;
|
dst_ptr = dst_ptr - drawRect.width() + dst_pitch;
|
||||||
src_ptr = src_ptr - source->w + src_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>
|
template<typename PixelType>
|
||||||
void VectorRendererSpec<PixelType>::
|
void VectorRendererSpec<PixelType>::
|
||||||
applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle) {
|
applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle) {
|
||||||
|
@ -1179,7 +1062,6 @@ drawString(const Graphics::Font *font, const Common::String &text, const Common:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** LINES **/
|
|
||||||
template<typename PixelType>
|
template<typename PixelType>
|
||||||
void VectorRendererSpec<PixelType>::
|
void VectorRendererSpec<PixelType>::
|
||||||
drawLine(int x1, int y1, int x2, int y2) {
|
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 pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
|
||||||
int st = Base::_strokeWidth >> 1;
|
int st = Base::_strokeWidth >> 1;
|
||||||
|
|
||||||
if (dy == 0) { // horizontal lines
|
bool useClippingVersions = !_clippingArea.contains(x1, y1) || !_clippingArea.contains(x2, y2);
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ptr_x = x1, ptr_y = y1;
|
int ptr_x = x1, ptr_y = y1;
|
||||||
|
|
||||||
if (dy == 0) { // horizontal lines
|
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) {
|
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);
|
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);
|
||||||
|
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
|
} else if (dx == 0) { // vertical lines
|
||||||
// these ones use a static pitch increase.
|
// these ones use a static pitch increase.
|
||||||
while (y1++ <= y2) {
|
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 += pitch;
|
||||||
++ptr_y;
|
++ptr_y;
|
||||||
}
|
}
|
||||||
|
@ -1298,14 +1128,22 @@ drawLineClip(int x1, int y1, int x2, int y2, Common::Rect clipping) {
|
||||||
pitch += (x2 > x1) ? 1 : -1;
|
pitch += (x2 > x1) ? 1 : -1;
|
||||||
|
|
||||||
while (dy--) {
|
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 += pitch;
|
||||||
++ptr_y;
|
++ptr_y;
|
||||||
if (x2 > x1) ++ptr_x; else --ptr_x;
|
if (x2 > x1) ++ptr_x; else --ptr_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // generic lines, use the standard algorithm...
|
} 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)
|
x - r < 0 || y - r < 0 || x == 0 || y == 0 || r <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
|
bool useClippingVersions = !_clippingArea.contains(Common::Rect(x - r, y - r, x + r, y + r));
|
||||||
&& 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)));
|
|
||||||
|
|
||||||
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
|
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
|
||||||
&& x + r + Base::_shadowOffset < Base::_activeSurface->w
|
&& x + r + Base::_shadowOffset < Base::_activeSurface->w
|
||||||
|
@ -1408,8 +1206,6 @@ drawCircleClip(int x, int y, int r, Common::Rect clipping) {
|
||||||
case kFillGradient:
|
case kFillGradient:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_clippingArea = backup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** SQUARES **/
|
/** SQUARES **/
|
||||||
|
@ -1420,45 +1216,7 @@ drawSquare(int x, int y, int w, int h) {
|
||||||
w <= 0 || h <= 0 || x < 0 || y < 0)
|
w <= 0 || h <= 0 || x < 0 || y < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
|
bool useClippingVersions = !_clippingArea.contains(Common::Rect(x, y, x + w, y + h));
|
||||||
&& 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)));
|
|
||||||
|
|
||||||
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
|
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
|
||||||
&& x + w + Base::_shadowOffset < Base::_activeSurface->w
|
&& x + w + Base::_shadowOffset < Base::_activeSurface->w
|
||||||
|
@ -1506,8 +1264,6 @@ drawSquareClip(int x, int y, int w, int h, Common::Rect clipping) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_clippingArea = backup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ROUNDED SQUARES **/
|
/** 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)
|
w <= 0 || h <= 0 || x < 0 || y < 0 || r <= 0)
|
||||||
return;
|
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)
|
if ((r * 2) > w || (r * 2) > h)
|
||||||
r = MIN(w / 2, h / 2);
|
r = MIN(w / 2, h / 2);
|
||||||
|
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Common::Rect backup = _clippingArea;
|
bool useOriginal = _clippingArea.contains(Common::Rect(x, y, x + w, y + h));
|
||||||
_clippingArea = clipping;
|
|
||||||
bool useOriginal = (_clippingArea.isEmpty() || _clippingArea.contains(Common::Rect(x, y, x + w, y + h)));
|
|
||||||
|
|
||||||
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
|
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
|
||||||
&& x + w + Base::_shadowOffset + 1 < Base::_activeSurface->w
|
&& 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 {
|
} else {
|
||||||
drawRoundedSquareAlgClip(x, y, r, w, h, _fgColor, Base::_fillMode);
|
drawRoundedSquareAlgClip(x, y, r, w, h, _fgColor, Base::_fillMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
_clippingArea = backup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename PixelType>
|
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)
|
w <= 0 || h <= 0 || x < 0 || y < 0 || r > w || r > h)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (r == 0 && Base::_bevel > 0) {
|
bool useClippingVersions = !_clippingArea.contains(Common::Rect(x, y, x + w, y + h));
|
||||||
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)));
|
|
||||||
|
|
||||||
if (r == 0 && Base::_bevel > 0) {
|
if (r == 0 && Base::_bevel > 0) {
|
||||||
if (useClippingVersions)
|
if (useClippingVersions)
|
||||||
drawBevelTabAlgClip(x, y, w, h, Base::_bevel, _bevelColor, _fgColor, (Base::_dynamicData >> 16), (Base::_dynamicData & 0xFFFF));
|
drawBevelTabAlgClip(x, y, w, h, Base::_bevel, _bevelColor, _fgColor, (Base::_dynamicData >> 16), (Base::_dynamicData & 0xFFFF));
|
||||||
else
|
else
|
||||||
drawBevelTabAlg(x, y, w, h, Base::_bevel, _bevelColor, _fgColor, (Base::_dynamicData >> 16), (Base::_dynamicData & 0xFFFF));
|
drawBevelTabAlg(x, y, w, h, Base::_bevel, _bevelColor, _fgColor, (Base::_dynamicData >> 16), (Base::_dynamicData & 0xFFFF));
|
||||||
_clippingArea = backup;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
_clippingArea = backup;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (Base::_fillMode) {
|
switch (Base::_fillMode) {
|
||||||
case kFillDisabled:
|
case kFillDisabled:
|
||||||
// FIXME: Implement this
|
// FIXME: Implement this
|
||||||
_clippingArea = backup;
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case kFillGradient:
|
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);
|
drawTabAlg(x, y, w, h, r, _fgColor, Base::_fillMode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_clippingArea = backup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename PixelType>
|
template<typename PixelType>
|
||||||
void VectorRendererSpec<PixelType>::
|
void VectorRendererSpec<PixelType>::
|
||||||
drawTriangle(int x, int y, int w, int h, TriangleOrientation orient) {
|
drawTriangle(int x, int y, int w, int h, TriangleOrientation orient) {
|
||||||
|
|
||||||
if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
|
if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1690,76 +1375,7 @@ drawTriangle(int x, int y, int w, int h, TriangleOrientation orient) {
|
||||||
if (Base::_dynamicData != 0)
|
if (Base::_dynamicData != 0)
|
||||||
orient = (TriangleOrientation)Base::_dynamicData;
|
orient = (TriangleOrientation)Base::_dynamicData;
|
||||||
|
|
||||||
if (w == h) {
|
bool useClippingVersions = !_clippingArea.contains(Common::Rect(x, y, x + w, y + 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)));
|
|
||||||
|
|
||||||
if (w == h) {
|
if (w == h) {
|
||||||
int newW = w;
|
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 **/
|
/** SQUARE ALGORITHM **/
|
||||||
template<typename PixelType>
|
template<typename PixelType>
|
||||||
void VectorRendererSpec<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 pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
|
||||||
int i, j;
|
int i, j;
|
||||||
PixelType *ptr_left;
|
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>
|
template<typename PixelType>
|
||||||
void VectorRendererSpec<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 pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
|
||||||
int i, j;
|
int i, j;
|
||||||
PixelType *ptr_left;
|
PixelType *ptr_left;
|
||||||
|
|
|
@ -51,29 +51,18 @@ public:
|
||||||
VectorRendererSpec(PixelFormat format);
|
VectorRendererSpec(PixelFormat format);
|
||||||
|
|
||||||
void drawLine(int x1, int y1, int x2, int y2);
|
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 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 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 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 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 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) {
|
void drawBeveledSquare(int x, int y, int w, int h) {
|
||||||
drawBevelSquareAlg(x, y, w, h, bevel, _bevelColor, _fgColor, Base::_fillMode != kFillDisabled);
|
bool useClippingVersions = !_clippingArea.contains(Common::Rect(x, y, x + w, y + h));
|
||||||
}
|
|
||||||
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)));
|
|
||||||
if (useClippingVersions) {
|
if (useClippingVersions) {
|
||||||
Common::Rect backup = _clippingArea;
|
drawBevelSquareAlgClip(x, y, w, h, _bevel, _bevelColor, _fgColor);
|
||||||
_clippingArea = clipping;
|
|
||||||
drawBevelSquareAlgClip(x, y, w, h, bevel, _bevelColor, _fgColor, Base::_fillMode != kFillDisabled);
|
|
||||||
_clippingArea = backup;
|
|
||||||
} else {
|
} 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,
|
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 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 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 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 copyFrame(OSystem *sys, const Common::Rect &r);
|
||||||
void copyWholeFrame(OSystem *sys) { copyFrame(sys, Common::Rect(0, 0, _activeSurface->w, _activeSurface->h)); }
|
void copyWholeFrame(OSystem *sys) { copyFrame(sys, Common::Rect(0, 0, _activeSurface->w, _activeSurface->h)); }
|
||||||
|
|
||||||
void fillSurface();
|
void fillSurface();
|
||||||
void fillSurfaceClip(Common::Rect clipping);
|
|
||||||
void blitSurface(const Graphics::Surface *source, const Common::Rect &r);
|
void blitSurface(const Graphics::Surface *source, const Common::Rect &r);
|
||||||
void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r);
|
void blitSubSurface(const Graphics::Surface *source, const Common::Point &p);
|
||||||
void blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping);
|
void blitKeyBitmap(const Graphics::Surface *source, const Common::Point &p);
|
||||||
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 blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r,
|
void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r,
|
||||||
GUI::ThemeEngine::AutoScaleMode autoscale = GUI::ThemeEngine::kAutoScaleNone,
|
GUI::ThemeEngine::AutoScaleMode autoscale = GUI::ThemeEngine::kAutoScaleNone,
|
||||||
Graphics::DrawStep::VectorAlignment xAlign = Graphics::DrawStep::kVectorAlignManual,
|
Graphics::DrawStep::VectorAlignment xAlign = Graphics::DrawStep::kVectorAlignManual,
|
||||||
|
@ -223,10 +210,10 @@ protected:
|
||||||
bool inverted, PixelType color, FillMode fill_m);
|
bool inverted, PixelType color, FillMode fill_m);
|
||||||
|
|
||||||
virtual void drawBevelSquareAlg(int x, int y, int w, int h,
|
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,
|
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,
|
virtual void drawTabAlg(int x, int y, int w, int h, int r,
|
||||||
PixelType color, VectorRenderer::FillMode fill_m,
|
PixelType color, VectorRenderer::FillMode fill_m,
|
||||||
|
|
|
@ -875,7 +875,7 @@ void ThemeEngine::drawDD(DrawData type, const Common::Rect &r, uint32 dynamic, b
|
||||||
if (drawData->_layer == _layerToDraw) {
|
if (drawData->_layer == _layerToDraw) {
|
||||||
Common::List<Graphics::DrawStep>::const_iterator step;
|
Common::List<Graphics::DrawStep>::const_iterator step;
|
||||||
for (step = drawData->_steps.begin(); step != drawData->_steps.end(); ++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);
|
addDirtyRect(extendedRect);
|
||||||
|
@ -912,23 +912,6 @@ void ThemeEngine::drawDDText(TextData type, TextColor color, const Common::Rect
|
||||||
addDirtyRect(dirty);
|
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
|
* 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())
|
if (!ready())
|
||||||
return;
|
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) {
|
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;
|
return oldRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThemeEngine::disableClipRect() {
|
||||||
|
_clip = Common::Rect(_screen.w, _screen.h);
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace GUI.
|
} // End of namespace GUI.
|
||||||
|
|
|
@ -387,6 +387,11 @@ public:
|
||||||
*/
|
*/
|
||||||
Common::Rect swapClipRect(const Common::Rect &newRect);
|
Common::Rect swapClipRect(const Common::Rect &newRect);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the clipping rect to allow rendering on the whole surface.
|
||||||
|
*/
|
||||||
|
void disableClipRect();
|
||||||
|
|
||||||
/** @name WIDGET DRAWING METHODS */
|
/** @name WIDGET DRAWING METHODS */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
|
@ -395,7 +400,7 @@ public:
|
||||||
void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled,
|
void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled,
|
||||||
uint16 hints = 0);
|
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);
|
void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled);
|
||||||
|
|
||||||
|
@ -633,7 +638,6 @@ protected:
|
||||||
bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft,
|
bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft,
|
||||||
TextAlignVertical alignV = kTextAlignVTop, int deltax = 0,
|
TextAlignVertical alignV = kTextAlignVTop, int deltax = 0,
|
||||||
const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 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.
|
* DEBUG: Draws a white square and writes some text next to it.
|
||||||
|
|
|
@ -163,6 +163,7 @@ void Dialog::drawDialog(DrawLayer layerToDraw) {
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
g_gui.theme()->disableClipRect();
|
||||||
g_gui.theme()->_layerToDraw = layerToDraw;
|
g_gui.theme()->_layerToDraw = layerToDraw;
|
||||||
g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _backgroundType);
|
g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _backgroundType);
|
||||||
|
|
||||||
|
|
|
@ -482,7 +482,7 @@ void PicButtonWidget::drawWidget() {
|
||||||
const int x = _x + (_w - gfx->w) / 2;
|
const int x = _x + (_w - gfx->w) / 2;
|
||||||
const int y = _y + (_h - gfx->h) / 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 x = _x + (_w - _gfx.w) / 2;
|
||||||
const int y = _y + (_h - _gfx.h) / 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue