Changeset 46120 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- May 16, 2013 10:39:25 AM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQImage.cpp
r46064 r46120 47 47 UIResizeEvent event(FramebufferPixelFormat_Opaque, NULL, 0, 0, 640, 480); 48 48 resizeEvent(&event); 49 } 50 51 void UIFrameBufferQImage::resizeEvent(UIResizeEvent *pEvent) 52 { 53 #if 0 54 LogFlowFunc (("fmt=%d, vram=%p, bpp=%d, bpl=%d, width=%d, height=%d\n", 55 pEvent->pixelFormat(), pEvent->VRAM(), 56 pEvent->bitsPerPixel(), pEvent->bytesPerLine(), 57 pEvent->width(), pEvent->height())); 58 #endif 59 60 /* Remember new width/height: */ 61 m_width = pEvent->width(); 62 m_height = pEvent->height(); 63 64 /* Check if we support the pixel format and can use the guest VRAM directly: */ 65 bool bRemind = false; 66 bool bFallback = false; 67 ulong bitsPerLine = pEvent->bytesPerLine() * 8; 68 if (pEvent->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB) 69 { 70 QImage::Format format; 71 switch (pEvent->bitsPerPixel()) 72 { 73 /* 32-, 8- and 1-bpp are the only depths supported by QImage: */ 74 case 32: 75 format = QImage::Format_RGB32; 76 break; 77 case 8: 78 format = QImage::Format_Indexed8; 79 bRemind = true; 80 break; 81 case 1: 82 format = QImage::Format_Mono; 83 bRemind = true; 84 break; 85 default: 86 format = QImage::Format_Invalid; 87 bRemind = true; 88 bFallback = true; 89 break; 90 } 91 92 if (!bFallback) 93 { 94 /* QImage only supports 32-bit aligned scan lines... */ 95 Assert((pEvent->bytesPerLine() & 3) == 0); 96 bFallback = ((pEvent->bytesPerLine() & 3) != 0); 97 } 98 if (!bFallback) 99 { 100 /* ...and the scan lines ought to be a whole number of pixels. */ 101 Assert((bitsPerLine & (pEvent->bitsPerPixel() - 1)) == 0); 102 bFallback = ((bitsPerLine & (pEvent->bitsPerPixel() - 1)) != 0); 103 } 104 if (!bFallback) 105 { 106 /* Make sure constraints are also passed: */ 107 Assert(bitsPerLine / pEvent->bitsPerPixel() >= m_width); 108 bFallback = RT_BOOL(bitsPerLine / pEvent->bitsPerPixel() < m_width); 109 } 110 if (!bFallback) 111 { 112 /* Finally compose image using VRAM directly: */ 113 m_img = QImage((uchar *)pEvent->VRAM(), m_width, m_height, bitsPerLine / 8, format); 114 m_uPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 115 m_bUsesGuestVRAM = true; 116 } 117 } 118 else 119 bFallback = true; 120 121 /* Fallback if requested: */ 122 if (bFallback) 123 goFallback(); 124 125 /* Remind if requested: */ 126 if (bRemind) 127 msgCenter().remindAboutWrongColorDepth(pEvent->bitsPerPixel(), 32); 49 128 } 50 129 … … 120 199 } 121 200 122 void UIFrameBufferQImage::resizeEvent(UIResizeEvent *pEvent)123 {124 #if 0125 LogFlowFunc (("fmt=%d, vram=%p, bpp=%d, bpl=%d, width=%d, height=%d\n",126 pEvent->pixelFormat(), pEvent->VRAM(),127 pEvent->bitsPerPixel(), pEvent->bytesPerLine(),128 pEvent->width(), pEvent->height()));129 #endif130 131 /* Remember new width/height: */132 m_width = pEvent->width();133 m_height = pEvent->height();134 135 /* Check if we support the pixel format and can use the guest VRAM directly: */136 bool bRemind = false;137 bool bFallback = false;138 ulong bitsPerLine = pEvent->bytesPerLine() * 8;139 if (pEvent->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB)140 {141 QImage::Format format;142 switch (pEvent->bitsPerPixel())143 {144 /* 32-, 8- and 1-bpp are the only depths supported by QImage: */145 case 32:146 format = QImage::Format_RGB32;147 break;148 case 8:149 format = QImage::Format_Indexed8;150 bRemind = true;151 break;152 case 1:153 format = QImage::Format_Mono;154 bRemind = true;155 break;156 default:157 format = QImage::Format_Invalid;158 bRemind = true;159 bFallback = true;160 break;161 }162 163 if (!bFallback)164 {165 /* QImage only supports 32-bit aligned scan lines... */166 Assert((pEvent->bytesPerLine() & 3) == 0);167 bFallback = ((pEvent->bytesPerLine() & 3) != 0);168 }169 if (!bFallback)170 {171 /* ...and the scan lines ought to be a whole number of pixels. */172 Assert((bitsPerLine & (pEvent->bitsPerPixel() - 1)) == 0);173 bFallback = ((bitsPerLine & (pEvent->bitsPerPixel() - 1)) != 0);174 }175 if (!bFallback)176 {177 /* Make sure constraints are also passed: */178 Assert(bitsPerLine / pEvent->bitsPerPixel() >= m_width);179 bFallback = RT_BOOL(bitsPerLine / pEvent->bitsPerPixel() < m_width);180 }181 if (!bFallback)182 {183 /* Finally compose image using VRAM directly: */184 m_img = QImage((uchar *)pEvent->VRAM(), m_width, m_height, bitsPerLine / 8, format);185 m_uPixelFormat = FramebufferPixelFormat_FOURCC_RGB;186 m_bUsesGuestVRAM = true;187 }188 }189 else190 bFallback = true;191 192 /* Fallback if requested: */193 if (bFallback)194 goFallback();195 196 /* Remind if requested: */197 if (bRemind)198 msgCenter().remindAboutWrongColorDepth(pEvent->bitsPerPixel(), 32);199 }200 201 201 void UIFrameBufferQImage::goFallback() 202 202 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.cpp
r46064 r46120 145 145 146 146 return S_OK; 147 } 148 149 void UIFrameBufferQuartz2D::resizeEvent(UIResizeEvent *aEvent) 150 { 151 #if 0 152 printf ("fmt=%lu, vram=%X, bpp=%lu, bpl=%lu, width=%lu, height=%lu\n", 153 aEvent->pixelFormat(), (unsigned int)aEvent->VRAM(), 154 aEvent->bitsPerPixel(), aEvent->bytesPerLine(), 155 aEvent->width(), aEvent->height()); 156 #endif 157 /* Clean out old stuff */ 158 clean(m_width == aEvent->width() 159 && m_height == aEvent->height()); 160 161 m_width = aEvent->width(); 162 m_height = aEvent->height(); 163 164 bool remind = false; 165 166 /* We need a color space in any case */ 167 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); 168 /* Check if we support the pixel format/colordepth and can use the guest VRAM directly. 169 * Mac OS X supports 16 bit also but not in the 565 mode. So we could use 170 * 32 bit only. */ 171 if ( aEvent->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB 172 && aEvent->bitsPerPixel() == 32) 173 { 174 m_fUsesGuestVRAM = true; 175 // printf ("VRAM\n"); 176 /* Create the image copy of the framebuffer */ 177 CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, aEvent->VRAM(), aEvent->bytesPerLine() * m_height, NULL); 178 m_image = CGImageCreate(m_width, m_height, 8, aEvent->bitsPerPixel(), aEvent->bytesPerLine(), cs, 179 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, 180 kCGRenderingIntentDefault); 181 m_pDataAddress = aEvent->VRAM(); 182 CGDataProviderRelease (dp); 183 } 184 else 185 { 186 m_fUsesGuestVRAM = false; 187 remind = true; 188 // printf ("No VRAM\n"); 189 /* Create the memory we need for our image copy 190 * Read somewhere that an alignment of 16 is 191 * best for optimal performance. So why not. */ 192 // int bitmapBytesPerRow = RT_ALIGN (m_width * 4, 16); 193 int bitmapBytesPerRow = m_width * 4; 194 int bitmapByteCount = (bitmapBytesPerRow * m_height); 195 m_pBitmapData = RTMemAllocZ(bitmapByteCount); 196 CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, m_pBitmapData, bitmapByteCount, NULL); 197 m_image = CGImageCreate(m_width, m_height, 8, 32, bitmapBytesPerRow, cs, 198 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, 199 kCGRenderingIntentDefault); 200 m_pDataAddress = static_cast<uchar*>(m_pBitmapData); 201 CGDataProviderRelease(dp); 202 } 203 CGColorSpaceRelease(cs); 204 #ifdef VBOX_WITH_ICHAT_THEATER 205 setImageRef(m_image); 206 #endif 207 208 // if (remind) 209 // msgCenter().remindAboutWrongColorDepth(aEvent->bitsPerPixel(), 32); 147 210 } 148 211 … … 400 463 } 401 464 402 void UIFrameBufferQuartz2D::resizeEvent(UIResizeEvent *aEvent)403 {404 #if 0405 printf ("fmt=%lu, vram=%X, bpp=%lu, bpl=%lu, width=%lu, height=%lu\n",406 aEvent->pixelFormat(), (unsigned int)aEvent->VRAM(),407 aEvent->bitsPerPixel(), aEvent->bytesPerLine(),408 aEvent->width(), aEvent->height());409 #endif410 /* Clean out old stuff */411 clean(m_width == aEvent->width()412 && m_height == aEvent->height());413 414 m_width = aEvent->width();415 m_height = aEvent->height();416 417 bool remind = false;418 419 /* We need a color space in any case */420 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();421 /* Check if we support the pixel format/colordepth and can use the guest VRAM directly.422 * Mac OS X supports 16 bit also but not in the 565 mode. So we could use423 * 32 bit only. */424 if ( aEvent->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB425 && aEvent->bitsPerPixel() == 32)426 {427 m_fUsesGuestVRAM = true;428 // printf ("VRAM\n");429 /* Create the image copy of the framebuffer */430 CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, aEvent->VRAM(), aEvent->bytesPerLine() * m_height, NULL);431 m_image = CGImageCreate(m_width, m_height, 8, aEvent->bitsPerPixel(), aEvent->bytesPerLine(), cs,432 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false,433 kCGRenderingIntentDefault);434 m_pDataAddress = aEvent->VRAM();435 CGDataProviderRelease (dp);436 }437 else438 {439 m_fUsesGuestVRAM = false;440 remind = true;441 // printf ("No VRAM\n");442 /* Create the memory we need for our image copy443 * Read somewhere that an alignment of 16 is444 * best for optimal performance. So why not. */445 // int bitmapBytesPerRow = RT_ALIGN (m_width * 4, 16);446 int bitmapBytesPerRow = m_width * 4;447 int bitmapByteCount = (bitmapBytesPerRow * m_height);448 m_pBitmapData = RTMemAllocZ(bitmapByteCount);449 CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, m_pBitmapData, bitmapByteCount, NULL);450 m_image = CGImageCreate(m_width, m_height, 8, 32, bitmapBytesPerRow, cs,451 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false,452 kCGRenderingIntentDefault);453 m_pDataAddress = static_cast<uchar*>(m_pBitmapData);454 CGDataProviderRelease(dp);455 }456 CGColorSpaceRelease(cs);457 #ifdef VBOX_WITH_ICHAT_THEATER458 setImageRef(m_image);459 #endif460 461 // if (remind)462 // msgCenter().remindAboutWrongColorDepth(aEvent->bitsPerPixel(), 32);463 }464 465 465 void UIFrameBufferQuartz2D::clean(bool fPreserveRegions) 466 466 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.h
r46064 r46120 6 6 7 7 /* 8 * Copyright (C) 2010-201 2Oracle Corporation8 * Copyright (C) 2010-2013 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 48 48 const CGImageRef imageRef() const { return m_image; } 49 49 50 void resizeEvent(UIResizeEvent *pEvent); 50 51 void paintEvent(QPaintEvent *pEvent); 51 void resizeEvent(UIResizeEvent *pEvent);52 52 53 53 #ifdef VBOX_WITH_VIDEOHWACCEL
Note:
See TracChangeset
for help on using the changeset viewer.