Qt 4.8
Classes | Macros | Functions | Variables
qgl_mac.mm File Reference
#include "qgl.h"
#include <AGL/agl.h>
#include <AGL/aglRenderers.h>
#include <OpenGL/gl.h>
#include <CoreServices/CoreServices.h>
#include <private/qfont_p.h>
#include <private/qfontengine_p.h>
#include <private/qgl_p.h>
#include <private/qpaintengine_opengl_p.h>
#include <private/qt_mac_p.h>
#include <qpixmap.h>
#include <qtimer.h>
#include <qapplication.h>
#include <qstack.h>
#include <qdesktopwidget.h>
#include <qdebug.h>

Go to the source code of this file.

Classes

class  QGLTemporaryContextPrivate
 

Macros

#define DEPRECATED_ATTRIBUTE
 

Functions

static CFBundleRef qt_getOpenGLBundle ()
 
QRegion qt_mac_convert_mac_region (RgnHandle)
 
void qt_mac_dispose_rgn (RgnHandle)
 
RgnHandle qt_mac_get_rgn ()
 
float qt_mac_get_scale_factor (QWidget *widget)
 
QRegion qt_mac_get_widget_rgn (const QWidget *widget)
 
quint32qt_mac_pixmap_get_base (const QPixmap *)
 
int qt_mac_pixmap_get_bytes_per_line (const QPixmap *)
 

Variables

static QColor cmap [256]
 
static bool cmap_init = false
 

Macro Definition Documentation

◆ DEPRECATED_ATTRIBUTE

#define DEPRECATED_ATTRIBUTE

Definition at line 47 of file qgl_mac.mm.

Function Documentation

◆ qt_getOpenGLBundle()

static CFBundleRef qt_getOpenGLBundle ( )
static

Definition at line 808 of file qgl_mac.mm.

809 {
810  CFBundleRef bundle = 0;
811  CFStringRef urlString = QCFString::toCFStringRef(QLatin1String("/System/Library/Frameworks/OpenGL.framework"));
812  QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
813  urlString, kCFURLPOSIXPathStyle, false);
814  if (url)
815  bundle = CFBundleCreate(kCFAllocatorDefault, url);
816  CFRelease(urlString);
817  return bundle;
818 }
const struct __CFString * CFStringRef
static CFStringRef toCFStringRef(const QString &str)
Definition: qcore_mac.cpp:69
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ qt_mac_convert_mac_region()

QRegion qt_mac_convert_mac_region ( RgnHandle  )

Referenced by qt_mac_get_widget_rgn().

◆ qt_mac_dispose_rgn()

void qt_mac_dispose_rgn ( RgnHandle  )

Referenced by qt_mac_get_widget_rgn().

◆ qt_mac_get_rgn()

RgnHandle qt_mac_get_rgn ( )

Referenced by qt_mac_get_widget_rgn().

◆ qt_mac_get_scale_factor()

float qt_mac_get_scale_factor ( QWidget widget)

Definition at line 565 of file qgl_mac.mm.

Referenced by QGLWidget::resizeEvent(), and QGLContext::updatePaintDevice().

566 {
567  if (!widget | !widget->window())
568  return 1;
569 
570  if (widget->window()->testAttribute(Qt::WA_MacFrameworkScaled) == false)
571  return 1;
572 
573  float systemScale = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4 ? HIGetScaleFactor() : 1;
574  if (systemScale == float(1))
575  return 1;
576 
577  return systemScale;
578 }
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646

◆ qt_mac_get_widget_rgn()

QRegion qt_mac_get_widget_rgn ( const QWidget widget)

Definition at line 836 of file qgl_mac.mm.

Referenced by QGLContext::updatePaintDevice().

