aboutsummaryrefslogtreecommitdiff
path: root/graphics/VectorRenderer.h
diff options
context:
space:
mode:
authorBastien Bouclet2019-08-27 08:07:14 +0200
committerBastien Bouclet2019-10-07 21:47:42 +0200
commit1d764bd787a20ab4b8d6edd79d3bc7db459e3eb0 (patch)
treeb6e201244aabf6c87b40905cc1097c0955c73991 /graphics/VectorRenderer.h
parentb87ebdce2101a9943f727168526fe89725ebe759 (diff)
downloadscummvm-rg350-1d764bd787a20ab4b8d6edd79d3bc7db459e3eb0.tar.gz
scummvm-rg350-1d764bd787a20ab4b8d6edd79d3bc7db459e3eb0.tar.bz2
scummvm-rg350-1d764bd787a20ab4b8d6edd79d3bc7db459e3eb0.zip
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.
Diffstat (limited to 'graphics/VectorRenderer.h')
-rw-r--r--graphics/VectorRenderer.h87
1 files changed, 38 insertions, 49 deletions
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h
index c2f7b40ed0..9be55460c2 100644
--- a/graphics/VectorRenderer.h
+++ b/graphics/VectorRenderer.h
@@ -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.
@@ -384,6 +370,16 @@ public:
}
/**
+ * 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,