Port QMacPrintEngine and QCoreGraphicsPaintEngine from Qt 4 to Qt 5
authorBradley T. Hughes <bradley.hughes@nokia.com>
Fri, 2 Mar 2012 11:17:24 +0000 (12:17 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 15 Mar 2012 08:50:18 +0000 (09:50 +0100)
commit7e3c632e96dbbd6f577c2ba98464a54176c5b7b0
treef45b610655c5362a8e027482d9d544a13f12d0d9
parentcad51669d83ff649fae70842abf095acb5b72abc
Port QMacPrintEngine and QCoreGraphicsPaintEngine from Qt 4 to Qt 5

Copy qprintengine_mac_p.h, qprintengine_mac.mm, qpaintengine_mac_p.h,
and qpaintengine_mac.cpp (as qpaintengine_mac.mm) from src/gui/painting/
in the 4.8 branch of http://git.gitorious.org/qt/qt.git at commit
e6bd33d4aef0e4538d7918e7ab130624c911b553.

The following changes are necessary to port these files to the Qt 5 API:

- The copyright notice on these files has been updated to match the
  header.LGPL template.

- Fix #includes for qprintengine_mac* and qpaintengine_mac*, as some
  headers have moved in Qt 5.

- Remove extern forward declarations for functions that no longer exist.

- Remove friend declarations for classes/functions that are not part of
  the Cocoa platform plugin.

- Remove QT_MAC_USE_COCOA blocks. Qt is always using Cocoa now, there
  is no need to keep the non-Cocoa code paths anymore. The
  QMacPrintEngine::shouldSuppressStatus() method was also removed,
  since it is no longer used.

- Do not use Qt::UniteClip, it was removed in commit
  01b72952c38b9193138eabdab6bdab632cd75ebd

- Use QCocoaAutoReleasePool in qprintengine_mac.mm

- Use QPlatformPrintSupport::convert*() functions in QMacPrintEngine,
  since we cannot use non-exported functions from QtPrintSupport in the
  Cocoa plugin.

- Use qt_mac_image_to_cg_image() to convert QPixmap to CGImageRef. First
  convert QPixmap to QImage (cheap, since the Cocoa platform plugin
  uses QRasterPlatformPixmap), and then convert the QImage to CFImageRef
  using the existing helper function.

- Copy qt_mac_cg_context() to the Cocoa platform plugin from
  qmacstyle_mac.mm, adding a note at each location about the
  duplication.

- Add qt_mac_QRegionToHIMutableShape() helper. Adapt the Qt 4.x code for
  QRegion::toHIMutableShape(), and use this in QCoreGraphicsPaintEngine.

- Add qt_mac_drawCGImage() and qt_mac_get_scalefactor() helper. These
  functions are copied directly from the 4.8 branch of
  http://git.gitorious.org/qt/qt.git at the same revision shown above.

- Add qt_mac_create_imagemask() helper in qpaintengine_mac.cpp.  This
  helper is based on the function with the same name from the 4.8
  branch of http://git.gitorious.org/qt/qt.git at the same revision
  shown above. The correctness of the implementation has not yet been
  verified.

Since these files use the QPrinter API from QtPrintSupport, the Cocoa
plugin now needs to link to that library as well.

Change-Id: I90b9bbe201327489ef9e1b3294e68e91ddda27bd
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
src/plugins/platforms/cocoa/cocoa.pro
src/plugins/platforms/cocoa/qcocoahelpers.h
src/plugins/platforms/cocoa/qcocoahelpers.mm
src/plugins/platforms/cocoa/qpaintengine_mac.mm [new file with mode: 0644]
src/plugins/platforms/cocoa/qpaintengine_mac_p.h [new file with mode: 0644]
src/plugins/platforms/cocoa/qprintengine_mac.mm [new file with mode: 0644]
src/plugins/platforms/cocoa/qprintengine_mac_p.h [new file with mode: 0644]
src/plugins/platforms/cocoa/qt_mac_p.h
src/widgets/styles/qmacstyle_mac.mm