GUI: Add fillSurfaceClip()

This commit is contained in:
Alexander Tkachev 2016-06-29 21:30:45 +06:00 committed by Eugene Sandulenko
parent a39a6533c4
commit e636894b06
3 changed files with 42 additions and 2 deletions

View file

@ -290,6 +290,7 @@ 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.
@ -394,8 +395,8 @@ public:
drawRoundedSquareClip(x, y, stepGetRadius(step, area), w, h, clip); drawRoundedSquareClip(x, y, stepGetRadius(step, area), w, h, clip);
} }
void drawCallback_FILLSURFACE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) { //TODO void drawCallback_FILLSURFACE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {
fillSurface(); fillSurfaceClip(clip);
} }
void drawCallback_TRIANGLE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) { void drawCallback_TRIANGLE(const Common::Rect &area, const DrawStep &step, const Common::Rect &clip) {

View file

@ -706,6 +706,44 @@ fillSurface() {
} }
} }
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;
}
byte *ptr = (byte *)_activeSurface->getPixels();
int pitch = _activeSurface->pitch;
if (Base::_fillMode == kFillBackground || Base::_fillMode == kFillForeground) {
PixelType color = (Base::_fillMode == kFillBackground ? _bgColor : _fgColor);
byte *ptrLeft = (ptr + _clippingArea.left), *ptrRight = ptr + _clippingArea.right;
for (int i = 0; i < h; i++) {
if (_clippingArea.top <= i && i < _clippingArea.bottom) {
colorFill<PixelType>((PixelType *)ptrLeft, (PixelType *)ptrRight, color);
}
ptrLeft += pitch;
ptrRight += pitch;
}
} else if (Base::_fillMode == kFillGradient) {
precalcGradient(h);
for (int i = 0; i < h; i++) {
if (_clippingArea.top <= i && i < _clippingArea.bottom) {
gradientFill((PixelType *)ptr + _clippingArea.left, _clippingArea.width(), 0, i);
}
ptr += pitch;
}
}
}
template<typename PixelType> template<typename PixelType>
void VectorRendererSpec<PixelType>:: void VectorRendererSpec<PixelType>::
copyFrame(OSystem *sys, const Common::Rect &r) { copyFrame(OSystem *sys, const Common::Rect &r) {

View file

@ -89,6 +89,7 @@ public:
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::Rect &r);
void blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r); void blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r);