ScummVM API documentation
Graphics::VectorRendererSpec< PixelType > Class Template Reference

#include <VectorRendererSpec.h>

Inheritance diagram for Graphics::VectorRendererSpec< PixelType >:
Graphics::VectorRenderer Graphics::VectorRendererAA< PixelType >

Public Member Functions

 VectorRendererSpec (PixelFormat format)
 
void drawLine (int x1, int y1, int x2, int y2) override
 
void drawCircle (int x, int y, int r) override
 
void drawSquare (int x, int y, int w, int h) override
 
void drawRoundedSquare (int x, int y, int r, int w, int h) override
 
void drawTriangle (int x, int y, int base, int height, TriangleOrientation orient) override
 
void drawTab (int x, int y, int r, int w, int h, int s) override
 
void drawBeveledSquare (int x, int y, int w, int h) override
 
void drawString (const Graphics::Font *font, const Common::U32String &text, const Common::Rect &area, Graphics::TextAlign alignH, GUI::ThemeEngine::TextAlignVertical alignV, int deltax, bool elipsis, const Common::Rect &textDrawableArea=Common::Rect(0, 0, 0, 0)) override
 
void setFgColor (uint8 r, uint8 g, uint8 b) override
 
void setBgColor (uint8 r, uint8 g, uint8 b) override
 
void setBevelColor (uint8 r, uint8 g, uint8 b) override
 
void setGradientColors (uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2) override
 
void setClippingRect (const Common::Rect &clippingArea) override
 
void copyFrame (OSystem *sys, const Common::Rect &r) override
 
void copyWholeFrame (OSystem *sys) override
 
void fillSurface () override
 
void blitSurface (const Graphics::ManagedSurface *source, const Common::Rect &r) override
 
void blitManagedSurface (const Graphics::ManagedSurface *source, const Common::Point &p) override
 
void applyScreenShading (GUI::ThemeEngine::ShadingStyle shadingStyle) override
 
- Public Member Functions inherited from Graphics::VectorRenderer
virtual void drawCross (int x, int y, int w, int h)
 
virtual void setSurface (ManagedSurface *surface)
 
virtual ManagedSurfacegetActiveSurface ()
 
virtual void clearSurface ()
 
virtual void setFillMode (FillMode mode)
 
virtual void setShadowFillMode (ShadowFillMode mode)
 
virtual void setStrokeWidth (int width)
 
virtual void setShadowOffset (int offset)
 
virtual void setBevel (int amount)
 
virtual void setGradientFactor (int factor)
 
virtual void setShadowIntensity (uint32 shadowIntensity)
 
void stepGetPositions (const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h)
 
int stepGetRadius (const DrawStep &step, const Common::Rect &area)
 
Common::Rect applyStepClippingRect (const Common::Rect &area, const Common::Rect &clip, const DrawStep &step)
 
void drawCallback_CIRCLE (const Common::Rect &area, const DrawStep &step)
 
void drawCallback_SQUARE (const Common::Rect &area, const DrawStep &step)
 
void drawCallback_LINE (const Common::Rect &area, const DrawStep &step)
 
void drawCallback_ROUNDSQ (const Common::Rect &area, const DrawStep &step)
 
void drawCallback_FILLSURFACE (const Common::Rect &area, const DrawStep &step)
 
void drawCallback_TRIANGLE (const Common::Rect &area, const DrawStep &step)
 
void drawCallback_BEVELSQ (const Common::Rect &area, const DrawStep &step)
 
void drawCallback_TAB (const Common::Rect &area, const DrawStep &step)
 
void drawCallback_BITMAP (const Common::Rect &area, const DrawStep &step)
 
void drawCallback_CROSS (const Common::Rect &area, const DrawStep &step)
 
void drawCallback_VOID (const Common::Rect &area, const DrawStep &step)
 
virtual void drawStep (const Common::Rect &area, const Common::Rect &clip, const DrawStep &step, uint32 extra=0)
 
virtual void disableShadows ()
 
virtual void enableShadows ()
 

Protected Member Functions

void putPixel (int x, int y, PixelType color)
 
void blendPixel (int x, int y, PixelType color, uint8 alpha)
 
void blendPixelPtr (PixelType *ptr, PixelType color, uint8 alpha)
 
void blendPixelPtrClip (PixelType *ptr, PixelType color, uint8 alpha, int x, int y)
 
void blendPixelDestAlphaPtr (PixelType *ptr, PixelType color, uint8 alpha)
 
