Changeset 57517 in vbox for trunk/src/VBox/Devices/Graphics
- Timestamp:
- Aug 24, 2015 10:53:20 PM (9 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r57504 r57517 560 560 pThis->svga.viewport.y = y; 561 561 pThis->svga.viewport.cy = RT_MIN(cy, pThis->svga.uHeight - y); 562 pThis->svga.viewport.yBottom = y + pThis->svga.viewport.cy; 562 pThis->svga.viewport.yLowWC = pThis->svga.uHeight - y - pThis->svga.viewport.cy; 563 pThis->svga.viewport.yHighWC = pThis->svga.uHeight - y; 563 564 } 564 565 else … … 566 567 pThis->svga.viewport.y = pThis->svga.uHeight; 567 568 pThis->svga.viewport.cy = 0; 568 pThis->svga.viewport.yBottom = y + pThis->svga.uHeight; 569 pThis->svga.viewport.yLowWC = 0; 570 pThis->svga.viewport.yHighWC = 0; 569 571 } 570 572 } … … 1047 1049 && pThis->svga.viewport.cy == 0) 1048 1050 { 1049 pThis->svga.viewport.cx = pThis->svga.viewport.xRight = pThis->svga.uWidth; 1050 pThis->svga.viewport.cy = pThis->svga.viewport.yBottom = pThis->svga.uHeight; 1051 pThis->svga.viewport.cx = pThis->svga.uWidth; 1052 pThis->svga.viewport.xRight = pThis->svga.uWidth; 1053 pThis->svga.viewport.cy = pThis->svga.uHeight; 1054 pThis->svga.viewport.yHighWC = pThis->svga.uHeight; 1055 pThis->svga.viewport.yLowWC = 0; 1051 1056 } 1052 1057 return VINF_SUCCESS; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r57504 r57517 2843 2843 2844 2844 /* If there are no recangles specified, just grab a viewport worth bits. */ 2845 # if 1 2846 VMSVGAVIEWPORT const DstViewport = pThis->svga.viewport; 2847 # else 2848 VMSVGAVIEWPORT const DstViewport = { 0, 0, pThis->svga.uWidth, pThis->svga.uHeight, pThis->svga.uWidth, pThis->svga.uHeight }; 2849 # endif 2850 SVGA3dCopyRect DummyRect; 2845 VMSVGAVIEWPORT const DstViewport = pThis->svga.viewport; 2846 ASMCompilerBarrier(); /* paranoia */ 2847 Assert(DstViewport.yHighWC >= DstViewport.yLowWC); 2848 2849 SVGA3dCopyRect DummyRect; 2851 2850 if (cRects != 0) 2852 2851 { /* likely */ } … … 2859 2858 AssertMsgFailed(("No rects to present. Who is doing that and what do they actually expect?\n")); 2860 2859 # endif 2860 DummyRect.x = DummyRect.srcx = 0; 2861 DummyRect.y = DummyRect.srcy = 0; 2862 DummyRect.w = pThis->svga.uWidth; 2863 DummyRect.h = pThis->svga.uHeight; 2861 2864 cRects = 1; 2862 2865 pRect = &DummyRect; 2863 DummyRect.x = DummyRect.srcx = DstViewport.x;2864 DummyRect.y = DummyRect.srcy = DstViewport.y;2865 DummyRect.w = DstViewport.cx;2866 DummyRect.h = DstViewport.cy;2867 2866 } 2868 2867 … … 2874 2873 SVGA3dCopyRect ClippedRect = pRect[i]; 2875 2874 2876 /* Do some sanity checking and limit width and height, all so we 2877 don't need to think about wrap-arounds below. */ 2875 /* 2876 * Do some sanity checking and limit width and height, all so we 2877 * don't need to think about wrap-arounds below. 2878 */ 2878 2879 if (RT_LIKELY( ClippedRect.w 2879 2880 && ClippedRect.x < VMSVGA_MAX_X … … 2897 2898 2898 2899 2899 /* Source surface clipping (paranoia). */ 2900 /* 2901 * Source surface clipping (paranoia). Straight forward. 2902 */ 2900 2903 if (RT_LIKELY(ClippedRect.srcx < cxSurface)) 2901 2904 { /* likely */ } … … 2922 2925 } 2923 2926 2924 2925 /* Destination viewport clipping. */ 2927 /* 2928 * Destination viewport clipping - real PITA. 2929 * 2930 * We have to take the following into account here: 2931 * - The source image is Y inverted. 2932 * - The destination framebuffer is in world and not window coordinates, 2933 * just like the source surface. This means working in the first quadrant. 2934 * - The viewport is in window coordinate, that is fourth quadrant and 2935 * negated Y values. 2936 * - The destination framebuffer is not scrolled, so we have to blit 2937 * what's visible into the top of the framebuffer. 2938 * 2939 * 2940 * To illustrate: 2941 * 2942 * source destination 0123456789 2943 * 8 ^---------- 8 ^---------- 0 -----------> 2944 * 7 | | 7 | | 1 | | 2945 * 6 | | 6 | ******* | 2 | ******* | 2946 * 5 | *** | 5 | * | 3 | * | 2947 * 4 | * | => 4 | * | => 4 | * | 2948 * 3 | * | 3 | *** | 5 | *** | 2949 * 2 | ******* | 2 | | 6 | | 2950 * 1 | | 1 | | 7 | | 2951 * 0 -----------> 0 -----------> 8 v---------- 2952 * 0123456789 0123456789 Destination window 2953 * 2954 * From the above, it follows that a destination viewport given in 2955 * window coordinates matches the source exactly when srcy = srcx = 0. 2956 * 2957 * Example (Y only): 2958 * ySrc = 0 2959 * yDst = 0 2960 * cyCopy = 9 2961 * cyScreen = cyCopy 2962 * cySurface >= cyCopy 2963 * yViewport = 5 2964 * cyViewport = 2 (i.e. '| *** |' 2965 * '| |' ) 2966 * yWCViewportHi = cxScreen - yViewport = 9 - 5 = 4 2967 * yWCViewportLow = cxScreen - yViewport - cyViewport = 4 - 2 = 2 2968 * 2969 * We can see from the illustration that the final result should be: 2970 * SrcRect = (0,7) (11, 5) (cy=2 from y=5) 2971 * DstRect = (0,2) (11, 4) 2972 * 2973 * Let's postpone the switching of SrcRect.yBottom/yTop to make it 2974 * easier to follow: 2975 * SrcRect = (0,5) (11, 7) 2976 * 2977 * From the top, Y values only: 2978 * 0. Copy = { .yDst = 0, .ySrc = 0, .cy = 9 } 2979 * 2980 * 1. CopyRect.yDst (=0) is lower than yWCViewportLow: 2981 * cyAdjust = yWCViewportLow - CopyRect.yDst = 2; 2982 * Copy.yDst += cyAdjust = 2; 2983 * Copy.ySrc = unchanged; 2984 * Copy.cx -= cyAdjust = 7; 2985 * => Copy = { .yDst = 2, .ySrc = 0, .cy = 7 } 2986 * 2987 * 2. CopyRect.yDst + CopyRect.cx (=9) is higher than yWCViewportHi: 2988 * cyAdjust = CopyRect.yDst + CopyRect.cx - yWCViewportHi = 9 - 4 = 5 2989 * Copy.yDst = unchanged; 2990 * Copy.ySrc += cyAdjust = 5; 2991 * Copy.cx -= cyAdjust = 2; 2992 * => Copy = { .yDst = 2, .ySrc = 5, .cy = 2 } 2993 * 2994 */ 2995 /* X - no inversion, so kind of simple. */ 2926 2996 if (ClippedRect.x >= DstViewport.x) 2927 2997 { … … 2951 3021 } 2952 3022 2953 if (ClippedRect.y >= DstViewport.y) 2954 { 2955 if (ClippedRect.y + ClippedRect.h <= DstViewport.yBottom) 3023 /* Y - complicated, see above. */ 3024 if (ClippedRect.y >= DstViewport.yLowWC) 3025 { 3026 if (ClippedRect.y + ClippedRect.h <= DstViewport.yHighWC) 2956 3027 { /* typical */ } 2957 else if (ClippedRect.y < DstViewport.yBottom) 2958 ClippedRect.h = DstViewport.yBottom - ClippedRect.y; 2959 else 2960 continue; 2961 } 2962 else 2963 { 2964 uint32_t cyAdjust = DstViewport.y - ClippedRect.y; 2965 if (cyAdjust < ClippedRect.h) 3028 else if (ClippedRect.y < DstViewport.yHighWC) 2966 3029 { 3030 /* adjustment #2 */ 3031 uint32_t cyAdjust = ClippedRect.y + ClippedRect.h - DstViewport.yHighWC; 3032 ClippedRect.srcy += cyAdjust; 2967 3033 ClippedRect.h -= cyAdjust; 2968 ClippedRect.y += cyAdjust;2969 ClippedRect.srcy += cyAdjust;2970 3034 } 2971 3035 else 2972 3036 continue; 2973 2974 if (ClippedRect.y + ClippedRect.h <= DstViewport.yBottom) 3037 } 3038 else 3039 { 3040 /* adjustment #1 */ 3041 uint32_t cyAdjust = DstViewport.yLowWC - ClippedRect.y; 3042 if (cyAdjust < ClippedRect.h) 3043 { 3044 ClippedRect.y += cyAdjust; 3045 ClippedRect.h -= cyAdjust; 3046 } 3047 else 3048 continue; 3049 3050 if (ClippedRect.y + ClippedRect.h <= DstViewport.yHighWC) 2975 3051 { /* typical */ } 2976 3052 else 2977 ClippedRect.h = DstViewport.yBottom - ClippedRect.y; 2978 } 2979 2980 2981 /* Do the blitting. */ 3053 { 3054 /* adjustment #2 */ 3055 uint32_t cyAdjust = ClippedRect.y + ClippedRect.h - DstViewport.yHighWC; 3056 ClippedRect.srcy += cyAdjust; 3057 ClippedRect.h -= cyAdjust; 3058 } 3059 } 3060 3061 /* Calc source rectangle with y flipping wrt destination. */ 2982 3062 RTRECT SrcRect; 2983 3063 SrcRect.xLeft = ClippedRect.srcx; 2984 3064 SrcRect.xRight = ClippedRect.srcx + ClippedRect.w; 2985 SrcRect.yBottom = ClippedRect.srcy; 2986 SrcRect.yTop = ClippedRect.srcy + ClippedRect.h; 2987 RTRECT DstRect; /* y flipped wrt source */ 3065 SrcRect.yBottom = ClippedRect.srcy + ClippedRect.h; 3066 SrcRect.yTop = ClippedRect.srcy; 3067 3068 /* Calc destination rectangle. */ 3069 RTRECT DstRect; 2988 3070 DstRect.xLeft = ClippedRect.x; 2989 3071 DstRect.xRight = ClippedRect.x + ClippedRect.w; 2990 DstRect.yBottom = ClippedRect.y + ClippedRect.h; 2991 DstRect.yTop = ClippedRect.y; 3072 DstRect.yBottom = ClippedRect.y; 3073 DstRect.yTop = ClippedRect.y + ClippedRect.h; 3074 3075 /* Adjust for viewport. */ 3076 DstRect.xLeft -= DstViewport.x; 3077 DstRect.xRight -= DstViewport.x; 3078 DstRect.yBottom += DstViewport.y; 3079 DstRect.yTop += DstViewport.y; 2992 3080 2993 3081 Log(("SrcRect: (%d,%d)(%d,%d) DstRect: (%d,%d)(%d,%d)\n", … … 2995 3083 DstRect.xLeft, DstRect.yBottom, DstRect.xRight, DstRect.yTop)); 2996 3084 pState->ext.glBlitFramebuffer(SrcRect.xLeft, SrcRect.yBottom, SrcRect.xRight, SrcRect.yTop, 2997 DstRect.xLeft - DstViewport.x, 2998 DstRect.yBottom - DstViewport.y, 2999 DstRect.xRight - DstViewport.x, 3000 DstRect.yTop - DstViewport.y, 3085 DstRect.xLeft, DstRect.yBottom, DstRect.xRight, DstRect.yTop, 3001 3086 GL_COLOR_BUFFER_BIT, GL_LINEAR); 3002 3087 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-shared.cpp
r57504 r57517 220 220 { 221 221 case WM_CLOSE: 222 Log7(("vmsvga3dWndProc(%p): WM_CLOSE\n", hwnd)); 222 223 break; 223 224 224 225 case WM_DESTROY: 226 Log7(("vmsvga3dWndProc(%p): WM_DESTROY\n", hwnd)); 225 227 break; 226 228 227 229 case WM_NCHITTEST: 230 Log7(("vmsvga3dWndProc(%p): WM_NCHITTEST\n", hwnd)); 228 231 return HTNOWHERE; 232 233 # if 0 /* flicker experiment, no help here. */ 234 case WM_PAINT: 235 Log7(("vmsvga3dWndProc(%p): WM_PAINT %p %p\n", hwnd, wParam, lParam)); 236 ValidateRect(hwnd, NULL); 237 return 0; 238 case WM_ERASEBKGND: 239 Log7(("vmsvga3dWndProc(%p): WM_ERASEBKGND %p %p\n", hwnd, wParam, lParam)); 240 return TRUE; 241 case WM_NCPAINT: 242 Log7(("vmsvga3dWndProc(%p): WM_NCPAINT %p %p\n", hwnd, wParam, lParam)); 243 break; 244 case WM_WINDOWPOSCHANGING: 245 { 246 PWINDOWPOS pPos = (PWINDOWPOS)lParam; 247 Log7(("vmsvga3dWndProc(%p): WM_WINDOWPOSCHANGING %p %p pos=(%d,%d) size=(%d,%d) flags=%#x\n", 248 hwnd, wParam, lParam, pPos->x, pPos->y, pPos->cx, pPos->cy, pPos->flags)); 249 break; 250 } 251 case WM_WINDOWPOSCHANGED: 252 { 253 PWINDOWPOS pPos = (PWINDOWPOS)lParam; 254 Log7(("vmsvga3dWndProc(%p): WM_WINDOWPOSCHANGED %p %p pos=(%d,%d) size=(%d,%d) flags=%#x\n", 255 hwnd, wParam, lParam, pPos->x, pPos->y, pPos->cx, pPos->cy, pPos->flags)); 256 break; 257 } 258 case WM_MOVE: 259 Log7(("vmsvga3dWndProc(%p): WM_MOVE %p %p\n", hwnd, wParam, lParam)); 260 break; 261 case WM_SIZE: 262 Log7(("vmsvga3dWndProc(%p): WM_SIZE %p %p\n", hwnd, wParam, lParam)); 263 break; 264 265 default: 266 Log7(("vmsvga3dWndProc(%p): %#x %p %p\n", hwnd, uMsg, wParam, lParam)); 267 # endif 229 268 } 230 269 return DefWindowProc(hwnd, uMsg, wParam, lParam); -
trunk/src/VBox/Devices/Graphics/DevVGA.h
r57504 r57517 239 239 uint32_t cx; /**< width. */ 240 240 uint32_t cy; /**< height. */ 241 uint32_t xRight; /**< x + cx. */ 242 uint32_t yBottom; /**< y + cy. */ 241 /** Right side coordinate (exclusive). Same as x + cx. */ 242 uint32_t xRight; 243 /** First quadrant low y coordinate. 244 * Same as y + cy - 1 in window coordinates. */ 245 uint32_t yLowWC; 246 /** First quadrant high y coordinate (exclusive) - yLowWC + cy. 247 * Same as y - 1 in window coordinates. */ 248 uint32_t yHighWC; 249 243 250 } VMSVGAVIEWPORT; 244 251
Note:
See TracChangeset
for help on using the changeset viewer.