Merge branch 'qtquick2' of scm.dev.nokia.troll.no:qt/qtbase-staging into qtquick2

This commit is contained in:
Gunnar Sletta 2011-05-04 10:01:30 +02:00
commit a41265a09e
31 changed files with 237 additions and 157 deletions

View File

@ -237,6 +237,7 @@ static void resolveAygLibs()
# define FE_FONTSMOOTHINGCLEARTYPE 0x0002
#endif
Q_GUI_EXPORT qreal qt_fontsmoothing_gamma;
Q_GUI_EXPORT bool qt_cleartype_enabled;
Q_GUI_EXPORT bool qt_win_owndc_required; // CS_OWNDC is required if we use the GL graphicssystem as default
@ -653,8 +654,18 @@ static void qt_win_read_cleartype_settings()
if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0))
qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE);
#endif
}
int winSmooth;
if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0)) {
qt_fontsmoothing_gamma = winSmooth / qreal(1000.0);
} else {
qt_fontsmoothing_gamma = 1.0;
}
// Safeguard ourselves against corrupt registry values...
if (qt_fontsmoothing_gamma > 5 || qt_fontsmoothing_gamma < 1)
qt_fontsmoothing_gamma = qreal(1.4);
}
static void qt_set_windows_resources()
{

View File

@ -51,6 +51,8 @@ QT_USE_NAMESPACE
void QDesktopWidgetPrivate::updateScreenList()
{
Q_Q(QDesktopWidget);
QList<QPlatformScreen *> screenList = QApplicationPrivate::platformIntegration()->screens();
int targetLength = screenList.length();
int currentLength = screens.length();
@ -72,19 +74,15 @@ void QDesktopWidgetPrivate::updateScreenList()
}
QRegion virtualGeometry;
bool doVirtualGeometry = QApplicationPrivate::platformIntegration()->isVirtualDesktop();
// update the geometry of each screen widget
for (int i = 0; i < screens.length(); i++) {
QRect screenGeometry = screenList.at(i)->geometry();
screens.at(i)->setGeometry(screenGeometry);
if (doVirtualGeometry)
virtualGeometry += screenGeometry;
virtualGeometry += screenGeometry;
}
virtualScreen.setGeometry(virtualGeometry.boundingRect());
Q_Q(QDesktopWidget);
q->setGeometry(virtualScreen.geometry());
q->setGeometry(virtualGeometry.boundingRect());
}
QDesktopWidget::QDesktopWidget()
@ -118,8 +116,6 @@ int QDesktopWidget::numScreens() const
QWidget *QDesktopWidget::screen(int screen)
{
Q_D(QDesktopWidget);
if (QApplicationPrivate::platformIntegration()->isVirtualDesktop())
return &d->virtualScreen;
if (screen < 0 || screen >= d->screens.length())
return d->screens.at(0);
return d->screens.at(screen);

View File

@ -76,7 +76,6 @@ public:
void updateScreenList();
QList<QDesktopScreenWidget *> screens;
QDesktopScreenWidget virtualScreen;
};
#endif // QDESKTOPWIDGET_QPA_P_H

View File

@ -214,6 +214,7 @@ QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
bool QPlatformIntegration::hasCapability(Capability cap) const
{
Q_UNUSED(cap);
return false;
}

View File

@ -150,7 +150,7 @@ void QPlatformWindow::setParent(const QPlatformWindow *parent)
/*!
Reimplement to set the window title to \a title
*/
void QPlatformWindow::setWindowTitle(const QString &title) {}
void QPlatformWindow::setWindowTitle(const QString &) {}
/*!
Reimplement to be able to let Qt rais windows to the top of the desktop

View File

@ -7198,14 +7198,8 @@ void qt_build_pow_tables() {
#endif
#ifdef Q_WS_WIN
int winSmooth;
if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0))
smoothing = winSmooth / qreal(1000.0);
// Safeguard ourselves against corrupt registry values...
if (smoothing > 5 || smoothing < 1)
smoothing = qreal(1.4);
extern qreal qt_fontsmoothing_gamma; // qapplication_win.cpp
smoothing = qt_fontsmoothing_gamma;
#endif
#ifdef Q_WS_X11

View File

@ -308,10 +308,10 @@ qreal QRawFont::descent() const
\sa setPixelSize()
*/
int QRawFont::pixelSize() const
qreal QRawFont::pixelSize() const
{
if (!isValid())
return -1;
return 0.0;
return d->fontEngine->fontDef.pixelSize;
}
@ -577,7 +577,7 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ
/*!
Sets the pixel size with which this font should be rendered to \a pixelSize.
*/
void QRawFont::setPixelSize(int pixelSize)
void QRawFont::setPixelSize(qreal pixelSize)
{
if (d->fontEngine == 0)
return;

View File

@ -96,8 +96,8 @@ public:
const QTransform &transform = QTransform()) const;
QPainterPath pathForGlyph(quint32 glyphIndex) const;
void setPixelSize(int pixelSize);
int pixelSize() const;
void setPixelSize(qreal pixelSize);
qreal pixelSize() const;
QFont::HintingPreference hintingPreference() const;