virtual void drawLineAlg (int x1, int y1, int x2, int y2, uint dx, uint dy, PixelType color)
 
virtual void drawLineAlgClip (int x1, int y1, int x2, int y2, uint dx, uint dy, PixelType color)
 
virtual void drawCircleAlg (int x, int y, int r, PixelType color, FillMode fill_m)
 
virtual void drawCircleAlgClip (int x, int y, int r, PixelType color, FillMode fill_m)
 
virtual void drawRoundedSquareAlg (int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m)
 
virtual void drawRoundedSquareAlgClip (int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m)
 
virtual void drawBorderRoundedSquareAlg (int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m, uint8 alpha_t, uint8 alpha_r, uint8 alpha_b, uint8 alpha_l)
 
virtual void drawBorderRoundedSquareAlgClip (int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m, uint8 alpha_t, uint8 alpha_r, uint8 alpha_b, uint8 alpha_l)
 
virtual void drawInteriorRoundedSquareAlg (int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m)
 
virtual void drawInteriorRoundedSquareAlgClip (int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m)
 
virtual void drawSquareAlg (int x, int y, int w, int h, PixelType color, FillMode fill_m)
 
virtual void drawSquareAlgClip (int x, int y, int w, int h, PixelType color, FillMode fill_m)
 
virtual void drawTriangleHorzAlg (int x, int y, int w, int h, bool inverted, PixelType color, FillMode fill_m)
 
virtual void drawTriangleHorzAlgClip (int x, int y, int w, int h, bool inverted, PixelType color, FillMode fill_m)
 
virtual void drawTriangleFastH (int x, int y, int size, bool inverted, PixelType color, FillMode fill_m)
 
virtual void drawTriangleVertAlg (int x, int y, int w, int h, bool inverted, PixelType color, FillMode fill_m)
 
virtual void drawTriangleVertAlgClip (int x, int y, int w, int h, bool inverted, PixelType color, FillMode fill_m)
 
virtual void drawTriangleFastV (int x, int y, int size, 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)
 
virtual void drawBevelSquareAlgClip (int x, int y, int w, int h, 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, int baseLeft, int baseRight, bool vFlip)
 
virtual void drawTabAlgClip (int x, int y, int w, int h, int r, PixelType color, VectorRenderer::FillMode fill_m, int baseLeft, int baseRight, bool vFlip)
 
virtual void drawTabShadow (int x, int y, int w, int h, int r, int offset, uint32 shadowIntensity, bool vFlip)
 
virtual void drawTabShadowClip (int x, int y, int w, int h, int r, int offset, uint32 shadowIntensity, bool vFlip)
 
virtual void drawBevelTabAlg (int x, int y, int w, int h, int bevel, PixelType topColor, PixelType bottomColor, int baseLeft, int baseRight, bool vFlip)
 
virtual void drawBevelTabAlgClip (int x, int y, int w, int h, int bevel, PixelType topColor, PixelType bottomColor, int baseLeft, int baseRight, bool vFlip)
 
virtual void drawSquareShadow (int x, int y, int w, int h, int offset)
 
virtual void drawSquareShadowClip (int x, int y, int w, int h, int offset)
 
virtual void drawRoundedSquareShadow (int x, int y, int r, int w, int h, int offset, uint32 shadowIntensity)
 
virtual void drawRoundedSquareShadowClip (int x, int y, int r, int w, int h, int offset, uint32 shadowIntensity)
 
PixelType calcGradient (uint32 pos, uint32 max)
 
void precalcGradient (int h)
 
void gradientFill (PixelType *first, int width, int x, int y)
 
void gradientFillClip (PixelType *first, int width, int x, int y, int realX, int realY)
 
void blendFill (PixelType *first, PixelType *last, PixelType color, uint8 alpha)
 
void blendFillClip (PixelType *first, PixelType *last, PixelType color, uint8 alpha, int realX, int realY)
 
void darkenFill (PixelType *first, PixelType *last)
 
void darkenFillClip (PixelType *first, PixelType *last, int x, int y)
 

Protected Attributes

Common::Rect _clippingArea
 
const PixelFormat _format
 
const PixelType _redMask
 
const PixelType _greenMask
 
const PixelType _blueMask
 
const PixelType _alphaMask
 
PixelType _fgColor
 
PixelType _bgColor
 
PixelType _gradientStart
 
PixelType _gradientEnd
 
int _gradientBytes [3]
 
Common::Array< PixelType > _gradCache
 
Common::Array< int > _gradIndexes
 
