Changeset 49172 in vbox for trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp
- Timestamp:
- Oct 17, 2013 7:34:35 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 90045
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp
r48897 r49172 34 34 #ifdef VBOX_WITH_CRDUMPER 35 35 36 static uint32_t g_CrDbgDumpRecTexInfo = 0; 36 static uint32_t g_CrDbgDumpRecTexInfo = 1; 37 static uint32_t g_CrDbgDumpAlphaData = 1; 37 38 38 39 /* dump stuff */ … … 463 464 { 464 465 crDmpImgF(pRec->pDumper, &Img, "ctx(%d), BUFFER: id(%d) hwid(%d), width(%d), height(%d)", ctx, id, Tex.hwid, width, height); 466 467 if (g_CrDbgDumpAlphaData) 468 { 469 CR_BLITTER_IMG AlphaImg = {0}; 470 rc = crRecAlphaImgCreate(&Img, &AlphaImg); 471 if (RT_SUCCESS(rc)) 472 { 473 crDmpImgF(pRec->pDumper, &AlphaImg, "Buffer ALPHA Data"); 474 crRecAlphaImgDestroy(&AlphaImg); 475 } 476 else 477 { 478 crWarning("crRecAlphaImgCreate failed rc %d", rc); 479 } 480 } 481 465 482 CrBltImgFree(pRec->pBlitter, &Img); 466 483 } … … 1232 1249 } 1233 1250 1251 int crRecAlphaImgCreate(const CR_BLITTER_IMG *pImg, CR_BLITTER_IMG *pAlphaImg) 1252 { 1253 if (pImg->enmFormat != GL_RGBA 1254 && pImg->enmFormat != GL_BGRA) 1255 { 1256 crWarning("unsupported format 0x%x", pImg->enmFormat); 1257 return VERR_NOT_IMPLEMENTED; 1258 } 1259 1260 pAlphaImg->bpp = 32; 1261 pAlphaImg->pitch = pImg->width * 4; 1262 pAlphaImg->cbData = pAlphaImg->pitch * pImg->height; 1263 pAlphaImg->enmFormat = GL_BGRA; 1264 pAlphaImg->width = pImg->width; 1265 pAlphaImg->height = pImg->height; 1266 1267 pAlphaImg->pvData = RTMemAlloc(pAlphaImg->cbData); 1268 if (!pAlphaImg->pvData) 1269 { 1270 crWarning("RTMemAlloc failed"); 1271 return VERR_NO_MEMORY; 1272 } 1273 1274 uint8_t *pu8SrcBuf = (uint8_t*)pImg->pvData; 1275 uint8_t *pu8DstBuf = (uint8_t*)pAlphaImg->pvData; 1276 for (uint32_t ih = 0; ih < pAlphaImg->height; ++ih) 1277 { 1278 uint32_t *pu32SrcBuf = (uint32_t*)pu8SrcBuf; 1279 uint32_t *pu32DstBuf = (uint32_t*)pu8DstBuf; 1280 for (uint32_t iw = 0; iw < pAlphaImg->width; ++iw) 1281 { 1282 uint8_t alpha = (((*pu32SrcBuf) >> 24) & 0xff); 1283 *pu32DstBuf = (0xff << 24) || (alpha << 16) || (alpha << 8) || alpha; 1284 ++pu32SrcBuf; 1285 ++pu32DstBuf; 1286 } 1287 pu8SrcBuf += pImg->pitch; 1288 pu8DstBuf += pAlphaImg->pitch; 1289 } 1290 1291 return VINF_SUCCESS; 1292 } 1293 1294 void crRecAlphaImgDestroy(CR_BLITTER_IMG *pImg) 1295 { 1296 RTMemFree(pImg->pvData); 1297 pImg->pvData = NULL; 1298 } 1299 1234 1300 void crRecDumpTextureV(CR_RECORDER *pRec, const VBOXVR_TEXTURE *pTex, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, va_list pArgList) 1235 1301 { … … 1242 1308 { 1243 1309 crDmpImgV(pRec->pDumper, &Img, pszStr, pArgList); 1310 if (g_CrDbgDumpAlphaData) 1311 { 1312 CR_BLITTER_IMG AlphaImg = {0}; 1313 rc = crRecAlphaImgCreate(&Img, &AlphaImg); 1314 if (RT_SUCCESS(rc)) 1315 { 1316 crDmpImgF(pRec->pDumper, &AlphaImg, "Texture ALPHA Data"); 1317 crRecAlphaImgDestroy(&AlphaImg); 1318 } 1319 else 1320 { 1321 crWarning("crRecAlphaImgCreate failed rc %d", rc); 1322 } 1323 } 1244 1324 CrBltImgFree(pRec->pBlitter, &Img); 1245 1325 }
Note:
See TracChangeset
for help on using the changeset viewer.