View File

@ -2996,10 +2996,19 @@ void QTextDocumentLayout::resizeInlineObject(QTextInlineObject item, int posInDo
QSizeF inlineSize = (pos == QTextFrameFormat::InFlow ? intrinsic : QSizeF(0, 0));
item.setWidth(inlineSize.width());
if (f.verticalAlignment() == QTextCharFormat::AlignMiddle) {
QFontMetrics m(f.font());
switch (f.verticalAlignment())
{
case QTextCharFormat::AlignMiddle:
item.setDescent(inlineSize.height() / 2);
item.setAscent(inlineSize.height() / 2 - 1);
} else {
break;
case QTextCharFormat::AlignBaseline:
item.setDescent(m.descent());
item.setAscent(inlineSize.height() - m.descent() - 1);
break;
default:
item.setDescent(0);
item.setAscent(inlineSize.height() - 1);
}

View File

@ -378,7 +378,8 @@ public:
AlignSubScript,
AlignMiddle,
AlignTop,
AlignBottom
AlignBottom,
AlignBaseline
};
enum UnderlineStyle { // keep in sync with Qt::PenStyle!
NoUnderline,

View File

@ -1548,6 +1548,14 @@ namespace {
}
#if defined(Q_WS_WIN)
static bool fontSmoothingApproximately(qreal target)
{
extern Q_GUI_EXPORT qreal qt_fontsmoothing_gamma; // qapplication_win.cpp
return (qAbs(qt_fontsmoothing_gamma - target) < 0.2);
}
#endif
// #define QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO
void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType,
@ -1786,7 +1794,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
shaderManager->setMaskType(QGLEngineShaderManager::PixelMask);
prepareForDraw(false); // Text always causes src pixels to be transparent
}
//### TODO: Gamma correction
QGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QGLTextureGlyphCache::Linear:QGLTextureGlyphCache::Nearest;
if (lastMaskTextureUsed != cache->texture() || cache->filterMode() != filterMode) {
@ -1809,12 +1816,31 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
}
}
bool srgbFrameBufferEnabled = false;
if (ctx->d_ptr->extension_flags & QGLExtensions::SRGBFrameBuffer) {
#if defined(Q_WS_MAC)
if (glyphType == QFontEngineGlyphCache::Raster_RGBMask)
#elif defined(Q_WS_WIN)
if (glyphType != QFontEngineGlyphCache::Raster_RGBMask || fontSmoothingApproximately(2.1))
#else
if (false)
#endif
{
glEnable(FRAMEBUFFER_SRGB_EXT);
srgbFrameBufferEnabled = true;
}
}
#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#else
glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data());
#endif
if (srgbFrameBufferEnabled)
glDisable(FRAMEBUFFER_SRGB_EXT);
}
void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
@ -1986,7 +2012,8 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
#if !defined(QT_OPENGL_ES_2)
#if defined(Q_WS_WIN)
if (qt_cleartype_enabled)
if (qt_cleartype_enabled
&& (fontSmoothingApproximately(1.0) || fontSmoothingApproximately(2.1)))
#endif
#if defined(Q_WS_MAC)
if (qt_applefontsmoothing_enabled)

View File

@ -5521,6 +5521,13 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions()
if (extensions.match("GL_EXT_bgra"))
glExtensions |= BGRATextureFormat;
{
GLboolean srgbCapableFramebuffers;
glGetBooleanv(FRAMEBUFFER_SRGB_CAPABLE_EXT, &srgbCapableFramebuffers);
if (srgbCapableFramebuffers)
glExtensions |= SRGBFrameBuffer;
}
return glExtensions;
}

View File