PixelType _bevelColor
 
- Protected Attributes inherited from Graphics::VectorRenderer
ManagedSurface_activeSurface
 
FillMode _fillMode
 
ShadowFillMode _shadowFillMode
 
int _shadowOffset
 
int _bevel
 
bool _disableShadows
 
int _strokeWidth
 
uint32 _dynamicData
 
int _gradientFactor
 
uint32 _shadowIntensity
 

Additional Inherited Members

- Public Types inherited from Graphics::VectorRenderer
enum  FillMode { kFillDisabled = 0, kFillForeground = 1, kFillBackground = 2, kFillGradient = 3 }
 
enum  TriangleOrientation {
  kTriangleAuto = 0, kTriangleUp, kTriangleDown, kTriangleLeft,
  kTriangleRight
}
 
enum  ShadowFillMode { kShadowLinear = 0, kShadowExponential = 1 }
 

Detailed Description

template<typename PixelType>
class Graphics::VectorRendererSpec< PixelType >

VectorRendererSpec: Specialized Vector Renderer Class

This templated class implements the basic subset of vector operations for all platforms by allowing the user to provide the actual Pixel Type and pixel information structs.

This class takes two template parameters:

Parameters
PixelTypeDefines a type which may hold the color value of a single pixel, such as "byte" or "uint16" for 8 and 16 BPP respectively.

TODO: Expand documentation.

See also
VectorRenderer

Member Function Documentation

◆ drawLine()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::drawLine ( int  x1,
int  y1,
int  x2,
int  y2 
)
overridevirtual

Draws a line by considering the special cases for optimization.

Parameters
x1Horizontal (X) coordinate for the line start
x2Horizontal (X) coordinate for the line end
y1Vertical (Y) coordinate for the line start
y2Vertical (Y) coordinate for the line end

Implements Graphics::VectorRenderer.

◆ drawCircle()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::drawCircle ( int  x,
int  y,
int  r 
)
overridevirtual

Draws a circle centered at (x,y) with radius r.

Parameters
xHorizontal (X) coordinate for the center of the circle
yVertical (Y) coordinate for the center of the circle
rRadius of the circle.

Implements Graphics::VectorRenderer.

◆ drawSquare()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::drawSquare ( int  x,
int  y,
int  w,
int  h 
)
overridevirtual

Draws a square starting at (x,y) with the given width and height.

Parameters
xHorizontal (X) coordinate for the center of the square
yVertical (Y) coordinate for the center of the square
wWidth of the square.
hHeight of the square

Implements Graphics::VectorRenderer.

◆ drawRoundedSquare()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::drawRoundedSquare ( int  x,
int  y,
int  r,
int  w,
int  h 
)
overridevirtual

Draws a rounded square starting at (x,y) with the given width and height. The corners of the square are rounded with the given radius.

Parameters
xHorizontal (X) coordinate for the center of the square
yVertical (Y) coordinate for the center of the square
wWidth of the square.
hHeight of the square
rRadius of the corners.

Implements Graphics::VectorRenderer.

◆ drawTriangle()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::drawTriangle ( int  x,
int  y,
int  base,
int  height,
TriangleOrientation  orient 
)
overridevirtual

Draws a triangle starting at (x,y) with the given base and height. The triangle will always be isosceles, with the given base and height. The orientation parameter controls the position of the base of the triangle.

Parameters
xHorizontal (X) coordinate for the top left corner of the triangle
yVertical (Y) coordinate for the top left corner of the triangle
baseWidth of the base of the triangle
heightHeight of the triangle
orientOrientation of the triangle.

Implements Graphics::VectorRenderer.

◆ drawTab()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::drawTab ( int  x,
int  y,
int  r,
int  w,
int  h,
int  s 
)
overridevirtual

Draws a tab-like shape, specially thought for the Tab widget. If a radius is given, the tab will have rounded corners. Otherwise, the tab will be squared.

Parameters
xHorizontal (X) coordinate for the tab
yVertical (Y) coordinate for the tab
wWidth of the tab
hHeight of the tab
rRadius of the corners of the tab (0 for squared tabs).
sShadow size

Implements Graphics::VectorRenderer.

◆ drawBeveledSquare()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::drawBeveledSquare ( int  x,
int  y,
int  w,
int  h 
)
inlineoverridevirtual

Draws a beveled square like the ones in the Classic GUI themes. Beveled squares are always drawn with a transparent background. Draw them on top of a standard square to fill it.

