Changeset 6794 in vbox
- Timestamp:
- Feb 4, 2008 5:45:03 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxFrameBuffer.h
r6725 r6794 509 509 ulong mPixelFormat; 510 510 CGImageRef mImage; 511 #if 1512 CGRect *mRegionRects;513 ULONG mRegionCount;514 #else515 511 typedef struct 516 512 { … … 520 516 ULONG used; 521 517 /** Variable sized array of the rectangle that makes up the region. */ 522 CGR ECTrcts[1];518 CGRect rcts[1]; 523 519 } RegionRects; 524 520 /** The current valid region, all access is by atomic cmpxchg or atomic xchg. … … 536 532 * This is operated with atomic cmpxchg and atomic xchg. */ 537 533 RegionRects volatile *mRegionUnused; 538 #endif539 534 }; 540 535 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp
r6725 r6794 21 21 #include "VBoxFrameBuffer.h" 22 22 #include "VBoxConsoleView.h" 23 #include "VBoxProblemReporter.h" 24 #include "VBoxGlobal.h" 23 25 /* Needed for checking against seamless mode */ 24 26 #include "VBoxConsoleWnd.h" … … 41 43 mPixelFormat(FramebufferPixelFormat_FOURCC_RGB), 42 44 mImage(NULL), 43 #if 144 mRegionRects(NULL),45 mRegionCount(0)46 #else47 45 mRegion (NULL), 48 46 mRegionUnused (NULL) 49 #endif50 47 { 51 48 Log (("Quartz2D: Creating\n")); … … 88 85 * ASMAtomic(Cmp)XchgPtr and a struct { cAllocated; cRects; aRects[1]; } 89 86 * *mRegion, *mUnusedRegion; should suffice (and permit you to reuse allocations). */ 90 #if 1 91 RTMemFree (mRegionRects); 92 mRegionCount = 0; 93 mRegionRects = static_cast <CGRect*> (RTMemAlloc (sizeof (CGRect) * aCount)); 94 #else 95 RegionRects *rgnRcts = (RegionRects *) ASMAtomicXchgPtr (&mRegionUnused, NULL); 87 RegionRects *rgnRcts = (RegionRects *) ASMAtomicXchgPtr ((void * volatile *) &mRegionUnused, NULL); 96 88 if (rgnRcts && rgnRcts->allocated < aCount) 97 89 { … … 103 95 ULONG allocated = RT_ALIGN_32 (aCount + 1, 32); 104 96 allocated = RT_MAX (128, allocated); 105 rgnRcts = (RegionRects *) RTMemAlloc (RT_OFFSETOF (R gionRects, rcts[allocated]));97 rgnRcts = (RegionRects *) RTMemAlloc (RT_OFFSETOF (RegionRects, rcts[allocated])); 106 98 if (!rgnRcts) 107 return E_ NOMEM;99 return E_OUTOFMEMORY; 108 100 rgnRcts->allocated = allocated; 109 101 } 110 102 rgnRcts->used = 0; 111 #endif112 103 113 104 QRegion reg; … … 135 126 continue; 136 127 137 #if 1138 mRegionRects[mRegionCount].origin.x = rect.x();139 mRegionRects[mRegionCount].origin.y = rect.y();140 mRegionRects[mRegionCount].size.width = rect.width();141 mRegionRects[mRegionCount].size.height = rect.height();142 // printf ("Region rect[%d - %d]: %d %d %d %d\n", mRegionCount, aCount, rect.x(), rect.y(), rect.height(), rect.width());143 ++mRegionCount;144 #else145 128 CGRect *cgRct = &rgnRcts->rcts[rgnRcts->used]; 146 129 cgRct->origin.x = rect.x(); … … 150 133 // printf ("Region rect[%d - %d]: %d %d %d %d\n", rgnRcts->used, aCount, rect.x(), rect.y(), rect.height(), rect.width()); 151 134 rgnRcts->used++; 152 #endif153 135 } 154 136 // printf ("..................................\n"); … … 163 145 return S_OK; 164 146 } 165 166 /* Saved for later optimization */167 //#define BEST_BYTE_ALIGNMENT 16168 //#define COMPUTE_BEST_BYTES_PER_ROW (bpr) ( ( (bpr) + (BEST_BYTE_ALIGNMENT-1) ) & ~(BEST_BYTE_ALIGNMENT-1) )169 //CGImageRef createImageFromImageInRect(CGImageRef* img, const QRect& rect)170 //{171 // const int sx = qRound(sr.x()), sy = qRound(sr.y()), sw = qRound(sr.width()), sh = qRound(sr.height());172 // const QMacPixmapData *pmData = static_cast<const QMacPixmapData*>(pm.data);173 // quint32 *pantherData = pmData->pixels + (sy * pm.width() + sx);174 //175 // QCFType<CGDataProviderRef> provider = CGDataProviderCreateWithData(0, pantherData, sw*sh*sizeof(uint), 0);176 //177 //178 // CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, mBitmapData, bitmapByteCount, NULL);179 // mImage = CGImageCreate(mWdt, mHgt, 8, 32, bitmapBytesPerRow, cs,180 // kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host, dp, 0, 0,181 // kCGRenderingIntentDefault);182 //183 // CGDataProviderRef dp = CGDataProviderCreateWithData(aFrameBuffer, aFrameBuffer->address(), aFrameBuffer->bitsPerPixel() / 8 * aFrameBuffer->width() * aFrameBuffer->height() , NULL);184 // image = CGImageCreate(sw, sh, 8, 32, pm.width() * sizeof(uint),185 // macGenericColorSpace(),186 // kCGImageAlphaPremultipliedFirst, provider, 0, 0,187 // kCGRenderingIntentDefault);188 //}189 147 190 148 void VBoxQuartz2DFrameBuffer::paintEvent (QPaintEvent *pe) … … 234 192 GetPortBounds (GetWindowPort (window), &winRect); 235 193 CGContextClearRect (ctx, CGRectMake (winRect.left, winRect.top, winRect.right - winRect.left, winRect.bottom - winRect.top)); 236 #if 1 237 if (mRegionRects && mRegionCount > 0) 238 #else 239 RegionRects *rgnRcts = (RegionRects *) ASMAtomicXchgPtr (&mRegion, NULL); 194 // ASMAtomicXchgPtr ((void * volatile *) &mRegion, &mRegionUnused); 195 RegionRects *rgnRcts = (RegionRects *) ASMAtomicXchgPtr ((void * volatile *) &mRegion, NULL); 240 196 if (rgnRcts) 241 #endif242 197 { 243 198 /* Save state for display fliping */ … … 249 204 * SetVisibleRegion. */ 250 205 CGContextBeginPath (ctx); 251 #if 1 252 CGContextAddRects (ctx, mRegionRects, mRegionCount); 253 #else 254 CGContextAddRects (ctx, rgnRects->rcts, rgnRects->used); 255 if ( !ASMAtomicCmpXchgPtr (&mRegion, rgnRects, NULL) 256 && !ASMAtomicCmpXchgPtr (&mRegionUnused, rgnRects, NULL)) 257 RTMemFree(rgnRects); 258 #endif 206 CGContextAddRects (ctx, rgnRcts->rcts, rgnRcts->used); 207 if ( !ASMAtomicCmpXchgPtr ((void * volatile *) &mRegion, rgnRcts, NULL) 208 && !ASMAtomicCmpXchgPtr ((void * volatile *) &mRegionUnused, rgnRcts, NULL)) 209 RTMemFree(rgnRcts); 259 210 /* Restore the context state. Note that the 260 211 * current path isn't destroyed. */ … … 331 282 mHgt = re->height(); 332 283 284 bool remind = false; 285 333 286 /* We need a color space in any case */ 334 287 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); … … 351 304 else 352 305 { 306 remind = true; 353 307 // printf ("No VRAM\n"); 354 /* Create the memory we need for our image copy */ 355 int bitmapBytesPerRow = (mWdt * 4); 308 /* Create the memory we need for our image copy 309 * Read somewhere that an alignment of 16 is 310 * best for optimal performance. So why not. */ 311 // int bitmapBytesPerRow = RT_ALIGN (mWdt * 4, 16); 312 int bitmapBytesPerRow = mWdt * 4; 356 313 int bitmapByteCount = (bitmapBytesPerRow * mHgt); 357 314 mBitmapData = RTMemAlloc (bitmapByteCount); … … 364 321 } 365 322 CGColorSpaceRelease (cs); 323 324 // if (remind) 325 // { 326 // class RemindEvent : public VBoxAsyncEvent 327 // { 328 // ulong mRealBPP; 329 // public: 330 // RemindEvent (ulong aRealBPP) 331 // : mRealBPP (aRealBPP) {} 332 // void handle() 333 // { 334 // vboxProblem().remindAboutWrongColorDepth (mRealBPP, 32); 335 // } 336 // }; 337 // (new RemindEvent (re->bitsPerPixel()))->post(); 338 // } 366 339 } 367 340 … … 378 351 mBitmapData = NULL; 379 352 } 380 #if 1381 if (mRegionRects)382 {383 RTMemFree (mRegionRects);384 mRegionRects = NULL;385 mRegionCount = 0;386 }387 #else388 353 if (mRegion) 389 354 { 390 RTMemFree ( mRegion)355 RTMemFree ((void *) mRegion); 391 356 mRegion = NULL; 392 357 } 393 358 if (mRegionUnused) 394 359 { 395 RTMemFree ( mRegionUnused)360 RTMemFree ((void *) mRegionUnused); 396 361 mRegionUnused = NULL; 397 362 } 398 #endif399 363 } 400 364
Note:
See TracChangeset
for help on using the changeset viewer.