Changeset 25385 in vbox
- Timestamp:
- Dec 15, 2009 9:43:23 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 56009
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxGL2D.h
r24409 r25385 134 134 #ifndef GL_STREAM_COPY 135 135 # define GL_STREAM_COPY 0x88E2 136 #endif 137 #ifndef GL_DYNAMIC_DRAW 138 # define GL_DYNAMIC_DRAW 0x88E8 136 139 #endif 137 140 -
trunk/include/VBox/WinNetConfig.h
r22491 r25385 120 120 VBOXNETCFGWIN_DECL(VOID) VBoxNetCfgWinSetLogging(LOG_ROUTINE Log); 121 121 122 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinEnumUpperBindings (); 123 122 124 RT_C_DECLS_END 123 125 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
r25309 r25385 309 309 } 310 310 311 static VBoxVHWATexture* vboxVHWATextureCreate(const QGLContext * pContext, const QRect & aRect, const VBoxVHWAColorFormat & aFormat, bool bVGA) 311 static VBoxVHWATextureImage* vboxVHWAImageCreate(const QRect & aRect, const VBoxVHWAColorFormat & aFormat, class VBoxVHWAGlProgramMngr * pMgr, bool bDisablePBO) 312 { 313 const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(NULL); 314 #ifdef VBOXVHWA_NEW_PBO 315 if(!bDisablePBO && info.getGlInfo().isPBOSupported()) 316 { 317 VBOXQGLLOG(("PBO Image\n")); 318 return new VBoxVHWATextureImagePBO(aRect, aFormat, pMgr); 319 } 320 #endif 321 VBOXQGLLOG(("Generic Image\n")); 322 return new VBoxVHWATextureImage(aRect, aFormat, pMgr, bDisablePBO); 323 } 324 325 static VBoxVHWATexture* vboxVHWATextureCreate(const QGLContext * pContext, const QRect & aRect, const VBoxVHWAColorFormat & aFormat, bool bDisablePBO) 312 326 { 313 327 const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(pContext); 314 315 if(!bVGA && info.getGlInfo().isPBOSupported()) 328 if(!bDisablePBO && info.getGlInfo().isPBOSupported()) 316 329 { 317 330 VBOXQGLLOG(("VBoxVHWATextureNP2RectPBO\n")); … … 1104 1117 } 1105 1118 1106 int VBoxVHWASurfaceBase::setCKey(VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorFormat * pFormat, const VBoxVHWAColorKey * pCKey, bool bDst)1107 {1108 float r,g,b;1109 pFormat->pixel2Normalized(pCKey->lower(), &r, &g, &b);1110 int rcL = bDst ? pProgram->setDstCKeyLowerRange(r, g, b) : pProgram->setSrcCKeyLowerRange(r, g, b);1111 Assert(RT_SUCCESS(rcL));1112 1113 return RT_SUCCESS(rcL) /*&& RT_SUCCESS(rcU)*/ ? VINF_SUCCESS: VERR_GENERAL_FAILURE;1114 }1115 1116 1117 1118 1119 void VBoxVHWASurfaceBase::setAddress(uchar * addr) 1119 1120 { … … 1130 1131 mFreeAddress = false; 1131 1132 1132 #ifdef VBOXVHWA_USE_TEXGROUP 1133 for(int i = mpTex.numSets()-1; i >=0; --i) 1134 { 1135 #endif 1136 mpTex[0]->setAddress(mAddress); 1137 if(fourcc() == FOURCC_YV12) 1138 { 1139 uchar *pTexAddr = mAddress+mpTex[0]->memSize(); 1140 mpTex[1]->setAddress(pTexAddr); 1141 pTexAddr = pTexAddr+mpTex[1]->memSize(); 1142 mpTex[2]->setAddress(pTexAddr); 1143 } 1144 #ifdef VBOXVHWA_USE_TEXGROUP 1145 mpTex.swap(); 1146 } 1147 #endif 1133 mImage->setAddress(mAddress); 1148 1134 1149 1135 mUpdateMem2TexRect.set(mRect); … … 1180 1166 bool bVGA) : 1181 1167 mRect(0,0,aSize.width(),aSize.height()), 1182 mpProgram(NULL),1183 mVisibleDisplayInitialized(false),1184 mNeedVisibilityReinit(true),1185 mNotIntersected(false),1186 1168 mAddress(NULL), 1187 mColorFormat(aColorFormat),1188 1169 mpSrcBltCKey(NULL), 1189 1170 mpDstBltCKey(NULL), … … 1194 1175 mLockCount(0), 1195 1176 mFreeAddress(false), 1177 mbNotIntersected(false), 1196 1178 mComplexList(NULL), 1179 mpPrimary(NULL), 1197 1180 mWidget(aWidget), 1198 1181 mHGHandle(VBOXVHWA_SURFHANDLE_INVALID) … … 1212 1195 resetDefaultSrcOverlayCKey(); 1213 1196 1214 #ifdef VBOXVHWA_USE_TEXGROUP 1215 mpTex.init(mColorFormat.fourcc() == FOURCC_YV12 ? 3 : 1, cBackTex); 1216 Assert(mpTex.numSets()); 1217 for(int i = mpTex.numSets()-1; i >=0; --i) 1218 { 1219 #endif 1220 mpTex[0] = vboxVHWATextureCreate(mWidget->context(), QRect(0,0,aSize.width(),aSize.height()), mColorFormat, bVGA); 1221 if(mColorFormat.fourcc() == FOURCC_YV12) 1222 { 1223 QRect rect(0,0,aSize.width()/2,aSize.height()/2); 1224 mpTex[1] = vboxVHWATextureCreate(mWidget->context(), rect, mColorFormat, bVGA); 1225 mpTex[2] = vboxVHWATextureCreate(mWidget->context(), rect, mColorFormat, bVGA); 1226 } 1227 #ifdef VBOXVHWA_USE_TEXGROUP 1228 mpTex.swap(); 1229 } 1230 #endif 1197 mImage = vboxVHWAImageCreate(QRect(0,0,aSize.width(),aSize.height()), aColorFormat, getGlProgramMngr(), bVGA); 1231 1198 1232 1199 setRectValues(aTargRect, aSrcRect); … … 1310 1277 void VBoxVHWASurfaceBase::uninit() 1311 1278 { 1312 deleteDisplay(); 1313 1314 #ifdef VBOXVHWA_USE_TEXGROUP 1315 for(int i = mpTex.numSets()-1; i >=0; --i) 1316 { 1317 #endif 1318 delete mpTex[0]; 1319 if(fourcc() == FOURCC_YV12) 1320 { 1321 delete mpTex[1]; 1322 delete mpTex[2]; 1323 } 1324 #ifdef VBOXVHWA_USE_TEXGROUP 1325 mpTex.swap(); 1326 } 1327 #endif 1279 delete mImage; 1328 1280 1329 1281 if(mAddress && mFreeAddress) … … 1336 1288 ulong VBoxVHWASurfaceBase::memSize() 1337 1289 { 1338 ulong size = mpTex[0]->memSize(); 1339 if(fourcc() == FOURCC_YV12) 1340 { 1341 size += mpTex[1]->memSize() + mpTex[2]->memSize(); 1342 } 1343 return size; 1290 return (ulong)mImage->memSize(); 1344 1291 } 1345 1292 … … 1356 1303 uchar * address = (uchar *)malloc(size); 1357 1304 #ifdef DEBUG_misha 1358 int tex0Size = m pTex[0]->memSize();1305 int tex0Size = mImage->component(0)->memSize(); 1359 1306 if(pPrimary) 1360 1307 { … … 1379 1326 #endif 1380 1327 1381 #ifdef VBOXVHWA_USE_TEXGROUP 1382 for(int i = mpTex.numSets()-1; i >=0; --i) 1383 { 1384 #endif 1385 mpTex[0]->init(address); 1386 if(fourcc() == FOURCC_YV12) 1387 { 1388 mpTex[1]->init(address); 1389 mpTex[2]->init(address); 1390 } 1391 #ifdef VBOXVHWA_USE_TEXGROUP 1392 mpTex.swap(); 1393 } 1394 #endif 1328 mImage->init(address); 1329 mpPrimary = pPrimary; 1395 1330 1396 1331 if(pvMem) … … 1407 1342 } 1408 1343 1409 #ifdef VBOXVHWA_USE_TEXGROUP 1410 for(int i = mpTex.numSets()-1; i >=0; --i) 1411 { 1412 #endif 1413 mpTex[0]->setAddress(mAddress); 1414 if(fourcc() == FOURCC_YV12) 1415 { 1416 uchar *pTexAddr = mAddress+mpTex[0]->memSize(); 1417 mpTex[1]->setAddress(pTexAddr); 1418 pTexAddr = pTexAddr+mpTex[1]->memSize(); 1419 mpTex[2]->setAddress(pTexAddr); 1420 } 1421 #ifdef VBOXVHWA_USE_TEXGROUP 1422 mpTex.swap(); 1423 } 1424 #endif 1425 1426 initDisplay(pPrimary); 1344 mImage->setAddress(mAddress); 1345 1346 initDisplay(); 1427 1347 1428 1348 mUpdateMem2TexRect.set(mRect); … … 1440 1360 } 1441 1361 1442 #ifdef DEBUGVHWASTRICT1443 bool g_DbgTest = false;1444 #endif1445 1446 1362 void VBoxVHWATexture::doUpdate(uchar * pAddress, const QRect * pRect) 1447 1363 { 1448 #ifdef DEBUGVHWASTRICT1449 if(g_DbgTest)1450 {1451 pAddress = (uchar*)malloc(memSize());1452 uchar val = 0;1453 for(uint32_t i = 0; i < memSize(); i++)1454 {1455 pAddress[i] = val;1456 val+=64;1457 }1458 }1459 #endif1460 1461 1364 GLenum tt = texTarget(); 1462 1365 if(pRect) … … 1493 1396 address); 1494 1397 ); 1495 1496 #ifdef DEBUGVHWASTRICT1497 if(g_DbgTest)1498 {1499 free(pAddress);1500 }1501 #endif1502 1398 } 1503 1399 … … 1520 1416 } 1521 1417 1522 VBoxVHWATexture::VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat) 1523 : mAddress(0), 1524 mTexture(0) 1418 VBoxVHWATexture::VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat) : 1419 mAddress(NULL), 1420 mTexture(0), 1421 mBytesPerPixel(0), 1422 mBytesPerPixelTex(0), 1423 mBytesPerLine(0) 1525 1424 { 1526 1425 mColorFormat = aFormat; … … 1623 1522 return false; 1624 1523 1625 #ifdef VBOXVHWA_USE_TEXGROUP1626 mpTex.swap();1627 #endif1628 1629 1524 #ifdef VBOXVHWA_PROFILE_FPS 1630 1525 mWidget->reportNewFrame(); 1631 1526 #endif 1632 1527 1633 mpTex[0]->update(&mUpdateMem2TexRect.rect()); 1634 if(fourcc() == FOURCC_YV12) 1635 { 1636 QRect rect(mUpdateMem2TexRect.rect().x()/2, mUpdateMem2TexRect.rect().y()/2, 1637 mUpdateMem2TexRect.rect().width()/2, mUpdateMem2TexRect.rect().height()/2); 1638 mpTex[1]->update(&rect); 1639 mpTex[2]->update(&rect); 1640 } 1528 mImage->update(&mUpdateMem2TexRect.rect()); 1641 1529 1642 1530 mUpdateMem2TexRect.clear(); … … 1751 1639 } 1752 1640 1753 void 1641 void VBoxVHWATextureNP2RectPBOMapped::unmapBuffer() 1754 1642 { 1755 1643 Assert(mpMappedAllignedBuffer); … … 1816 1704 vboxglBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); 1817 1705 ); 1818 }1819 1820 void VBoxVHWASurfaceBase::doTex2FB(const QRect * pDstRect, const QRect * pSrcRect)1821 {1822 int tx1, ty1, tx2, ty2;1823 pSrcRect->getCoords(&tx1, &ty1, &tx2, &ty2);1824 int bx1, by1, bx2, by2;1825 pDstRect->getCoords(&bx1, &by1, &bx2, &by2);1826 tx2++; ty2++;bx2++; by2++;1827 1828 VBOXQGLLOG_QRECT("texRect: ", &mpTex[0]->texRect(), "\n");1829 glBegin(GL_QUADS);1830 mpTex[0]->texCoord(tx1, ty1);1831 glVertex2i(bx1, by1);1832 mpTex[0]->texCoord(tx1, ty2);1833 glVertex2i(bx1, by2);1834 mpTex[0]->texCoord(tx2, ty2);1835 glVertex2i(bx2, by2);1836 mpTex[0]->texCoord(tx2, ty1);1837 glVertex2i(bx2, by1);1838 glEnd();1839 }1840 1841 1842 void VBoxVHWASurfaceBase::doMultiTex2FB(const QRect * pDstRect, const QRect * pSrcRect, int cSrcTex)1843 {1844 int tx1, ty1, tx2, ty2;1845 pSrcRect->getCoords(&tx1, &ty1, &tx2, &ty2);1846 int bx1, by1, bx2, by2;1847 pDstRect->getCoords(&bx1, &by1, &bx2, &by2);1848 tx2++; ty2++;bx2++; by2++;1849 uint32_t t0width = mpTex[0]->rect().width();1850 uint32_t t0height = mpTex[0]->rect().height();1851 1852 glBegin(GL_QUADS);1853 for(int i = 0; i < cSrcTex; i++)1854 {1855 mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx1/(t0width/mpTex[i]->texRect().width()), ty1/(t0height/mpTex[i]->rect().height()));1856 }1857 glVertex2i(bx1, by1);1858 for(int i = 0; i < cSrcTex; i++)1859 {1860 mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx1/(t0width/mpTex[i]->texRect().width()), ty2/(t0height/mpTex[i]->rect().height()));1861 }1862 glVertex2i(bx1, by2);1863 for(int i = 0; i < cSrcTex; i++)1864 {1865 mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx2/(t0width/mpTex[i]->texRect().width()), ty2/(t0height/mpTex[i]->rect().height()));1866 1867 }1868 glVertex2i(bx2, by2);1869 for(int i = 0; i < cSrcTex; i++)1870 {1871 mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx2/(t0width/mpTex[i]->texRect().width()), ty1/(t0height/mpTex[i]->rect().height()));1872 }1873 glVertex2i(bx2, by1);1874 glEnd();1875 }1876 1877 void VBoxVHWASurfaceBase::doMultiTex2FB(const QRect * pDstRect, VBoxVHWATexture * pDstTex, const QRect * pSrcRect, int cSrcTex)1878 {1879 int tx1, ty1, tx2, ty2;1880 pSrcRect->getCoords(&tx1, &ty1, &tx2, &ty2);1881 int bx1, by1, bx2, by2;1882 pDstRect->getCoords(&bx1, &by1, &bx2, &by2);1883 tx2++; ty2++;bx2++; by2++;1884 uint32_t t0width = mpTex[0]->rect().width();1885 uint32_t t0height = mpTex[0]->rect().height();1886 1887 glBegin(GL_QUADS);1888 1889 for(int i = 0; i < cSrcTex; i++)1890 {1891 mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx1/(t0width/mpTex[i]->rect().width()), ty1/(t0height/mpTex[i]->rect().height()));1892 }1893 pDstTex->multiTexCoord(GL_TEXTURE0 + cSrcTex, bx1, by1);1894 glVertex2i(bx1, by1);1895 1896 for(int i = 0; i < cSrcTex; i++)1897 {1898 mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx1/(t0width/mpTex[i]->rect().width()), ty2/(t0height/mpTex[i]->rect().height()));1899 }1900 pDstTex->multiTexCoord(GL_TEXTURE0 + cSrcTex, bx1, by2);1901 glVertex2i(bx1, by2);1902 1903 for(int i = 0; i < cSrcTex; i++)1904 {1905 mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx2/(t0width/mpTex[i]->rect().width()), ty2/(t0height/mpTex[i]->rect().height()));1906 }1907 pDstTex->multiTexCoord(GL_TEXTURE0 + cSrcTex, bx2, by2);1908 glVertex2i(bx2, by2);1909 1910 for(int i = 0; i < cSrcTex; i++)1911 {1912 mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx2/(t0width/mpTex[i]->rect().width()), ty1/(t0height/mpTex[i]->rect().height()));1913 }1914 pDstTex->multiTexCoord(GL_TEXTURE0 + cSrcTex, bx2, by1);1915 glVertex2i(bx2, by1);1916 1917 glEnd();1918 1919 1706 } 1920 1707 … … 1999 1786 { 2000 1787 setRectValues(aTargRect, aSrcRect); 2001 mNeedVisibilityReinit = true;2002 1788 } 2003 1789 } … … 2012 1798 void VBoxVHWASurfaceBase::updateVisibility (VBoxVHWASurfaceBase *pPrimary, const QRect & aVisibleTargRect, bool bNotIntersected, bool bForce) 2013 1799 { 2014 if( mNeedVisibilityReinit || bForce || aVisibleTargRect.intersected(mTargRect) != mVisibleTargRect || mNotIntersected != bNotIntersected)1800 if(bForce || aVisibleTargRect.intersected(mTargRect) != mVisibleTargRect) 2015 1801 { 2016 1802 setVisibleRectValues(aVisibleTargRect); 2017 mNotIntersected = bNotIntersected; 2018 initDisplay(pPrimary); 2019 mNeedVisibilityReinit = false; 2020 } 2021 } 2022 2023 void VBoxVHWASurfaceBase::deleteDisplay() 2024 { 2025 if(mVisibleDisplayInitialized) 2026 { 2027 #ifdef VBOXVHWA_USE_TEXGROUP 2028 for(int i = mpTex.numSets()-1; i >=0; --i) 2029 { 2030 if(mpTex.display()) 2031 { 2032 glDeleteLists(mpTex.display(), 1); 2033 mpTex.display() = 0; 2034 } 2035 if(mpProgram) 2036 { 2037 mpProgram = NULL; 2038 } 2039 mpTex.swap(); 2040 } 2041 #else 2042 if(mVisibleDisplay) 2043 { 2044 glDeleteLists(mVisibleDisplay, 1); 2045 mVisibleDisplay = 0; 2046 } 2047 if(mpProgram) 2048 { 2049 mpProgram = NULL; 2050 } 2051 #endif 2052 mVisibleDisplayInitialized = false; 2053 } 2054 } 2055 2056 void VBoxVHWASurfaceBase::doDisplay(VBoxVHWASurfaceBase *pPrimary, bool bProgram, bool bBindDst) 2057 { 2058 bool bInvokeMultiTex2 = false; 2059 2060 if(bProgram) 2061 { 2062 if(bBindDst) 2063 { 2064 if(fourcc() == FOURCC_YV12) 2065 { 2066 vboxglActiveTexture(GL_TEXTURE1); 2067 mpTex[1]->bind(); 2068 vboxglActiveTexture(GL_TEXTURE1+1); 2069 mpTex[2]->bind(); 2070 2071 vboxglActiveTexture(GL_TEXTURE1+2); 2072 } 2073 else 2074 { 2075 vboxglActiveTexture(GL_TEXTURE1); 2076 } 2077 pPrimary->mpTex[0]->bind(); 2078 2079 vboxglActiveTexture(GL_TEXTURE0); 2080 mpTex[0]->bind(); 2081 bInvokeMultiTex2 = true; 2082 } 2083 else 2084 { 2085 if(fourcc() == FOURCC_YV12) 2086 { 2087 vboxglActiveTexture(GL_TEXTURE1); 2088 mpTex[1]->bind(); 2089 vboxglActiveTexture(GL_TEXTURE0); 2090 } 2091 mpTex[0]->bind(); 2092 } 2093 } 2094 else 2095 { 2096 mpTex[0]->bind(); 2097 } 2098 2099 if(bInvokeMultiTex2) 2100 { 2101 doMultiTex2FB(&mVisibleTargRect, pPrimary->mpTex[0], &mVisibleSrcRect, 2102 (fourcc() == FOURCC_YV12) ? 2 : 1); 2103 } 2104 else 2105 { 2106 if(fourcc() == FOURCC_YV12) 2107 { 2108 doMultiTex2FB(&mVisibleTargRect, &mVisibleSrcRect, 2); 2109 } 2110 else 2111 { 2112 VBOXQGLLOG_QRECT("mVisibleTargRect: ", &mVisibleTargRect, "\n"); 2113 VBOXQGLLOG_QRECT("mVisibleSrcRect: ", &mVisibleSrcRect, "\n"); 2114 doTex2FB(&mVisibleTargRect, &mVisibleSrcRect); 2115 } 2116 } 2117 } 2118 2119 class VBoxVHWAGlProgramVHWA * VBoxVHWASurfaceBase::calcProgram(VBoxVHWASurfaceBase * pPrimary) 2120 { 2121 const VBoxVHWAColorKey * pSrcCKey = NULL, *pDstCKey = NULL; 2122 uint32_t type = 0; 2123 2124 pSrcCKey = getActiveSrcOverlayCKey(); 2125 /* we use src (overlay) surface to maintain overridden dst ckey info 2126 * to allow multiple overlays have different overridden dst keys for one primary surface */ 2127 /* non-null dstOverlayCKey for overlay would mean the overlay surface contains the overridden 2128 * dst ckey value in defaultDstOverlayCKey 2129 * this allows the NULL to be a valid overridden value as well */ 2130 pDstCKey = getActiveDstOverlayCKey(pPrimary); 2131 2132 if(pDstCKey != NULL) 2133 type |= VBOXVHWA_PROGRAM_DSTCOLORKEY; 2134 if(pSrcCKey) 2135 type |= VBOXVHWA_PROGRAM_SRCCOLORKEY; 2136 if((pDstCKey || pSrcCKey) && mNotIntersected) 2137 type |= VBOXVHWA_PROGRAM_COLORKEYNODISCARD; 2138 2139 return mWidget->vboxVHWAGetGlProgramMngr()->getProgram(type, &colorFormat(), &pPrimary->colorFormat()); 2140 } 2141 2142 int VBoxVHWASurfaceBase::createDisplay(VBoxVHWASurfaceBase *pPrimary, GLuint *pDisplay, class VBoxVHWAGlProgramVHWA ** ppProgram) 2143 { 1803 } 1804 1805 mpPrimary = pPrimary; 1806 mbNotIntersected = bNotIntersected; 1807 1808 initDisplay(); 1809 } 1810 1811 void VBoxVHWASurfaceBase::initDisplay() 1812 { 1813 if(mVisibleTargRect.isEmpty() || mVisibleSrcRect.isEmpty()) 1814 { 1815 Assert(mVisibleTargRect.isEmpty() && mVisibleSrcRect.isEmpty()); 1816 mImage->deleteDisplay(); 1817 return; 1818 } 1819 1820 int rc = mImage->initDisplay(mpPrimary ? mpPrimary->mImage : NULL, &mVisibleTargRect, &mVisibleSrcRect, getActiveDstOverlayCKey(mpPrimary), getActiveSrcOverlayCKey(), mbNotIntersected); 1821 AssertRC(rc); 1822 } 1823 1824 void VBoxVHWASurfaceBase::updatedMem(const QRect *rec) 1825 { 1826 if(rec) 1827 { 1828 Assert(mRect.contains(*rec)); 1829 } 1830 mUpdateMem2TexRect.add(*rec); 1831 } 1832 1833 bool VBoxVHWASurfaceBase::performDisplay(VBoxVHWASurfaceBase *pPrimary, bool bForce) 1834 { 1835 Assert(mImage->displayInitialized()); 1836 2144 1837 if(mVisibleTargRect.isEmpty()) 2145 {2146 Assert(mVisibleSrcRect.isEmpty());2147 return 0;2148 }2149 Assert(!mVisibleSrcRect.isEmpty());2150 /* just for the fallback */2151 if(mVisibleSrcRect.isEmpty())2152 {2153 *pDisplay = 0;2154 return VINF_SUCCESS;2155 }2156 2157 VBoxVHWAGlProgramVHWA * pProgram = NULL;2158 if(pPrimary)2159 {2160 pProgram = calcProgram(pPrimary);2161 if(pProgram)2162 {2163 const VBoxVHWAColorKey *pResSrcCKey = getActiveSrcOverlayCKey();2164 const VBoxVHWAColorKey *pResDstCKey = getActiveDstOverlayCKey(pPrimary);2165 2166 pProgram->start();2167 if(pResSrcCKey)2168 {2169 VBoxVHWASurfaceBase::setCKey(pProgram, &colorFormat(), pResSrcCKey, false);2170 }2171 if(pResDstCKey)2172 {2173 VBoxVHWASurfaceBase::setCKey(pProgram, &pPrimary->colorFormat(), pResDstCKey, true);2174 }2175 pProgram->stop();2176 }2177 }2178 2179 glGetError(); /* clear the err flag */2180 GLuint display = glGenLists(1);2181 GLenum err = glGetError();2182 if(err == GL_NO_ERROR)2183 {2184 Assert(display);2185 if(!display)2186 {2187 /* well, it seems it should not return 0 on success according to the spec,2188 * but just in case, pick another one */2189 display = glGenLists(1);2190 err = glGetError();2191 if(err == GL_NO_ERROR)2192 {2193 Assert(display);2194 }2195 else2196 {2197 /* we are failed */2198 Assert(!display);2199 display = 0;2200 }2201 }2202 2203 if(display)2204 {2205 const VBoxVHWAColorKey * pDstCKey = pPrimary ? getActiveDstOverlayCKey(pPrimary) : NULL;2206 2207 glNewList(display, GL_COMPILE);2208 2209 doDisplay(pPrimary, pProgram != 0, pDstCKey != NULL);2210 2211 glEndList();2212 VBOXQGL_ASSERTNOERR();2213 *pDisplay = display;2214 *ppProgram = pProgram;2215 return VINF_SUCCESS;2216 }2217 }2218 else2219 {2220 VBOXQGLLOG(("gl error ocured (0x%x)\n", err));2221 Assert(err == GL_NO_ERROR);2222 }2223 2224 return VERR_GENERAL_FAILURE;2225 }2226 2227 void VBoxVHWASurfaceBase::initDisplay(VBoxVHWASurfaceBase *pPrimary)2228 {2229 deleteDisplay();2230 2231 int rc;2232 #ifdef VBOXVHWA_USE_TEXGROUP2233 for(int i = mpTex.numSets()-1; i >=0; --i)2234 {2235 rc = createDisplay(pPrimary, &mpTex.display(), &mpProgram);2236 AssertRC(rc);2237 if(RT_FAILURE(rc))2238 break;2239 mpTex.swap();2240 }2241 #else2242 rc = createDisplay(pPrimary, &mVisibleDisplay, &mpProgram);2243 AssertRC(rc);2244 #endif2245 if(RT_SUCCESS(rc))2246 {2247 mVisibleDisplayInitialized = true;2248 }2249 else2250 {2251 mVisibleDisplayInitialized = false;2252 }2253 }2254 2255 void VBoxVHWASurfaceBase::updatedMem(const QRect *rec)2256 {2257 if(rec)2258 {2259 Assert(mRect.contains(*rec));2260 }2261 mUpdateMem2TexRect.add(*rec);2262 }2263 2264 bool VBoxVHWASurfaceBase::performDisplay(VBoxVHWASurfaceBase *pPrimary, bool bForce)2265 {2266 Assert(mVisibleDisplayInitialized);2267 2268 #ifdef VBOXVHWA_USE_TEXGROUP2269 if(mpTex.display() == 0)2270 #else2271 if(mVisibleDisplay == 0)2272 #endif2273 1838 { 2274 1839 /* nothing to display, i.e. the surface is not visible, 2275 1840 * in the sense that it's located behind the viewport ranges */ 2276 1841 Assert(mVisibleSrcRect.isEmpty()); 2277 Assert(mVisibleTargRect.isEmpty());2278 1842 return false; 2279 1843 } … … 2281 1845 { 2282 1846 Assert(!mVisibleSrcRect.isEmpty()); 2283 Assert(!mVisibleTargRect.isEmpty());2284 1847 } 2285 1848 2286 1849 bForce |= synchTexMem(&mVisibleSrcRect); 2287 if(pPrimary && getActiveDstOverlayCKey(pPrimary)) 1850 1851 const VBoxVHWAColorKey * pDstCKey = getActiveDstOverlayCKey(pPrimary); 1852 if(pPrimary && pDstCKey) 2288 1853 { 2289 1854 bForce |= pPrimary->synchTexMem(&mVisibleTargRect); … … 2293 1858 return false; 2294 1859 2295 #ifdef VBOXVHWA_USE_TEXGROUP 2296 Assert(mpTex.display()); 2297 #else 2298 Assert(mVisibleDisplay); 2299 #endif 2300 2301 if(!mVisibleDisplayInitialized) 2302 { 2303 VBoxVHWAGlProgramVHWA * pProgram = NULL; 2304 if(pPrimary) 2305 { 2306 pProgram = calcProgram(pPrimary); 2307 } 2308 2309 const VBoxVHWAColorKey * pDstCKey = NULL; 2310 pDstCKey = getActiveDstOverlayCKey(pPrimary); 2311 2312 if(pProgram) 2313 pProgram->start(); 2314 doDisplay(pPrimary, pProgram != 0, pDstCKey != NULL); 2315 if(pProgram) 2316 pProgram->stop(); 2317 } 2318 else 2319 { 2320 if(mpProgram) 2321 mpProgram->start(); 2322 #ifdef VBOXVHWA_USE_TEXGROUP 2323 VBOXQGL_CHECKERR( 2324 glCallList(mpTex.display()); 2325 ); 2326 #else 2327 VBOXQGL_CHECKERR( 2328 glCallList(mVisibleDisplay); 2329 ); 2330 #endif 2331 if(mpProgram) 2332 mpProgram->stop(); 2333 2334 } 1860 mImage->display(); 2335 1861 2336 1862 Assert(bForce); 2337 1863 return true; 1864 } 1865 1866 class VBoxVHWAGlProgramMngr * VBoxVHWASurfaceBase::getGlProgramMngr() 1867 { 1868 return mWidget->vboxVHWAGetGlProgramMngr(); 2338 1869 } 2339 1870 … … 2877 2408 QSize surfSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height); 2878 2409 QRect primaryRect = mDisplay.getPrimary()->rect(); 2879 surf = new VBoxVHWASurfaceBase(this, surfSize, 2410 surf = new VBoxVHWASurfaceBase(this, 2411 surfSize, 2880 2412 primaryRect, 2881 2413 QRect(0, 0, surfSize.width(), surfSize.height()), … … 2894 2426 2895 2427 VBoxVHWAColorFormat format(pCmd->SurfInfo.PixelFormat.fourCC); 2896 surf = new VBoxVHWASurfaceBase(this, surfSize, 2428 surf = new VBoxVHWASurfaceBase(this, 2429 surfSize, 2897 2430 primaryRect, 2898 2431 QRect(0, 0, surfSize.width(), surfSize.height()), … … 3152 2685 void VBoxGLWidget::vhwaDoSurfaceOverlayUpdate(VBoxVHWASurfaceBase *pDstSurf, VBoxVHWASurfaceBase *pSrcSurf, struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE *pCmd) 3153 2686 { 3154 /* get old values first to check whether we need to re-init display and program values */3155 bool bHadSrcCKey = false, bHadDstCKey = false;3156 3157 if(pDstSurf)3158 {3159 bHadSrcCKey = !!(pSrcSurf->getActiveSrcOverlayCKey());3160 bHadDstCKey = !!(pSrcSurf->getActiveDstOverlayCKey(pDstSurf));3161 }3162 3163 2687 if(pCmd->u.in.flags & VBOXVHWA_OVER_KEYDEST) 3164 2688 { … … 3233 2757 VBOXQGLLOG_QRECT("srcRect:", &srcRect, "\n"); 3234 2758 3235 const VBoxVHWAColorKey *pResSrcCKey = pSrcSurf->getActiveSrcOverlayCKey(); 3236 const VBoxVHWAColorKey *pResDstCKey = pSrcSurf->getActiveDstOverlayCKey(pDstSurf); 3237 3238 if(bHadSrcCKey != !!pResSrcCKey || bHadDstCKey != !!pResDstCKey) 3239 { 3240 pSrcSurf->setVisibilityReinitFlag(); 3241 } 3242 else if(pResSrcCKey || pResDstCKey) 3243 { 3244 VBoxVHWAGlProgramVHWA *pProgram = pSrcSurf->getProgram(pDstSurf); 3245 if(pProgram) 3246 { 3247 pProgram->start(); 3248 if(pResSrcCKey) 3249 { 3250 VBoxVHWASurfaceBase::setCKey(pProgram, &pSrcSurf->colorFormat(), pResSrcCKey, false); 3251 } 3252 if(pResDstCKey) 3253 { 3254 VBoxVHWASurfaceBase::setCKey(pProgram, &pDstSurf->colorFormat(), pResDstCKey, true); 3255 } 3256 pProgram->stop(); 3257 } 3258 } 2759 pSrcSurf->setPrimary(pDstSurf); 3259 2760 3260 2761 pSrcSurf->setRects(dstRect, srcRect); 3261 3262 2762 } 3263 2763 } … … 3400 2900 { 3401 2901 VBoxVHWASurfaceBase *pOverlaySurf = *sit; 3402 pOverlaySurf->setVisibilityReinitFlag();3403 2902 } 3404 2903 } … … 5505 5004 } 5506 5005 5507 #endif 5006 VBoxVHWATextureImage::VBoxVHWATextureImage(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, bool bDisablePBO) : 5007 mVisibleDisplay(0), 5008 mpProgram(0), 5009 mProgramMngr(aMgr), 5010 mpDst(NULL), 5011 mpDstCKey(NULL), 5012 mpSrcCKey(NULL), 5013 mbNotIntersected(false) 5014 { 5015 mpTex[0] = vboxVHWATextureCreate(NULL, size, format, bDisablePBO); 5016 mColorFormat = format; 5017 if(mColorFormat.fourcc() == FOURCC_YV12) 5018 { 5019 QRect rect(size.x()/2,size.y()/2,size.width()/2,size.height()/2); 5020 mpTex[1] = vboxVHWATextureCreate(NULL, rect, format, bDisablePBO); 5021 mpTex[2] = vboxVHWATextureCreate(NULL, rect, format, bDisablePBO); 5022 mcTex = 3; 5023 } 5024 else 5025 { 5026 mcTex = 1; 5027 } 5028 } 5029 5030 void VBoxVHWATextureImage::deleteDisplayList() 5031 { 5032 if(mVisibleDisplay) 5033 { 5034 glDeleteLists(mVisibleDisplay, 1); 5035 mVisibleDisplay = 0; 5036 } 5037 } 5038 5039 void VBoxVHWATextureImage::deleteDisplay() 5040 { 5041 deleteDisplayList(); 5042 mpProgram = NULL; 5043 } 5044 5045 void VBoxVHWATextureImage::draw(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect) 5046 { 5047 int tx1, ty1, tx2, ty2; 5048 pSrcRect->getCoords(&tx1, &ty1, &tx2, &ty2); 5049 int bx1, by1, bx2, by2; 5050 pDstRect->getCoords(&bx1, &by1, &bx2, &by2); 5051 tx2++; ty2++;bx2++; by2++; 5052 5053 glBegin(GL_QUADS); 5054 uint32_t c = texCoord(GL_TEXTURE0, tx1, ty1); 5055 if(pDst) 5056 { 5057 pDst->texCoord(GL_TEXTURE0 + c, bx1, by1); 5058 } 5059 glVertex2i(bx1, by1); 5060 5061 texCoord(GL_TEXTURE0, tx1, ty2); 5062 if(pDst) 5063 { 5064 pDst->texCoord(GL_TEXTURE0 + c, bx1, by2); 5065 } 5066 glVertex2i(bx1, by2); 5067 5068 texCoord(GL_TEXTURE0, tx2, ty2); 5069 if(pDst) 5070 { 5071 pDst->texCoord(GL_TEXTURE0 + c, bx2, by2); 5072 } 5073 glVertex2i(bx2, by2); 5074 5075 texCoord(GL_TEXTURE0, tx2, ty1); 5076 if(pDst) 5077 { 5078 pDst->texCoord(GL_TEXTURE0 + c, bx2, by1); 5079 } 5080 glVertex2i(bx2, by1); 5081 5082 glEnd(); 5083 } 5084 5085 void VBoxVHWATextureImage::internalSetDstCKey(const VBoxVHWAColorKey * pDstCKey) 5086 { 5087 if(pDstCKey) 5088 { 5089 mDstCKey = *pDstCKey; 5090 mpDstCKey = &mDstCKey; 5091 } 5092 else 5093 { 5094 mpDstCKey = NULL; 5095 } 5096 } 5097 5098 void VBoxVHWATextureImage::internalSetSrcCKey(const VBoxVHWAColorKey * pSrcCKey) 5099 { 5100 if(pSrcCKey) 5101 { 5102 mSrcCKey = *pSrcCKey; 5103 mpSrcCKey = &mSrcCKey; 5104 } 5105 else 5106 { 5107 mpSrcCKey = NULL; 5108 } 5109 } 5110 5111 int VBoxVHWATextureImage::initDisplay(VBoxVHWATextureImage *pDst, 5112 const QRect * pDstRect, const QRect * pSrcRect, 5113 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected) 5114 { 5115 if(!mVisibleDisplay 5116 || mpDst != pDst 5117 || *pDstRect != mDstRect 5118 || *pSrcRect != mSrcRect 5119 || !!(pDstRect) != !!(mpDstCKey) 5120 || !!(pSrcCKey) != !!(mpSrcCKey) 5121 || mbNotIntersected != bNotIntersected) 5122 { 5123 return createSetDisplay(pDst, pDstRect, pSrcRect, 5124 pDstCKey, pSrcCKey, bNotIntersected, 5125 &mVisibleDisplay, &mpProgram); 5126 5127 } 5128 else if((pDstCKey && mpDstCKey && *pDstCKey == *mpDstCKey) 5129 || (pSrcCKey && mpSrcCKey && *pSrcCKey == *mpSrcCKey)) 5130 { 5131 Assert(mpProgram); 5132 updateSetCKeys(pDstCKey, pSrcCKey); 5133 return VINF_SUCCESS; 5134 } 5135 mVisibleDisplay = 0; 5136 mpProgram = 0; 5137 return VINF_SUCCESS; 5138 } 5139 5140 void VBoxVHWATextureImage::bind(VBoxVHWATextureImage * pPrimary) 5141 { 5142 for(uint32_t i = 1; i < mcTex; i++) 5143 { 5144 vboxglActiveTexture(GL_TEXTURE0 + i); 5145 mpTex[i]->bind(); 5146 } 5147 if(pPrimary) 5148 { 5149 for(uint32_t i = 0; i < pPrimary->mcTex; i++) 5150 { 5151 vboxglActiveTexture(GL_TEXTURE0 + i + mcTex); 5152 pPrimary->mpTex[i]->bind(); 5153 } 5154 } 5155 5156 vboxglActiveTexture(GL_TEXTURE0); 5157 mpTex[0]->bind(); 5158 } 5159 5160 class VBoxVHWAGlProgramVHWA * VBoxVHWATextureImage::calcProgram(VBoxVHWATextureImage *pDst, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected) 5161 { 5162 uint32_t type = 0; 5163 5164 if(pDstCKey != NULL) 5165 type |= VBOXVHWA_PROGRAM_DSTCOLORKEY; 5166 if(pSrcCKey) 5167 type |= VBOXVHWA_PROGRAM_SRCCOLORKEY; 5168 if((pDstCKey || pSrcCKey) && bNotIntersected) 5169 type |= VBOXVHWA_PROGRAM_COLORKEYNODISCARD; 5170 5171 return mProgramMngr->getProgram(type, &colorFormat(), pDst ? &pDst->colorFormat() : NULL); 5172 } 5173 5174 int VBoxVHWATextureImage::createSetDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect, 5175 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected, 5176 GLuint *pDisplay, class VBoxVHWAGlProgramVHWA ** ppProgram) 5177 { 5178 deleteDisplay(); 5179 int rc = createDisplay(pDst, pDstRect, pSrcRect, 5180 pDstCKey, pSrcCKey, bNotIntersected, 5181 &mVisibleDisplay, &mpProgram); 5182 if(RT_FAILURE(rc)) 5183 { 5184 mVisibleDisplay = 0; 5185 mpProgram = NULL; 5186 } 5187 5188 mpDst = pDst; 5189 5190 mDstRect = *pDstRect; 5191 mSrcRect = *pSrcRect; 5192 5193 internalSetDstCKey(pDstCKey); 5194 internalSetSrcCKey(pSrcCKey); 5195 5196 mbNotIntersected = bNotIntersected; 5197 5198 return rc; 5199 } 5200 5201 5202 int VBoxVHWATextureImage::createDisplayList(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect, 5203 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected, 5204 GLuint *pDisplay) 5205 { 5206 glGetError(); /* clear the err flag */ 5207 GLuint display = glGenLists(1); 5208 GLenum err = glGetError(); 5209 if(err == GL_NO_ERROR) 5210 { 5211 Assert(display); 5212 if(!display) 5213 { 5214 /* well, it seems it should not return 0 on success according to the spec, 5215 * but just in case, pick another one */ 5216 display = glGenLists(1); 5217 err = glGetError(); 5218 if(err == GL_NO_ERROR) 5219 { 5220 Assert(display); 5221 } 5222 else 5223 { 5224 /* we are failed */ 5225 Assert(!display); 5226 display = 0; 5227 } 5228 } 5229 5230 if(display) 5231 { 5232 glNewList(display, GL_COMPILE); 5233 5234 runDisplay(pDst, pDstRect, pSrcRect); 5235 5236 glEndList(); 5237 VBOXQGL_ASSERTNOERR(); 5238 *pDisplay = display; 5239 return VINF_SUCCESS; 5240 } 5241 } 5242 else 5243 { 5244 VBOXQGLLOG(("gl error ocured (0x%x)\n", err)); 5245 Assert(err == GL_NO_ERROR); 5246 } 5247 return VERR_GENERAL_FAILURE; 5248 } 5249 5250 void VBoxVHWATextureImage::updateCKeys(VBoxVHWATextureImage * pDst, class VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey) 5251 { 5252 if(pProgram) 5253 { 5254 pProgram->start(); 5255 if(pSrcCKey) 5256 { 5257 VBoxVHWATextureImage::setCKey(pProgram, &colorFormat(), pSrcCKey, false); 5258 } 5259 if(pDstCKey) 5260 { 5261 VBoxVHWATextureImage::setCKey(pProgram, &pDst->colorFormat(), pDstCKey, true); 5262 } 5263 pProgram->stop(); 5264 } 5265 } 5266 5267 void VBoxVHWATextureImage::updateSetCKeys(const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey) 5268 { 5269 updateCKeys(mpDst, mpProgram, pDstCKey, pSrcCKey); 5270 internalSetDstCKey(pDstCKey); 5271 internalSetSrcCKey(pSrcCKey); 5272 } 5273 5274 int VBoxVHWATextureImage::createDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect, 5275 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected, 5276 GLuint *pDisplay, class VBoxVHWAGlProgramVHWA ** ppProgram) 5277 { 5278 VBoxVHWAGlProgramVHWA * pProgram = NULL; 5279 if(!pDst) 5280 { 5281 /* sanity */ 5282 Assert(pDstCKey == NULL); 5283 pDstCKey = NULL; 5284 } 5285 5286 pProgram = calcProgram(pDst, pDstCKey, pSrcCKey, bNotIntersected); 5287 5288 updateCKeys(pDst, pProgram, pDstCKey, pSrcCKey); 5289 5290 GLuint displ; 5291 int rc = createDisplayList(pDst, pDstRect, pSrcRect, 5292 pDstCKey, pSrcCKey, bNotIntersected, 5293 &displ); 5294 if(RT_SUCCESS(rc)) 5295 { 5296 *pDisplay = displ; 5297 *ppProgram = pProgram; 5298 } 5299 5300 return rc; 5301 } 5302 5303 void VBoxVHWATextureImage::display(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect, 5304 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected) 5305 { 5306 VBoxVHWAGlProgramVHWA * pProgram = calcProgram(pDst, pDstCKey, pSrcCKey, bNotIntersected); 5307 if(pProgram) 5308 pProgram->start(); 5309 5310 runDisplay(pDst, pDstRect, pSrcRect); 5311 5312 if(pProgram) 5313 pProgram->stop(); 5314 } 5315 5316 void VBoxVHWATextureImage::display() 5317 { 5318 Assert(mVisibleDisplay); 5319 if(mVisibleDisplay) 5320 { 5321 if(mpProgram) 5322 mpProgram->start(); 5323 5324 VBOXQGL_CHECKERR( 5325 glCallList(mVisibleDisplay); 5326 ); 5327 5328 if(mpProgram) 5329 mpProgram->stop(); 5330 } 5331 else 5332 { 5333 display(mpDst, &mDstRect, &mSrcRect, 5334 mpDstCKey, mpSrcCKey, mbNotIntersected); 5335 } 5336 } 5337 5338 //int VBoxVHWATextureImage::updateDstCKeyInfo(const VBoxVHWAColorKey * pDstCKey) 5339 //{ 5340 // if(mpProgram) 5341 // { 5342 // pProgram->start(); 5343 // int rc = setCKey(mpProgram, &mColorFormat, pDstCKey, true); 5344 // pProgram->stop(); 5345 // return rc; 5346 // } 5347 // return VERR_INVALID_STATE; 5348 //} 5349 // 5350 //int VBoxVHWATextureImage::updateSrcCKeyInfo(const VBoxVHWAColorKey * pSrcCKey) 5351 //{ 5352 // if(mpProgram) 5353 // { 5354 // pProgram->start(); 5355 // int rc = setCKey(mpProgram, &mColorFormat, pSrcCKey, false); 5356 // pProgram->stop(); 5357 // return rc; 5358 // } 5359 // return VERR_INVALID_STATE; 5360 //} 5361 5362 int VBoxVHWATextureImage::setCKey(VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorFormat * pFormat, const VBoxVHWAColorKey * pCKey, bool bDst) 5363 { 5364 float r,g,b; 5365 pFormat->pixel2Normalized(pCKey->lower(), &r, &g, &b); 5366 int rcL = bDst ? pProgram->setDstCKeyLowerRange(r, g, b) : pProgram->setSrcCKeyLowerRange(r, g, b); 5367 Assert(RT_SUCCESS(rcL)); 5368 5369 return RT_SUCCESS(rcL) /*&& RT_SUCCESS(rcU)*/ ? VINF_SUCCESS: VERR_GENERAL_FAILURE; 5370 } 5371 5372 5373 5374 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.h
r25309 r25385 27 27 //#define VBOXQGL_DBG_SURF 1 28 28 29 //#define VBOXVHWADBG_RENDERCHECK 30 29 31 #include "COMDefs.h" 30 32 #include <QGLWidget> … … 234 236 { 235 237 public: 236 VBoxVHWATexture() {} 238 VBoxVHWATexture() : 239 mAddress(NULL), 240 mTexture(0), 241 mBytesPerPixel(0), 242 mBytesPerPixelTex(0), 243 mBytesPerLine(0) 244 {} 237 245 VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat); 238 246 virtual ~VBoxVHWATexture(); … … 245 253 virtual void multiTexCoord(GLenum texUnit, int x, int y); 246 254 247 // GLuint texture() {return mTexture;}248 255 const QRect & texRect() {return mTexRect;} 249 256 const QRect & rect() {return mRect;} … … 268 275 virtual void load(); 269 276 virtual GLenum texTarget() {return GL_TEXTURE_2D; } 270 277 GLuint texture() {return mTexture;} 271 278 272 279 QRect mTexRect; /* texture size */ … … 280 287 private: 281 288 void uninit(); 289 290 friend class VBoxVHWAFBO; 282 291 }; 283 292 … … 366 375 }; 367 376 368 #ifdef VBOXVHWA_USE_TEXGROUP 369 class VBoxVHWATextureGroup 370 { 371 public: 372 VBoxVHWATextureGroup() 373 { 374 init(0, 0); 375 } 376 377 VBoxVHWATextureGroup(uint32_t cTextures, uint32_t cBacks) 378 { 379 init(cTextures, cBacks); 380 } 381 382 ~VBoxVHWATextureGroup() 383 { 384 delete[] mppTextures; 385 delete[] mpDisplays; 386 } 387 388 VBoxVHWATexture*& operator[] (size_t i) { return mppCurTextures[i]; } 389 void swap() 390 { 391 mCur = ((++mCur) % mcSets); 392 if(mCur) 393 mppCurTextures += mcTextures; 377 class VBoxVHWATextureImage 378 { 379 public: 380 VBoxVHWATextureImage(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, bool bDisablePBO); 381 382 virtual ~VBoxVHWATextureImage() 383 { 384 for(uint i = 0; i < mcTex; i++) 385 { 386 delete mpTex[i]; 387 } 388 } 389 390 virtual void init(uchar *pvMem) 391 { 392 for(uint32_t i = 0; i < mcTex; i++) 393 { 394 mpTex[i]->init(pvMem); 395 pvMem += mpTex[i]->memSize(); 396 } 397 } 398 399 virtual void update(const QRect * pRect) 400 { 401 mpTex[0]->update(pRect); 402 if(mColorFormat.fourcc() == FOURCC_YV12) 403 { 404 if(pRect) 405 { 406 QRect rect(pRect->x()/2, pRect->y()/2, 407 pRect->width()/2, pRect->height()/2); 408 mpTex[1]->update(&rect); 409 mpTex[2]->update(&rect); 410 } 411 else 412 { 413 mpTex[1]->update(NULL); 414 mpTex[2]->update(NULL); 415 } 416 } 417 } 418 419 virtual void display(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect, 420 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected); 421 422 423 virtual void display(); 424 425 void deleteDisplay(); 426 427 int initDisplay(VBoxVHWATextureImage *pDst, 428 const QRect * pDstRect, const QRect * pSrcRect, 429 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected); 430 431 bool displayInitialized() { return !!mVisibleDisplay;} 432 433 virtual void setAddress(uchar *pvMem) 434 { 435 for(uint32_t i = 0; i < mcTex; i++) 436 { 437 mpTex[i]->setAddress(pvMem); 438 pvMem += mpTex[i]->memSize(); 439 } 440 } 441 442 size_t memSize() 443 { 444 size_t size = 0; 445 for(uint32_t i = 0; i < mcTex; i++) 446 { 447 size+=mpTex[i]->memSize(); 448 } 449 return size; 450 } 451 452 uint32_t bytesPerLine() { return mpTex[0]->bytesPerLine(); } 453 454 const VBoxVHWAColorFormat &colorFormat() { return mColorFormat; } 455 456 uint32_t numComponents() {return mcTex;} 457 458 VBoxVHWATexture* component(uint32_t i) {return mpTex[i]; } 459 460 const VBoxVHWATextureImage *dst() { return mpDst;} 461 const QRect& dstRect() { return mDstRect; } 462 const QRect& srcRect() { return mSrcRect; } 463 const VBoxVHWAColorKey* dstCKey() { return mpDstCKey; } 464 const VBoxVHWAColorKey* srcCKey() { return mpSrcCKey; } 465 bool notIntersectedMode() { return mbNotIntersected; } 466 protected: 467 static int setCKey(class VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorFormat * pFormat, const VBoxVHWAColorKey * pCKey, bool bDst); 468 469 static bool matchCKeys(const VBoxVHWAColorKey * pCKey1, const VBoxVHWAColorKey * pCKey2) 470 { 471 return (pCKey1 == NULL && pCKey2 == NULL) 472 || (*pCKey1 == *pCKey2); 473 } 474 475 void runDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect) 476 { 477 bind(pDst); 478 479 draw(pDst, pDstRect, pSrcRect); 480 } 481 482 void draw(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect); 483 484 uint32_t texCoord(GLenum tex, int x, int y) 485 { 486 uint32_t c = 1; 487 mpTex[0]->multiTexCoord(tex, x, y); 488 if(mColorFormat.fourcc() == FOURCC_YV12) 489 { 490 int x2 = x/2; 491 int y2 = y/2; 492 mpTex[1]->multiTexCoord(tex + 1, x2, y2); 493 ++c; 494 } 495 return c; 496 } 497 498 void bind(VBoxVHWATextureImage * pPrimary); 499 500 class VBoxVHWAGlProgramVHWA * calcProgram(VBoxVHWATextureImage *pDst, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected); 501 502 int createDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect, 503 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected, 504 GLuint *pDisplay, class VBoxVHWAGlProgramVHWA ** ppProgram); 505 506 int createSetDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect, 507 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected, 508 GLuint *pDisplay, class VBoxVHWAGlProgramVHWA ** ppProgram); 509 510 virtual int createDisplayList(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect, 511 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected, 512 GLuint *pDisplay); 513 514 virtual void deleteDisplayList(); 515 516 virtual void updateCKeys(VBoxVHWATextureImage * pDst, class VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey); 517 virtual void updateSetCKeys(const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey); 518 519 void internalSetDstCKey(const VBoxVHWAColorKey * pDstCKey); 520 void internalSetSrcCKey(const VBoxVHWAColorKey * pSrcCKey); 521 522 VBoxVHWATexture *mpTex[3]; 523 uint32_t mcTex; 524 GLuint mVisibleDisplay; 525 class VBoxVHWAGlProgramVHWA * mpProgram; 526 class VBoxVHWAGlProgramMngr * mProgramMngr; 527 VBoxVHWAColorFormat mColorFormat; 528 529 /* display info */ 530 VBoxVHWATextureImage *mpDst; 531 QRect mDstRect; 532 QRect mSrcRect; 533 VBoxVHWAColorKey * mpDstCKey; 534 VBoxVHWAColorKey * mpSrcCKey; 535 VBoxVHWAColorKey mDstCKey; 536 VBoxVHWAColorKey mSrcCKey; 537 bool mbNotIntersected; 538 }; 539 540 class VBoxVHWATextureImagePBO : public VBoxVHWATextureImage 541 { 542 public: 543 VBoxVHWATextureImagePBO(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr) : 544 VBoxVHWATextureImage(size, format, aMgr, true), 545 mPBO(0) 546 { 547 } 548 549 virtual ~VBoxVHWATextureImagePBO() 550 { 551 if(mPBO) 552 { 553 VBOXQGL_CHECKERR( 554 vboxglDeleteBuffers(1, &mPBO); 555 ); 556 } 557 } 558 559 virtual void init(uchar *pvMem) 560 { 561 VBoxVHWATextureImage::init(pvMem); 562 563 VBOXQGL_CHECKERR( 564 vboxglGenBuffers(1, &mPBO); 565 ); 566 mAddress = pvMem; 567 568 VBOXQGL_CHECKERR( 569 vboxglBindBuffer(GL_PIXEL_UNPACK_BUFFER, mPBO); 570 ); 571 572 VBOXQGL_CHECKERR( 573 vboxglBufferData(GL_PIXEL_UNPACK_BUFFER, memSize(), NULL, GL_STREAM_DRAW); 574 ); 575 576 GLvoid *buf = vboxglMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); 577 Assert(buf); 578 if(buf) 579 { 580 memcpy(buf, mAddress, memSize()); 581 582 bool unmapped = vboxglUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); 583 Assert(unmapped); NOREF(unmapped); 584 } 585 586 vboxglBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); 587 588 } 589 590 virtual void update(const QRect * pRect) 591 { 592 VBOXQGL_CHECKERR( 593 vboxglBindBuffer(GL_PIXEL_UNPACK_BUFFER, mPBO); 594 ); 595 596 GLvoid *buf; 597 598 VBOXQGL_CHECKERR( 599 buf = vboxglMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); 600 ); 601 Assert(buf); 602 if(buf) 603 { 604 #ifdef VBOXVHWADBG_RENDERCHECK 605 uint32_t * pBuf32 = (uint32_t*)buf; 606 uchar * pBuf8 = (uchar*)buf; 607 for(uint32_t i = 0; i < mcTex; i++) 608 { 609 uint32_t dbgSetVal = 0x40404040 * (i+1); 610 for(uint32_t k = 0; k < mpTex[i]->memSize()/sizeof(pBuf32[0]); k++) 611 { 612 pBuf32[k] = dbgSetVal; 613 } 614 615 pBuf8 += mpTex[i]->memSize(); 616 pBuf32 = (uint32_t *)pBuf8; 617 } 618 #else 619 memcpy(buf, mAddress, memSize()); 620 #endif 621 622 bool unmapped; 623 VBOXQGL_CHECKERR( 624 unmapped = vboxglUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); 625 ); 626 627 Assert(unmapped); 628 629 VBoxVHWATextureImage::setAddress(0); 630 631 VBoxVHWATextureImage::update(NULL); 632 633 VBoxVHWATextureImage::setAddress(mAddress); 634 635 vboxglBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); 636 } 394 637 else 395 mppCurTextures = mppTextures; 396 } 397 uint32_t numSets() { return mcSets; } 398 399 void init(uint32_t cTextures, uint32_t cBacks) 400 { 401 mCur = 0; 402 mcTextures = cTextures; 403 mcSets = cBacks + 1; 404 if(mcTextures) 405 { 406 mppTextures = new VBoxVHWATexture*[mcSets * cTextures]; 407 mppCurTextures = mppTextures; 408 memset(mppTextures, 0, sizeof(mppTextures[0]) * mcSets * cTextures); 409 mpDisplays = new GLuint[mcSets]; 410 memset(mpDisplays, 0, sizeof(mpDisplays[0]) * mcSets); 411 } 412 else 413 { 414 mppTextures = mppCurTextures = NULL; 415 mpDisplays = NULL; 416 } 417 } 418 419 GLuint& display() {return mpDisplays[mCur];} 420 private: 421 VBoxVHWATexture **mppTextures; 422 VBoxVHWATexture **mppCurTextures; 423 GLuint * mpDisplays; 424 uint32_t mCur; 425 uint32_t mcTextures; 426 uint32_t mcSets; 638 { 639 VBOXQGLLOGREL(("failed to map PBO, trying fallback to non-PBO approach\n")); 640 641 VBoxVHWATextureImage::setAddress(mAddress); 642 643 VBoxVHWATextureImage::update(pRect); 644 } 645 } 646 647 virtual void setAddress(uchar *pvMem) 648 { 649 mAddress = pvMem; 650 } 651 private: 652 GLuint mPBO; 653 uchar* mAddress; 654 }; 655 #if 0 656 class VBoxVHWAFBO 657 { 658 public: 659 VBoxVHWAFBO() : 660 mFBO(0) 661 {} 662 663 ~VBoxVHWAFBO() 664 { 665 if(mFBO) 666 { 667 vboxglDeleteFramebuffers(1, mFBO); 668 } 669 } 670 671 void init() 672 { 673 VBOXQGL_CHECKERR( 674 vboxglGenFramebuffers(1, &mFBO); 675 ); 676 } 677 678 void bind(VBoxVHWATexture *pTex) 679 { 680 VBOXQGL_CHECKERR( 681 vboxglBindFramebuffer(GL_FRAMEBUFFER, mFBO); 682 ); 683 VBOXQGL_CHECKERR( 684 vboxglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pTex->texTarget(), pTex->texture(), 0); 685 ); 686 } 687 private: 688 GLuint mFBO; 427 689 }; 428 690 #endif … … 470 732 public: 471 733 VBoxVHWASurfaceBase( 472 class VBoxGLWidget *mWidget, 473 #if 0 474 class VBoxVHWAGlContextState *aState, 475 bool aIsYInverted, 476 #endif 734 class VBoxGLWidget *aWidget, 477 735 const QSize & aSize, 478 736 const QRect & aTargRect, … … 482 740 VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey, 483 741 VBoxVHWAColorKey * pSrcOverlayCKey, VBoxVHWAColorKey * pDstOverlayCKey, 484 #ifdef VBOXVHWA_USE_TEXGROUP485 uint32_t cBackTex,486 #endif487 742 bool bVGA); 488 743 … … 507 762 void setRects (const QRect & aTargRect, const QRect & aSrcRect); 508 763 void setTargRectPosition (const QPoint & aPoint); 509 void setVisibilityReinitFlag() { mNeedVisibilityReinit = true; } 764 510 765 void updateVisibility (VBoxVHWASurfaceBase *pPrimary, const QRect & aVisibleTargRect, bool bNotIntersected, bool bForce); 511 766 … … 523 778 const QSize size() {return mRect.size();} 524 779 525 GLenum format() {return mColorFormat.format(); } 526 GLint internalFormat() { return mColorFormat.internalFormat(); } 527 GLenum type() { return mColorFormat.type(); } 528 uint32_t fourcc() {return mColorFormat.fourcc(); } 529 530 // ulong bytesPerPixel() { return mpTex[0]->bytesPerPixel(); } 531 ulong bitsPerPixel() { return mColorFormat.bitsPerPixel(); } 532 // ulong bitsPerPixelDd() { return mColorFormat.bitsPerPixelDd(); } 533 ulong bytesPerLine() { return mpTex[0]->bytesPerLine(); } 780 // GLenum format() {return mImage->colorFormat().format(); } 781 // GLint internalFormat() { return mImage->colorFormat().internalFormat(); } 782 // GLenum type() { return mImage->colorFormat().type(); } 783 uint32_t fourcc() {return mImage->colorFormat().fourcc(); } 784 785 ulong bitsPerPixel() { return mImage->colorFormat().bitsPerPixel(); } 786 ulong bytesPerLine() { return mImage->bytesPerLine(); } 534 787 535 788 const VBoxVHWAColorKey * dstBltCKey() const { return mpDstBltCKey; } … … 627 880 const VBoxVHWAColorKey * getActiveDstOverlayCKey(VBoxVHWASurfaceBase * pPrimary) 628 881 { 629 return mpDstOverlayCKey ? mpDefaultDstOverlayCKey : pPrimary->mpDstOverlayCKey;630 } 631 632 const VBoxVHWAColorFormat & colorFormat() { return mColorFormat; }882 return mpDstOverlayCKey ? mpDefaultDstOverlayCKey : (pPrimary ? pPrimary->mpDstOverlayCKey : NULL); 883 } 884 885 const VBoxVHWAColorFormat & colorFormat() { return mImage->colorFormat(); } 633 886 634 887 void setAddress(uchar * addr); … … 640 893 641 894 class VBoxVHWAGlProgramMngr * getGlProgramMngr(); 642 static int setCKey(class VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorFormat * pFormat, const VBoxVHWAColorKey * pCKey, bool bDst);643 895 644 896 uint32_t handle() const {return mHGHandle;} … … 647 899 const VBoxVHWADirtyRect & getDirtyRect() { return mUpdateMem2TexRect; } 648 900 649 class VBoxVHWAGlProgramVHWA * getProgram(VBoxVHWASurfaceBase * pPrimary) 650 { 651 if(mVisibleDisplayInitialized) 652 return mpProgram; 653 return calcProgram(pPrimary); 654 } 655 private: 656 class VBoxVHWAGlProgramVHWA * calcProgram(VBoxVHWASurfaceBase * pPrimary); 901 VBoxVHWASurfaceBase * primary() { return mpPrimary; } 902 void setPrimary(VBoxVHWASurfaceBase *apPrimary) { mpPrimary = apPrimary; } 903 private: 657 904 void setRectValues (const QRect & aTargRect, const QRect & aSrcRect); 658 905 void setVisibleRectValues (const QRect & aVisTargRect); 659 906 660 907 void setComplexList(VBoxVHWASurfList *aComplexList) { mComplexList = aComplexList; } 661 void initDisplay(VBoxVHWASurfaceBase *pPrimary); 662 void deleteDisplay(); 663 664 int createDisplay(VBoxVHWASurfaceBase *pPrimary, GLuint *pDisplay, class VBoxVHWAGlProgramVHWA ** ppProgram); 665 void doDisplay(VBoxVHWASurfaceBase *pPrimary, bool bProgram, bool bBindDst); 908 void initDisplay(); 909 666 910 bool synchTexMem(const QRect * aRect); 667 911 668 912 int performBlt(const QRect * pDstRect, VBoxVHWASurfaceBase * pSrcSurface, const QRect * pSrcRect, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool blt); 669 670 void doTex2FB(const QRect * pDstRect, const QRect * pSrcRect);671 void doMultiTex2FB(const QRect * pDstRect, VBoxVHWATexture * pDstTex, const QRect * pSrcRect, int cSrcTex);672 void doMultiTex2FB(const QRect * pDstRect, const QRect * pSrcRect, int cSrcTex);673 913 674 914 QRect mRect; /* == Inv FB size */ … … 680 920 QRect mVisibleSrcRect; 681 921 682 #ifndef VBOXVHWA_USE_TEXGROUP 683 GLuint mVisibleDisplay; 684 #endif 685 class VBoxVHWAGlProgramVHWA * mpProgram; 686 687 bool mVisibleDisplayInitialized; 688 bool mNeedVisibilityReinit; 689 bool mNotIntersected; 922 class VBoxVHWATextureImage * mImage; 690 923 691 924 uchar * mAddress; 692 #ifdef VBOXVHWA_USE_TEXGROUP693 VBoxVHWATextureGroup mpTex;694 #else695 VBoxVHWATexture *mpTex[3];696 #endif697 698 VBoxVHWAColorFormat mColorFormat;699 925 700 926 VBoxVHWAColorKey *mpSrcBltCKey; … … 718 944 719 945 bool mFreeAddress; 946 bool mbNotIntersected; 720 947 721 948 class VBoxVHWASurfList *mComplexList; 949 950 VBoxVHWASurfaceBase *mpPrimary; 722 951 723 952 class VBoxGLWidget *mWidget; … … 1334 1563 } 1335 1564 1336 // VBOXFBOVERLAY_RESUT onPaintEvent (const QPaintEvent *pe, QRect *pRect);1337 1338 1565 void onResizeEvent (const class VBoxResizeEvent *re); 1339 1566 void onResizeEventPostprocess (const class VBoxResizeEvent *re); … … 1396 1623 if(mOverlayVisible) 1397 1624 { 1398 #if 01399 mpOverlayWidget->updateGL();1400 #else1401 1625 makeCurrent(); 1402 1626 mpOverlayWidget->performDisplayAndSwap(false); 1403 #endif1404 1627 } 1405 1628 } -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/NetFltInstall.cpp
r25072 r25385 94 94 if(hr == S_OK) 95 95 { 96 #if 0 96 97 int i = 0; 97 98 do … … 161 162 } 162 163 } while(true); 164 #endif 165 VBoxNetCfgWinEnumUpperBindings (); 163 166 164 167 CoUninitialize(); -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/WinNetConfig.cpp
r24280 r25385 2306 2306 } 2307 2307 2308 static BOOL vboxNetCfgWinListUpperBindings (IN INetCfg *pNc, IN INetCfgComponent *pNcc, PVOID pContext) 2309 { 2310 INetCfgComponentBindings *pNccb = NULL; 2311 IEnumNetCfgBindingPath *pEnumNccbp; 2312 GUID *pGuid = (GUID*)pContext; 2313 HRESULT hr; 2314 LPWSTR pszwCompDisplayName; 2315 2316 hr = pNcc->GetDisplayName(&pszwCompDisplayName); 2317 Assert(hr == S_OK); 2318 if ( hr == S_OK ) 2319 { 2320 Log(L" enumerating bindings for component (%s)\n", pszwCompDisplayName); 2321 /* Get component's binding. */ 2322 hr = pNcc->QueryInterface( IID_INetCfgComponentBindings, 2323 (PVOID *)&pNccb ); 2324 Assert(hr == S_OK); 2325 if ( hr == S_OK ) 2326 { 2327 /* Get binding path enumerator reference. */ 2328 hr = pNccb->EnumBindingPaths(EBP_ABOVE, &pEnumNccbp); 2329 Assert(hr == S_OK); 2330 if(hr == S_OK) 2331 { 2332 INetCfgBindingPath *pNccbp; 2333 hr = pEnumNccbp->Reset(); 2334 Assert(hr == S_OK); 2335 do 2336 { 2337 hr = VBoxNetCfgWinGetNextBindingPath(pEnumNccbp, &pNccbp); 2338 Assert(hr == S_OK || hr == S_FALSE); 2339 if(hr == S_OK) 2340 { 2341 LPWSTR pszwPathToken; 2342 hr = pNccbp->GetPathToken(&pszwPathToken); 2343 Assert(hr == S_OK); 2344 if(hr == S_OK) 2345 { 2346 Log(L" enumerating bp (%s), enabled(0x%x)\n", pszwPathToken, pNccbp->IsEnabled()); 2347 IEnumNetCfgBindingInterface *pEnumNcbi; 2348 hr = VBoxNetCfgWinGetBindingInterfaceEnum(pNccbp, &pEnumNcbi); 2349 Assert(hr == S_OK); 2350 if ( hr == S_OK ) 2351 { 2352 INetCfgBindingInterface *pNcbi; 2353 hr = pEnumNcbi->Reset(); 2354 Assert(hr == S_OK); 2355 do 2356 { 2357 hr = VBoxNetCfgWinGetNextBindingInterface(pEnumNcbi, &pNcbi); 2358 Assert(hr == S_OK || hr == S_FALSE); 2359 if(hr == S_OK) 2360 { 2361 LPWSTR pszwInterfaceName; 2362 hr = pNcbi->GetName(&pszwInterfaceName); 2363 if(hr == S_OK) 2364 { 2365 Log(L" enumerating bi (%s)\n", pszwInterfaceName); 2366 INetCfgComponent * pNccBoud; 2367 hr = pNcbi->GetUpperComponent(&pNccBoud); 2368 Assert(hr == S_OK); 2369 if(hr == S_OK) 2370 { 2371 LPWSTR pszwDisplayName; 2372 hr = pNccBoud->GetDisplayName(&pszwDisplayName); 2373 Assert(hr == S_OK); 2374 if(hr == S_OK) 2375 { 2376 Log(L" name (%s)\n", pszwDisplayName); 2377 CoTaskMemFree(pszwDisplayName); 2378 } 2379 else 2380 { 2381 Log(L" ERROR getting name (0x%x)\n", hr); 2382 } 2383 2384 VBoxNetCfgWinReleaseRef(pNccBoud); 2385 } 2386 VBoxNetCfgWinReleaseRef(pNcbi); 2387 } 2388 else 2389 { 2390 Log(L" ERROR getting bi name (0x%x)\n", hr); 2391 } 2392 } 2393 else 2394 { 2395 if(hr == S_FALSE) 2396 { 2397 hr = S_OK; 2398 break; 2399 } 2400 else 2401 { 2402 Log(L"vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority: VBoxNetCfgWinGetNextBindingInterface failed, hr (0x%x)\n", hr); 2403 } 2404 break; 2405 } 2406 } while(true); 2407 VBoxNetCfgWinReleaseRef(pEnumNcbi); 2408 } 2409 else 2410 { 2411 Log(L"vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority: VBoxNetCfgWinGetBindingInterfaceEnum failed, hr (0x%x)\n", hr); 2412 } 2413 CoTaskMemFree(pszwPathToken); 2414 } 2415 else 2416 { 2417 Log(L" ERROR getting bp name (0x%x)\n", hr); 2418 } 2419 2420 VBoxNetCfgWinReleaseRef(pNccbp); 2421 } 2422 else 2423 { 2424 if(hr = S_FALSE) 2425 { 2426 hr = S_OK; 2427 break; 2428 } 2429 else 2430 { 2431 Log(L"vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority: VBoxNetCfgWinGetNextBindingPath failed, hr (0x%x)\n", hr); 2432 } 2433 break; 2434 } 2435 } while(true); 2436 2437 VBoxNetCfgWinReleaseRef(pEnumNccbp); 2438 } 2439 else 2440 { 2441 Log(L"vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority: EnumBindingPaths failed, hr (0x%x)\n", hr); 2442 } 2443 2444 VBoxNetCfgWinReleaseRef( pNccb ); 2445 } 2446 else 2447 { 2448 Log(L"vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority: QueryInterface for IID_INetCfgComponentBindings failed, hr (0x%x)\n", hr); 2449 } 2450 2451 CoTaskMemFree(pszwCompDisplayName); 2452 } 2453 else 2454 { 2455 Log(L" ERROR getting component name (0x%x)\n", hr); 2456 } 2457 2458 return true; 2459 } 2460 2308 2461 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinCreateHostOnlyNetworkInterface (LPCWSTR pInfPath, bool bIsInfPathFile, /* <- input params */ 2309 2462 GUID *pGuid, BSTR *lppszName, BSTR *pErrMsg) /* <- output params */ … … 2767 2920 2768 2921 #undef SetErrBreak 2922 2923 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinEnumUpperBindings () 2924 { 2925 INetCfg *pNc; 2926 LPWSTR lpszApp = NULL; 2927 HRESULT hr = VBoxNetCfgWinQueryINetCfgEx( FALSE, 2928 L"VirtualBox Host-Only Creation", 2929 30000, /* on Vista we often get 6to4svc.dll holding the lock, wait for 30 sec, */ 2930 &pNc, /* TODO: special handling for 6to4svc.dll ???, i.e. several retrieves */ 2931 &lpszApp ); 2932 Assert(hr == S_OK); 2933 if(hr == S_OK) 2934 { 2935 Log(L"Enumerating Net\n"); 2936 hr = vboxNetCfgWinEnumNetCfgComponents(pNc, 2937 &GUID_DEVCLASS_NET, 2938 vboxNetCfgWinListUpperBindings, 2939 NULL); 2940 Assert(hr == S_OK); 2941 2942 Log(L"Enumerating NetService\n"); 2943 hr = vboxNetCfgWinEnumNetCfgComponents(pNc, 2944 &GUID_DEVCLASS_NETSERVICE, 2945 vboxNetCfgWinListUpperBindings, 2946 NULL); 2947 Assert(hr == S_OK); 2948 2949 Log(L"Enumerating NetTrans\n"); 2950 hr = vboxNetCfgWinEnumNetCfgComponents(pNc, 2951 &GUID_DEVCLASS_NETTRANS, 2952 vboxNetCfgWinListUpperBindings, 2953 NULL); 2954 Assert(hr == S_OK); 2955 2956 Log(L"Enumerating NetClient\n"); 2957 hr = vboxNetCfgWinEnumNetCfgComponents(pNc, 2958 &GUID_DEVCLASS_NETCLIENT, 2959 vboxNetCfgWinListUpperBindings, 2960 NULL); 2961 Assert(hr == S_OK); 2962 2963 if(hr == S_OK) 2964 { 2965 hr = pNc->Apply(); 2966 Assert(hr == S_OK); 2967 } 2968 2969 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE); 2970 } 2971 else if(hr == NETCFG_E_NO_WRITE_LOCK && lpszApp) 2972 { 2973 Log(L"VBoxNetCfgWinCreateHostOnlyNetworkInterface: app %s is holding the lock, failed\n", lpszApp); 2974 CoTaskMemFree(lpszApp); 2975 } 2976 else 2977 { 2978 Log(L"VBoxNetCfgWinCreateHostOnlyNetworkInterface: VBoxNetCfgWinQueryINetCfgEx failed, hr 0x%x\n", hr); 2979 } 2980 2981 return hr; 2982 } 2983 2769 2984 2770 2985 #define VBOX_CONNECTION_NAME L"VirtualBox Host-Only Network"
Note:
See TracChangeset
for help on using the changeset viewer.