diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-03-24 14:36:47 (GMT) |
---|---|---|
committer | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-03-24 14:36:47 (GMT) |
commit | 2a1e23be4a730bdcbadb4f59075828bc9bad62c1 (patch) | |
tree | 82faab46eb2da64a53dd24d14cfb33dab87d1299 /src/opengl/qgl_symbian.cpp | |
parent | 83d33a9f64d1472926c61e472655182e539a8e10 (diff) | |
download | Qt-2a1e23be4a730bdcbadb4f59075828bc9bad62c1.zip Qt-2a1e23be4a730bdcbadb4f59075828bc9bad62c1.tar.gz Qt-2a1e23be4a730bdcbadb4f59075828bc9bad62c1.tar.bz2 |
Native image handle provider support in QGLPixmapData
QGLPixmapData's fromNativeType() accepts QNativeImageHandleProvider
pointers with type NativeImageHandleProvider from now on, similarly
to OpenVG pixmaps.
Task-number: QTBUG-18209
Reviewed-by: Jani Hautakangas
Diffstat (limited to 'src/opengl/qgl_symbian.cpp')
-rw-r--r-- | src/opengl/qgl_symbian.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp index 7caaabd..1b41db4 100644 --- a/src/opengl/qgl_symbian.cpp +++ b/src/opengl/qgl_symbian.cpp @@ -48,6 +48,7 @@ #include <private/qgl_p.h> #include <private/qpaintengine_opengl_p.h> #include <private/qwidget_p.h> // to access QWExtra +#include <private/qnativeimagehandleprovider_p.h> #include "qgl_egl_p.h" #include "qpixmapdata_gl_p.h" #include "qgltexturepool_p.h" @@ -411,6 +412,11 @@ void QGLPixmapData::fromNativeType(void* pixmap, NativeType type) m_hasAlpha = m_source.hasAlphaChannel(); m_hasFillColor = false; m_dirty = true; + } else if (type == QPixmapData::NativeImageHandleProvider && pixmap) { + destroyTexture(); + nativeImageHandleProvider = static_cast<QNativeImageHandleProvider *>(pixmap); + // Cannot defer the retrieval, we need at least the size right away. + createFromNativeImageHandleProvider(); } } @@ -425,4 +431,42 @@ void* QGLPixmapData::toNativeType(NativeType type) return 0; } +bool QGLPixmapData::initFromNativeImageHandle(void *handle, const QString &type) +{ + if (type == QLatin1String("RSgImage")) { + fromNativeType(handle, QPixmapData::SgImage); + return true; + } else if (type == QLatin1String("CFbsBitmap")) { + fromNativeType(handle, QPixmapData::FbsBitmap); + return true; + } + return false; +} + +void QGLPixmapData::createFromNativeImageHandleProvider() +{ + void *handle = 0; + QString type; + nativeImageHandleProvider->get(&handle, &type); + if (handle) { + if (initFromNativeImageHandle(handle, type)) { + nativeImageHandle = handle; + nativeImageType = type; + } else { + qWarning("QGLPixmapData: Unknown native image type '%s'", qPrintable(type)); + } + } else { + qWarning("QGLPixmapData: Native handle is null"); + } +} + +void QGLPixmapData::releaseNativeImageHandle() +{ + if (nativeImageHandleProvider && nativeImageHandle) { + nativeImageHandleProvider->release(nativeImageHandle, nativeImageType); + nativeImageHandle = 0; + nativeImageType = QString(); + } +} + QT_END_NAMESPACE |