VirtualBox

Changeset 31233 in vbox


Ignore:
Timestamp:
Jul 30, 2010 10:00:01 AM (14 years ago)
Author:
vboxsync
Message:

FE/Qt4-OSX: fix distortion problems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.cpp

    r31214 r31233  
    246246        /* Create a subimage of the current view in the size
    247247         * of the bounding box of the current paint event */
    248         QRect qir = aEvent->rect();
    249         CGRect ir = ::darwinToCGRect(qir);
    250         CGRect is = CGRectMake(qir.x() + m_pMachineView->contentsX(), qir.y() + m_pMachineView->contentsY(), qir.width(), qir.height());
    251         ir = ::darwinFlipCGRect(ir, CGRectGetHeight(viewRect));
     248        CGRect ir = ::darwinToCGRect(aEvent->rect());
     249        CGRect is = CGRectMake(CGRectGetMinX(ir) + m_pMachineView->contentsX(), CGRectGetMinY(ir) + m_pMachineView->contentsY(), CGRectGetWidth(ir), CGRectGetHeight(ir));
     250
    252251        double iw = 1.0;
    253252        double ih = 1.0;
     
    267266            iw = (double)CGImageGetWidth(m_image) / m_scaledSize.width();
    268267            ih = (double)CGImageGetHeight(m_image) / m_scaledSize.height();
    269             is.origin.x = (double)(is.origin.x * iw);
    270             is.origin.y = (double)(is.origin.y * ih);
    271             is.size.width = (double)(is.size.width * iw);
    272             is.size.height = (double)(is.size.height * ih);
    273             ir.origin.x = (double)(ir.origin.x * iw);
    274             ir.origin.y = (double)(ir.origin.y * ih);
    275             ir.size.width = (double)(ir.size.width * iw);
    276             ir.size.height = (double)(ir.size.height * ih);
     268            /* We make sure the image is always bigger than requested to
     269             * compensate rounding errors. */
     270            /* Round down */
     271            is.origin.x = (int)(is.origin.x * iw);
     272            is.origin.y = (int)(is.origin.y * ih);
     273            /* Round up */
     274            is.size.width = (int)(is.size.width * iw) + 2;
     275            is.size.height = (int)(is.size.height * ih) + 2;
     276            /* Make sure the size is within the image boundaries */
     277            is = CGRectIntersection(is, CGRectMake(0, 0, CGImageGetWidth(m_image), CGImageGetHeight(m_image)));
     278            /* Cause we probably changed the rectangle to update in the origin
     279             * coordinate system, we have to recalculate the update rectangle
     280             * for the screen coordinates as well. Please note that this has to
     281             * be in double precision. */
     282            ir.origin.x = is.origin.x / iw;
     283            ir.origin.y = is.origin.y / ih;
     284            ir.size.width = is.size.width / iw;
     285            ir.size.height = is.size.height / ih;
     286            /* Create the sub image */
    277287            subImage = CGImageCreateWithImageInRect(m_image, is);
    278288        }
     
    291301                CGContextClip(ctx);
    292302            }
    293 
    294303            /* In any case clip the drawing to the view window */
    295304            CGContextClipToRect(ctx, viewRect);
    296305            /* Turn the high interpolation quality on. */
    297306            CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh);
    298             CGContextScaleCTM(ctx, 1.0 / iw, 1.0 / ih);
    299307            /* Draw the image. */
    300             CGContextDrawImage(ctx, ir, subImage);
     308
     309            CGContextDrawImage(ctx, ::darwinFlipCGRect(ir, CGRectGetHeight(viewRect)), subImage);
    301310            CGImageRelease(subImage);
    302311        }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette