Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qplatformgraphicsbufferhelper.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | bool QPlatformGraphicsBufferHelper::lockAndBindToTexture(QPlatformGraphicsBuffer *graphicsBuffer, | - | ||||||||||||
4 | bool *swizzle, bool *premultiplied, | - | ||||||||||||
5 | const QRect &rect) | - | ||||||||||||
6 | { | - | ||||||||||||
7 | if (graphicsBuffer->lock(QPlatformGraphicsBuffer::TextureAccess)
| 0 | ||||||||||||
8 | if (!graphicsBuffer->bindToTexture(rect)
| 0 | ||||||||||||
9 | QMessageLogger(__FILE__, 86, __PRETTY_FUNCTION__).warning("Failed to bind %sgraphicsbuffer to texture", ""); | - | ||||||||||||
10 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
11 | } | - | ||||||||||||
12 | if (swizzle
| 0 | ||||||||||||
13 | * never executed: swizzle = false;*swizzle = false; never executed: *swizzle = false; | 0 | ||||||||||||
14 | if (premultiplied
| 0 | ||||||||||||
15 | * never executed: premultiplied = false;*premultiplied = false; never executed: *premultiplied = false; | 0 | ||||||||||||
16 | } never executed: else if (graphicsBuffer->lock(QPlatformGraphicsBuffer::SWReadAccess)end of block
| 0 | ||||||||||||
17 | if (!bindSWToTexture(graphicsBuffer, swizzle, premultiplied, rect)
| 0 | ||||||||||||
18 | QMessageLogger(__FILE__, 95, __PRETTY_FUNCTION__).warning("Failed to bind %sgraphicsbuffer to texture", "SW "); | - | ||||||||||||
19 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
20 | } | - | ||||||||||||
21 | } never executed: else {end of block | 0 | ||||||||||||
22 | QMessageLogger(__FILE__, 99, __PRETTY_FUNCTION__).warning("Failed to lock"); | - | ||||||||||||
23 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
24 | } | - | ||||||||||||
25 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
26 | } | - | ||||||||||||
27 | bool QPlatformGraphicsBufferHelper::bindSWToTexture(const QPlatformGraphicsBuffer *graphicsBuffer, | - | ||||||||||||
28 | bool *swizzleRandB, bool *premultipliedB, | - | ||||||||||||
29 | const QRect &subRect) | - | ||||||||||||
30 | { | - | ||||||||||||
31 | - | |||||||||||||
32 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||||||||
33 | if (!ctx
| 0 | ||||||||||||
34 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
35 | - | |||||||||||||
36 | if (!(graphicsBuffer->isLocked() & QPlatformGraphicsBuffer::SWReadAccess)
| 0 | ||||||||||||
37 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
38 | - | |||||||||||||
39 | QSize size = graphicsBuffer->size(); | - | ||||||||||||
40 | - | |||||||||||||
41 | ((!(subRect.isEmpty() || QRect(QPoint(0,0), size).contains(subRect))) ? qt_assert("subRect.isEmpty() || QRect(QPoint(0,0), size).contains(subRect)",__FILE__,141) : qt_noop()); | - | ||||||||||||
42 | - | |||||||||||||
43 | GLenum internalFormat = 0x1908; | - | ||||||||||||
44 | GLuint pixelType = 0x1401; | - | ||||||||||||
45 | - | |||||||||||||
46 | bool needsConversion = false; | - | ||||||||||||
47 | bool swizzle = false; | - | ||||||||||||
48 | bool premultiplied = false; | - | ||||||||||||
49 | QImage::Format imageformat = QImage::toImageFormat(graphicsBuffer->format()); | - | ||||||||||||
50 | QImage image(graphicsBuffer->data(), size.width(), size.height(), graphicsBuffer->bytesPerLine(), imageformat); | - | ||||||||||||
51 | if (graphicsBuffer->bytesPerLine() != (size.width() * 4)
| 0 | ||||||||||||
52 | needsConversion = true; | - | ||||||||||||
53 | } never executed: else {end of block | 0 | ||||||||||||
54 | switch (imageformat) { | - | ||||||||||||
55 | case never executed: QImage::Format_ARGB32_Premultiplied:case QImage::Format_ARGB32_Premultiplied: never executed: case QImage::Format_ARGB32_Premultiplied: | 0 | ||||||||||||
56 | premultiplied = true; | - | ||||||||||||
57 | - | |||||||||||||
58 | case never executed: QImage::Format_RGB32:case QImage::Format_RGB32: never executed: case QImage::Format_RGB32: code before this statement never executed: case QImage::Format_RGB32: | 0 | ||||||||||||
59 | case never executed: QImage::Format_ARGB32:case QImage::Format_ARGB32: never executed: case QImage::Format_ARGB32: | 0 | ||||||||||||
60 | swizzle = true; | - | ||||||||||||
61 | break; never executed: break; | 0 | ||||||||||||
62 | case never executed: QImage::Format_RGBA8888_Premultiplied:case QImage::Format_RGBA8888_Premultiplied: never executed: case QImage::Format_RGBA8888_Premultiplied: | 0 | ||||||||||||
63 | premultiplied = true; | - | ||||||||||||
64 | - | |||||||||||||
65 | case never executed: QImage::Format_RGBX8888:case QImage::Format_RGBX8888: never executed: case QImage::Format_RGBX8888: code before this statement never executed: case QImage::Format_RGBX8888: | 0 | ||||||||||||
66 | case never executed: QImage::Format_RGBA8888:case QImage::Format_RGBA8888: never executed: case QImage::Format_RGBA8888: | 0 | ||||||||||||
67 | break; never executed: break; | 0 | ||||||||||||
68 | case never executed: QImage::Format_BGR30:case QImage::Format_BGR30: never executed: case QImage::Format_BGR30: | 0 | ||||||||||||
69 | case never executed: QImage::Format_A2BGR30_Premultiplied:case QImage::Format_A2BGR30_Premultiplied: never executed: case QImage::Format_A2BGR30_Premultiplied: | 0 | ||||||||||||
70 | if (!ctx->isOpenGLES()
| 0 | ||||||||||||
71 | pixelType = 0x8368; | - | ||||||||||||
72 | internalFormat = 0x8059; | - | ||||||||||||
73 | premultiplied = true; | - | ||||||||||||
74 | } never executed: else {end of block | 0 | ||||||||||||
75 | needsConversion = true; | - | ||||||||||||
76 | } never executed: end of block | 0 | ||||||||||||
77 | break; never executed: break; | 0 | ||||||||||||
78 | case never executed: QImage::Format_RGB30:case QImage::Format_RGB30: never executed: case QImage::Format_RGB30: | 0 | ||||||||||||
79 | case never executed: QImage::Format_A2RGB30_Premultiplied:case QImage::Format_A2RGB30_Premultiplied: never executed: case QImage::Format_A2RGB30_Premultiplied: | 0 | ||||||||||||
80 | if (!ctx->isOpenGLES()
| 0 | ||||||||||||
81 | pixelType = 0x8368; | - | ||||||||||||
82 | internalFormat = 0x8059; | - | ||||||||||||
83 | premultiplied = true; | - | ||||||||||||
84 | swizzle = true; | - | ||||||||||||
85 | } never executed: else {end of block | 0 | ||||||||||||
86 | needsConversion = true; | - | ||||||||||||
87 | } never executed: end of block | 0 | ||||||||||||
88 | break; never executed: break; | 0 | ||||||||||||
89 | default never executed: :default: never executed: default: | 0 | ||||||||||||
90 | needsConversion = true; | - | ||||||||||||
91 | break; never executed: break; | 0 | ||||||||||||
92 | } | - | ||||||||||||
93 | } | - | ||||||||||||
94 | if (needsConversion
| 0 | ||||||||||||
95 | image = image.convertToFormat(QImage::Format_RGBA8888); never executed: image = image.convertToFormat(QImage::Format_RGBA8888); | 0 | ||||||||||||
96 | - | |||||||||||||
97 | QOpenGLFunctions *funcs = ctx->functions(); | - | ||||||||||||
98 | - | |||||||||||||
99 | QRect rect = subRect; | - | ||||||||||||
100 | if (rect.isNull()
| 0 | ||||||||||||
101 | funcs->glTexImage2D(0x0DE1, 0, internalFormat, size.width(), size.height(), 0, 0x1908, pixelType, image.constBits()); | - | ||||||||||||
102 | } never executed: else {end of block | 0 | ||||||||||||
103 | - | |||||||||||||
104 | if (!ctx->isOpenGLES()
| 0 | ||||||||||||
105 | funcs->glPixelStorei(0x0CF2, image.width()); | - | ||||||||||||
106 | funcs->glTexSubImage2D(0x0DE1, 0, rect.x(), rect.y(), rect.width(), rect.height(), 0x1908, pixelType, | - | ||||||||||||
107 | image.constScanLine(rect.y()) + rect.x() * 4); | - | ||||||||||||
108 | funcs->glPixelStorei(0x0CF2, 0); | - | ||||||||||||
109 | } never executed: elseend of block | 0 | ||||||||||||
110 | - | |||||||||||||
111 | { | - | ||||||||||||
112 | - | |||||||||||||
113 | - | |||||||||||||
114 | if (rect.width() >= size.width() / 2
| 0 | ||||||||||||
115 | rect.setX(0); | - | ||||||||||||
116 | rect.setWidth(size.width()); | - | ||||||||||||
117 | } never executed: end of block | 0 | ||||||||||||
118 | - | |||||||||||||
119 | - | |||||||||||||
120 | - | |||||||||||||
121 | - | |||||||||||||
122 | if (rect.width() == size.width()
| 0 | ||||||||||||
123 | funcs->glTexSubImage2D(0x0DE1, 0, 0, rect.y(), rect.width(), rect.height(), 0x1908, pixelType, | - | ||||||||||||
124 | image.constScanLine(rect.y())); | - | ||||||||||||
125 | } never executed: else {end of block | 0 | ||||||||||||
126 | funcs->glTexSubImage2D(0x0DE1, 0, rect.x(), rect.y(), rect.width(), rect.height(), 0x1908, pixelType, | - | ||||||||||||
127 | image.copy(rect).constBits()); | - | ||||||||||||
128 | } never executed: end of block | 0 | ||||||||||||
129 | } | - | ||||||||||||
130 | } | - | ||||||||||||
131 | if (swizzleRandB
| 0 | ||||||||||||
132 | * never executed: swizzleRandB = swizzle;*swizzleRandB = swizzle; never executed: *swizzleRandB = swizzle; | 0 | ||||||||||||
133 | if (premultipliedB
| 0 | ||||||||||||
134 | * never executed: premultipliedB = premultiplied;*premultipliedB = premultiplied; never executed: *premultipliedB = premultiplied; | 0 | ||||||||||||
135 | - | |||||||||||||
136 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
137 | } | - | ||||||||||||
138 | - | |||||||||||||
139 | - | |||||||||||||
Switch to Source code | Preprocessed file |