837 {
838  if(!widget->isVisible() || widget->isMinimized())
839  return QRegion();
840  const QRect wrect = QRect(qt_mac_posInWindow(widget), widget->size());
841  if(!wrect.isValid())
842  return QRegion();
843 
844  RgnHandle macr = qt_mac_get_rgn();
845  GetControlRegion((HIViewRef)widget->winId(), kControlStructureMetaPart, macr);
846  OffsetRgn(macr, wrect.x(), wrect.y());
848 
849  QPoint clip_pos = wrect.topLeft();
850  for(const QWidget *last_clip = 0, *clip = widget; clip; last_clip = clip, clip = clip->parentWidget()) {
851  if(clip != widget) {
852  GetControlRegion((HIViewRef)clip->winId(), kControlStructureMetaPart, macr);
853  OffsetRgn(macr, clip_pos.x(), clip_pos.y());
854  ret &= qt_mac_convert_mac_region(macr);
855  }
856  const QObjectList &children = clip->children();
857  for(int i = children.size()-1; i >= 0; --i) {
858  if(QWidget *child = qobject_cast<QWidget*>(children.at(i))) {
859  if(child == last_clip)
860  break;
861 
862  // This check may seem weird, but when we are using a unified toolbar
863  // The widget is actually being owned by that toolbar and not by Qt.
864  // This means that the geometry it reports will be wrong
865  // and will accidentally cause problems when calculating the region
866  // So, it is better to skip these widgets since they aren't the hierarchy
867  // anyway.
868  if (HIViewGetSuperview(HIViewRef(child->winId())) != HIViewRef(clip->winId()))
869  continue;
870 
871  if(child->isVisible() && !child->isMinimized() && !child->isTopLevel()) {
872  const QRect childRect = QRect(clip_pos+child->pos(), child->size());
873  if(childRect.isValid() && wrect.intersects(childRect)) {
874  GetControlRegion((HIViewRef)child->winId(), kControlStructureMetaPart, macr);
875  OffsetRgn(macr, childRect.x(), childRect.y());
876  ret -= qt_mac_convert_mac_region(macr);
877  }
878  }
879  }
880  }
881  if(clip->isWindow())
882  break;
883  clip_pos -= clip->pos();
884  }
885  qt_mac_dispose_rgn(macr);
886  return ret;
887 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
RgnHandle qt_mac_get_rgn()
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
struct OpaqueControlRef * HIViewRef
QRegion qt_mac_convert_mac_region(RgnHandle)
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
struct OpaqueRgnHandle * RgnHandle
void qt_mac_dispose_rgn(RgnHandle)
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
bool isMinimized() const
Definition: qwidget.cpp:3027
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
Definition: qrect.cpp:1429
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Q_GUI_EXPORT QPoint qt_mac_posInWindow(const QWidget *w)
Definition: qwidget_mac.mm:380
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ qt_mac_pixmap_get_base()

quint32* qt_mac_pixmap_get_base ( const QPixmap )

Definition at line 75 of file qpixmap_mac.cpp.

Referenced by QGLContext::updatePaintDevice().

76 {
78  return reinterpret_cast<quint32 *>(static_cast<QRasterPixmapData*>(pix->data.data())->buffer()->bits());
79  else
80  return static_cast<QMacPixmapData*>(pix->data.data())->pixels;
81 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QString graphics_system_name
unsigned int quint32
Definition: qglobal.h:938

◆ qt_mac_pixmap_get_bytes_per_line()

int qt_mac_pixmap_get_bytes_per_line ( const QPixmap )

Definition at line 83 of file qpixmap_mac.cpp.

Referenced by QGLContext::updatePaintDevice().

84 {
86  return static_cast<QRasterPixmapData*>(pix->data.data())->buffer()->bytesPerLine();
87  else
88  return static_cast<QMacPixmapData*>(pix->data.data())->bytesPerRow;
89 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QString graphics_system_name

Variable Documentation

◆ cmap

QColor cmap[256]
static

◆ cmap_init

bool cmap_init = false
static

Definition at line 761 of file qgl_mac.mm.