@ -288,7 +288,8 @@ public:
PVRTCTextureCompression = 0x00020000,
FragmentShader = 0x00040000,
ElementIndexUint = 0x00080000,
Depth24 = 0x00100000
Depth24 = 0x00100000,
SRGBFrameBuffer = 0x00200000
};
Q_DECLARE_FLAGS(Extensions, Extension)

View File

@ -477,6 +477,14 @@ struct QGLExtensionFuncs
// OpenGL constants
#ifndef FRAMEBUFFER_SRGB_CAPABLE_EXT
#define FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
#endif
#ifndef FRAMEBUFFER_SRGB_EXT
#define FRAMEBUFFER_SRGB_EXT 0x8DB9
#endif
#ifndef GL_ARRAY_BUFFER
#define GL_ARRAY_BUFFER 0x8892
#endif

View File

@ -69,13 +69,8 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
Q_UNUSED(launchOptions)
Q_UNUSED(application)
foreach (QWidget *widget, qApp->topLevelWidgets()) {
QRect geom = widget->geometry();
CGRect bar = application.statusBarFrame;
if (geom.y() <= bar.size.height) {
geom.setY(bar.size.height);
widget->setGeometry(geom);
}
QUIKitWindow *platformWindow = static_cast<QUIKitWindow *>(widget->platformWindow());
platformWindow->ensureNativeWindow();
}

View File

@ -66,7 +66,7 @@ QUIKitIntegration::~QUIKitIntegration()
QPixmapData *QUIKitIntegration::createPixmapData(QPixmapData::PixelType type) const
{
return new QRasterPixmapData(type);
return new QRasterPixmapData(type);
}
QPlatformWindow *QUIKitIntegration::createPlatformWindow(QWidget *widget, WId winId) const

View File

