summaryrefslogtreecommitdiffstats
path: root/src/imports/qtcanvas3d/context3d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/qtcanvas3d/context3d.cpp')
-rw-r--r--src/imports/qtcanvas3d/context3d.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/imports/qtcanvas3d/context3d.cpp b/src/imports/qtcanvas3d/context3d.cpp
index c300772..76dff42 100644
--- a/src/imports/qtcanvas3d/context3d.cpp
+++ b/src/imports/qtcanvas3d/context3d.cpp
@@ -94,6 +94,7 @@ CanvasContext::CanvasContext(QQmlEngine *engine, bool isES2, int maxVertexAttrib
m_v4engine(QQmlEnginePrivate::getV4Engine(engine)),
m_unpackFlipYEnabled(false),
m_unpackPremultiplyAlphaEnabled(false),
+ m_unpackAlignmentValue(4),
m_devicePixelRatio(1.0),
m_currentProgram(0),
m_currentArrayBuffer(0),
@@ -1360,6 +1361,11 @@ QByteArray *CanvasContext::unpackPixels(uchar *srcData, bool useSrcDataAsDst,
<< ")";
int bytesPerRow = width * bytesPerPixel;
+
+ // Align bytesPerRow to UNPACK_ALIGNMENT setting
+ if ( m_unpackAlignmentValue > 1)
+ bytesPerRow = bytesPerRow + (m_unpackAlignmentValue - 1) - (bytesPerRow - 1) % m_unpackAlignmentValue;
+
int totalBytes = bytesPerRow * height;
QByteArray *unpackedData = 0;
@@ -2498,10 +2504,28 @@ void CanvasContext::pixelStorei(glEnums pname, int param)
case UNPACK_COLORSPACE_CONVERSION_WEBGL:
// Intentionally ignored
break;
- case PACK_ALIGNMENT: // Intentional fall-through
+ case PACK_ALIGNMENT:
+ if ( param == 1 || param == 2 || param == 4 || param == 8 ) {
+ m_commandQueue->queueCommand(CanvasGlCommandQueue::glPixelStorei,
+ GLint(pname), GLint(param));
+ } else {
+ m_error |= CANVAS_INVALID_VALUE;
+ qCWarning(canvas3drendering).nospace() << "Context3D::" << __FUNCTION__
+ << ":INVALID_VALUE:"
+ << "Invalid pack alignment: " << param;
+ }
+ break;
case UNPACK_ALIGNMENT:
- m_commandQueue->queueCommand(CanvasGlCommandQueue::glPixelStorei,
- GLint(pname), GLint(param));
+ if ( param == 1 || param == 2 || param == 4 || param == 8 ) {
+ m_unpackAlignmentValue = param;
+ m_commandQueue->queueCommand(CanvasGlCommandQueue::glPixelStorei,
+ GLint(pname), GLint(param));
+ } else {
+ m_error |= CANVAS_INVALID_VALUE;
+ qCWarning(canvas3drendering).nospace() << "Context3D::" << __FUNCTION__
+ << ":INVALID_VALUE:"
+ << "Invalid unpack alignment: " << param;
+ }
break;
default:
qCWarning(canvas3drendering).nospace() << "Context3D::" << __FUNCTION__