MCPcopy Create free account
hub / github.com/Aleksoid1978/VideoRenderer / TextureResizeShader

Method TextureResizeShader

Source/DX9VideoProcessor.cpp:2858–2942  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2856}
2857
2858HRESULT CDX9VideoProcessor::TextureResizeShader(
2859 IDirect3DTexture9* pTexture, const CRect& srcRect, const CRect& dstRect,
2860 IDirect3DPixelShader9* pShader, const int iRotation, const bool bFlip)
2861{
2862 HRESULT hr = S_OK;
2863
2864 D3DSURFACE_DESC desc;
2865 if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
2866 return E_FAIL;
2867 }
2868
2869 const float dx = 1.0f / desc.Width;
2870 const float dy = 1.0f / desc.Height;
2871
2872 float scale_x = (float)srcRect.Width();
2873 float scale_y = (float)srcRect.Height();
2874 if (iRotation == 90 || iRotation == 270) {
2875 scale_x /= dstRect.Height();
2876 scale_y /= dstRect.Width();
2877 } else {
2878 scale_x /= dstRect.Width();
2879 scale_y /= dstRect.Height();
2880 }
2881
2882 //const float steps_x = floor(scale_x + 0.5f);
2883 //const float steps_y = floor(scale_y + 0.5f);
2884
2885 const float tx0 = (float)srcRect.left - 0.5f;
2886 const float ty0 = (float)srcRect.top - 0.5f;
2887 const float tx1 = (float)srcRect.right - 0.5f;
2888 const float ty1 = (float)srcRect.bottom - 0.5f;
2889
2890 POINT points[4];
2891 switch (iRotation) {
2892 case 90:
2893 points[0] = { dstRect.right, dstRect.top };
2894 points[1] = { dstRect.right, dstRect.bottom };
2895 points[2] = { dstRect.left, dstRect.top };
2896 points[3] = { dstRect.left, dstRect.bottom };
2897 break;
2898 case 180:
2899 points[0] = { dstRect.right, dstRect.bottom };
2900 points[1] = { dstRect.left, dstRect.bottom };
2901 points[2] = { dstRect.right, dstRect.top };
2902 points[3] = { dstRect.left, dstRect.top };
2903 break;
2904 case 270:
2905 points[0] = { dstRect.left, dstRect.bottom };
2906 points[1] = { dstRect.left, dstRect.top };
2907 points[2] = { dstRect.right, dstRect.bottom };
2908 points[3] = { dstRect.right, dstRect.top };
2909 break;
2910 default:
2911 points[0] = { dstRect.left, dstRect.top };
2912 points[1] = { dstRect.right, dstRect.top };
2913 points[2] = { dstRect.left, dstRect.bottom };
2914 points[3] = { dstRect.right, dstRect.bottom };
2915 break;

Callers

nothing calls this directly

Calls 1

TextureBltFunction · 0.85

Tested by

no test coverage detected