TINYGL: Implemented equality operators for draw calls.

This commit is contained in:
Stefano Musumeci 2014-07-31 15:26:03 +02:00
parent a54020bd75
commit ae59f92ce4
2 changed files with 45 additions and 0 deletions

View File

@ -105,6 +105,26 @@ namespace Graphics {
DrawCall::DrawCall(DrawCallType type) : _type(type) {
}
bool DrawCall::operator==(const DrawCall &other) const {
if (_type == other._type) {
switch (_type) {
case Graphics::DrawCall_Rasterization:
return *(RasterizationDrawCall *)this == (const RasterizationDrawCall &)other;
break;
case Graphics::DrawCall_Blitting:
return *(BlittingDrawCall *)this == (const BlittingDrawCall &)other;
break;
case Graphics::DrawCall_Clear:
return *(ClearBufferDrawCall *)this == (const ClearBufferDrawCall &)other;
break;
default:
break;
}
} else {
return false;
}
}
RasterizationDrawCall::RasterizationDrawCall() : DrawCall(DrawCall_Rasterization) {
TinyGL::GLContext *c = TinyGL::gl_get_context();
_vertexCount = c->vertex_cnt;
@ -305,6 +325,19 @@ const Common::Rect RasterizationDrawCall::getDirtyRegion() const {
return _dirtyRegion;
}
bool RasterizationDrawCall::operator==(const RasterizationDrawCall &other) const {
if (_vertexCount == other._vertexCount && _drawTriangleFront == other._drawTriangleFront &&
_drawTriangleBack == other._drawTriangleBack && _state == other._state) {
for (int i = 0; i < _vertexCount; i++) {
if ((_vertex[i] == other._vertex[i]) == false) {
return false;
}
}
return true;
}
return false;
}
BlittingDrawCall::BlittingDrawCall(Graphics::BlitImage *image, const BlitTransform &transform, BlittingMode blittingMode) : DrawCall(DrawCall_Blitting), _transform(transform), _mode(blittingMode), _image(image) {
_blitState = loadState();
}
@ -380,6 +413,10 @@ const Common::Rect BlittingDrawCall::getDirtyRegion() const {
return Common::Rect(_transform._destinationRectangle.left, _transform._destinationRectangle.top, _transform._destinationRectangle.left + blitWidth, _transform._destinationRectangle.top + blitHeight);
}
bool BlittingDrawCall::operator==(const BlittingDrawCall &other) const {
return _mode == other._mode && _image == other._image && _transform == other._transform && _blitState == other._blitState;
}
ClearBufferDrawCall::ClearBufferDrawCall(bool clearZBuffer, int zValue, bool clearColorBuffer, int rValue, int gValue, int bValue) : clearZBuffer(clearZBuffer),
clearColorBuffer(clearColorBuffer), zValue(zValue), rValue(rValue), gValue(gValue), bValue(bValue), DrawCall(DrawCall_Clear) {
@ -399,4 +436,9 @@ const Common::Rect ClearBufferDrawCall::getDirtyRegion() const {
return Common::Rect(0, 0, c->fb->xsize, c->fb->ysize);
}
bool ClearBufferDrawCall::operator==(const ClearBufferDrawCall &other) const {
return clearZBuffer == other.clearZBuffer && clearColorBuffer == other.clearColorBuffer && rValue == other.rValue && gValue == other.gValue &&
bValue == other.bValue && zValue == other.zValue;
}
} // end of namespace Graphics

View File

@ -58,6 +58,7 @@ private:
class ClearBufferDrawCall : public DrawCall {
public:
ClearBufferDrawCall(bool clearZBuffer, int zValue, bool clearColorBuffer, int rValue, int gValue, int bValue);
bool operator==(const ClearBufferDrawCall &other) const;
virtual void execute(bool restoreState) const;
virtual void execute(const Common::Rect &clippingRectangle, bool restoreState) const;
virtual const Common::Rect getDirtyRegion() const;
@ -70,6 +71,7 @@ class RasterizationDrawCall : public DrawCall {
public:
RasterizationDrawCall();
~RasterizationDrawCall();
bool operator==(const RasterizationDrawCall &other) const;
virtual void execute(bool restoreState) const;
virtual void execute(const Common::Rect &clippingRectangle, bool restoreState) const;
virtual const Common::Rect getDirtyRegion() const;
@ -136,6 +138,7 @@ public:
};
BlittingDrawCall(BlitImage *image, const BlitTransform &transform, BlittingMode blittingMode);
bool operator==(const BlittingDrawCall &other) const;
virtual void execute(bool restoreState) const;
virtual void execute(const Common::Rect &clippingRectangle, bool restoreState) const;
virtual const Common::Rect getDirtyRegion() const;