TINYGL: Simplify setting & disabling scissors.

This commit is contained in:
Vincent Pelletier 2017-04-22 06:28:24 +00:00
parent e1de3407f1
commit 6087492dbd
6 changed files with 20 additions and 28 deletions

View file

@ -238,7 +238,7 @@ void glInit(void *zbuffer1, int textureSize) {
c->_drawCallAllocator[1].initialize(kDrawCallMemory);
c->_enableDirtyRectangles = false;
Graphics::Internal::tglBlitSetScissorRect(0, 0, c->fb->xsize, c->fb->ysize);
Graphics::Internal::tglBlitResetScissorRect();
}
void glClose() {

View file

@ -727,16 +727,13 @@ void tglCleanupImages() {
}
}
void tglBlitSetScissorRect(int left, int top, int right, int bottom) {
void tglBlitSetScissorRect(const Common::Rect &rect) {
TinyGL::gl_get_context()->_scissorRect = rect;
}
void tglBlitResetScissorRect(void) {
TinyGL::GLContext *c = TinyGL::gl_get_context();
c->_scissorRect.left = left;
c->_scissorRect.right = right;
c->_scissorRect.top = top;
c->_scissorRect.bottom = bottom;
if (c->_scissorRect.right == 0 || c->_scissorRect.bottom == 0) {
c->_scissorRect.right = c->fb->xsize;
c->_scissorRect.bottom = c->fb->ysize;
}
c->_scissorRect = Common::Rect(0, 0, c->fb->xsize, c->fb->ysize);
}
} // end of namespace Internal

View file

@ -183,12 +183,9 @@ namespace Internal {
/**
@brief Sets up a scissor rectangle for blit calls: every blit call is affected by this rectangle.
@param left coordinate
@param right coordinate
@param top coordinate
@param bottom coordinate
*/
void tglBlitSetScissorRect(int left, int top, int right, int bottom);
void tglBlitSetScissorRect(const Common::Rect &rect);
void tglBlitResetScissorRect(void);
} // end of namespace Internal
} // end of namespace Graphics

View file

@ -80,7 +80,7 @@ void memset_l(void *adr, int val, int count) {
*p++ = val;
}
FrameBuffer::FrameBuffer(int width, int height, const Graphics::PixelBuffer &frame_buffer) : _depthWrite(true) {
FrameBuffer::FrameBuffer(int width, int height, const Graphics::PixelBuffer &frame_buffer) : _depthWrite(true), _enableScissor(false) {
int size;
this->xsize = width;
@ -90,8 +90,6 @@ FrameBuffer::FrameBuffer(int width, int height, const Graphics::PixelBuffer &fra
this->pixelbits = this->cmode.bytesPerPixel * 8;
this->linesize = (xsize * this->pixelbytes + 3) & ~3;
this->setScissorRectangle(0, xsize, 0, ysize);
size = this->xsize * this->ysize * sizeof(unsigned int);
this->_zbuf = (unsigned int *)gl_malloc(size);

View file

@ -446,12 +446,12 @@ struct FrameBuffer {
void fillLineFlat(ZBufferPoint *p1, ZBufferPoint *p2);
void fillLineInterp(ZBufferPoint *p1, ZBufferPoint *p2);
void setScissorRectangle(int left, int right, int top, int bottom) {
_clipRectangle.left = left;
_clipRectangle.right = right;
_clipRectangle.top = top;
_clipRectangle.bottom = bottom;
_enableScissor = left != 0 || right != xsize || top != 0 || bottom != ysize;
void setScissorRectangle(const Common::Rect &rect) {
_clipRectangle = rect;
_enableScissor = true;
}
void resetScissorRectangle() {
_enableScissor = false;
}
Common::Rect _clipRectangle;

View file

@ -526,9 +526,9 @@ void RasterizationDrawCall::applyState(const RasterizationDrawCall::Rasterizatio
void RasterizationDrawCall::execute(const Common::Rect &clippingRectangle, bool restoreState) const {
TinyGL::GLContext *c = TinyGL::gl_get_context();
c->fb->setScissorRectangle(clippingRectangle.left, clippingRectangle.right, clippingRectangle.top, clippingRectangle.bottom);
c->fb->setScissorRectangle(clippingRectangle);
execute(restoreState);
c->fb->setScissorRectangle(0, c->fb->xsize, 0, c->fb->ysize);
c->fb->resetScissorRectangle();
}
const Common::Rect RasterizationDrawCall::getDirtyRegion() const {
@ -589,9 +589,9 @@ void BlittingDrawCall::execute(bool restoreState) const {
}
void BlittingDrawCall::execute(const Common::Rect &clippingRectangle, bool restoreState) const {
Graphics::Internal::tglBlitSetScissorRect(clippingRectangle.left, clippingRectangle.top, clippingRectangle.right, clippingRectangle.bottom);
Graphics::Internal::tglBlitSetScissorRect(clippingRectangle);
execute(restoreState);
Graphics::Internal::tglBlitSetScissorRect(0, 0, 0, 0);
Graphics::Internal::tglBlitResetScissorRect();
}
BlittingDrawCall::BlittingState BlittingDrawCall::captureState() const {