Parameters
xHorizontal (X) coordinate for the center of the square
yVertical (Y) coordinate for the center of the square
wWidth of the square.
hHeight of the square
bevelAmount of bevel. Must be positive.

Implements Graphics::VectorRenderer.

◆ drawString()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::drawString ( const Graphics::Font font,
const Common::U32String text,
const Common::Rect area,
Graphics::TextAlign  alignH,
GUI::ThemeEngine::TextAlignVertical  alignV,
int  deltax,
bool  useEllipsis,
const Common::Rect textDrawableArea = Common::Rect(0, 0, 0, 0) 
)
overridevirtual

Draws a string into the screen. Wrapper for the Graphics::Font string drawing method.

Implements Graphics::VectorRenderer.

◆ setFgColor()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::setFgColor ( uint8  r,
uint8  g,
uint8  b 
)
inlineoverridevirtual

Set the active foreground painting color for the renderer. All the foreground drawing from then on will be done with that color, unless specified otherwise.

Foreground drawing means all outlines and basic shapes.

Parameters
rvalue of the red color byte
gvalue of the green color byte
bvalue of the blue color byte

Implements Graphics::VectorRenderer.

◆ setBgColor()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::setBgColor ( uint8  r,
uint8  g,
uint8  b 
)
inlineoverridevirtual

Set the active background painting color for the renderer. All the background drawing from then on will be done with that color, unless specified otherwise.

Background drawing means all the shape filling.

Parameters
rvalue of the red color byte
gvalue of the green color byte
bvalue of the blue color byte

Implements Graphics::VectorRenderer.

◆ setGradientColors()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::setGradientColors ( uint8  r1,
uint8  g1,
uint8  b1,
uint8  r2,
uint8  g2,
uint8  b2 
)
overridevirtual

Set the active gradient color. All shapes drawn using kFillGradient as their fill mode will use this VERTICAL gradient as their fill color.

Parameters
r1value of the red color byte for the start color
g1value of the green color byte for the start color
b1value of the blue color byte for the start color
r2value of the red color byte for the end color
g2value of the green color byte for the end color
b2value of the blue color byte for the end color

Implements Graphics::VectorRenderer.

◆ setClippingRect()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::setClippingRect ( const Common::Rect clippingArea)
inlineoverridevirtual

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.

Implements Graphics::VectorRenderer.

◆ copyFrame()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::copyFrame ( OSystem sys,
const Common::Rect r 
)
overridevirtual

Copies the part of the current frame to the system overlay.

Parameters
sysPointer to the global System class
rZone of the surface to copy into the overlay.

Implements Graphics::VectorRenderer.

◆ copyWholeFrame()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::copyWholeFrame ( OSystem sys)
inlineoverridevirtual

Copies the current surface to the system overlay

Parameters
sysPointer to the global System class

Implements Graphics::VectorRenderer.

◆ fillSurface()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::fillSurface ( )
overridevirtual

Fills the active surface with the specified fg/bg color or the active gradient. Defaults to using the active Foreground color for filling.

Implements Graphics::VectorRenderer.

◆ blitSurface()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::blitSurface ( const Graphics::ManagedSurface source,
const Common::Rect r 
)
overridevirtual

Blits a given graphics surface on top of the current drawing surface.

Note that the source surface and the active surface are expected to be of the same size, hence the area delimited by "r" in the source surface will be blitted into the area delimited by "r" on the current surface.

If you wish to blit a smaller surface into the active drawing area, use VectorRenderer::blitSubSurface().

Parameters
sourceSurface to blit into the drawing surface.
rPosition in the active drawing surface to do the blitting.

Implements Graphics::VectorRenderer.

◆ applyScreenShading()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::applyScreenShading ( GUI::ThemeEngine::ShadingStyle  )
overridevirtual

Applies a whole-screen shading effect, used before opening a new dialog. Currently supports screen dimmings and luminance (b&w).

Implements Graphics::VectorRenderer.

◆ putPixel()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::putPixel ( int  x,
int  y,
PixelType  color 
)
inlineprotected

Draws a single pixel on the surface with the given coordinates and the given color.

Parameters
xHorizontal coordinate of the pixel.
yVertical coordinate of the pixel.
colorColor of the pixel

◆ blendPixel()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::blendPixel ( int  x,
int  y,
PixelType  color,
uint8  alpha 
)
inlineprotected

Blends a single pixel on the surface with the given coordinates, color and Alpha intensity.

Parameters
xHorizontal coordinate of the pixel.
yVertical coordinate of the pixel.
colorColor of the pixel
alphaAlpha intensity of the pixel (0-255)

◆ blendPixelPtr()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::blendPixelPtr ( PixelType *  ptr,
PixelType  color,
uint8  alpha 
)
inlineprotected

Blends a single pixel on the surface in the given pixel pointer, using supplied color and Alpha intensity.

This is implemented to prevent blendPixel() to calculate the surface pointer on each call. Optimized drawing algorithms should call this function when possible.

See also
blendPixel
Parameters
ptrPointer to the pixel to blend on top of
colorColor of the pixel
alphaAlpha intensity of the pixel (0-255)

◆ blendPixelDestAlphaPtr()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::blendPixelDestAlphaPtr ( PixelType *  ptr,
PixelType  color,
uint8  alpha 
)
inlineprotected

Blends a single pixel on the surface in the given pixel pointer, using supplied color and Alpha intensity. If the destination pixel has 0 alpha, set the color and alpha channels, overwriting the destination pixel entirely. If the destination pixel has non-zero alpha, blend dest with src.

This is implemented to prevent blendPixel() to calculate the surface pointer on each call. Optimized drawing algorithms should call this function when possible.

See also
blendPixel
Parameters
ptrPointer to the pixel to blend on top of
colorColor of the pixel
alphaAlpha intensity of the pixel (0-255)

◆ drawLineAlg()

template<typename PixelType >
virtual void Graphics::VectorRendererSpec< PixelType >::drawLineAlg ( int  x1,
int  y1,
int  x2,
int  y2,
uint  dx,
uint  dy,
PixelType  color 
)
protectedvirtual

PRIMITIVE DRAWING ALGORITHMS

Generic algorithms for drawing all kinds of aliased primitive shapes. These may be overloaded in inheriting classes to implement platform-specific optimizations or improve looks.

See also
VectorRendererAA
VectorRendererAA::drawLineAlg
VectorRendererAA::drawCircleAlg

Reimplemented in Graphics::VectorRendererAA< PixelType >.

◆ drawSquareShadow()

template<typename PixelType >
virtual void Graphics::VectorRendererSpec< PixelType >::drawSquareShadow ( int  x,
int  y,
int  w,
int  h,
int  offset 
)
protectedvirtual

SHADOW DRAWING ALGORITHMS

Optimized versions of the primitive drawing algorithms with alpha blending for shadow drawing. There functions may be overloaded in inheriting classes to improve performance in the slowest platforms where pixel alpha blending just doesn't cut it.

Parameters
offsetIntensity/size of the shadow.

◆ calcGradient()

template<typename PixelType >
PixelType Graphics::VectorRendererSpec< PixelType >::calcGradient ( uint32  pos,
uint32  max 
)
inlineprotected

Calculates the color gradient on a given point. This function assumes that the gradient start/end colors have been set beforehand from the API function call.

Parameters
posProgress of the gradient.
maxMaximum amount of the progress.
Returns
Composite color of the gradient at the given "progress" amount.

◆ blendFill()

template<typename PixelType >
void Graphics::VectorRendererSpec< PixelType >::blendFill ( PixelType *  first,
PixelType *  last,
PixelType  color,
uint8  alpha 
)
inlineprotected

Fills several pixels in a row with a given color and the specified alpha blending.

See also
blendPixelPtr
blendPixel
Parameters
firstPointer to the first pixel to fill.
lastPointer to the last pixel to fill.
colorColor of the pixel
alphaAlpha intensity of the pixel (0-255)

Member Data Documentation

◆ _fgColor

template<typename PixelType >
PixelType Graphics::VectorRendererSpec< PixelType >::_fgColor
protected

Foreground color currently being used to draw on the renderer

◆ _bgColor

template<typename PixelType >
PixelType Graphics::VectorRendererSpec< PixelType >::_bgColor
protected

Background color currently being used to draw on the renderer

◆ _gradientStart

template<typename PixelType >
PixelType Graphics::VectorRendererSpec< PixelType >::_gradientStart
protected

Start color for the fill gradient

◆ _gradientEnd

template<typename PixelType >
PixelType Graphics::VectorRendererSpec< PixelType >::_gradientEnd
protected

End color for the fill gradient

◆ _gradientBytes

template<typename PixelType >
int Graphics::VectorRendererSpec< PixelType >::_gradientBytes[3]
protected

Color bytes of the active gradient, used to speed up calculation


The documentation for this class was generated from the following file: