Changeset 35280 in vbox
- Timestamp:
- Dec 21, 2010 4:48:30 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 2 edited
-
VBoxFBOverlay.cpp (modified) (15 diffs)
-
VBoxFBOverlay.h (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
r34740 r35280 371 371 } 372 372 373 static VBoxVHWATexture* vboxVHWATextureCreate(const QGLContext * pContext, const QRect & aRect, const VBoxVHWAColorFormat & aFormat, VBOXVHWAIMG_TYPE flags)373 static VBoxVHWATexture* vboxVHWATextureCreate(const QGLContext * pContext, const QRect & aRect, const VBoxVHWAColorFormat & aFormat, uint32_t bytesPerLine, VBOXVHWAIMG_TYPE flags) 374 374 { 375 375 const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(pContext); … … 378 378 { 379 379 VBOXQGLLOG(("VBoxVHWATextureNP2RectPBO\n")); 380 return new VBoxVHWATextureNP2RectPBO(aRect, aFormat, scaleFunc);380 return new VBoxVHWATextureNP2RectPBO(aRect, aFormat, bytesPerLine, scaleFunc); 381 381 } 382 382 else if(info.getGlInfo().isTextureRectangleSupported()) 383 383 { 384 384 VBOXQGLLOG(("VBoxVHWATextureNP2Rect\n")); 385 return new VBoxVHWATextureNP2Rect(aRect, aFormat, scaleFunc);385 return new VBoxVHWATextureNP2Rect(aRect, aFormat, bytesPerLine, scaleFunc); 386 386 } 387 387 else if(info.getGlInfo().isTextureNP2Supported()) 388 388 { 389 389 VBOXQGLLOG(("VBoxVHWATextureNP2\n")); 390 return new VBoxVHWATextureNP2(aRect, aFormat, scaleFunc);390 return new VBoxVHWATextureNP2(aRect, aFormat, bytesPerLine, scaleFunc); 391 391 } 392 392 VBOXQGLLOG(("VBoxVHWATexture\n")); 393 return new VBoxVHWATexture(aRect, aFormat, scaleFunc);393 return new VBoxVHWATexture(aRect, aFormat, bytesPerLine, scaleFunc); 394 394 } 395 395 … … 1435 1435 1436 1436 VBOXQGL_CHECKERR( 1437 glPixelStorei(GL_UNPACK_ROW_LENGTH, m Rect.width()/mColorFormat.widthCompression());1437 glPixelStorei(GL_UNPACK_ROW_LENGTH, mBytesPerLine * 8 /mColorFormat.bitsPerPixelTex()); 1438 1438 ); 1439 1439 … … 1446 1446 address); 1447 1447 ); 1448 1449 VBOXQGL_CHECKERR( 1450 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 1451 ); 1448 1452 } 1449 1453 … … 1466 1470 } 1467 1471 1468 VBoxVHWATexture::VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion) :1472 VBoxVHWATexture::VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) : 1469 1473 mAddress(NULL), 1470 1474 mTexture(0), … … 1478 1482 mBytesPerPixel = mColorFormat.bitsPerPixel()/8; 1479 1483 mBytesPerPixelTex = mColorFormat.bitsPerPixelTex()/8; 1480 mBytesPerLine = mBytesPerPixel * mRect.width();1484 mBytesPerLine = bytesPerLine ? bytesPerLine : mBytesPerPixel * mRect.width(); 1481 1485 GLsizei wdt = VBoxVHWASurfaceBase::makePowerOf2(mRect.width()/mColorFormat.widthCompression()); 1482 1486 GLsizei hgt = VBoxVHWASurfaceBase::makePowerOf2(mRect.height()/mColorFormat.heightCompression()); … … 2432 2436 if (!reportedFormat.isValid()) 2433 2437 { 2434 pCmd->SurfInfo.pitch = surf->b itsPerPixel() * surf->width() / 8;2438 pCmd->SurfInfo.pitch = surf->bytesPerLine(); 2435 2439 pCmd->SurfInfo.sizeX = surf->memSize(); 2436 2440 pCmd->SurfInfo.sizeY = 1; … … 2493 2497 if (format.isValid()) 2494 2498 { 2495 pCmd->SurfInfo.pitch = format.bitsPerPixel() * pCmd->SurfInfo.width / 8; 2496 // pCmd->SurfInfo.pitch = ((pCmd->SurfInfo.pitch + 3) & (~3)); 2497 pCmd->SurfInfo.sizeX = format.bitsPerPixelMem() * pCmd->SurfInfo.width / 8; 2498 // pCmd->SurfInfo.sizeX = ((pCmd->SurfInfo.sizeX + 3) & (~3)); 2499 pCmd->SurfInfo.sizeX *= pCmd->SurfInfo.height; 2499 pCmd->SurfInfo.pitch = VBoxVHWATextureImage::calcBytesPerLine(format, pCmd->SurfInfo.width); 2500 pCmd->SurfInfo.sizeX = VBoxVHWATextureImage::calcMemSize(format, 2501 pCmd->SurfInfo.width, pCmd->SurfInfo.height); 2500 2502 pCmd->SurfInfo.sizeY = 1; 2501 2503 return VINF_SUCCESS; … … 3970 3972 case FOURCC_AYUV: 3971 3973 mBitsPerPixel = 32; 3972 #ifdef VBOX_WITH_WDDM3973 mBitsPerPixelMem = 32;3974 #endif3975 3974 mWidthCompression = 1; 3976 3975 break; … … 3978 3977 case FOURCC_YUY2: 3979 3978 mBitsPerPixel = 16; 3980 #ifdef VBOX_WITH_WDDM3981 mBitsPerPixelMem = 16;3982 #endif3983 3979 mWidthCompression = 2; 3984 3980 break; 3985 3981 case FOURCC_YV12: 3986 3982 mBitsPerPixel = 8; 3987 #ifdef VBOX_WITH_WDDM3988 mBitsPerPixelMem = 12;3989 #endif3990 3983 mWidthCompression = 4; 3991 3984 break; … … 3994 3987 mBitsPerPixel = 0; 3995 3988 mBitsPerPixelTex = 0; 3996 #ifdef VBOX_WITH_WDDM3997 mBitsPerPixelMem = 0;3998 #endif3999 3989 mWidthCompression = 0; 4000 3990 break; … … 4006 3996 mBitsPerPixel = bitsPerPixel; 4007 3997 mBitsPerPixelTex = bitsPerPixel; 4008 #ifdef VBOX_WITH_WDDM4009 mBitsPerPixelMem = bitsPerPixel;4010 #endif4011 3998 mDataFormat = 0; 4012 3999 switch (bitsPerPixel) … … 4066 4053 mBitsPerPixel = 0; 4067 4054 mBitsPerPixelTex = 0; 4068 #ifdef VBOX_WITH_WDDM4069 mBitsPerPixelMem = 0;4070 #endif4071 4055 break; 4072 4056 } … … 5383 5367 } 5384 5368 5369 /* static */ 5370 uint32_t VBoxVHWATextureImage::calcBytesPerLine(const VBoxVHWAColorFormat & format, int width) 5371 { 5372 uint32_t pitch = (format.bitsPerPixel() * width + 7)/8; 5373 switch (format.fourcc()) 5374 { 5375 case FOURCC_YV12: 5376 /* make sure the color components pitch is multiple of 8 5377 * where 8 is 2 (for color component width is Y width / 2) * 4 for 4byte texture format */ 5378 pitch = (pitch + 7) & ~7; 5379 break; 5380 default: 5381 pitch = (pitch + 3) & ~3; 5382 break; 5383 } 5384 return pitch; 5385 } 5386 5387 /* static */ 5388 uint32_t VBoxVHWATextureImage::calcMemSize(const VBoxVHWAColorFormat & format, int width, int height) 5389 { 5390 uint32_t pitch = calcBytesPerLine(format, width); 5391 switch (format.fourcc()) 5392 { 5393 case FOURCC_YV12: 5394 /* we have 3 separate planes here 5395 * Y - pitch x height 5396 * U - pitch/2 x height/2 5397 * V - pitch/2 x height/2 5398 * */ 5399 return 3 * pitch * height / 2; 5400 break; 5401 default: 5402 return pitch * height; 5403 break; 5404 } 5405 } 5406 5385 5407 VBoxVHWATextureImage::VBoxVHWATextureImage(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, VBOXVHWAIMG_TYPE flags) : 5386 5408 mVisibleDisplay(0), … … 5392 5414 mbNotIntersected(false) 5393 5415 { 5394 mpTex[0] = vboxVHWATextureCreate(NULL, size, format, flags); 5416 uint32_t pitch = calcBytesPerLine(format, size.width()); 5417 5418 mpTex[0] = vboxVHWATextureCreate(NULL, size, format, pitch, flags); 5395 5419 mColorFormat = format; 5396 5420 if(mColorFormat.fourcc() == FOURCC_YV12) 5397 5421 { 5398 5422 QRect rect(size.x()/2,size.y()/2,size.width()/2,size.height()/2); 5399 mpTex[1] = vboxVHWATextureCreate(NULL, rect, format, flags);5400 mpTex[2] = vboxVHWATextureCreate(NULL, rect, format, flags);5423 mpTex[1] = vboxVHWATextureCreate(NULL, rect, format, pitch/2, flags); 5424 mpTex[2] = vboxVHWATextureCreate(NULL, rect, format, pitch/2, flags); 5401 5425 mcTex = 3; 5402 5426 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.h
r34490 r35280 233 233 uint32_t bitsPerPixel() const { return mBitsPerPixel; } 234 234 uint32_t bitsPerPixelTex() const { return mBitsPerPixelTex; } 235 #ifdef VBOX_WITH_WDDM236 uint32_t bitsPerPixelMem() const { return mBitsPerPixelMem; }237 #endif238 235 void pixel2Normalized(uint32_t pix, float *r, float *g, float *b) const; 239 236 uint32_t widthCompression() const {return mWidthCompression;} … … 271 268 uint32_t mBitsPerPixel; 272 269 uint32_t mBitsPerPixelTex; 273 #ifdef VBOX_WITH_WDDM274 uint32_t mBitsPerPixelMem;275 #endif276 270 uint32_t mWidthCompression; 277 271 uint32_t mHeightCompression; … … 293 287 mScaleFuncttion(GL_NEAREST) 294 288 {} 295 VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion);289 VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion); 296 290 virtual ~VBoxVHWATexture(); 297 291 virtual void init(uchar *pvMem); … … 349 343 public: 350 344 VBoxVHWATextureNP2() : VBoxVHWATexture() {} 351 VBoxVHWATextureNP2(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion) :352 VBoxVHWATexture(aRect, aFormat, scaleFuncttion){345 VBoxVHWATextureNP2(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) : 346 VBoxVHWATexture(aRect, aFormat, bytesPerLine, scaleFuncttion){ 353 347 mTexRect = QRect(0, 0, aRect.width()/aFormat.widthCompression(), aRect.height()/aFormat.heightCompression()); 354 348 } … … 359 353 public: 360 354 VBoxVHWATextureNP2Rect() : VBoxVHWATextureNP2() {} 361 VBoxVHWATextureNP2Rect(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion) :362 VBoxVHWATextureNP2(aRect, aFormat, scaleFuncttion){}355 VBoxVHWATextureNP2Rect(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) : 356 VBoxVHWATextureNP2(aRect, aFormat, bytesPerLine, scaleFuncttion){} 363 357 364 358 virtual void texCoord(int x, int y); … … 375 369 mPBO(0) 376 370 {} 377 VBoxVHWATextureNP2RectPBO(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion) :378 VBoxVHWATextureNP2Rect(aRect, aFormat, scaleFuncttion),371 VBoxVHWATextureNP2RectPBO(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) : 372 VBoxVHWATextureNP2Rect(aRect, aFormat, bytesPerLine, scaleFuncttion), 379 373 mPBO(0) 380 374 {} … … 398 392 mcbOffset(0) 399 393 {} 400 VBoxVHWATextureNP2RectPBOMapped(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, GLint scaleFuncttion) :401 VBoxVHWATextureNP2RectPBO(aRect, aFormat, scaleFuncttion),394 VBoxVHWATextureNP2RectPBOMapped(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) : 395 VBoxVHWATextureNP2RectPBO(aRect, aFormat, bytesPerLine, scaleFuncttion), 402 396 mpMappedAllignedBuffer(NULL), 403 397 mcbOffset(0) … … 529 523 const VBoxVHWAColorKey* srcCKey() { return mpSrcCKey; } 530 524 bool notIntersectedMode() { return mbNotIntersected; } 525 526 static uint32_t calcBytesPerLine(const VBoxVHWAColorFormat & format, int width); 527 static uint32_t calcMemSize(const VBoxVHWAColorFormat & format, int width, int height); 531 528 532 529 #ifdef DEBUG_misha
Note:
See TracChangeset
for help on using the changeset viewer.

