Renderer: Adjust source rectangle when crop would draw off screen

This prevents us from requiring an oversized and/or negative viewport by
shrinking the source rectangle instead.
This commit is contained in:
Stenzek
2019-04-28 16:53:16 +10:00
parent d2d8d7ce90
commit 3c64f0c616
4 changed files with 57 additions and 10 deletions

View File

@ -171,6 +171,13 @@ public:
const MathUtil::Rectangle<int>& GetTargetRectangle() const { return m_target_rectangle; }
float CalculateDrawAspectRatio() const;
// Crops the target rectangle to the framebuffer dimensions, reducing the size of the source
// rectangle if it is greater. Works even if the source and target rectangles don't have a
// 1:1 pixel mapping, scaling as appropriate.
void AdjustRectanglesToFitBounds(MathUtil::Rectangle<int>* target_rect,
MathUtil::Rectangle<int>* source_rect, int fb_width,
int fb_height);
std::tuple<float, float> ScaleToDisplayAspectRatio(int width, int height) const;
void UpdateDrawRectangle();