Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. The performance of QPainter::drawImage
Forum Updated to NodeBB v4.3 + New Features

The performance of QPainter::drawImage

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    glacierx
    wrote on last edited by
    #1

    Dear all,

    Currently Im porting an application written with QT 4.8 on windows into mac os x. I found the performance of QPainter::drawImage differs dramatically on mac os x and windows.

    After I googled a bunch of articles and profile my qt application on mac, I found the reason is that the mac version drawImage was implemented by calling Quartz function CGContextDrawImage which consequently calls argb32_sample_argb32. argb32_sample_argb32 wastes most of the cpu cycles.

    Most probably, mac os x convert generic color space into device-dependent color space in the API CGContextDrawImage. However I modified the source code of QT 4.8 the obtain the system display color space directly.

    The result is still not good. My mac version app is significantly slower than windows version.

    Anyone can tell me why?

    @
    /// QT 4.8's source code modified by me

    CGColorSpaceRef QCoreGraphicsPaintEngine::macGenericColorSpace()
    {

    #if 0
    if (!m_genericColorSpace) {
    #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
    if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
    m_genericColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
    } else
    #endif
    {
    m_genericColorSpace = CGColorSpaceCreateDeviceRGB();
    }
    if (!m_postRoutineRegistered) {
    m_postRoutineRegistered = true;
    qAddPostRoutine(QCoreGraphicsPaintEngine::cleanUpMacColorSpaces);
    }
    }
    return m_genericColorSpace;
    #else
    // Just return the main display colorspace for the moment.
    // return macDisplayColorSpace();
    return CreateSystemColorSpace();
    #endif
    }

    CGColorSpaceRef CreateSystemColorSpace () {
    CMProfileRef sysprof = NULL;
    CGColorSpaceRef dispColorSpace = NULL;

    // Get the Systems Profile for the main display
    if (CMGetSystemProfile(&sysprof) == noErr)
    {
    // Create a colorspace with the systems profile
    dispColorSpace = CGColorSpaceCreateWithPlatformColorSpace(sysprof);

      // Close the profile                                                                                                                                                                                                                                                      
      CMCloseProfile(sysprof);
    }
    

    return dispColorSpace;
    }
    @

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Welcome to devnet

      You need to embrace your code section with '@' "(See also)":http://developer.qt.nokia.com/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01
      Otherwise it is unreadable. You can edit your post with the link below your name.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qttester5
        wrote on last edited by
        #3

        Did you ever get to the bottom of this?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved