Permalink
Browse files

Move CropSource to WIN32Util

  • Loading branch information...
CrystalP committed Oct 4, 2011
1 parent d53cb41 commit a1c9d92bcc26e2b53489921082f822feb539bf29
@@ -28,7 +28,7 @@
#include <map>
#include "ConvolutionKernels.h"
#include "YUV2RGBShader.h"
-#include "../WinRenderer.h"
+#include "win32/WIN32Util.h"
CYUV2RGBMatrix::CYUV2RGBMatrix()
{
@@ -736,7 +736,7 @@ void CConvolutionShaderSeparable::PrepareParameters(unsigned int sourceWidth, un
// Alter rectangles the destination rectangle exceeds the intermediate target width when zooming and causes artifacts.
// Work on the parameters rather than the members to avoid disturbing the parameter change detection the next time the function is called
CRect tgtRect(0, 0, destWidth, destHeight);
- CWinRenderer::CropSource(sourceRect, destRect, tgtRect);
+ CWIN32Util::CropSource(sourceRect, destRect, tgtRect);
// Manipulate the coordinates to work only on the active parts of the textures,
// and therefore avoid the need to clear surfaces/render targets
@@ -36,6 +36,7 @@
#include "DllSwScale.h"
#include "guilib/LocalizeStrings.h"
#include "dialogs/GUIDialogKaiToast.h"
+#include "win32/WIN32Util.h"
typedef struct {
RenderMethod method;
@@ -634,39 +635,6 @@ void CWinRenderer::UpdateVideoFilter()
}
}
-// Adjust the src rectangle so that the dst is always contained in the target rectangle.
-void CWinRenderer::CropSource(CRect& src, CRect& dst, CRect target)
-{
- if(dst.x1 < target.x1)
- {
- src.x1 -= (dst.x1 - target.x1)
- * (src.x2 - src.x1)
- / (dst.x2 - dst.x1);
- dst.x1 = target.x1;
- }
- if(dst.y1 < target.y1)
- {
- src.y1 -= (dst.y1 - target.y1)
- * (src.y2 - src.y1)
- / (dst.y2 - dst.y1);
- dst.y1 = target.y1;
- }
- if(dst.x2 > target.x2)
- {
- src.x2 -= (dst.x2 - target.x2)
- * (src.x2 - src.x1)
- / (dst.x2 - dst.x1);
- dst.x2 = target.x2;
- }
- if(dst.y2 > target.y2)
- {
- src.y2 -= (dst.y2 - target.y2)
- * (src.y2 - src.y1)
- / (dst.y2 - dst.y1);
- dst.y2 = target.y2;
- }
-}
-
void CWinRenderer::Render(DWORD flags)
{
if (m_renderMethod == RENDER_DXVA)
@@ -779,7 +747,7 @@ void CWinRenderer::ScaleStretchRect()
CRect tgtRect(0, 0, desc.Width, desc.Height);
// Need to manipulate the coordinates since StretchRect doesn't accept off-screen coordinates.
- CropSource(sourceRect, destRect, tgtRect);
+ CWIN32Util::CropSource(sourceRect, destRect, tgtRect);
RECT srcRect = { sourceRect.x1, sourceRect.y1, sourceRect.x2, sourceRect.y2 };
IDirect3DSurface9* source;
@@ -192,8 +192,6 @@ class CWinRenderer : public CBaseRenderer
virtual unsigned int GetProcessorSize() { return m_processor.Size(); }
- static void CropSource(CRect& src, CRect& dst, CRect target);
-
protected:
virtual void Render(DWORD flags);
void RenderSW();
@@ -41,6 +41,7 @@
#include "utils/AutoPtrHandle.h"
#include "settings/AdvancedSettings.h"
#include "cores/VideoRenderers/RenderManager.h"
+#include "win32/WIN32Util.h"
#define ALLOW_ADDING_SURFACES 0
@@ -1440,7 +1441,7 @@ bool CProcessor::Render(CRect src, CRect dst, IDirect3DSurface9* target, REFEREN
D3DSURFACE_DESC desc;
CHECK(target->GetDesc(&desc));
CRect rectTarget(0, 0, desc.Width, desc.Height);
- CWinRenderer::CropSource(src, dst, rectTarget);
+ CWIN32Util::CropSource(src, dst, rectTarget);
RECT sourceRECT = { src.x1, src.y1, src.x2, src.y2 };
RECT dstRECT = { dst.x1, dst.y1, dst.x2, dst.y2 };
View
@@ -1421,6 +1421,39 @@ bool CWIN32Util::GetFocussedProcess(CStdString &strProcessFile)
return true;
}
+// Adjust the src rectangle so that the dst is always contained in the target rectangle.
+void CWIN32Util::CropSource(CRect& src, CRect& dst, CRect target)
+{
+ if(dst.x1 < target.x1)
+ {
+ src.x1 -= (dst.x1 - target.x1)
+ * (src.x2 - src.x1)
+ / (dst.x2 - dst.x1);
+ dst.x1 = target.x1;
+ }
+ if(dst.y1 < target.y1)
+ {
+ src.y1 -= (dst.y1 - target.y1)
+ * (src.y2 - src.y1)
+ / (dst.y2 - dst.y1);
+ dst.y1 = target.y1;
+ }
+ if(dst.x2 > target.x2)
+ {
+ src.x2 -= (dst.x2 - target.x2)
+ * (src.x2 - src.x1)
+ / (dst.x2 - dst.x1);
+ dst.x2 = target.x2;
+ }
+ if(dst.y2 > target.y2)
+ {
+ src.y2 -= (dst.y2 - target.y2)
+ * (src.y2 - src.y1)
+ / (dst.y2 - dst.y1);
+ dst.y2 = target.y2;
+ }
+}
+
void CWinIdleTimer::StartZero()
{
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
View
@@ -28,6 +28,7 @@
#endif
#include "MediaSource.h"
#include "utils/Stopwatch.h"
+#include "guilib/Geometry.h"
enum Drive_Types
{
@@ -80,6 +81,7 @@ class CWIN32Util
static bool GetCrystalHDLibraryPath(CStdString &strPath);
static bool GetFocussedProcess(CStdString &strProcessFile);
+ static void CropSource(CRect& src, CRect& dst, CRect target);
private:
#if _MSC_VER > 1400

0 comments on commit a1c9d92

Please sign in to comment.