source: trunk/src/gui/painting/qwindowsurface_raster.cpp@ 347

Last change on this file since 347 was 308, checked in by Dmitry A. Kuminov, 16 years ago

gui: Use manual image flipping (from Qt to PM) instead of setting the world transformation matrix. Added a simple pixel/ms counter for measurements.

File size: 17.7 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include <qdebug.h>
43
44#include <qglobal.h> // for Q_WS_WIN define (non-PCH)
45#ifdef Q_WS_WIN
46#include <qt_windows.h>
47#endif
48
49#include <QtGui/qpaintdevice.h>
50#include <QtGui/qwidget.h>
51
52#include "private/qwindowsurface_raster_p.h"
53#include "private/qnativeimage_p.h"
54#include "private/qwidget_p.h"
55
56#ifdef Q_WS_X11
57#include "private/qpixmap_x11_p.h"
58#include "private/qt_x11_p.h"
59#include "private/qwidget_p.h"
60#include "qx11info_x11.h"
61#endif
62#include "private/qdrawhelper_p.h"
63
64#ifdef Q_WS_MAC
65#include <private/qt_cocoa_helpers_mac_p.h>
66#endif
67
68#if defined(Q_WS_PM) && defined(QT_LOG_BLITSPEED)
69#include <InnotekLIBC/FastInfoBlocks.h>
70#endif
71
72QT_BEGIN_NAMESPACE
73
74#ifdef Q_WS_WIN
75PtrUpdateLayeredWindowIndirect ptrUpdateLayeredWindowIndirect;
76#endif
77
78#if defined(Q_WS_PM) && defined(QT_LOG_BLITSPEED)
79unsigned long long qt_total_blit_ms = 0;
80unsigned long long qt_total_blit_pixels = 0;
81#endif
82
83class QRasterWindowSurfacePrivate
84{
85public:
86 QNativeImage *image;
87
88#ifdef Q_WS_X11
89 GC gc;
90#ifndef QT_NO_XRENDER
91 uint translucentBackground : 1;
92#endif
93#endif
94#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
95 uint canUseLayeredWindow : 1;
96#endif
97 uint inSetGeometry : 1;
98};
99
100QRasterWindowSurface::QRasterWindowSurface(QWidget *window)
101 : QWindowSurface(window), d_ptr(new QRasterWindowSurfacePrivate)
102{
103#ifdef Q_WS_X11
104 d_ptr->gc = XCreateGC(X11->display, window->handle(), 0, 0);
105#ifndef QT_NO_XRENDER
106 d_ptr->translucentBackground = X11->use_xrender
107 && window->x11Info().depth() == 32;
108#endif
109#endif
110#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
111 d_ptr->canUseLayeredWindow = ptrUpdateLayeredWindowIndirect
112 && (qt_widget_private(window)->data.window_flags & Qt::FramelessWindowHint);
113#endif
114 d_ptr->image = 0;
115 d_ptr->inSetGeometry = false;
116 setStaticContentsSupport(true);
117}
118
119
120QRasterWindowSurface::~QRasterWindowSurface()
121{