@ -54,7 +54,7 @@ QUIKitScreen::QUIKitScreen(int screenIndex)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
UIScreen *screen = [[UIScreen screens] objectAtIndex:screenIndex];
CGRect bounds = [screen bounds];
m_geometry = QRect(0, 0, bounds.size.width, bounds.size.height);
m_geometry = QRect(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
m_format = QImage::Format_ARGB32;
@ -62,7 +62,7 @@ QUIKitScreen::QUIKitScreen(int screenIndex)
const qreal inch = 25.4;
qreal dpi = 160.;
int dragDistance = 14;
int dragDistance = 12;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
dpi = 132.;
dragDistance = 10;

View File

@ -47,6 +47,8 @@
#import <UIKit/UIKit.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#import <OpenGLES/EAGL.h>
@interface EAGLView : UIView <UIKeyInput>
@ -59,6 +61,7 @@
GLuint mFramebuffer, mColorRenderbuffer, mDepthRenderbuffer;
id delegate;
// ------- Text Input ----------
UITextAutocapitalizationType autocapitalizationType;
UITextAutocorrectionType autocorrectionType;
@ -77,6 +80,8 @@
- (void)setWindow:(QPlatformWindow *)window;
- (void)sendMouseEventForTouches:(NSSet *)touches withEvent:(UIEvent *)event fakeButtons:(Qt::MouseButtons)buttons;
@property (readonly,getter=fbo) GLint fbo;
@property (nonatomic, assign) id delegate;
// ------- Text Input ----------
@ -90,6 +95,10 @@
@end
@protocol EAGLViewDelegate
- (void)eaglView:(EAGLView *)view usesFramebuffer:(GLuint)buffer;
@end
class EAGLPlatformContext;
QT_BEGIN_NAMESPACE
@ -103,7 +112,7 @@ public:
~QUIKitWindow();
UIWindow *nativeWindow() const { return mWindow; }
UIView *nativeView() const { return mView; }
EAGLView *nativeView() const { return mView; }
void setGeometry(const QRect &rect);
UIWindow *ensureNativeWindow();

View File

@ -79,7 +79,11 @@ public:
mFormat.setStereo(false);
mFormat.setDirectRendering(false);
#if defined(QT_OPENGL_ES_2)
EAGLContext *aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
#else
EAGLContext *aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
#endif
[mView setContext:aContext];
}
@ -116,6 +120,8 @@ private:
@implementation EAGLView
@synthesize delegate;
+ (Class)layerClass
{
return [CAEAGLLayer class];
@ -156,8 +162,8 @@ private:
{
if (mContext) {
[EAGLContext setCurrentContext:mContext];
glBindRenderbufferOES(GL_RENDERBUFFER_OES, mColorRenderbuffer);
[mContext presentRenderbuffer:GL_RENDERBUFFER_OES];
glBindRenderbuffer(GL_RENDERBUFFER, mColorRenderbuffer);
[mContext presentRenderbuffer:GL_RENDERBUFFER];
}
}
@ -167,15 +173,15 @@ private:
{
[EAGLContext setCurrentContext:mContext];
if (mFramebuffer) {
glDeleteFramebuffersOES(1, &mFramebuffer);
glDeleteFramebuffers(1, &mFramebuffer);
mFramebuffer = 0;
}
if (mColorRenderbuffer) {
glDeleteRenderbuffersOES(1, &mColorRenderbuffer);
glDeleteRenderbuffers(1, &mColorRenderbuffer);
mColorRenderbuffer = 0;
}
if (mDepthRenderbuffer) {
glDeleteRenderbuffersOES(1, &mDepthRenderbuffer);
glDeleteRenderbuffers(1, &mDepthRenderbuffer);
mDepthRenderbuffer = 0;
}
}
@ -186,24 +192,27 @@ private:
if (mContext && !mFramebuffer)
{
[EAGLContext setCurrentContext:mContext];
glGenFramebuffersOES(1, &mFramebuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, mFramebuffer);
glGenFramebuffers(1, &mFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
glGenRenderbuffersOES(1, &mColorRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, mColorRenderbuffer);
[mContext renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer *)self.layer];
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &mFramebufferWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &mFramebufferHeight);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, mColorRenderbuffer);
glGenRenderbuffers(1, &mColorRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, mColorRenderbuffer);
[mContext renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer];
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &mFramebufferWidth);
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &mFramebufferHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, mColorRenderbuffer);
glGenRenderbuffersOES(1, &mDepthRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, mDepthRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH24_STENCIL8_OES, mFramebufferWidth, mFramebufferHeight);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, mDepthRenderbuffer);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, mDepthRenderbuffer);
glGenRenderbuffers(1, &mDepthRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, mDepthRenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, mFramebufferWidth, mFramebufferHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthRenderbuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mDepthRenderbuffer);
if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES)
NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
if (delegate && [delegate respondsToSelector:@selector(eaglView:usesFramebuffer:)]) {
[delegate eaglView:self usesFramebuffer:mFramebuffer];
}
}
}
@ -214,11 +223,16 @@ private:
[EAGLContext setCurrentContext:mContext];
if (!mFramebuffer)
[self createFramebuffer];
glBindFramebufferOES(GL_FRAMEBUFFER_OES, mFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
glViewport(0, 0, mFramebufferWidth, mFramebufferHeight);
}
}
- (GLint)fbo
{
return mFramebuffer;
}
- (void)setWindow:(QPlatformWindow *)window
{
mWindow = window;
@ -322,6 +336,7 @@ QUIKitWindow::QUIKitWindow(QWidget *tlw) :
CGRect screenBounds = [mScreen->uiScreen() bounds];
QRect geom(screenBounds.origin.x, screenBounds.origin.y, screenBounds.size.width, screenBounds.size.height);
setGeometry(geom);
mView = [[EAGLView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
// TODO ensure the native window if the application is already running
}
@ -334,7 +349,7 @@ QUIKitWindow::~QUIKitWindow()
void QUIKitWindow::setGeometry(const QRect &rect)
{
if (mWindow) {
if (mWindow && rect != geometry()) {
mWindow.frame = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
mView.frame = CGRectMake(0, 0, rect.width(), rect.height());
[mView deleteFramebuffer];
@ -347,14 +362,16 @@ UIWindow *QUIKitWindow::ensureNativeWindow()
{
if (!mWindow) {
// window
QRect geom = geometry();
CGRect frame = CGRectMake(geom.x(), geom.y(), geom.width(), geom.height());
mWindow = [[UIWindow alloc] initWithFrame:frame];
CGRect frame = [mScreen->uiScreen() applicationFrame];
QRect geom = QRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
widget()->setGeometry(geom);
mWindow = [[UIWindow alloc] init];
mWindow.screen = mScreen->uiScreen();
mWindow.frame = frame; // for some reason setting the screen resets frame.origin
mWindow.frame = frame; // for some reason setting the screen resets frame.origin, so we need to set the frame afterwards
// view
mView = [[EAGLView alloc] initWithFrame:CGRectMake(0, 0, geom.width(), geom.height())];
[mView deleteFramebuffer];
mView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height); // fill
[mView setMultipleTouchEnabled:YES];
[mView setWindow:this];
[mWindow addSubview:mView];

View File

@ -47,27 +47,64 @@
#include <QtDebug>
class EAGLPaintDevice;
@interface PaintDeviceHelper : NSObject {
EAGLPaintDevice *device;
}
@property (nonatomic, assign) EAGLPaintDevice *device;
- (void)eaglView:(EAGLView *)view usesFramebuffer:(GLuint)buffer;
@end
class EAGLPaintDevice : public QGLPaintDevice
{
public:
EAGLPaintDevice(QPlatformWindow *window)
:QGLPaintDevice(), mWindow(window)
{
#if defined(QT_OPENGL_ES_2)
helper = [[PaintDeviceHelper alloc] init];
helper.device = this;
EAGLView *view = static_cast<QUIKitWindow *>(window)->nativeView();
view.delegate = helper;
m_thisFBO = view.fbo;
#endif
}
~EAGLPaintDevice()
{
#if defined(QT_OPENGL_ES_2)
[helper release];
#endif
}
void setFramebuffer(GLuint buffer) { m_thisFBO = buffer; }
int devType() const { return QInternal::OpenGL; }
QSize size() const { return mWindow->geometry().size(); }
QGLContext* context() const { return QGLContext::fromPlatformGLContext(mWindow->glContext()); }
QPaintEngine *paintEngine() const { return qt_qgl_paint_engine(); }
void beginPaint(){
QGLPaintDevice::beginPaint();
}
private:
QPlatformWindow *mWindow;
PaintDeviceHelper *helper;
};
@implementation PaintDeviceHelper
@synthesize device;
- (void)eaglView:(EAGLView *)view usesFramebuffer:(GLuint)buffer
{
Q_UNUSED(view)
if (device)
device->setFramebuffer(buffer);
}
@end
QT_BEGIN_NAMESPACE
QUIKitWindowSurface::QUIKitWindowSurface(QWidget *window)

View File

@ -49,7 +49,6 @@
QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay)
: mWaylandDisplay(waylandDisplay)
, mNativeEglDisplay(wl_egl_display_create(mWaylandDisplay))
{
qDebug() << "Using Wayland-EGL";
}
@ -63,7 +62,7 @@ QWaylandEglIntegration::~QWaylandEglIntegration()
void QWaylandEglIntegration::initialize()
{
EGLint major,minor;
mEglDisplay = eglGetDisplay((EGLNativeDisplayType)mNativeEglDisplay);
mEglDisplay = eglGetDisplay(mWaylandDisplay);
if (mEglDisplay == NULL) {
qWarning("EGL not available");
} else {
@ -84,11 +83,6 @@ EGLDisplay QWaylandEglIntegration::eglDisplay() const
return mEglDisplay;
}
wl_egl_display * QWaylandEglIntegration::nativeDisplay() const
{
return mNativeEglDisplay;
}
QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay)
{
return new QWaylandEglIntegration(waylandDisplay->wl_display());

View File

@ -65,9 +65,6 @@ private:
struct wl_display *mWaylandDisplay;
EGLDisplay mEglDisplay;
struct wl_egl_display *mNativeEglDisplay;
};
#endif // QWAYLANDEGLINTEGRATION_H

View File

@ -103,7 +103,7 @@ void QWaylandEglWindow::newSurfaceCreated()
if (!size.isValid())
size = QSize(0,0);
mWaylandEglWindow = wl_egl_window_create(mEglIntegration->nativeDisplay(),mSurface,size.width(),size.height(),visual);
mWaylandEglWindow = wl_egl_window_create(mSurface,size.width(),size.height(),visual);
if (mGLContext) {
EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL);

View File

@ -111,9 +111,9 @@ const struct wl_xcomposite_listener QWaylandXCompositeEGLIntegration::xcomposite
void QWaylandXCompositeEGLIntegration::wlDisplayHandleGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data)
{
Q_UNUSED(version);
if (strcmp(interface, "xcomposite") == 0) {
if (strcmp(interface, "wl_xcomposite") == 0) {
QWaylandXCompositeEGLIntegration *integration = static_cast<QWaylandXCompositeEGLIntegration *>(data);
integration->mWaylandComposite = wl_xcomposite_create(display,id);
integration->mWaylandComposite = wl_xcomposite_create(display,id,1);
wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration);
}

View File

@ -106,9 +106,9 @@ const struct wl_xcomposite_listener QWaylandXCompositeGLXIntegration::xcomposite
void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data)
{
Q_UNUSED(version);
if (strcmp(interface, "xcomposite") == 0) {
if (strcmp(interface, "wl_xcomposite") == 0) {
QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
integration->mWaylandComposite = wl_xcomposite_create(display,id);
integration->mWaylandComposite = wl_xcomposite_create(display,id,1);
wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration);
}

View File

@ -39,7 +39,6 @@
**
****************************************************************************/
#ifndef XCOMPOSITE_CLIENT_PROTOCOL_H
#define XCOMPOSITE_CLIENT_PROTOCOL_H
@ -55,84 +54,63 @@ struct wl_client;
struct wl_xcomposite;
struct wl_proxy;
extern void
wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...);
extern struct wl_proxy *
wl_proxy_create(struct wl_proxy *factory,
const struct wl_interface *interface);
extern struct wl_proxy *
wl_proxy_create_for_id(struct wl_display *display,
const struct wl_interface *interface, uint32_t id);
extern void
wl_proxy_destroy(struct wl_proxy *proxy);
extern int
wl_proxy_add_listener(struct wl_proxy *proxy,
void (**implementation)(void), void *data);
extern void
wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data);
extern void *
wl_proxy_get_user_data(struct wl_proxy *proxy);
extern const struct wl_interface wl_xcomposite_interface;
struct wl_xcomposite_listener {
void (*root)(void *data,
struct wl_xcomposite *xcomposite,
struct wl_xcomposite *wl_xcomposite,
const char *display_name,
uint32_t root_window);
};
static inline int
wl_xcomposite_add_listener(struct wl_xcomposite *xcomposite,
const struct wl_xcomposite_listener *listener, void *data)
wl_xcomposite_add_listener(struct wl_xcomposite *wl_xcomposite,
const struct wl_xcomposite_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) xcomposite,
return wl_proxy_add_listener((struct wl_proxy *) wl_xcomposite,
(void (**)(void)) listener, data);
}
#define WL_XCOMPOSITE_CREATE_BUFFER 0
static inline struct wl_xcomposite *
wl_xcomposite_create(struct wl_display *display, uint32_t id)
wl_xcomposite_create(struct wl_display *display, uint32_t id, uint32_t version)
{
wl_display_bind(display, id, "wl_xcomposite", version);
return (struct wl_xcomposite *)
wl_proxy_create_for_id(display, &wl_xcomposite_interface, id);
}
static inline void
wl_xcomposite_set_user_data(struct wl_xcomposite *xcomposite, void *user_data)
wl_xcomposite_set_user_data(struct wl_xcomposite *wl_xcomposite, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) xcomposite, user_data);
wl_proxy_set_user_data((struct wl_proxy *) wl_xcomposite, user_data);
}
static inline void *
wl_xcomposite_get_user_data(struct wl_xcomposite *xcomposite)
wl_xcomposite_get_user_data(struct wl_xcomposite *wl_xcomposite)
{
return wl_proxy_get_user_data((struct wl_proxy *) xcomposite);
return wl_proxy_get_user_data((struct wl_proxy *) wl_xcomposite);
}
static inline void
wl_xcomposite_destroy(struct wl_xcomposite *xcomposite)
wl_xcomposite_destroy(struct wl_xcomposite *wl_xcomposite)
{
wl_proxy_destroy((struct wl_proxy *) xcomposite);
wl_proxy_destroy((struct wl_proxy *) wl_xcomposite);
}
static inline struct wl_buffer *
wl_xcomposite_create_buffer(struct wl_xcomposite *xcomposite, uint32_t x_window, int width, int height, struct wl_visual *visual)
wl_xcomposite_create_buffer(struct wl_xcomposite *wl_xcomposite, uint32_t x_window, int width, int height, struct wl_visual *visual)
{
struct wl_proxy *id;
id = wl_proxy_create((struct wl_proxy *) xcomposite,
id = wl_proxy_create((struct wl_proxy *) wl_xcomposite,
&wl_buffer_interface);
if (!id)
return NULL;
wl_proxy_marshal((struct wl_proxy *) xcomposite,
wl_proxy_marshal((struct wl_proxy *) wl_xcomposite,
WL_XCOMPOSITE_CREATE_BUFFER, id, x_window, width, height, visual);
return (struct wl_buffer *) id;

View File

@ -43,17 +43,17 @@
#include <stdint.h>
#include "wayland-util.h"
static const struct wl_message xcomposite_requests[] = {
static const struct wl_message wl_xcomposite_requests[] = {
{ "create_buffer", "nuiio" },
};
static const struct wl_message xcomposite_events[] = {
static const struct wl_message wl_xcomposite_events[] = {
{ "root", "su" },
};
WL_EXPORT const struct wl_interface wl_xcomposite_interface = {
"xcomposite", 1,
ARRAY_LENGTH(xcomposite_requests), xcomposite_requests,
ARRAY_LENGTH(xcomposite_events), xcomposite_events,
"wl_xcomposite", 1,
ARRAY_LENGTH(wl_xcomposite_requests), wl_xcomposite_requests,
ARRAY_LENGTH(wl_xcomposite_events), wl_xcomposite_events,
};

View File

@ -126,6 +126,7 @@ QWaylandDisplay::QWaylandDisplay(void)
#ifdef QT_WAYLAND_GL_SUPPORT
mEglIntegration = QWaylandGLIntegration::createGLIntegration(this);
#endif
blockingReadEvents();
qRegisterMetaType<uint32_t>("uint32_t");
@ -216,9 +217,6 @@ void QWaylandDisplay::outputHandleGeometry(void *data,
int32_t x, int32_t y,
int32_t width, int32_t height)
{
//call back function called from another thread;
//but its safe to call createScreen from another thread since
//QWaylandScreen does a moveToThread
QWaylandDisplay *waylandDisplay = static_cast<QWaylandDisplay *>(data);
QRect outputRect = QRect(x, y, width, height);
waylandDisplay->createNewScreen(output,outputRect);
@ -252,17 +250,17 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id,
{
Q_UNUSED(version);
if (interface == "output") {
struct wl_output *output = wl_output_create(mDisplay, id);
if (interface == "wl_output") {
struct wl_output *output = wl_output_create(mDisplay, id, 1);
wl_output_add_listener(output, &outputListener, this);
} else if (interface == "compositor") {
mCompositor = wl_compositor_create(mDisplay, id);
} else if (interface == "shm") {
mShm = wl_shm_create(mDisplay, id);
} else if (interface == "shell"){
mShell = wl_shell_create(mDisplay, id);
} else if (interface == "wl_compositor") {
mCompositor = wl_compositor_create(mDisplay, id, 1);
} else if (interface == "wl_shm") {
mShm = wl_shm_create(mDisplay, id, 1);
} else if (interface == "wl_shell"){
mShell = wl_shell_create(mDisplay, id, 1);
wl_shell_add_listener(mShell, &shellListener, this);
} else if (interface == "input_device") {
} else if (interface == "wl_input_device") {
QWaylandInputDevice *inputDevice =
new QWaylandInputDevice(mDisplay, id);
mInputDevices.append(inputDevice);

View File

@ -61,7 +61,7 @@
QWaylandInputDevice::QWaylandInputDevice(struct wl_display *display,
uint32_t id)
: mDisplay(display)
, mInputDevice(wl_input_device_create(display, id))
, mInputDevice(wl_input_device_create(display, id, 1))
, mPointerFocus(NULL)
, mKeyboardFocus(NULL)
, mButtons(0)

View File

@ -146,6 +146,7 @@ void QWaylandWindow::newSurfaceCreated()
void QWaylandWindow::frameCallback(struct wl_surface *surface, void *data, uint32_t time)
{
Q_UNUSED(time);
Q_UNUSED(surface);
QWaylandWindow *self = static_cast<QWaylandWindow*>(data);
self->mWaitingForFrameSync = false;
}

View File

@ -104,7 +104,7 @@ void tst_QRawFont::invalidRawFont()
{
QRawFont font;
QVERIFY(!font.isValid());
QCOMPARE(font.pixelSize(), -1);
QCOMPARE(font.pixelSize(), 0.0);
QVERIFY(font.familyName().isEmpty());
QCOMPARE(font.style(), QFont::StyleNormal);
QCOMPARE(font.weight(), -1);
@ -165,7 +165,7 @@ void tst_QRawFont::correctFontData_data()
QTest::addColumn<QFont::Weight>("weight");
QTest::addColumn<QFont::HintingPreference>("hintingPreference");
QTest::addColumn<qreal>("unitsPerEm");
QTest::addColumn<int>("pixelSize");
QTest::addColumn<qreal>("pixelSize");
int hintingPreferences[] = {
int(QFont::PreferDefaultHinting),
@ -189,7 +189,7 @@ void tst_QRawFont::correctFontData_data()
<< QFont::Normal
<< QFont::HintingPreference(*hintingPreference)
<< 1000.0
<< 10;
<< 10.0;
fileName = QLatin1String(SRCDIR "testfont_bold_italic.ttf");
title = fileName
@ -203,7 +203,7 @@ void tst_QRawFont::correctFontData_data()
<< QFont::Bold
<< QFont::HintingPreference(*hintingPreference)
<< 1000.0
<< 10;
<< 10.0;
++hintingPreference;
}
@ -217,7 +217,7 @@ void tst_QRawFont::correctFontData()
QFETCH(QFont::Weight, weight);
QFETCH(QFont::HintingPreference, hintingPreference);
QFETCH(qreal, unitsPerEm);
QFETCH(int, pixelSize);
QFETCH(qreal, pixelSize);
QRawFont font(fileName, 10, hintingPreference);
QVERIFY(font.isValid());
@ -284,7 +284,7 @@ void tst_QRawFont::textLayout()
QString familyName = QString::fromLatin1("QtBidiTestFont");
QFont font(familyName);
font.setPixelSize(18);
font.setPixelSize(18.0);
QCOMPARE(QFontInfo(font).family(), familyName);
QTextLayout layout(QLatin1String("Foobar"));
@ -301,7 +301,7 @@ void tst_QRawFont::textLayout()
QRawFont rawFont = glyphs.font();
QVERIFY(rawFont.isValid());
QCOMPARE(rawFont.familyName(), familyName);
QCOMPARE(rawFont.pixelSize(), 18);
QCOMPARE(rawFont.pixelSize(), 18.0);
QVector<quint32> expectedGlyphIndices;
expectedGlyphIndices << 44 << 83 << 83 << 70 << 69 << 86;
@ -597,12 +597,12 @@ void tst_QRawFont::fromFont()
QFont font(familyName);
font.setHintingPreference(hintingPreference);
font.setPixelSize(26);
font.setPixelSize(26.0);
QRawFont rawFont = QRawFont::fromFont(font, writingSystem);
QVERIFY(rawFont.isValid());
QCOMPARE(rawFont.familyName(), familyName);
QCOMPARE(rawFont.pixelSize(), 26);
QCOMPARE(rawFont.pixelSize(), 26.0);
QVERIFY(fontDatabase.removeApplicationFont(id));
}
@ -623,7 +623,7 @@ void tst_QRawFont::copyConstructor()
{
QString rawFontFamilyName;
int rawFontPixelSize;
qreal rawFontPixelSize;
qreal rawFontAscent;
qreal rawFontDescent;
int rawFontTableSize;
@ -691,7 +691,7 @@ void tst_QRawFont::detach()
{
QString rawFontFamilyName;
int rawFontPixelSize;
qreal rawFontPixelSize;
qreal rawFontAscent;
qreal rawFontDescent;
int rawFontTableSize;
@ -773,15 +773,15 @@ void tst_QRawFont::unsupportedWritingSystem()
QFont font("QtBidiTestFont");
font.setHintingPreference(hintingPreference);
font.setPixelSize(12);
font.setPixelSize(12.0);
QRawFont rawFont = QRawFont::fromFont(font, QFontDatabase::Any);
QCOMPARE(rawFont.familyName(), QString::fromLatin1("QtBidiTestFont"));
QCOMPARE(rawFont.pixelSize(), 12);
QCOMPARE(rawFont.pixelSize(), 12.0);
rawFont = QRawFont::fromFont(font, QFontDatabase::Hebrew);
QCOMPARE(rawFont.familyName(), QString::fromLatin1("QtBidiTestFont"));
QCOMPARE(rawFont.pixelSize(), 12);
QCOMPARE(rawFont.pixelSize(), 12.0);
QString arabicText = QFontDatabase::writingSystemSample(QFontDatabase::Arabic);
@ -798,11 +798,11 @@ void tst_QRawFont::unsupportedWritingSystem()
QGlyphs glyphs = glyphss.at(0);
QRawFont layoutFont = glyphs.font();
QVERIFY(layoutFont.familyName() != QString::fromLatin1("QtBidiTestFont"));
QCOMPARE(layoutFont.pixelSize(), 12);
QCOMPARE(layoutFont.pixelSize(), 12.0);
rawFont = QRawFont::fromFont(font, QFontDatabase::Arabic);
QCOMPARE(rawFont.familyName(), layoutFont.familyName());
QCOMPARE(rawFont.pixelSize(), 12);
QCOMPARE(rawFont.pixelSize(), 12.0);
fontDatabase.removeApplicationFont(id);
}