summaryrefslogtreecommitdiffstats
path: root/src/plugins/graphicssystems
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/graphicssystems')
-rw-r--r--src/plugins/graphicssystems/meego/dithering.cpp306
-rw-r--r--src/plugins/graphicssystems/meego/meego.pro4
-rw-r--r--src/plugins/graphicssystems/meego/qmeegoextensions.cpp80
-rw-r--r--src/plugins/graphicssystems/meego/qmeegoextensions.h22
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.cpp244
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.h30
-rw-r--r--src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp292
-rw-r--r--src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h71
-rw-r--r--src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp74
-rw-r--r--src/plugins/graphicssystems/meego/qmeegopixmapdata.h2
-rw-r--r--src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp60
-rw-r--r--src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h55
12 files changed, 983 insertions, 257 deletions
diff --git a/src/plugins/graphicssystems/meego/dithering.cpp b/src/plugins/graphicssystems/meego/dithering.cpp
new file mode 100644
index 0000000..1a2e3fa
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/dithering.cpp
@@ -0,0 +1,306 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This is an implementation of the 32bit => 16bit Floyd-Steinberg dithering.
+// The alghorithm used here is not the fastest possible but it's prolly fast enough:
+// uses look-up tables, integer-only arthmetics and works in one pass on two lines
+// at a time. It's a high-quality dithering using 1/8 diffusion precission.
+// Two functions here to look at:
+//
+// * convertRGBA32_to_RGB565
+// * convertRGBA32_to_RGBA4444
+//
+// Each channel (RGBA) is diffused independently and alpha is dithered too.
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <QVarLengthArray>
+
+// Gets a component (red = 1, green = 2...) from a RGBA data structure.
+// data is unsigned char. stride is the number of bytes per line.
+#define GET_RGBA_COMPONENT(data, x, y, stride, c) (data[(y * stride) + (x << 2) + c])
+
+// Writes a new pixel with r, g, b to data in 565 16bit format. Data is a short.
+#define PUT_565(data, x, y, width, r, g, b) (data[(y * width) + x] = (r << 11) | (g << 5) | b)
+
+// Writes a new pixel with r, g, b, a to data in 4444 RGBA 16bit format. Data is a short.
+#define PUT_4444(data, x, y, width, r, g, b, a) (data[(y * width) + x] = (r << 12) | (g << 8) | (b << 4) | a)
+
+// Writes(ads) a new value to the diffusion accumulator. accumulator is a short.
+// x, y is a position in the accumulation buffer. y can be 0 or 1 -- we operate on two lines at time.
+#define ACCUMULATE(accumulator, x, y, width, v) if (x < width && x >= 0) accumulator[(y * width) + x] += v
+
+// Clamps a value to be in 0..255 range.
+#define CLAMP_256(v) if (v > 255) v = 255; if (v < 0) v = 0;
+
+// Converts incoming RGB32 (QImage::Format_RGB32) to RGB565. Returns the newly allocated data.
+unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int height, int stride)
+{
+ // Output line stride. Aligned to 4 bytes.
+ int alignedWidth = width;
+ if (alignedWidth % 2 > 0)
+ alignedWidth++;
+
+ // Will store output
+ unsigned short *out = (unsigned short *) malloc(alignedWidth * height * 2);
+
+ // Lookup tables for the 8bit => 6bit and 8bit => 5bit conversion
+ unsigned char lookup_8bit_to_5bit[256];
+ short lookup_8bit_to_5bit_diff[256];
+ unsigned char lookup_8bit_to_6bit[256];
+ short lookup_8bit_to_6bit_diff[256];
+
+ // Macros for the conversion using the lookup table.
+ #define CONVERT_8BIT_TO_5BIT(v) (lookup_8bit_to_5bit[v])
+ #define DIFF_8BIT_TO_5BIT(v) (lookup_8bit_to_5bit_diff[v])
+
+ #define CONVERT_8BIT_TO_6BIT(v) (lookup_8bit_to_6bit[v])
+ #define DIFF_8BIT_TO_6BIT(v) (lookup_8bit_to_6bit_diff[v])
+
+ int i;
+ int x, y, c; // Pixel we're processing. c is component number (0, 1, 2 for r, b, b)
+ short component[3]; // Stores the new components (r, g, b) for pixel produced during conversion
+ short diff; // The difference between the converted value and the original one. To be accumulated.
+ QVarLengthArray <short> accumulatorData(3 * width * 2); // Data for three acumulators for r, g, b. Each accumulator is two lines.
+ short *accumulator[3]; // Helper for accessing the accumulator on a per-channel basis more easily.
+ accumulator[0] = accumulatorData.data();
+ accumulator[1] = accumulatorData.data() + width;
+ accumulator[2] = accumulatorData.data() + (width * 2);
+
+ // Produce the conversion lookup tables.
+ for (i = 0; i < 256; i++) {
+ lookup_8bit_to_5bit[i] = round(i / 8.0);
+
+ // Before bitshifts: (i * 8) - (... * 8 * 8)
+ lookup_8bit_to_5bit_diff[i] = (i << 3) - (lookup_8bit_to_5bit[i] << 6);
+ if (lookup_8bit_to_5bit[i] > 31)
+ lookup_8bit_to_5bit[i] -= 1;
+
+ lookup_8bit_to_6bit[i] = round(i / 4.0);
+
+ // Before bitshifts: (i * 8) - (... * 4 * 8)
+ lookup_8bit_to_6bit_diff[i] = (i << 3) - (lookup_8bit_to_6bit[i] << 5);
+ if (lookup_8bit_to_6bit[i] > 63)
+ lookup_8bit_to_6bit[i] -= 1;
+ }
+
+ // Clear the accumulators
+ memset(accumulator[0], 0, width * 4);
+ memset(accumulator[1], 0, width * 4);
+ memset(accumulator[2], 0, width * 4);
+
+ // For each line...
+ for (y = 0; y < height; y++) {
+
+ // For each accumulator, move the second line (index 1) to replace the first line (index 0).
+ // Clear the second line (index 1)
+ memcpy(accumulator[0], accumulator[0] + width, width * 2);
+ memset(accumulator[0] + width, 0, width * 2);
+
+ memcpy(accumulator[1], accumulator[1] + width, width * 2);
+ memset(accumulator[1] + width, 0, width * 2);
+
+ memcpy(accumulator[2], accumulator[2] + width, width * 2);
+ memset(accumulator[2] + width, 0, width * 2);
+
+ // For each column....
+ for (x = 0; x < width; x++) {
+
+ // For each component (r, g, b)...
+ for (c = 0; c < 3; c++) {
+
+ // Get the 8bit value from the original image
+ component[c] = GET_RGBA_COMPONENT(in, x, y, stride, c);
+
+ // Add the diffusion for this pixel we stored in the accumulator.
+ // >> 7 because the values in accumulator are stored * 128
+ component[c] += accumulator[c][x] >> 7;
+
+ // Make sure we're not over the boundaries.
+ CLAMP_256(component[c]);
+
+ // For green component we use 6 bits. Otherwise 5 bits.
+ // Store the difference from converting 8bit => 6 bit and the orig pixel.
+ // Convert 8bit => 6(5) bit.
+ if (c == 1) {
+ diff = DIFF_8BIT_TO_6BIT(component[c]);
+ component[c] = CONVERT_8BIT_TO_6BIT(component[c]);
+ } else {
+ diff = DIFF_8BIT_TO_5BIT(component[c]);
+ component[c] = CONVERT_8BIT_TO_5BIT(component[c]);
+ }
+
+ // Distribute the difference according to the matrix in the
+ // accumulation bufffer.
+ ACCUMULATE(accumulator[c], x + 1, 0, width, diff * 7);
+ ACCUMULATE(accumulator[c], x - 1, 1, width, diff * 3);
+ ACCUMULATE(accumulator[c], x, 1, width, diff * 5);
+ ACCUMULATE(accumulator[c], x + 1, 1, width, diff * 1);
+ }
+
+ // Write the newly produced pixel
+ PUT_565(out, x, y, alignedWidth, component[2], component[1], component[0]);
+ }
+ }
+
+ return out;
+}
+
+// Converts incoming RGBA32 (QImage::Format_ARGB32_Premultiplied) to RGB565. Returns the newly allocated data.
+// This function is similar (yet different) to the _565 variant but it makes sense to duplicate it here for simplicity.
+// The output has each scan line aligned to 4 bytes (as expected by GL by default).
+unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, int height, int stride)
+{
+ // Output line stride. Aligned to 4 bytes.
+ int alignedWidth = width;
+ if (alignedWidth % 2 > 0)
+ alignedWidth++;
+
+ // Will store output
+ unsigned short *out = (unsigned short *) malloc(alignedWidth * 2 * height);
+
+ // Lookup tables for the 8bit => 4bit conversion
+ unsigned char lookup_8bit_to_4bit[256];
+ short lookup_8bit_to_4bit_diff[256];
+
+ // Macros for the conversion using the lookup table.
+ #define CONVERT_8BIT_TO_4BIT(v) (lookup_8bit_to_4bit[v])
+ #define DIFF_8BIT_TO_4BIT(v) (lookup_8bit_to_4bit_diff[v])
+
+ int i;
+ int x, y, c; // Pixel we're processing. c is component number (0, 1, 2, 3 for r, b, b, a)
+ short component[4]; // Stores the new components (r, g, b, a) for pixel produced during conversion
+ short diff; // The difference between the converted value and the original one. To be accumulated.
+ QVarLengthArray <short> accumulatorData(4 * width * 2); // Data for three acumulators for r, g, b. Each accumulator is two lines.
+ short *accumulator[4]; // Helper for accessing the accumulator on a per-channel basis more easily.
+ accumulator[0] = accumulatorData.data();
+ accumulator[1] = accumulatorData.data() + width;
+ accumulator[2] = accumulatorData.data() + (width * 2);
+ accumulator[3] = accumulatorData.data() + (width * 3);
+
+ // Produce the conversion lookup tables.
+ for (i = 0; i < 256; i++) {
+ lookup_8bit_to_4bit[i] = round(i / 16.0);
+ // Before bitshifts: (i * 8) - (... * 16 * 8)
+ lookup_8bit_to_4bit_diff[i] = (i << 3) - (lookup_8bit_to_4bit[i] << 7);
+
+ if (lookup_8bit_to_4bit[i] > 15)
+ lookup_8bit_to_4bit[i] = 15;
+ }
+
+ // Clear the accumulators
+ memset(accumulator[0], 0, width * 4);
+ memset(accumulator[1], 0, width * 4);
+ memset(accumulator[2], 0, width * 4);
+ memset(accumulator[3], 0, width * 4);
+
+ // For each line...
+ for (y = 0; y < height; y++) {
+
+ // For each component (r, g, b, a)...
+ memcpy(accumulator[0], accumulator[0] + width, width * 2);
+ memset(accumulator[0] + width, 0, width * 2);
+
+ memcpy(accumulator[1], accumulator[1] + width, width * 2);
+ memset(accumulator[1] + width, 0, width * 2);
+
+ memcpy(accumulator[2], accumulator[2] + width, width * 2);
+ memset(accumulator[2] + width, 0, width * 2);
+
+ memcpy(accumulator[3], accumulator[3] + width, width * 2);
+ memset(accumulator[3] + width, 0, width * 2);
+
+ // For each column....
+ for (x = 0; x < width; x++) {
+
+ // For each component (r, g, b, a)...
+ for (c = 0; c < 4; c++) {
+
+ // Get the 8bit value from the original image
+ component[c] = GET_RGBA_COMPONENT(in, x, y, stride, c);
+
+ // Add the diffusion for this pixel we stored in the accumulator.
+ // >> 7 because the values in accumulator are stored * 128
+ component[c] += accumulator[c][x] >> 7;
+
+ // Make sure we're not over the boundaries.
+ CLAMP_256(component[c]);
+
+ // Store the difference from converting 8bit => 4bit and the orig pixel.
+ // Convert 8bit => 4bit.
+ diff = DIFF_8BIT_TO_4BIT(component[c]);
+ component[c] = CONVERT_8BIT_TO_4BIT(component[c]);
+
+ // Distribute the difference according to the matrix in the
+ // accumulation bufffer.
+ ACCUMULATE(accumulator[c], x + 1, 0, width, diff * 7);
+ ACCUMULATE(accumulator[c], x - 1, 1, width, diff * 3);
+ ACCUMULATE(accumulator[c], x, 1, width, diff * 5);
+ ACCUMULATE(accumulator[c], x + 1, 1, width, diff * 1);
+ }
+
+ // Write the newly produced pixel
+ PUT_4444(out, x, y, alignedWidth, component[0], component[1], component[2], component[3]);
+ }
+ }
+
+ return out;
+}
+
+unsigned char* convertBGRA32_to_RGBA32(const unsigned char *in, int width, int height, int stride)
+{
+ unsigned char *out = (unsigned char *) malloc(stride * height);
+
+ // For each line...
+ for (int y = 0; y < height; y++) {
+ // For each column
+ for (int x = 0; x < width; x++) {
+ out[(stride * y) + (x * 4) + 0] = in[(stride * y) + (x * 4) + 2];
+ out[(stride * y) + (x * 4) + 1] = in[(stride * y) + (x * 4) + 1];
+ out[(stride * y) + (x * 4) + 2] = in[(stride * y) + (x * 4) + 0];
+ out[(stride * y) + (x * 4) + 3] = in[(stride * y) + (x * 4) + 3];
+ }
+ }
+
+ return out;
+}
diff --git a/src/plugins/graphicssystems/meego/meego.pro b/src/plugins/graphicssystems/meego/meego.pro
index d750d34..0d3cce6 100644
--- a/src/plugins/graphicssystems/meego/meego.pro
+++ b/src/plugins/graphicssystems/meego/meego.pro
@@ -5,8 +5,8 @@ QT += gui opengl
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems
-HEADERS = qmeegographicssystem.h qmeegopixmapdata.h qmeegoextensions.h
-SOURCES = qmeegographicssystem.cpp qmeegographicssystem.h qmeegographicssystemplugin.h qmeegographicssystemplugin.cpp qmeegopixmapdata.h qmeegopixmapdata.cpp qmeegoextensions.h qmeegoextensions.cpp
+HEADERS = qmeegographicssystem.h qmeegopixmapdata.h qmeegoextensions.h qmeegorasterpixmapdata.h qmeegolivepixmapdata.h
+SOURCES = qmeegographicssystem.cpp qmeegographicssystem.h qmeegographicssystemplugin.h qmeegographicssystemplugin.cpp qmeegopixmapdata.h qmeegopixmapdata.cpp qmeegoextensions.h qmeegoextensions.cpp qmeegorasterpixmapdata.h qmeegorasterpixmapdata.cpp qmeegolivepixmapdata.cpp qmeegolivepixmapdata.h dithering.cpp
target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
INSTALLS += target
diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp
index 611c962..dff80a4 100644
--- a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp
+++ b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp
@@ -47,6 +47,7 @@ bool QMeeGoExtensions::initialized = false;
bool QMeeGoExtensions::hasImageShared = false;
bool QMeeGoExtensions::hasSurfaceScaling = false;
bool QMeeGoExtensions::hasLockSurface = false;
+bool QMeeGoExtensions::hasFenceSync = false;
/* Extension funcs */
@@ -54,8 +55,12 @@ typedef EGLBoolean (EGLAPIENTRY *eglQueryImageNOKFunc)(EGLDisplay, EGLImageKHR,
typedef EGLNativeSharedImageTypeNOK (EGLAPIENTRY *eglCreateSharedImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint*);
typedef EGLBoolean (EGLAPIENTRY *eglDestroySharedImageNOKFunc)(EGLDisplay, EGLNativeSharedImageTypeNOK);
typedef EGLBoolean (EGLAPIENTRY *eglSetSurfaceScalingNOKFunc)(EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint);
-typedef EGLBoolean (EGLAPIENTRY *eglLockSurfaceKHRFunc)(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
-typedef EGLBoolean (EGLAPIENTRY *eglUnlockSurfaceKHRFunc)(EGLDisplay display, EGLSurface surface);
+typedef EGLBoolean (EGLAPIENTRY *eglLockSurfaceKHRFunc)(EGLDisplay, EGLSurface, const EGLint*);
+typedef EGLBoolean (EGLAPIENTRY *eglUnlockSurfaceKHRFunc)(EGLDisplay, EGLSurface);
+typedef EGLSyncKHR (EGLAPIENTRY *eglCreateSyncKHRFunc)(EGLDisplay, EGLenum, const EGLint*);
+typedef EGLBoolean (EGLAPIENTRY *eglDestroySyncKHRFunc)(EGLDisplay, EGLSyncKHR);
+typedef EGLint (EGLAPIENTRY *eglClientWaitSyncKHRFunc)(EGLDisplay, EGLSyncKHR, EGLint, EGLTimeKHR);
+typedef EGLBoolean (EGLAPIENTRY *eglGetSyncAttribKHRFunc)(EGLDisplay, EGLSyncKHR, EGLint, EGLint*);
static eglQueryImageNOKFunc _eglQueryImageNOK = 0;
static eglCreateSharedImageNOKFunc _eglCreateSharedImageNOK = 0;
@@ -63,6 +68,10 @@ static eglDestroySharedImageNOKFunc _eglDestroySharedImageNOK = 0;
static eglSetSurfaceScalingNOKFunc _eglSetSurfaceScalingNOK = 0;
static eglLockSurfaceKHRFunc _eglLockSurfaceKHR = 0;
static eglUnlockSurfaceKHRFunc _eglUnlockSurfaceKHR = 0;
+static eglCreateSyncKHRFunc _eglCreateSyncKHR = 0;
+static eglDestroySyncKHRFunc _eglDestroySyncKHR = 0;
+static eglClientWaitSyncKHRFunc _eglClientWaitSyncKHR = 0;
+static eglGetSyncAttribKHRFunc _eglGetSyncAttribKHR = 0;
/* Public */
@@ -76,15 +85,15 @@ void QMeeGoExtensions::ensureInitialized()
EGLNativeSharedImageTypeNOK QMeeGoExtensions::eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props)
{
- if (! hasImageShared)
+ if (!hasImageShared)
qFatal("EGL_NOK_image_shared not found but trying to use capability!");
-
+
return _eglCreateSharedImageNOK(dpy, image, props);
}
bool QMeeGoExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v)
{
- if (! hasImageShared)
+ if (!hasImageShared)
qFatal("EGL_NOK_image_shared not found but trying to use capability!");
return _eglQueryImageNOK(dpy, image, prop, v);
@@ -92,7 +101,7 @@ bool QMeeGoExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLin
bool QMeeGoExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img)
{
- if (! hasImageShared)
+ if (!hasImageShared)
qFatal("EGL_NOK_image_shared not found but trying to use capability!");
return _eglDestroySharedImageNOK(dpy, img);
@@ -100,7 +109,7 @@ bool QMeeGoExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedI
bool QMeeGoExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height)
{
- if (! hasSurfaceScaling)
+ if (!hasSurfaceScaling)
qFatal("EGL_NOK_surface_scaling not found but trying to use capability!");
return _eglSetSurfaceScalingNOK(dpy, surface, x, y, width, height);
@@ -108,7 +117,7 @@ bool QMeeGoExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surfac
bool QMeeGoExtensions::eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
{
- if (! hasLockSurface)
+ if (!hasLockSurface)
qFatal("EGL_KHR_lock_surface2 not found but trying to use capability!");
return _eglLockSurfaceKHR(display, surface, attrib_list);
@@ -116,19 +125,51 @@ bool QMeeGoExtensions::eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface,
bool QMeeGoExtensions::eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
{
- if (! hasLockSurface)
+ if (!hasLockSurface)
qFatal("EGL_KHR_lock_surface2 not found but trying to use capability!");
return _eglUnlockSurfaceKHR(display, surface);
}
+EGLSyncKHR QMeeGoExtensions::eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
+{
+ if (!hasFenceSync)
+ qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
+
+ return _eglCreateSyncKHR(dpy, type, attrib_list);
+}
+
+bool QMeeGoExtensions::eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
+{
+ if (!hasFenceSync)
+ qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
+
+ return _eglDestroySyncKHR(dpy, sync);
+}
+
+EGLint QMeeGoExtensions::eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
+{
+ if (!hasFenceSync)
+ qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
+
+ return _eglClientWaitSyncKHR(dpy, sync, flags, timeout);
+}
+
+EGLBoolean QMeeGoExtensions::eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
+{
+ if (!hasFenceSync)
+ qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
+
+ return _eglGetSyncAttribKHR(dpy, sync, attribute, value);
+}
+
/* Private */
void QMeeGoExtensions::initialize()
{
QGLContext *ctx = (QGLContext *) QGLContext::currentContext();
qt_resolve_eglimage_gl_extensions(ctx);
-
+
if (QEgl::hasExtension("EGL_NOK_image_shared")) {
qDebug("MeegoGraphics: found EGL_NOK_image_shared");
_eglQueryImageNOK = (eglQueryImageNOKFunc) eglGetProcAddress("eglQueryImageNOK");
@@ -136,15 +177,15 @@ void QMeeGoExtensions::initialize()
_eglDestroySharedImageNOK = (eglDestroySharedImageNOKFunc) eglGetProcAddress("eglDestroySharedImageNOK");
_eglLockSurfaceKHR = (eglLockSurfaceKHRFunc) eglGetProcAddress("eglLockSurfaceKHR");
_eglUnlockSurfaceKHR = (eglUnlockSurfaceKHRFunc) eglGetProcAddress("eglUnlockSurfaceKHR");
-
+
Q_ASSERT(_eglQueryImageNOK && _eglCreateSharedImageNOK && _eglDestroySharedImageNOK);
hasImageShared = true;
}
-
+
if (QEgl::hasExtension("EGL_NOK_surface_scaling")) {
qDebug("MeegoGraphics: found EGL_NOK_surface_scaling");
_eglSetSurfaceScalingNOK = (eglSetSurfaceScalingNOKFunc) eglGetProcAddress("eglSetSurfaceScalingNOK");
-
+
Q_ASSERT(_eglSetSurfaceScalingNOK);
hasSurfaceScaling = true;
}
@@ -153,9 +194,20 @@ void QMeeGoExtensions::initialize()
qDebug("MeegoGraphics: found EGL_KHR_lock_surface2");
_eglLockSurfaceKHR = (eglLockSurfaceKHRFunc) eglGetProcAddress("eglLockSurfaceKHR");
_eglUnlockSurfaceKHR = (eglUnlockSurfaceKHRFunc) eglGetProcAddress("eglUnlockSurfaceKHR");
-
+
Q_ASSERT(_eglLockSurfaceKHR && _eglUnlockSurfaceKHR);
hasLockSurface = true;
}
+
+ if (QEgl::hasExtension("EGL_KHR_fence_sync")) {
+ qDebug("MeegoGraphics: found EGL_KHR_fence_sync");
+ _eglCreateSyncKHR = (eglCreateSyncKHRFunc) eglGetProcAddress("eglCreateSyncKHR");
+ _eglDestroySyncKHR = (eglDestroySyncKHRFunc) eglGetProcAddress("eglDestroySyncKHR");
+ _eglClientWaitSyncKHR = (eglClientWaitSyncKHRFunc) eglGetProcAddress("eglClientWaitSyncKHR");
+ _eglGetSyncAttribKHR = (eglGetSyncAttribKHRFunc) eglGetProcAddress("eglGetSyncAttribKHR");
+
+ Q_ASSERT(_eglCreateSyncKHR && _eglDestroySyncKHR && _eglClientWaitSyncKHR && _eglGetSyncAttribKHR);
+ hasFenceSync = true;
+ }
}
diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.h b/src/plugins/graphicssystems/meego/qmeegoextensions.h
index 9e78caf..49a1e30 100644
--- a/src/plugins/graphicssystems/meego/qmeegoextensions.h
+++ b/src/plugins/graphicssystems/meego/qmeegoextensions.h
@@ -77,6 +77,23 @@ typedef void* EGLNativeSharedImageTypeNOK;
#define EGL_WRITE_SURFACE_BIT_KHR 0x0002
#endif
+#ifndef EGL_SYNC_FENCE_KHR
+#define EGL_SYNC_FENCE_KHR 0x30F9
+#define EGL_SYNC_TYPE_KHR 0x30F7
+#define EGL_SYNC_STATUS_KHR 0x30F1
+#define EGL_SYNC_CONDITION_KHR 0x30F8
+#define EGL_SIGNALED_KHR 0x30F2
+#define EGL_UNSIGNALED_KHR 0x30F3
+#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0
+#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001
+#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull
+#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5
+#define EGL_CONDITION_SATISFIED_KHR 0x30F6
+#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0)
+typedef void* EGLSyncKHR;
+typedef khronos_utime_nanoseconds_t EGLTimeKHR;
+#endif
+
/* Class */
class QMeeGoExtensions
@@ -90,6 +107,10 @@ public:
static bool eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height);
static bool eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
static bool eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface);
+ static EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
+ static bool eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);
+ static EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
+ static EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
private:
static void initialize();
@@ -98,6 +119,7 @@ private:
static bool hasImageShared;
static bool hasSurfaceScaling;
static bool hasLockSurface;
+ static bool hasFenceSync;
};
#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
index f8b228c..507f70b 100644
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
@@ -54,6 +54,7 @@
#include <private/qpixmap_x11_p.h>
#include "qmeegopixmapdata.h"
+#include "qmeegolivepixmapdata.h"
#include "qmeegographicssystem.h"
#include "qmeegoextensions.h"
@@ -81,12 +82,12 @@ QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const
QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
{
- // Long story short: without this it's possible to hit an
- // unitialized paintDevice due to a Qt bug too complex to even
- // explain here... not to mention fix without going crazy.
+ // Long story short: without this it's possible to hit an
+ // uninitialized paintDevice due to a Qt bug too complex to even
+ // explain here... not to mention fix without going crazy.
// MDK
QGLShareContextScope ctx(qt_gl_share_widget()->context());
-
+
return new QRasterPixmapData(type);
}
@@ -102,8 +103,8 @@ QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData *origin)
if (QMeeGoPixmapData::sharedImagesMap.contains(rawResource))
return new QMeeGoPixmapData();
- }
-
+ }
+
return new QRasterPixmapData(origin->pixelType());
}
@@ -150,11 +151,11 @@ void QMeeGoGraphicsSystem::setTranslucent(bool translucent)
QPixmapData *QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage)
{
if (softImage.format() != QImage::Format_ARGB32_Premultiplied &&
- softImage.format() != QImage::Format_ARGB32) {
- qFatal("For egl shared images, the soft image has to be ARGB32 or ARGB32_Premultiplied");
+ softImage.format() != QImage::Format_RGB32) {
+ qFatal("For egl shared images, the soft image has to be ARGB32_Premultiplied or RGB32");
return NULL;
}
-
+
if (QMeeGoGraphicsSystem::meeGoRunning()) {
QMeeGoPixmapData *pmd = new QMeeGoPixmapData;
pmd->fromEGLSharedImage(handle, softImage);
@@ -173,28 +174,12 @@ QPixmapData *QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handl
}
}
-QPixmapData *QMeeGoGraphicsSystem::pixmapDataFromEGLImage(Qt::HANDLE handle)
-{
- if (QMeeGoGraphicsSystem::meeGoRunning()) {
- QMeeGoPixmapData *pmd = new QMeeGoPixmapData;
- pmd->fromEGLImage(handle);
-
- // FIXME Ok. This is a bit BAD BAD BAD. We're abusing here the fact that we KNOW
- // that this function is used for the live pixmap...
- pmd->texture()->options &= ~QGLContext::InvertedYBindOption;
- return QMeeGoGraphicsSystem::wrapPixmapData(pmd);
- } else {
- qFatal("Can't create from EGL image when not running meego graphics system!");
- return NULL;
- }
-}
-
void QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(QPixmap *pixmap)
{
QMeeGoPixmapData *pmd = (QMeeGoPixmapData *) pixmap->pixmapData();
-
+
// Basic sanity check to make sure this is really a QMeeGoPixmapData...
- if (pmd->classId() != QPixmapData::OpenGLClass)
+ if (pmd->classId() != QPixmapData::OpenGLClass)
qFatal("Trying to updated EGLSharedImage pixmap but it's not really a shared image pixmap!");
pmd->updateFromSoftImage();
@@ -207,169 +192,62 @@ QPixmapData *QMeeGoGraphicsSystem::pixmapDataWithGLTexture(int w, int h)
return QMeeGoGraphicsSystem::wrapPixmapData(pmd);
}
-Qt::HANDLE QMeeGoGraphicsSystem::createLiveTexture(int w, int h, QImage::Format format)
-{
- // No need to wrap the QPixmapData here. This QPixmap(Data) is a
- // internal implementation and we don't migrate it between
- // graphics system switching.
-
- // We use a bit ugly way of enforcing a color format on the X pixmap -- we create
- // a local QImage and fromImage from there. This is quite redundant (extra overhead of creating
- // the useless image only to delete it) but shouldn't be too bad for now... you're not expected
- // to call createLiveTexture too often anyways. Would be great if QX11PixmapData had a way to
- // force the X format upon creation or resize.
-
- QImage image(w, h, format);
- QX11PixmapData *pmd = new QX11PixmapData(QPixmapData::PixmapType);
- pmd->fromImage(image, Qt::NoOpaqueDetection);
- QPixmap *p = new QPixmap(pmd);
-
- liveTexturePixmaps.insert(p->handle(), p);
- return p->handle();
-}
-
-void QMeeGoGraphicsSystem::destroyLiveTexture(Qt::HANDLE h)
-{
- if (liveTexturePixmaps.contains(h)) {
- QPixmap *p = liveTexturePixmaps.value(h);
- delete p;
- liveTexturePixmaps.remove(h);
- } else
- qWarning("Trying to destroy live texture %ld which was not found!", h);
-}
-
-bool QMeeGoGraphicsSystem::lockLiveTexture(Qt::HANDLE h)
+bool QMeeGoGraphicsSystem::meeGoRunning()
{
- if (! liveTexturePixmaps.contains(h)) {
- qWarning("Trying to lock live texture %ld which was not found!", h);
+ if (! QApplicationPrivate::instance()) {
+ qWarning("Application not running just yet... hard to know what system running!");
return false;
}
- EGLint attribs[] = {
- EGL_MAP_PRESERVE_PIXELS_KHR, EGL_TRUE,
- EGL_LOCK_USAGE_HINT_KHR, EGL_READ_SURFACE_BIT_KHR | EGL_WRITE_SURFACE_BIT_KHR,
- EGL_NONE
- };
+ QString name = QApplicationPrivate::instance()->graphics_system_name;
+ if (name == "runtime") {
+ QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system;
+ name = rsystem->graphicsSystemName();
+ }
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- EGLSurface surface = getSurfaceForLiveTexturePixmap(liveTexturePixmaps.value(h));
- return QMeeGoExtensions::eglLockSurfaceKHR(QEgl::display(), surface, attribs);
+ return (name == "meego");
}
-bool QMeeGoGraphicsSystem::unlockLiveTexture(Qt::HANDLE h)
+QPixmapData* QMeeGoGraphicsSystem::pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format)
{
- if (! liveTexturePixmaps.contains(h)) {
- qWarning("Trying to lock live texture %ld which was not found!", h);
- return false;
- }
-
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- EGLSurface surface = getSurfaceForLiveTexturePixmap(liveTexturePixmaps.value(h));
- if (QMeeGoExtensions::eglUnlockSurfaceKHR(QEgl::display(), surface)) {
- glFinish();
- return true;
- } else {
- return false;
- }
+ return new QMeeGoLivePixmapData(w, h, format);
}
-void QMeeGoGraphicsSystem::queryLiveTexture(Qt::HANDLE h, void **data, int *pitch)
+QPixmapData* QMeeGoGraphicsSystem::pixmapDataFromLiveTextureHandle(Qt::HANDLE handle)
{
- // FIXME Only allow this on locked surfaces
- if (! liveTexturePixmaps.contains(h)) {
- qWarning("Trying to query live texture %ld which was not found!", h);
- return;
- }
-
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- EGLSurface surface = getSurfaceForLiveTexturePixmap(liveTexturePixmaps.value(h));
- eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_POINTER_KHR, (EGLint*) data);
- eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_PITCH_KHR, (EGLint*) pitch);
+ return new QMeeGoLivePixmapData(handle);
}
-Qt::HANDLE QMeeGoGraphicsSystem::liveTextureToEGLImage(Qt::HANDLE h)
+QImage* QMeeGoGraphicsSystem::lockLiveTexture(QPixmap* pixmap, void* fenceSync)
{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- EGLint attribs[] = {
- EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
- EGL_NONE
- };
-
- EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
- (EGLClientBuffer) h, attribs);
-
- if (eglImage == EGL_NO_IMAGE_KHR)
- qWarning("eglCreateImageKHR failed!");
-
- return (Qt::HANDLE) eglImage;
+ QMeeGoLivePixmapData *pixmapData = static_cast<QMeeGoLivePixmapData*>(pixmap->data_ptr().data());
+ return pixmapData->lock(fenceSync);
}
-bool QMeeGoGraphicsSystem::meeGoRunning()
+bool QMeeGoGraphicsSystem::releaseLiveTexture(QPixmap *pixmap, QImage *image)
{
- if (! QApplicationPrivate::instance()) {
- qWarning("Application not running just yet... hard to know what system running!");
- return false;
- }
-
- QString name = QApplicationPrivate::instance()->graphics_system_name;
- if (name == "runtime") {
- QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system;
- name = rsystem->graphicsSystemName();
- }
-
- return (name == "meego");
+ QMeeGoLivePixmapData *pixmapData = static_cast<QMeeGoLivePixmapData*>(pixmap->data_ptr().data());
+ return pixmapData->release(image);
}
-void QMeeGoGraphicsSystem::destroySurfaceForLiveTexturePixmap(QPixmapData* pmd)
+Qt::HANDLE QMeeGoGraphicsSystem::getLiveTextureHandle(QPixmap *pixmap)
{
- Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
- if (pixmapData->gl_surface) {
- eglDestroySurface(QEgl::display(), (EGLSurface)pixmapData->gl_surface);
- pixmapData->gl_surface = 0;
- }
+ QMeeGoLivePixmapData *pixmapData = static_cast<QMeeGoLivePixmapData*>(pixmap->data_ptr().data());
+ return pixmapData->handle();
}
-EGLSurface QMeeGoGraphicsSystem::getSurfaceForLiveTexturePixmap(QPixmap *pixmap)
+void* QMeeGoGraphicsSystem::createFenceSync()
{
- // This code is a crative remix of the stuff that can be found in the
- // Qt's TFP implementation in /src/opengl/qgl_x11egl.cpp ::bindiTextureFromNativePixmap
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pixmap->data_ptr().data());
- Q_ASSERT(pixmapData->classId() == QPixmapData::X11Class);
- bool hasAlpha = pixmapData->hasAlphaChannel();
-
- if (pixmapData->gl_surface &&
- hasAlpha == (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha))
- return pixmapData->gl_surface;
-
- // Check to see if the surface is still valid
- if (pixmapData->gl_surface &&
- hasAlpha != ((pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha) > 0)) {
- // Surface is invalid!
- QMeeGoGraphicsSystem::destroySurfaceForLiveTexturePixmap(pixmapData);
- }
-
- if (pixmapData->gl_surface == 0) {
- EGLConfig config = QEgl::defaultConfig(QInternal::Pixmap,
- QEgl::OpenGL,
- hasAlpha ? QEgl::Translucent : QEgl::NoOptions);
-
- pixmapData->gl_surface = (void*)QEgl::createSurface(pixmap, config);
-
- if (hasAlpha)
- pixmapData->flags = pixmapData->flags | QX11PixmapData::GlSurfaceCreatedWithAlpha;
-
- if (pixmapData->gl_surface == (void*)EGL_NO_SURFACE)
- return NULL;
- }
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QMeeGoExtensions::ensureInitialized();
+ return QMeeGoExtensions::eglCreateSyncKHR(QEgl::display(), EGL_SYNC_FENCE_KHR, NULL);
+}
- return pixmapData->gl_surface;
+void QMeeGoGraphicsSystem::destroyFenceSync(void *fenceSync)
+{
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QMeeGoExtensions::ensureInitialized();
+ QMeeGoExtensions::eglDestroySyncKHR(QEgl::display(), fenceSync);
}
/* C API */
@@ -384,11 +262,6 @@ QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const
return QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(handle, softImage);
}
-QPixmapData* qt_meego_pixmapdata_from_egl_image(Qt::HANDLE handle)
-{
- return QMeeGoGraphicsSystem::pixmapDataFromEGLImage(handle);
-}
-
QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h)
{
return QMeeGoGraphicsSystem::pixmapDataWithGLTexture(w, h);
@@ -419,32 +292,37 @@ void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap)
QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(pixmap);
}
-Qt::HANDLE qt_meego_live_texture_create(int w, int h, QImage::Format format)
+QPixmapData* qt_meego_pixmapdata_with_new_live_texture(int w, int h, QImage::Format format)
+{
+ return QMeeGoGraphicsSystem::pixmapDataWithNewLiveTexture(w, h, format);
+}
+
+QPixmapData* qt_meego_pixmapdata_from_live_texture_handle(Qt::HANDLE handle)
{
- return QMeeGoGraphicsSystem::createLiveTexture(w, h, format);
+ return QMeeGoGraphicsSystem::pixmapDataFromLiveTextureHandle(handle);
}
-void qt_meego_live_texture_destroy(Qt::HANDLE h)
+QImage* qt_meego_live_texture_lock(QPixmap *pixmap, void *fenceSync)
{
- QMeeGoGraphicsSystem::destroyLiveTexture(h);
+ return QMeeGoGraphicsSystem::lockLiveTexture(pixmap, fenceSync);
}
-bool qt_meego_live_texture_lock(Qt::HANDLE h)
+bool qt_meego_live_texture_release(QPixmap *pixmap, QImage *image)
{
- return QMeeGoGraphicsSystem::lockLiveTexture(h);
+ return QMeeGoGraphicsSystem::releaseLiveTexture(pixmap, image);
}
-bool qt_meego_live_texture_unlock(Qt::HANDLE h)
+Qt::HANDLE qt_meego_live_texture_get_handle(QPixmap *pixmap)
{
- return QMeeGoGraphicsSystem::unlockLiveTexture(h);
+ return QMeeGoGraphicsSystem::getLiveTextureHandle(pixmap);
}
-void qt_meego_live_texture_query(Qt::HANDLE h, void **data, int *pitch)
+void* qt_meego_create_fence_sync(void)
{
- return QMeeGoGraphicsSystem::queryLiveTexture(h, data, pitch);
+ return QMeeGoGraphicsSystem::createFenceSync();
}
-Qt::HANDLE qt_meego_live_texture_to_egl_image(Qt::HANDLE h)
+void qt_meego_destroy_fence_sync(void* fs)
{
- return QMeeGoGraphicsSystem::liveTextureToEGLImage(h);
+ return QMeeGoGraphicsSystem::destroyFenceSync(fs);
}
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
index 934d32d..1e50f00 100644
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
@@ -67,12 +67,14 @@ public:
static QPixmapData *pixmapDataWithGLTexture(int w, int h);
static void updateEGLSharedImagePixmap(QPixmap *pixmap);
- static Qt::HANDLE createLiveTexture(int w, int h, QImage::Format format);
- static void destroyLiveTexture(Qt::HANDLE h);
- static bool lockLiveTexture(Qt::HANDLE h);
- static bool unlockLiveTexture(Qt::HANDLE h);
- static void queryLiveTexture(Qt::HANDLE h, void **data, int *pitch);
- static Qt::HANDLE liveTextureToEGLImage(Qt::HANDLE h);
+ static QPixmapData *pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format);
+ static QPixmapData *pixmapDataFromLiveTextureHandle(Qt::HANDLE handle);
+ static QImage *lockLiveTexture(QPixmap* pixmap, void* fenceSync);
+ static bool releaseLiveTexture(QPixmap *pixmap, QImage *image);
+ static Qt::HANDLE getLiveTextureHandle(QPixmap *pixmap);
+
+ static void* createFenceSync();
+ static void destroyFenceSync(void* fenceSync);
private:
static bool meeGoRunning();
@@ -88,19 +90,19 @@ private:
extern "C" {
Q_DECL_EXPORT int qt_meego_image_to_egl_shared_image(const QImage &image);
Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage);
- Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_egl_image(Qt::HANDLE handle);
Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h);
Q_DECL_EXPORT void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap);
Q_DECL_EXPORT bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle);
Q_DECL_EXPORT void qt_meego_set_surface_fixed_size(int width, int height);
Q_DECL_EXPORT void qt_meego_set_surface_scaling(int x, int y, int width, int height);
- Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent);
- Q_DECL_EXPORT Qt::HANDLE m_live_texture_create(int w, int h, QImage::Format format);
- Q_DECL_EXPORT void m_live_texture_destroy(Qt::HANDLE h);
- Q_DECL_EXPORT bool m_live_texture_lock(Qt::HANDLE h);
- Q_DECL_EXPORT bool m_live_texture_unlock(Qt::HANDLE h);
- Q_DECL_EXPORT void m_live_texture_query(Qt::HANDLE h, void **data, int *pitch);
- Q_DECL_EXPORT Qt::HANDLE m_live_texture_to_egl_image(Qt::HANDLE h);
+ Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent);
+ Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_new_live_texture(int w, int h, QImage::Format format);
+ Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_live_texture_handle(Qt::HANDLE handle);
+ Q_DECL_EXPORT QImage* qt_meego_live_texture_lock(QPixmap *pixmap, void *fenceSync);
+ Q_DECL_EXPORT bool qt_meego_live_texture_release(QPixmap *pixmap, QImage *image);
+ Q_DECL_EXPORT Qt::HANDLE qt_meego_live_texture_get_handle(QPixmap *pixmap);
+ Q_DECL_EXPORT void* qt_meego_create_fence_sync(void);
+ Q_DECL_EXPORT void qt_meego_destroy_fence_sync(void* fs);
}
#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
new file mode 100644
index 0000000..16096c9
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
@@ -0,0 +1,292 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmeegolivepixmapdata.h"
+#include "qmeegorasterpixmapdata.h"
+#include <private/qimage_p.h>
+#include <private/qwindowsurface_gl_p.h>
+#include <private/qeglcontext_p.h>
+#include <private/qapplication_p.h>
+#include <private/qgraphicssystem_runtime_p.h>
+#include <private/qpixmap_x11_p.h>
+#include <stdio.h>
+
+static EGLint lock_attribs[] = {
+ EGL_MAP_PRESERVE_PIXELS_KHR, EGL_TRUE,
+ EGL_LOCK_USAGE_HINT_KHR, EGL_READ_SURFACE_BIT_KHR | EGL_WRITE_SURFACE_BIT_KHR,
+ EGL_NONE
+};
+
+static EGLint preserved_attribs[] = {
+ EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
+ EGL_NONE
+};
+
+// as copied from qwindowsurface.cpp
+void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
+{
+ // make sure we don't detach
+ uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits());
+
+ int lineskip = img.bytesPerLine();
+ int depth = img.depth() >> 3;
+
+ const QRect imageRect(0, 0, img.width(), img.height());
+ const QRect r = rect & imageRect & imageRect.translated(-offset);
+ const QPoint p = rect.topLeft() + offset;
+
+ if (r.isEmpty())
+ return;
+
+ const uchar *src;
+ uchar *dest;
+
+ if (r.top() < p.y()) {
+ src = mem + r.bottom() * lineskip + r.left() * depth;
+ dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth;
+ lineskip = -lineskip;
+ } else {
+ src = mem + r.top() * lineskip + r.left() * depth;
+ dest = mem + p.y() * lineskip + p.x() * depth;
+ }
+
+ const int w = r.width();
+ int h = r.height();
+ const int bytes = w * depth;
+
+ // overlapping segments?
+ if (offset.y() == 0 && qAbs(offset.x()) < w) {
+ do {
+ ::memmove(dest, src, bytes);
+ dest += lineskip;
+ src += lineskip;
+ } while (--h);
+ } else {
+ do {
+ ::memcpy(dest, src, bytes);
+ dest += lineskip;
+ src += lineskip;
+ } while (--h);
+ }
+}
+
+/* Public */
+
+QMeeGoLivePixmapData::QMeeGoLivePixmapData(int w, int h, QImage::Format format) : QGLPixmapData(QPixmapData::PixmapType)
+{
+ QImage image(w, h, format);
+ QX11PixmapData *pmd = new QX11PixmapData(QPixmapData::PixmapType);
+ pmd->fromImage(image, Qt::NoOpaqueDetection);
+ backingX11Pixmap = new QPixmap(pmd);
+
+ initializeThroughEGLImage();
+}
+
+QMeeGoLivePixmapData::QMeeGoLivePixmapData(Qt::HANDLE h) : QGLPixmapData(QPixmapData::PixmapType)
+{
+ backingX11Pixmap = new QPixmap(QPixmap::fromX11Pixmap(h));
+ initializeThroughEGLImage();
+}
+
+QMeeGoLivePixmapData::~QMeeGoLivePixmapData()
+{
+ delete backingX11Pixmap;
+}
+
+void QMeeGoLivePixmapData::initializeThroughEGLImage()
+{
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QMeeGoExtensions::ensureInitialized();
+
+ EGLImageKHR eglImage = EGL_NO_IMAGE_KHR;
+ GLuint newTextureId = 0;
+
+ eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
+ (EGLClientBuffer) backingX11Pixmap->handle(), preserved_attribs);
+
+ if (eglImage == EGL_NO_IMAGE_KHR) {
+ qWarning("eglCreateImageKHR failed (live texture)!");
+ return;
+ }
+
+ glGenTextures(1, &newTextureId);
+ glBindTexture(GL_TEXTURE_2D, newTextureId);
+
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (EGLImageKHR) eglImage);
+ if (glGetError() == GL_NO_ERROR) {
+ resize(backingX11Pixmap->width(), backingX11Pixmap->height());
+ texture()->id = newTextureId;
+ texture()->options &= ~QGLContext::InvertedYBindOption;
+ m_hasAlpha = backingX11Pixmap->hasAlphaChannel();
+ } else {
+ qWarning("Failed to create a texture from an egl image (live texture)!");
+ glDeleteTextures(1, &newTextureId);
+ }
+
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
+}
+
+QPixmapData *QMeeGoLivePixmapData::createCompatiblePixmapData() const
+{
+ qWarning("Create compatible called on live pixmap! Expect fail soon...");
+ return new QMeeGoRasterPixmapData(pixelType());
+}
+
+QImage* QMeeGoLivePixmapData::lock(EGLSyncKHR fenceSync)
+{
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QMeeGoExtensions::ensureInitialized();
+
+ if (fenceSync) {
+ QMeeGoExtensions::eglClientWaitSyncKHR(QEgl::display(),
+ fenceSync,
+ EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
+ EGL_FOREVER_KHR);
+ }
+
+ void *data = 0;
+ int pitch = 0;
+ EGLSurface surface = 0;
+ QImage::Format format;
+ lockedImage = QImage();
+
+ surface = getSurfaceForBackingPixmap();
+ if (! QMeeGoExtensions::eglLockSurfaceKHR(QEgl::display(), surface, lock_attribs)) {
+ qWarning("Failed to lock surface (live texture)!");
+ return &lockedImage;
+ }
+
+ eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_POINTER_KHR, (EGLint*) &data);
+ eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_PITCH_KHR, (EGLint*) &pitch);
+
+ // Ok, here we know we just support those two formats. Real solution would be:
+ // uqery also the format.
+ if (backingX11Pixmap->depth() > 16)
+ format = QImage::Format_ARGB32_Premultiplied;
+ else
+ format = QImage::Format_RGB16;
+
+ if (data == NULL || pitch == 0) {
+ qWarning("Failed to query the live texture!");
+ return &lockedImage;
+ }
+
+ lockedImage = QImage((uchar *) data, width(), height(), format);
+ return &lockedImage;
+}
+
+bool QMeeGoLivePixmapData::release(QImage* /*img*/)
+{
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QMeeGoExtensions::ensureInitialized();
+
+ if (QMeeGoExtensions::eglUnlockSurfaceKHR(QEgl::display(), getSurfaceForBackingPixmap())) {
+ lockedImage = QImage();
+ return true;
+ } else {
+ lockedImage = QImage();
+ return false;
+ }
+}
+
+Qt::HANDLE QMeeGoLivePixmapData::handle()
+{
+ return backingX11Pixmap->handle();
+}
+
+bool QMeeGoLivePixmapData::scroll(int dx, int dy, const QRect &rect)
+{
+ lock(NULL);
+
+ if (!lockedImage.isNull())
+ qt_scrollRectInImage(lockedImage, rect, QPoint(dx, dy));
+
+ release(&lockedImage);
+ return true;
+}
+
+EGLSurface QMeeGoLivePixmapData::getSurfaceForBackingPixmap()
+{
+ // This code is a crative remix of the stuff that can be found in the
+ // Qt's TFP implementation in /src/opengl/qgl_x11egl.cpp ::bindiTextureFromNativePixmap
+ QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(backingX11Pixmap->data_ptr().data());
+ Q_ASSERT(pixmapData->classId() == QPixmapData::X11Class);
+ bool hasAlpha = pixmapData->hasAlphaChannel();
+
+ if (pixmapData->gl_surface &&
+ hasAlpha == (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha))
+ return pixmapData->gl_surface;
+
+ // Check to see if the surface is still valid
+ if (pixmapData->gl_surface &&
+ hasAlpha != ((pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha) > 0)) {
+ // Surface is invalid!
+ destroySurfaceForPixmapData(pixmapData);
+ }
+
+ if (pixmapData->gl_surface == 0) {
+ EGLConfig config = QEgl::defaultConfig(QInternal::Pixmap,
+ QEgl::OpenGL,
+ hasAlpha ? QEgl::Translucent : QEgl::NoOptions);
+
+ pixmapData->gl_surface = (void*)QEgl::createSurface(backingX11Pixmap, config);
+
+ if (hasAlpha)
+ pixmapData->flags |= QX11PixmapData::GlSurfaceCreatedWithAlpha;
+ else
+ pixmapData->flags &= ~QX11PixmapData::GlSurfaceCreatedWithAlpha;
+
+ if (pixmapData->gl_surface == (void*)EGL_NO_SURFACE)
+ return NULL;
+ }
+
+ return pixmapData->gl_surface;
+}
+
+void QMeeGoLivePixmapData::destroySurfaceForPixmapData(QPixmapData* pmd)
+{
+ Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
+ QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
+ if (pixmapData->gl_surface) {
+ eglDestroySurface(QEgl::display(), (EGLSurface)pixmapData->gl_surface);
+ pixmapData->gl_surface = 0;
+ }
+}
diff --git a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h
new file mode 100644
index 0000000..2c6854e
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MLIVEPIXMAPDATA_H
+#define MLIVEPIXMAPDATA_H
+
+#include <private/qpixmapdata_gl_p.h>
+#include "qmeegoextensions.h"
+
+class QMeeGoLivePixmapData : public QGLPixmapData
+{
+public:
+ QMeeGoLivePixmapData(int w, int h, QImage::Format format);
+ QMeeGoLivePixmapData(Qt::HANDLE h);
+ ~QMeeGoLivePixmapData();
+
+ QPixmapData *createCompatiblePixmapData() const;
+ bool scroll(int dx, int dy, const QRect &rect);
+
+ void initializeThroughEGLImage();
+
+ QImage* lock(EGLSyncKHR fenceSync);
+ bool release(QImage *img);
+ Qt::HANDLE handle();
+
+ EGLSurface getSurfaceForBackingPixmap();
+ void destroySurfaceForPixmapData(QPixmapData* pmd);
+
+ QPixmap *backingX11Pixmap;
+ QImage lockedImage;
+};
+
+#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp
index 84fc593..eb63692 100644
--- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp
+++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp
@@ -41,12 +41,18 @@
#include "qmeegopixmapdata.h"
#include "qmeegoextensions.h"
+#include "qmeegorasterpixmapdata.h"
#include <private/qimage_p.h>
#include <private/qwindowsurface_gl_p.h>
#include <private/qeglcontext_p.h>
#include <private/qapplication_p.h>
#include <private/qgraphicssystem_runtime_p.h>
+// from dithering.cpp
+extern unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int height, int stride);
+extern unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, int height, int stride);
+extern unsigned char* convertBGRA32_to_RGBA32(const unsigned char *in, int width, int height, int stride);
+
static EGLint preserved_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE };
QHash <void*, QMeeGoImageInfo*> QMeeGoPixmapData::sharedImagesMap;
@@ -87,36 +93,6 @@ void QMeeGoPixmapData::fromImage(const QImage &image,
}
}
-void QMeeGoPixmapData::fromEGLImage(Qt::HANDLE handle)
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- bool textureIsBound = false;
- GLuint newTextureId;
- GLint newWidth, newHeight;
-
- glGenTextures(1, &newTextureId);
- glBindTexture(GL_TEXTURE_2D, newTextureId);
-
- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (EGLImageKHR) handle);
- GLint err = glGetError();
- if (err == GL_NO_ERROR)
- textureIsBound = true;
-
- QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), (EGLImageKHR) handle, EGL_WIDTH, &newWidth);
- QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), (EGLImageKHR) handle, EGL_HEIGHT, &newHeight);
-
- if (textureIsBound) {
- // FIXME Remove this ugly hasAlphaChannel check when Qt lands the NoOpaqueCheck flag fix
- // for QGLPixmapData.
- fromTexture(newTextureId, newWidth, newHeight, true);
- } else {
- qWarning("Failed to create a texture from an egl image!");
- glDeleteTextures(1, &newTextureId);
- }
-}
-
void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si)
{
if (si.isNull())
@@ -133,12 +109,10 @@ void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si)
glGenTextures(1, &newTextureId);
glBindTexture(GL_TEXTURE_2D, newTextureId);
- glFinish();
EGLImageKHR image = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_SHARED_IMAGE_NOK,
(EGLClientBuffer)handle, preserved_image_attribs);
if (image != EGL_NO_IMAGE_KHR) {
- glFinish();
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
GLint err = glGetError();
if (err == GL_NO_ERROR)
@@ -148,14 +122,12 @@ void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si)
QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_HEIGHT, &newHeight);
QEgl::eglDestroyImageKHR(QEgl::display(), image);
- glFinish();
}
if (textureIsBound) {
- // FIXME Remove this ugly hasAlphaChannel check when Qt lands the NoOpaqueCheck flag fix
- // for QGLPixmapData.
fromTexture(newTextureId, newWidth, newHeight,
(si.hasAlphaChannel() && const_cast<QImage &>(si).data_ptr()->checkForAlphaPixels()));
+ texture()->options &= ~QGLContext::InvertedYBindOption;
softImage = si;
QMeeGoPixmapData::registerSharedImage(handle, softImage);
} else {
@@ -170,22 +142,32 @@ Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image)
QMeeGoExtensions::ensureInitialized();
- glFinish();
- QGLPixmapData pixmapData(QPixmapData::PixmapType);
- pixmapData.fromImage(image, 0);
- GLuint textureId = pixmapData.bind();
+ GLuint textureId;
+
+ glGenTextures(1, &textureId);
+ glBindTexture(GL_TEXTURE_2D, textureId);
+ if (image.hasAlphaChannel() && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()) {
+ void *converted = convertBGRA32_to_RGBA32(image.bits(), image.width(), image.height(), image.bytesPerLine());
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, converted);
+ free(converted);
+ } else {
+ void *converted = convertRGB32_to_RGB565(image.bits(), image.width(), image.height(), image.bytesPerLine());
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, converted);
+ free(converted);
+ }
- glFinish();
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ glBindTexture(GL_TEXTURE_2D, textureId);
EGLImageKHR eglimage = QEgl::eglCreateImageKHR(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->context(),
EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer) textureId,
preserved_image_attribs);
- glFinish();
-
+ glDeleteTextures(1, &textureId);
if (eglimage) {
EGLNativeSharedImageTypeNOK handle = QMeeGoExtensions::eglCreateSharedImageNOK(QEgl::display(), eglimage, NULL);
QEgl::eglDestroyImageKHR(QEgl::display(), eglimage);
- glFinish();
return (Qt::HANDLE) handle;
} else {
qWarning("Failed to create shared image from pixmap/texture!");
@@ -195,6 +177,7 @@ Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image)
void QMeeGoPixmapData::updateFromSoftImage()
{
+ // FIXME That's broken with recent 16bit textures changes.
m_dirty = true;
m_source = softImage;
ensureCreated();
@@ -234,3 +217,8 @@ void QMeeGoPixmapData::registerSharedImage(Qt::HANDLE handle, const QImage &si)
qWarning("Inconsistency detected: overwriting entry in sharedImagesMap but handle/format different");
}
}
+
+QPixmapData *QMeeGoPixmapData::createCompatiblePixmapData() const
+{
+ return new QMeeGoRasterPixmapData(pixelType());
+}
diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h
index 8b1ae14..c66e719 100644
--- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h
+++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h
@@ -55,8 +55,8 @@ class QMeeGoPixmapData : public QGLPixmapData
public:
QMeeGoPixmapData();
void fromTexture(GLuint textureId, int w, int h, bool alpha);
+ QPixmapData *createCompatiblePixmapData() const;
- virtual void fromEGLImage(Qt::HANDLE handle);
virtual void fromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage);
virtual void fromImage (const QImage &image, Qt::ImageConversionFlags flags);
virtual QImage toImage() const;
diff --git a/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp
new file mode 100644
index 0000000..b6a3727
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmeegorasterpixmapdata.h"
+
+/* Public */
+
+QMeeGoRasterPixmapData::QMeeGoRasterPixmapData() : QRasterPixmapData(QPixmapData::PixmapType)
+{
+}
+
+QMeeGoRasterPixmapData::QMeeGoRasterPixmapData(QPixmapData::PixelType t) : QRasterPixmapData(t)
+{
+}
+
+void QMeeGoRasterPixmapData::copy(const QPixmapData *data, const QRect &rect)
+{
+ if (data->classId() == QPixmapData::OpenGLClass)
+ fromImage(data->toImage(rect).copy(), Qt::NoOpaqueDetection);
+ else
+ QRasterPixmapData::copy(data, rect);
+}
diff --git a/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h b/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h
new file mode 100644
index 0000000..636b0e6
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MRASTERPIXMAPDATA_H
+#define MRASTERPIXMAPDATA_H
+
+#include <private/qpixmap_raster_p.h>
+
+class QMeeGoRasterPixmapData : public QRasterPixmapData
+{
+public:
+ QMeeGoRasterPixmapData();
+ QMeeGoRasterPixmapData(QPixmapData::PixelType t);
+ void copy(const QPixmapData *data, const QRect &rect);
+};
+
+#endif