| 2796 | |
| 2797 | |
| 2798 | HRESULT CDX9VideoProcessor::TextureCopyRect( |
| 2799 | IDirect3DTexture9* pTexture, const CRect& srcRect, const CRect& dstRect, |
| 2800 | D3DTEXTUREFILTERTYPE filter, const int iRotation, const bool bFlip) |
| 2801 | { |
| 2802 | HRESULT hr; |
| 2803 | |
| 2804 | D3DSURFACE_DESC desc; |
| 2805 | if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) { |
| 2806 | return E_FAIL; |
| 2807 | } |
| 2808 | |
| 2809 | const float dx = 1.0f / desc.Width; |
| 2810 | const float dy = 1.0f / desc.Height; |
| 2811 | |
| 2812 | POINT points[4]; |
| 2813 | switch (iRotation) { |
| 2814 | case 90: |
| 2815 | points[0] = { dstRect.right, dstRect.top }; |
| 2816 | points[1] = { dstRect.right, dstRect.bottom }; |
| 2817 | points[2] = { dstRect.left, dstRect.top }; |
| 2818 | points[3] = { dstRect.left, dstRect.bottom }; |
| 2819 | break; |
| 2820 | case 180: |
| 2821 | points[0] = { dstRect.right, dstRect.bottom }; |
| 2822 | points[1] = { dstRect.left, dstRect.bottom }; |
| 2823 | points[2] = { dstRect.right, dstRect.top }; |
| 2824 | points[3] = { dstRect.left, dstRect.top }; |
| 2825 | break; |
| 2826 | case 270: |
| 2827 | points[0] = { dstRect.left, dstRect.bottom }; |
| 2828 | points[1] = { dstRect.left, dstRect.top }; |
| 2829 | points[2] = { dstRect.right, dstRect.bottom }; |
| 2830 | points[3] = { dstRect.right, dstRect.top }; |
| 2831 | break; |
| 2832 | default: |
| 2833 | points[0] = { dstRect.left, dstRect.top }; |
| 2834 | points[1] = { dstRect.right, dstRect.top }; |
| 2835 | points[2] = { dstRect.left, dstRect.bottom }; |
| 2836 | points[3] = { dstRect.right, dstRect.bottom }; |
| 2837 | break; |
| 2838 | } |
| 2839 | |
| 2840 | if (bFlip) { |
| 2841 | std::swap(points[0], points[1]); |
| 2842 | std::swap(points[2], points[3]); |
| 2843 | } |
| 2844 | |
| 2845 | MYD3DVERTEX<1> v[] = { |
| 2846 | { {(float)points[0].x - 0.5f, (float)points[0].y - 0.5f, 0.5f, 2.0f}, {{srcRect.left * dx, srcRect.top * dy}} }, |
| 2847 | { {(float)points[1].x - 0.5f, (float)points[1].y - 0.5f, 0.5f, 2.0f}, {{srcRect.right * dx, srcRect.top * dy}} }, |
| 2848 | { {(float)points[2].x - 0.5f, (float)points[2].y - 0.5f, 0.5f, 2.0f}, {{srcRect.left * dx, srcRect.bottom * dy}} }, |
| 2849 | { {(float)points[3].x - 0.5f, (float)points[3].y - 0.5f, 0.5f, 2.0f}, {{srcRect.right * dx, srcRect.bottom * dy}} }, |
| 2850 | }; |
| 2851 | |
| 2852 | hr = m_pD3DDevEx->SetTexture(0, pTexture); |
| 2853 | hr = TextureBlt(m_pD3DDevEx, v, filter); |
| 2854 | |
| 2855 | return hr; |
nothing calls this directly
no test coverage detected