Changeset 34763 in vbox
- Timestamp:
- Dec 6, 2010 4:55:41 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/x11/vboxvideo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/vboxvideo/vboxutils.c
r34747 r34763 216 216 continue; 217 217 cmdHdr.x = (int16_t)aRects[i].x1 218 - pVBox->aScreenLocation[j].x * 2 219 + pVBox->aScreenLocation[0].x; 218 - pVBox->aScreenLocation[0].x; 220 219 cmdHdr.y = (int16_t)aRects[i].y1 221 - pVBox->aScreenLocation[j].y * 2 222 + pVBox->aScreenLocation[0].y; 220 - pVBox->aScreenLocation[0].y - 1; 223 221 cmdHdr.w = (uint16_t)(aRects[i].x2 - aRects[i].x1); 224 222 cmdHdr.h = (uint16_t)(aRects[i].y2 - aRects[i].y1); -
trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c
r34747 r34763 297 297 (void) mode; 298 298 VBOXPtr pVBox = VBOXGetRec(crtc->scrn); 299 int bpp = crtc->scrn->depth == 24 ? 32 : 16;300 299 301 300 TRACE_LOG("name=%s, HDisplay=%d, VDisplay=%d, x=%d, y=%d\n", adjusted_mode->name, … … 683 682 } 684 683 684 /** Calculate the BPP from the screen depth */ 685 static uint16_t 686 vboxBPP(ScrnInfoPtr pScrn) 687 { 688 return pScrn->depth == 24 ? 32 : 16; 689 } 690 691 /** Calculate the scan line length for a display width */ 692 static int32_t 693 vboxLineLength(ScrnInfoPtr pScrn, int32_t cDisplayWidth) 694 { 695 uint64_t cbLine = ((uint64_t)cDisplayWidth * vboxBPP(pScrn) / 8 + 7) & ~7; 696 return cbLine < INT32_MAX ? cbLine : INT32_MAX; 697 } 698 699 /** Calculate the display pitch from the scan line length */ 700 static int32_t 701 vboxDisplayPitch(ScrnInfoPtr pScrn, int32_t cbLine) 702 { 703 return (uint64_t)cbLine * 8 / vboxBPP(pScrn); 704 } 705 685 706 /* 686 707 * QUOTE from the XFree86 DESIGN document: … … 848 869 849 870 /* Needed before we initialise DRI. */ 850 pScrn->displayWidth = pScrn->virtualX; 871 pVBox->cbLine = vboxLineLength(pScrn, pScrn->virtualX); 872 pScrn->displayWidth = vboxDisplayPitch(pScrn, pVBox->cbLine); 851 873 852 874 xf86PrintModes(pScrn); … … 1163 1185 pScreen->CloseScreen = pVBox->CloseScreen; 1164 1186 return pScreen->CloseScreen(scrnIndex, pScreen); 1187 } 1188 1189 static void 1190 vboxCalcDisplayDimensions(VBOXPtr pVBox, int32_t *pcWidth, int32_t *pcHeight) 1191 { 1192 int32_t cWidth = 0, cHeight = 0; 1193 unsigned i; 1194 for (i = 0; i < pVBox->cScreens; ++i) 1195 { 1196 int32_t cWidthScreen = pVBox->aScreenLocation[i].x 1197 + pVBox->aScreenLocation[i].cx; 1198 int32_t cHeightScreen = pVBox->aScreenLocation[i].y 1199 + pVBox->aScreenLocation[i].cy; 1200 if (cWidthScreen > cWidth) 1201 cWidth = cWidthScreen; 1202 if (cHeightScreen > cWidth) 1203 cWidth = cWidthScreen; 1204 } 1205 *pcWidth = cWidth; 1206 *pcHeight = cHeight; 1165 1207 } 1166 1208 … … 1184 1226 rc = VBOXSetMode(pScrn, 0, pMode->HDisplay, pMode->VDisplay, 1185 1227 pScrn->frameX0, pScrn->frameY0); 1228 { 1229 int32_t cWidth, cHeight; 1230 vboxCalcDisplayDimensions(pVBox, &cWidth, &cHeight); 1231 VBOXAdjustScreenPixmap(pScrn, cWidth, cHeight); 1232 } 1186 1233 if (rc) 1187 1234 { … … 1211 1258 uint32_t yRel = cDisplay ? y - pVBox->aScreenLocation[0].y : 0; 1212 1259 1213 int bpp = pScrn->depth == 24 ? 32 : 16;1214 1260 TRACE_LOG("cDisplay=%u, cWidth=%u, cHeight=%u, x=%d, y=%d, displayWidth=%d\n", 1215 1261 cDisplay, cWidth, cHeight, x, y, pScrn->displayWidth); … … 1220 1266 if (cDisplay == 0) 1221 1267 VBoxVideoSetModeRegisters(cWidth, cHeight, pScrn->displayWidth, 1222 bpp, x, y);1268 vboxBPP(pScrn), x, y); 1223 1269 /* Tell the host we support graphics */ 1224 1270 if (vbox_device_available(pVBox)) … … 1229 1275 && !pVBox->vtSwitch) 1230 1276 VBoxHGSMIProcessDisplayInfo(&pVBox->guestCtx, cDisplay, xRel, yRel, 1231 (y * pScrn->displayWidth + x) * bpp/ 8,1232 p Scrn->displayWidth * bpp / 8,1233 cWidth, cHeight, bpp);1277 pVBox->cbLine + x * vboxBPP(pScrn) / 8, 1278 pVBox->cbLine, 1279 cWidth, cHeight, vboxBPP(pScrn)); 1234 1280 pVBox->aScreenLocation[cDisplay].cx = cWidth; 1235 1281 pVBox->aScreenLocation[cDisplay].cy = cHeight; … … 1245 1291 PixmapPtr pPixmap = pScreen->GetScreenPixmap(pScreen); 1246 1292 VBOXPtr pVBox = VBOXGetRec(pScrn); 1247 int bpp = pScrn->depth == 24 ? 32 : 16;1293 uint64_t cbLine = vboxLineLength(pScrn, width); 1248 1294 1249 1295 TRACE_LOG("width=%d, height=%d\n", width, height); 1250 if ((uint64_t)width * height * bpp / 8 >= pVBox->cbFramebuffer) 1296 if (!pPixmap) { 1297 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 1298 "Failed to get the screen pixmap.\n"); 1299 return FALSE; 1300 } 1301 if (cbLine > UINT32_MAX || cbLine * height >= pVBox->cbFramebuffer) 1251 1302 { 1252 1303 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, … … 1255 1306 return FALSE; 1256 1307 } 1257 if (!pPixmap) {1258 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,1259 "Failed to get the screen pixmap.\n");1260 return FALSE;1261 }1262 1308 pScreen->ModifyPixmapHeader(pPixmap, width, height, 1263 pScrn->depth, bpp, width * bpp / 8,1309 pScrn->depth, vboxBPP(pScrn), cbLine, 1264 1310 pVBox->base); 1265 1311 pScrn->virtualX = width; 1266 1312 pScrn->virtualY = height; 1267 pScrn->displayWidth = width; 1313 pScrn->displayWidth = vboxDisplayPitch(pScrn, cbLine); 1314 pVBox->cbLine = cbLine; 1268 1315 #ifdef VBOX_DRI 1269 1316 if (pVBox->useDRI) … … 1273 1320 /* Write the new values to the hardware */ 1274 1321 xf86SetDesiredModes(pScrn); 1275 #else1276 pScrn->EnableDisableFBAccess(pScrn->scrnIndex, FALSE);1277 pScrn->EnableDisableFBAccess(pScrn->scrnIndex, TRUE);1278 1322 #endif 1279 1323 return TRUE; -
trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.h
r34747 r34763 185 185 /** The amount of VRAM available for use as a framebuffer */ 186 186 unsigned long cbFramebuffer; 187 /** The current line size in bytes */ 188 uint32_t cbLine; 187 189 CARD8 *state, *pstate; /* SVGA state */ 188 190 int statePage, stateSize, stateMode;
Note:
See TracChangeset
for help on using the changeset viewer.