mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Merge some scissor rect related code to VideoCommon.
This commit is contained in:
@ -44,9 +44,24 @@ void SetGenerationMode(const BPCmd &bp)
|
||||
g_renderer->SetGenerationMode();
|
||||
}
|
||||
|
||||
void SetScissor(const BPCmd &bp)
|
||||
void SetScissor()
|
||||
{
|
||||
g_renderer->SetScissorRect();
|
||||
const int xoff = bpmem.scissorOffset.x * 2 - 342;
|
||||
const int yoff = bpmem.scissorOffset.y * 2 - 342;
|
||||
|
||||
EFBRectangle rc (bpmem.scissorTL.x - xoff - 342, bpmem.scissorTL.y - yoff - 342,
|
||||
bpmem.scissorBR.x - xoff - 341, bpmem.scissorBR.y - yoff - 341);
|
||||
|
||||
if (rc.left < 0) rc.left = 0;
|
||||
if (rc.top < 0) rc.top = 0;
|
||||
if (rc.right > EFB_WIDTH) rc.right = EFB_WIDTH;
|
||||
if (rc.bottom > EFB_HEIGHT) rc.bottom = EFB_HEIGHT;
|
||||
|
||||
if (rc.left > rc.right) rc.right = rc.left;
|
||||
if (rc.top > rc.bottom) rc.bottom = rc.top;
|
||||
|
||||
TargetRectangle trc = g_renderer->ConvertEFBRectangle(rc);
|
||||
g_renderer->SetScissorRect(trc);
|
||||
}
|
||||
|
||||
void SetLineWidth(const BPCmd &bp)
|
||||
|
@ -38,7 +38,7 @@ enum
|
||||
|
||||
void FlushPipeline();
|
||||
void SetGenerationMode(const BPCmd &bp);
|
||||
void SetScissor(const BPCmd &bp);
|
||||
void SetScissor();
|
||||
void SetLineWidth(const BPCmd &bp);
|
||||
void SetDepthMode(const BPCmd &bp);
|
||||
void SetBlendMode(const BPCmd &bp);
|
||||
|
@ -162,7 +162,7 @@ void BPWritten(const BPCmd& bp)
|
||||
case BPMEM_SCISSORTL: // Scissor Rectable Top, Left
|
||||
case BPMEM_SCISSORBR: // Scissor Rectable Bottom, Right
|
||||
case BPMEM_SCISSOROFFSET: // Scissor Offset
|
||||
SetScissor(bp);
|
||||
SetScissor();
|
||||
break;
|
||||
case BPMEM_LINEPTWIDTH: // Line Width
|
||||
SetLineWidth(bp);
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
|
||||
virtual void SetColorMask() = 0;
|
||||
virtual void SetBlendMode(bool forceUpdate) = 0;
|
||||
virtual void SetScissorRect() = 0;
|
||||
virtual void SetScissorRect(const TargetRectangle& rc) = 0;
|
||||
virtual void SetGenerationMode() = 0;
|
||||
virtual void SetDepthMode() = 0;
|
||||
virtual void SetLogicOpMode() = 0;
|
||||
@ -175,16 +175,4 @@ extern Renderer *g_renderer;
|
||||
|
||||
void UpdateViewport(Matrix44& vpCorrection);
|
||||
|
||||
template <typename R>
|
||||
void GetScissorRect(MathUtil::Rectangle<R> &rect)
|
||||
{
|
||||
const int xoff = bpmem.scissorOffset.x * 2 - 342;
|
||||
const int yoff = bpmem.scissorOffset.y * 2 - 342;
|
||||
|
||||
rect.left = (R)(bpmem.scissorTL.x - xoff - 342);
|
||||
rect.top = (R)(bpmem.scissorTL.y - yoff - 342);
|
||||
rect.right = (R)(bpmem.scissorBR.x - xoff - 341);
|
||||
rect.bottom = (R)(bpmem.scissorBR.y - yoff - 341);
|
||||
}
|
||||
|
||||
#endif // _COMMON_RENDERBASE_H_
|
||||
|
@ -70,8 +70,7 @@ void HandleGLError();
|
||||
// This structure should only be used to represent a rectangle in EFB
|
||||
// coordinates, where the origin is at the upper left and the frame dimensions
|
||||
// are 640 x 528.
|
||||
struct EFBRectangle : public MathUtil::Rectangle<int>
|
||||
{};
|
||||
typedef MathUtil::Rectangle<int> EFBRectangle;
|
||||
|
||||
// This structure should only be used to represent a rectangle in standard target
|
||||
// coordinates, where the origin is at the lower left and the frame dimensions
|
||||
|
Reference in New Issue
Block a user