Changeset 27022 in vbox for trunk/src/VBox
- Timestamp:
- Mar 4, 2010 1:01:56 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.cpp
r27021 r27022 163 163 * updated.*/ 164 164 165 Assert (m_image); 166 167 // VBoxConsoleWnd *main = qobject_cast <VBoxConsoleWnd *> (vboxGlobal().mainWindow()); 168 // Assert (VALID_PTR (main)); 165 Assert(m_image); 166 169 167 QWidget* viewport = m_pMachineView->viewport(); 170 Assert(VALID_PTR 168 Assert(VALID_PTR(viewport)); 171 169 /* Get the dimensions of the viewport */ 172 170 CGRect viewRect = ::darwinToCGRect(viewport->geometry()); … … 176 174 177 175 /* Flip the context */ 178 CGContextTranslateCTM 179 CGContextScaleCTM 176 CGContextTranslateCTM(ctx, 0, viewRect.size.height); 177 CGContextScaleCTM(ctx, 1.0, -1.0); 180 178 181 179 /* We handle the seamless mode as a special case. */ … … 190 188 if (!m_pMachineView->pauseShot().isNull()) 191 189 { 192 CGImageRef pauseImg = ::darwinToCGImageRef 193 subImage = CGImageCreateWithImageInRect 194 CGImageRelease 190 CGImageRef pauseImg = ::darwinToCGImageRef(&m_pMachineView->pauseShot()); 191 subImage = CGImageCreateWithImageInRect(pauseImg, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight())); 192 CGImageRelease(pauseImg); 195 193 } 196 194 else 197 subImage = CGImageCreateWithImageInRect 198 Assert (VALID_PTR(subImage));195 subImage = CGImageCreateWithImageInRect(m_image, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight())); 196 Assert(VALID_PTR(subImage)); 199 197 /* Clear the background (Make the rect fully transparent) */ 200 CGContextClearRect 198 CGContextClearRect(ctx, viewRect); 201 199 #ifdef OVERLAY_CLIPRECTS 202 CGContextSetRGBFillColor 203 CGContextFillRect 200 CGContextSetRGBFillColor(ctx, 0.0, 0.0, 5.0, 0.7); 201 CGContextFillRect(ctx, viewRect); 204 202 #endif 205 203 #ifdef COMP_WITH_SHADOW 206 204 /* Enable shadows */ 207 CGContextSetShadow 208 CGContextBeginTransparencyLayer 205 CGContextSetShadow(ctx, CGSizeMake (10, -10), 10); 206 CGContextBeginTransparencyLayer(ctx, NULL); 209 207 #endif 210 208 /* Grab the current visible region. */ 211 RegionRects *rgnRcts = (RegionRects *) ASMAtomicXchgPtr ((void * volatile *)&mRegion, NULL);209 RegionRects *rgnRcts = (RegionRects *)ASMAtomicXchgPtr((void * volatile *)&mRegion, NULL); 212 210 if (rgnRcts) 213 211 { … … 216 214 /* Add the clipping rects all at once. They are defined in 217 215 * SetVisibleRegion. */ 218 CGContextBeginPath 219 CGContextAddRects 216 CGContextBeginPath(ctx); 217 CGContextAddRects(ctx, rgnRcts->rcts, rgnRcts->used); 220 218 /* Now convert the path to a clipping path. */ 221 CGContextClip 219 CGContextClip(ctx); 222 220 } 223 221 /* Put back the visible region, free if we cannot (2+ SetVisibleRegion calls). */ 224 if ( !ASMAtomicCmpXchgPtr ((void * volatile *)&mRegion, rgnRcts, NULL)225 && !ASMAtomicCmpXchgPtr ((void * volatile *)&mRegionUnused, rgnRcts, NULL))226 RTMemFree 222 if ( !ASMAtomicCmpXchgPtr((void * volatile *)&mRegion, rgnRcts, NULL) 223 && !ASMAtomicCmpXchgPtr((void * volatile *)&mRegionUnused, rgnRcts, NULL)) 224 RTMemFree(rgnRcts); 227 225 } 228 226 /* In any case clip the drawing to the view window */ 229 CGContextClipToRect 227 CGContextClipToRect(ctx, viewRect); 230 228 /* At this point draw the real vm image */ 231 CGContextDrawImage 229 CGContextDrawImage(ctx, ::darwinFlipCGRect (viewRect, viewRect.size.height), subImage); 232 230 #ifdef COMP_WITH_SHADOW 233 CGContextEndTransparencyLayer 234 #endif 235 CGImageRelease 231 CGContextEndTransparencyLayer(ctx); 232 #endif 233 CGImageRelease(subImage); 236 234 #ifdef OVERLAY_CLIPRECTS 237 235 if (rgnRcts && rgnRcts->used > 0) 238 236 { 239 CGContextBeginPath 240 CGContextAddRects 241 CGContextSetRGBStrokeColor 242 CGContextDrawPath 243 } 244 CGContextSetRGBStrokeColor 245 CGContextStrokeRect 237 CGContextBeginPath(ctx); 238 CGContextAddRects(ctx, rgnRcts->rcts, rgnRcts->used); 239 CGContextSetRGBStrokeColor(ctx, 1.0, 0.0, 0.0, 0.7); 240 CGContextDrawPath(ctx, kCGPathStroke); 241 } 242 CGContextSetRGBStrokeColor(ctx, 0.0, 1.0, 0.0, 0.7); 243 CGContextStrokeRect(ctx, viewRect); 246 244 #endif 247 245 } … … 257 255 if (!m_pMachineView->pauseShot().isNull()) 258 256 { 259 CGImageRef pauseImg = ::darwinToCGImageRef 260 subImage = CGImageCreateWithImageInRect (pauseImg, ::darwinToCGRect(is));261 CGImageRelease 257 CGImageRef pauseImg = ::darwinToCGImageRef(&m_pMachineView->pauseShot()); 258 subImage = CGImageCreateWithImageInRect(pauseImg, ::darwinToCGRect(is)); 259 CGImageRelease(pauseImg); 262 260 } 263 261 else 264 subImage = CGImageCreateWithImageInRect (m_image, ::darwinToCGRect(is));265 Assert (VALID_PTR(subImage));262 subImage = CGImageCreateWithImageInRect(m_image, ::darwinToCGRect(is)); 263 Assert(VALID_PTR(subImage)); 266 264 /* Ok, for more performance we set a clipping path of the 267 265 * regions given by this paint event. */ … … 272 270 /* Add all region rects to the current context as path components */ 273 271 for (int i = 0; i < a.size(); ++i) 274 CGContextAddRect (ctx, ::darwinFlipCGRect (::darwinToCGRect(a[i]), viewRect.size.height));272 CGContextAddRect(ctx, ::darwinFlipCGRect(::darwinToCGRect(a[i]), viewRect.size.height)); 275 273 /* Now convert the path to a clipping path. */ 276 CGContextClip 274 CGContextClip(ctx); 277 275 } 278 276 279 277 /* In any case clip the drawing to the view window */ 280 CGContextClipToRect 278 CGContextClipToRect(ctx, viewRect); 281 279 /* At this point draw the real vm image */ 282 CGContextDrawImage (ctx, ::darwinFlipCGRect(::darwinToCGRect (ir), viewRect.size.height), subImage);283 284 CGImageRelease 285 } 286 } 287 288 void UIFrameBufferQuartz2D::resizeEvent 280 CGContextDrawImage(ctx, ::darwinFlipCGRect(::darwinToCGRect (ir), viewRect.size.height), subImage); 281 282 CGImageRelease(subImage); 283 } 284 } 285 286 void UIFrameBufferQuartz2D::resizeEvent(UIResizeEvent *aEvent) 289 287 { 290 288 #if 0 … … 313 311 // printf ("VRAM\n"); 314 312 /* Create the image copy of the framebuffer */ 315 CGDataProviderRef dp = CGDataProviderCreateWithData 316 m_image = CGImageCreate 313 CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, aEvent->VRAM(), aEvent->bitsPerPixel() / 8 * m_width * m_height, NULL); 314 m_image = CGImageCreate(m_width, m_height, 8, aEvent->bitsPerPixel(), aEvent->bytesPerLine(), cs, 317 315 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, 318 316 kCGRenderingIntentDefault); … … 330 328 int bitmapBytesPerRow = m_width * 4; 331 329 int bitmapByteCount = (bitmapBytesPerRow * m_height); 332 m_pBitmapData = RTMemAlloc 333 CGDataProviderRef dp = CGDataProviderCreateWithData 334 m_image = CGImageCreate 335 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false,336 kCGRenderingIntentDefault);337 m_pDataAddress = static_cast <uchar*>(m_pBitmapData);338 CGDataProviderRelease 339 } 340 CGColorSpaceRelease 330 m_pBitmapData = RTMemAlloc(bitmapByteCount); 331 CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, m_pBitmapData, bitmapByteCount, NULL); 332 m_image = CGImageCreate(m_width, m_height, 8, 32, bitmapBytesPerRow, cs, 333 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, 334 kCGRenderingIntentDefault); 335 m_pDataAddress = static_cast<uchar*>(m_pBitmapData); 336 CGDataProviderRelease(dp); 337 } 338 CGColorSpaceRelease(cs); 341 339 #ifdef VBOX_WITH_ICHAT_THEATER 342 setImageRef 340 setImageRef(m_image); 343 341 #endif 344 342 … … 364 362 if (m_image) 365 363 { 366 CGImageRelease 364 CGImageRelease(m_image); 367 365 m_image = NULL; 368 366 } 369 367 if (m_pBitmapData) 370 368 { 371 RTMemFree 369 RTMemFree(m_pBitmapData); 372 370 m_pBitmapData = NULL; 373 371 } 374 372 if (mRegion) 375 373 { 376 RTMemFree ((void *)mRegion);374 RTMemFree((void *)mRegion); 377 375 mRegion = NULL; 378 376 } 379 377 if (mRegionUnused) 380 378 { 381 RTMemFree ((void *)mRegionUnused);379 RTMemFree((void *)mRegionUnused); 382 380 mRegionUnused = NULL; 383 381 }
Note:
See TracChangeset
for help on using the changeset viewer.