Source

Target

Commits (21)
Showing with 313 additions and 660 deletions
......@@ -2991,15 +2991,19 @@ void splitCriticalEdges(IR::Function *f, DominatorTree &df, StatementWorklist &w
toBB->in[inIdx] = newBB;
newBB->out.append(toBB);
BasicBlock *container = 0;
for (container = fromBB->containingGroup(); container; container = container->containingGroup()) {
if (container == toBB || container == toBB->containingGroup())
break;
// add newBB to the correct loop group
if (toBB->isGroupStart()) {
BasicBlock *container;
for (container = fromBB->containingGroup(); container; container = container->containingGroup())
if (container == toBB)
break;
if (container == toBB) // if we were already inside the toBB loop
newBB->setContainingGroup(toBB);
else
newBB->setContainingGroup(toBB->containingGroup());
} else {
newBB->setContainingGroup(toBB->containingGroup());
}
if (container == 0)
container = fromBB->containingGroup();
newBB->setContainingGroup(container);
// patch the terminator
Stmt *terminator = fromBB->terminator();
......
......@@ -34,8 +34,3 @@ HEADERS += \
$$PWD/qqmlprofiler_p.h
INCLUDEPATH += $$PWD
!contains(DEFINES, QT_QML_NO_DEBUGGER): static {
DEFINES += QML_DEBUGGER_EMBED
include(../../plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pri)
}
......@@ -419,6 +419,7 @@ QQmlDebugServer::QQmlDebugServer()
}
}
#else
Q_UNUSED(&cleanup)
if (!appD->qmljsDebugArgumentsString().isEmpty()) {
qWarning() << QString(QLatin1String(
"QML Debugger: Ignoring \"-qmljsdebugger=%1\". "
......
......@@ -96,8 +96,16 @@ QDataStream &operator>>(QDataStream &ds,
QDataStream &operator<<(QDataStream &ds,
const QQmlEngineDebugService::QQmlObjectProperty &data)
{
ds << (int)data.type << data.name << data.value << data.valueTypeName
<< data.binding << data.hasNotifySignal;
ds << (int)data.type << data.name;
// check first whether the data can be saved
// (otherwise we assert in QVariant::operator<<)
QByteArray buffer;
QDataStream fakeStream(&buffer, QIODevice::WriteOnly);
if (QMetaType::save(fakeStream, data.value.type(), data.value.constData()))
ds << data.value;
else
ds << QVariant();
ds << data.valueTypeName << data.binding << data.hasNotifySignal;
return ds;
}
......
......@@ -412,25 +412,24 @@ InternalClass *InternalClass::frozen()
void InternalClass::destroy()
{
if (!engine)
return;
engine = 0;
propertyTable.~PropertyHash();
nameMap.~SharedInternalClassData<String *>();
propertyData.~SharedInternalClassData<PropertyAttributes>();
QList<InternalClass *> destroyStack;
destroyStack.append(this);
if (m_sealed)
m_sealed->destroy();
if (m_frozen)
m_frozen->destroy();
for (QHash<Transition, InternalClass *>::ConstIterator it = transitions.begin(), end = transitions.end();
it != end; ++it)
it.value()->destroy();
transitions.clear();
while (!destroyStack.isEmpty()) {
InternalClass *next = destroyStack.takeLast();
if (!next->engine)
continue;
next->engine = 0;
next->propertyTable.~PropertyHash();
next->nameMap.~SharedInternalClassData<String *>();
next->propertyData.~SharedInternalClassData<PropertyAttributes>();
if (next->m_sealed)
destroyStack.append(next->m_sealed);
if (next->m_frozen)
destroyStack.append(next->m_frozen);
destroyStack.append(next->transitions.values());
next->transitions.clear();
}
}
struct InternalClassPoolVisitor
......
......@@ -174,7 +174,7 @@ struct QQmlLocaleData : public QV4::Object
private:
static void destroy(Managed *that)
{
static_cast<QQmlLocaleData *>(that)->~QQmlLocaleData();
static_cast<QQmlLocaleData *>(that)->d()->~Data();
}
};
......
......@@ -72,8 +72,8 @@ The following pages show how to develop Qt applications using
\l{Qt Creator Manual}{Qt Creator} and Qt Quick. The pages demonstrate various
steps such as use cases and introductory material. For more information about Qt Quick Applications and related modules, visit the \l{QML Applications} page.
\div {class="landingicons"}
\div {class="icons1of3"}
\div {class="multi-column"}
\div {class="doc-column"}
\b{Development Environment}
\list
\li \l{Qt Creator: Creating Qt Quick Projects}{Creating Qt Quick Projects}
......@@ -84,7 +84,7 @@ steps such as use cases and introductory material. For more information about Qt
\li \l{Qt Creator: Using QML Modules with Plugins}{Using QML Modules with Plugins}
\endlist
\enddiv
\div {class="icons1of3"}
\div {class="doc-column"}
\b{Beginning with QML and Qt Quick}
\list
\li \l{First Steps with QML}
......@@ -92,7 +92,7 @@ steps such as use cases and introductory material. For more information about Qt
\li \l{QML Advanced Tutorial}{SameGame}
\endlist
\enddiv
\div {class="icons1of3"}
\div {class="doc-column"}
\b{Use Cases}
\list
\li \l{qtquick-usecase-visual.html}{Visual types in QML}
......@@ -120,8 +120,8 @@ Examples are small applications which show how to implement various Qt Quick
features. The examples run on various platforms and are opened from within Qt
Creator.
\div {class="landingicons"}
\div {class="icons1of3"}
\div {class="multi-column"}
\div {class="doc-column"}
\b{QML Types and Controls}
\list
\li \l{Qt Quick Controls - Gallery}{Controls Gallery}
......@@ -132,7 +132,7 @@ Creator.
\li \l{Qt Quick Examples - Toggle Switch}{Custom Toggle Switch}
\endlist
\enddiv
\div {class="icons1of3"}
\div {class="doc-column"}
\b{Layouts and Views}
\list
\li \l{Qt Quick Controls - Basic Layouts Example}{Basic Layouts}
......@@ -142,7 +142,7 @@ Creator.
\li \l{Qt Quick Examples - Right to Left}{Right-to-Left and Text Layout}
\endlist
\enddiv
\div {class="icons1of3"}
\div {class="doc-column"}
\b{Image and Graphics}
\list
\li \l{Qt Quick Examples - Image Elements}{Image Elements}
......@@ -153,8 +153,8 @@ Creator.
\enddiv
\enddiv
\div {class="landingicons"}
\div {class="icons1of3"}
\div {class="multi-column"}
\div {class="doc-column"}
\b{Keyboard, Focus, and Touch}
\list
\li \l{Qt Quick Examples - Key Interaction}{Key Interaction}
......@@ -162,7 +162,7 @@ Creator.
\li \l{Qt Quick Controls - Touch Gallery}{Touch Gallery}
\endlist
\enddiv
\div {class="icons1of3"}
\div {class="doc-column"}
\b{System and Events}
\list
\li \l{Qt Quick Examples - Threading}{Threading}
......@@ -171,7 +171,7 @@ Creator.
\li \l{Qt Quick Examples - Drag and Drop}{Drag and Drop}
\endlist
\enddiv
\div {class="icons1of3"}
\div {class="doc-column"}
\b{Scene Graph}
\list
\li \l{Scene Graph - OpenGL Under QML}{OpenGL Under QML}
......
This diff is collapsed.
......@@ -87,8 +87,6 @@ private Q_SLOTS:
void sciRequestFinished();
private:
static QImage shallowCopy(const QImage &image, const QRect &rect);
Q_DISABLE_COPY(QQuickBorderImage)
Q_DECLARE_PRIVATE(QQuickBorderImage)
};
......
......@@ -89,16 +89,6 @@ public:
QQuickBorderImage::TileMode verticalTileMode;
int redirectCount;
struct BorderImageRegion
{
BorderImageRegion() : node(0), textureFactory(0) {}
QImage image;
QSGImageNode *node;
QScopedPointer<QQuickTextureFactory> textureFactory;
QRectF targetRect;
};
BorderImageRegion regions[9];
bool pixmapChanged : 1;
};
......
......@@ -75,9 +75,6 @@ public:
QSize sourcesize;
QSize oldSourceSize;
qreal devicePixelRatio;
QRectF oldInnerSourceRect;
QRectF oldInnerTargetRect;
QSizeF oldSize;
bool async : 1;
bool cache : 1;
bool mirror: 1;
......
......@@ -893,8 +893,10 @@ void QQuickWindowPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item,
void QQuickWindowPrivate::clearFocusObject()
{
if (activeFocusItem)
activeFocusItem->setFocus(false, Qt::OtherFocusReason);
if (activeFocusItem == contentItem)
return;
clearFocusInScope(contentItem, QQuickItemPrivate::get(contentItem)->subFocusItem, Qt::OtherFocusReason);
}
void QQuickWindowPrivate::notifyFocusChangesRecur(QQuickItem **items, int remaining)
......@@ -1250,6 +1252,14 @@ bool QQuickWindow::isPersistentSceneGraph() const
/*!
\qmlattachedproperty Item Window::contentItem
\since 5.4
This attached property holds the invisible root item of the scene or
\c null if the item is not in a window. The Window attached property
can be attached to any Item.
*/
/*!
\property QQuickWindow::contentItem
......
......@@ -65,6 +65,11 @@ QQuickItem *QQuickWindowAttached::activeFocusItem() const
return (m_window ? m_window->activeFocusItem() : Q_NULLPTR);
}
QQuickItem *QQuickWindowAttached::contentItem() const
{
return (m_window ? m_window->contentItem() : Q_NULLPTR);
}
void QQuickWindowAttached::windowChanged(QQuickWindow *window)
{
if (window != m_window) {
......@@ -83,6 +88,7 @@ void QQuickWindowAttached::windowChanged(QQuickWindow *window)
emit activeChanged();
if (!oldWindow || window->activeFocusItem() != oldWindow->activeFocusItem())
emit activeFocusItemChanged();
emit contentItemChanged();
// QQuickWindowQmlImpl::visibilityChanged also exists, and window might even
// be QQuickWindowQmlImpl, but that's not what we are connecting to.
......
......@@ -49,6 +49,7 @@ class Q_AUTOTEST_EXPORT QQuickWindowAttached : public QObject
Q_PROPERTY(QWindow::Visibility visibility READ visibility NOTIFY visibilityChanged)
Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
Q_PROPERTY(QQuickItem* activeFocusItem READ activeFocusItem NOTIFY activeFocusItemChanged)
Q_PROPERTY(QQuickItem* contentItem READ contentItem NOTIFY contentItemChanged)
public:
QQuickWindowAttached(QObject* attachee);
......@@ -56,12 +57,14 @@ public:
QWindow::Visibility visibility() const;
bool isActive() const;
QQuickItem* activeFocusItem() const;
QQuickItem* contentItem() const;
Q_SIGNALS:
void visibilityChanged();
void activeChanged();
void activeFocusItemChanged();
void contentItemChanged();
protected Q_SLOTS:
void windowChanged(QQuickWindow*);
......
......@@ -174,6 +174,11 @@ void QSGDistanceFieldGlyphCache::update()
storeGlyphs(distanceFields);
#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG)
foreach (Texture texture, m_textures)
saveTexture(texture.textureId, texture.size.width(), texture.size.height());
#endif
if (QSG_LOG_TIME_GLYPH().isDebugEnabled()) {
quint64 now = qsg_render_timer.elapsed();
qCDebug(QSG_LOG_TIME_GLYPH,
......@@ -284,6 +289,163 @@ void QSGDistanceFieldGlyphCache::updateTexture(GLuint oldTex, GLuint newTex, con
}
}
#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG)
#include <QtGui/qopenglfunctions.h>
void QSGDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width, int height) const
{
QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions();
GLuint fboId;
functions->glGenFramebuffers(1, &fboId);
GLuint tmpTexture = 0;
functions->glGenTextures(1, &tmpTexture);
functions->glBindTexture(GL_TEXTURE_2D, tmpTexture);
functions->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
functions->glBindTexture(GL_TEXTURE_2D, 0);
functions->glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId);
functions->glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
tmpTexture, 0);
functions->glActiveTexture(GL_TEXTURE0);
functions->glBindTexture(GL_TEXTURE_2D, textureId);
functions->glDisable(GL_STENCIL_TEST);
functions->glDisable(GL_DEPTH_TEST);
functions->glDisable(GL_SCISSOR_TEST);
functions->glDisable(GL_BLEND);
GLfloat textureCoordinateArray[8];
textureCoordinateArray[0] = 0.0f;
textureCoordinateArray[1] = 0.0f;
textureCoordinateArray[2] = 1.0f;
textureCoordinateArray[3] = 0.0f;
textureCoordinateArray[4] = 1.0f;
textureCoordinateArray[5] = 1.0f;
textureCoordinateArray[6] = 0.0f;
textureCoordinateArray[7] = 1.0f;
GLfloat vertexCoordinateArray[8];
vertexCoordinateArray[0] = -1.0f;
vertexCoordinateArray[1] = -1.0f;
vertexCoordinateArray[2] = 1.0f;
vertexCoordinateArray[3] = -1.0f;
vertexCoordinateArray[4] = 1.0f;
vertexCoordinateArray[5] = 1.0f;
vertexCoordinateArray[6] = -1.0f;
vertexCoordinateArray[7] = 1.0f;
functions->glViewport(0, 0, width, height);
functions->glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray);
functions->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray);
{
static const char *vertexShaderSource =
"attribute vec4 vertexCoordsArray; \n"
"attribute vec2 textureCoordArray; \n"
"varying vec2 textureCoords; \n"
"void main(void) \n"
"{ \n"
" gl_Position = vertexCoordsArray; \n"
" textureCoords = textureCoordArray; \n"
"} \n";
static const char *fragmentShaderSource =
"varying vec2 textureCoords; \n"
"uniform sampler2D texture; \n"
"void main() \n"
"{ \n"
" gl_FragColor = texture2D(texture, textureCoords); \n"
"} \n";
GLuint vertexShader = functions->glCreateShader(GL_VERTEX_SHADER);
GLuint fragmentShader = functions->glCreateShader(GL_FRAGMENT_SHADER);
if (vertexShader == 0 || fragmentShader == 0) {
GLenum error = functions->glGetError();
qWarning("QSGDistanceFieldGlyphCache::saveTexture: Failed to create shaders. (GL error: %x)",
error);
return;
}
functions->glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
functions->glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
functions->glCompileShader(vertexShader);
GLint len = 1;
functions->glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &len);
char infoLog[2048];
functions->glGetShaderInfoLog(vertexShader, 2048, NULL, infoLog);
if (qstrlen(infoLog) > 0)
qWarning("Problems compiling vertex shader:\n %s", infoLog);
functions->glCompileShader(fragmentShader);
functions->glGetShaderInfoLog(fragmentShader, 2048, NULL, infoLog);
if (qstrlen(infoLog) > 0)
qWarning("Problems compiling fragment shader:\n %s", infoLog);
GLuint shaderProgram = functions->glCreateProgram();
functions->glAttachShader(shaderProgram, vertexShader);
functions->glAttachShader(shaderProgram, fragmentShader);
functions->glBindAttribLocation(shaderProgram, 0, "vertexCoordsArray");
functions->glBindAttribLocation(shaderProgram, 1, "textureCoordArray");
functions->glLinkProgram(shaderProgram);
functions->glGetProgramInfoLog(shaderProgram, 2048, NULL, infoLog);
if (qstrlen(infoLog) > 0)
qWarning("Problems linking shaders:\n %s", infoLog);
functions->glUseProgram(shaderProgram);
functions->glEnableVertexAttribArray(0);
functions->glEnableVertexAttribArray(1);
int textureUniformLocation = functions->glGetUniformLocation(shaderProgram, "texture");
functions->glUniform1i(textureUniformLocation, 0);
}
functions->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
{
GLenum error = functions->glGetError();
if (error != GL_NO_ERROR)
qWarning("glDrawArrays reported error 0x%x", error);
}
uchar *data = new uchar[width * height * 4];
functions->glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
QImage image(data, width, height, QImage::Format_ARGB32);
QByteArray fileName = m_referenceFont.familyName().toLatin1() + '_' + QByteArray::number(textureId);
fileName = fileName.replace('/', '_').replace(' ', '_') + ".png";
image.save(QString::fromLocal8Bit(fileName));
{
GLenum error = functions->glGetError();
if (error != GL_NO_ERROR)
qWarning("glReadPixels reported error 0x%x", error);
}
functions->glDisableVertexAttribArray(0);
functions->glDisableVertexAttribArray(1);
functions->glDeleteFramebuffers(1, &fboId);
functions->glDeleteTextures(1, &tmpTexture);
delete[] data;
}
#endif
void QSGNodeVisitorEx::visitChildren(QSGNode *node)
{
for (QSGNode *child = node->firstChild(); child; child = child->nextSibling()) {
......
......@@ -126,17 +126,6 @@ public:
class Q_QUICK_PRIVATE_EXPORT QSGImageNode : public QSGVisitableNode
{
public:
enum AntialiasingFlag
{
AntialiasingNone = 0,
AntialiasingLeft = 1,
AntialiasingRight = 2,
AntialiasingTop = 4,
AntialiasingBottom = 8,
AntialiasingAll = AntialiasingLeft | AntialiasingRight | AntialiasingBottom | AntialiasingTop
};
Q_DECLARE_FLAGS(AntialiasingFlags, AntialiasingFlag)
virtual void setTargetRect(const QRectF &rect) = 0;
virtual void setInnerTargetRect(const QRectF &rect) = 0;
virtual void setInnerSourceRect(const QRectF &rect) = 0;
......@@ -151,7 +140,6 @@ public:
virtual void setFiltering(QSGTexture::Filtering filtering) = 0;
virtual void setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) = 0;
virtual void setVerticalWrapMode(QSGTexture::WrapMode wrapMode) = 0;
virtual void setAntialiasing(AntialiasingFlags flags) { Q_UNUSED(flags); }
virtual void update() = 0;
......@@ -357,6 +345,10 @@ protected:
GlyphData &glyphData(glyph_t glyph);
#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG)
void saveTexture(GLuint textureId, int width, int height) const;
#endif
inline bool isCoreProfile() const { return m_coreProfile; }
private:
......
......@@ -161,6 +161,7 @@ public:
, m_time(0)
, m_vsync(0)
, m_mode(VSyncMode)
, m_lag(0)
, m_bad(0)
, m_good(0)
{
......
......@@ -140,11 +140,10 @@ void SmoothTextureMaterialShader::initialize()
QSGDefaultImageNode::QSGDefaultImageNode()
: m_innerSourceRect(0, 0, 1, 1)
, m_subSourceRect(0, 0, 1, 1)
, m_antialiasing(false)
, m_mirror(false)
, m_dirtyGeometry(false)
, m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
, m_antialiasing(AntialiasingNone)
{
setMaterial(&m_materialO);
setOpaqueMaterial(&m_material);
......@@ -250,20 +249,10 @@ void QSGDefaultImageNode::setTexture(QSGTexture *texture)
void QSGDefaultImageNode::setAntialiasing(bool antialiasing)
{
AntialiasingFlags antialiasingFlags = antialiasing
? AntialiasingAll
: AntialiasingNone;
setAntialiasing(antialiasingFlags);
}
void QSGDefaultImageNode::setAntialiasing(AntialiasingFlags antialiasingFlags)
{
if (antialiasingFlags == m_antialiasing)
if (antialiasing == m_antialiasing)
return;
m_antialiasing = antialiasingFlags;
if (m_antialiasing != AntialiasingNone) {
m_antialiasing = antialiasing;
if (m_antialiasing) {
setMaterial(&m_smoothMaterial);
setOpaqueMaterial(0);
setGeometry(new QSGGeometry(smoothAttributeSet(), 0));
......@@ -375,14 +364,11 @@ void QSGDefaultImageNode::updateGeometry()
}
// An image can be rendered as a single quad if:
// - There is antialiasing on all or no edges
// - There are no margins, and either:
// - the image isn't repeated
// - the source rectangle fills the entire texture so that texture wrapping can be used,
// and NPOT is supported
if (!hasMargins
&& (m_antialiasing == AntialiasingAll || m_antialiasing == AntialiasingNone)
&& (!hasTiles || (fullTexture && wrapSupported))) {
if (!hasMargins && (!hasTiles || (fullTexture && wrapSupported))) {
QRectF sr;
if (!fullTexture) {
sr = QRectF(innerSourceRect.x() + (m_subSourceRect.left() - floorLeft) * innerSourceRect.width(),
......@@ -561,35 +547,10 @@ void QSGDefaultImageNode::updateGeometry()
topDv = bottomDv *= 0.5f;
}
if (!m_antialiasing.testFlag(AntialiasingTop)) {
topDy = 0.0f;
topDv = 0.0f;
}
if (!m_antialiasing.testFlag(AntialiasingBottom)) {
bottomDy = 0.0f;
bottomDv = 0.0f;
}
if (!m_antialiasing.testFlag(AntialiasingLeft)) {
leftDx = 0.0f;
leftDu = 0.0f;
}
if (!m_antialiasing.testFlag(AntialiasingRight)) {
rightDx = 0.0f;
rightDu = 0.0f;
}
// This delta is how much the fuzziness can reach out from the image.
float delta = float(qAbs(m_targetRect.width()) < qAbs(m_targetRect.height())
? m_targetRect.width() : m_targetRect.height()) * 0.5f;
float deltaTop = m_antialiasing.testFlag(AntialiasingTop) ? delta : 0.0f;
float deltaBottom = m_antialiasing.testFlag(AntialiasingBottom) ? delta : 0.0f;
float deltaLeft = m_antialiasing.testFlag(AntialiasingLeft) ? delta : 0.0f;
float deltaRight = m_antialiasing.testFlag(AntialiasingRight) ? delta : 0.0f;
quint16 index = 0;
ys = yData.data();
for (int j = 0; j < vCells; ++j, ys += 2) {
......@@ -639,28 +600,28 @@ void QSGDefaultImageNode::updateGeometry()
if (isTop) {
vertices[topLeft].dy = vertices[topRight].dy = topDy;
vertices[topLeft].dv = vertices[topRight].dv = topDv;
vertices[topLeft + 1].dy = vertices[topRight + 1].dy = -deltaTop;
vertices[topLeft + 1].dy = vertices[topRight + 1].dy = -delta;
appendQuad(&indices, topLeft + 1, topRight + 1, topLeft, topRight);
}
if (isBottom) {
vertices[bottomLeft].dy = vertices[bottomRight].dy = -bottomDy;
vertices[bottomLeft].dv = vertices[bottomRight].dv = -bottomDv;
vertices[bottomLeft + 1].dy = vertices[bottomRight + 1].dy = deltaBottom;
vertices[bottomLeft + 1].dy = vertices[bottomRight + 1].dy = delta;
appendQuad(&indices, bottomLeft, bottomRight, bottomLeft + 1, bottomRight + 1);
}
if (isLeft) {
vertices[topLeft].dx = vertices[bottomLeft].dx = leftDx;
vertices[topLeft].du = vertices[bottomLeft].du = leftDu;
vertices[topLeft + 1].dx = vertices[bottomLeft + 1].dx = -deltaLeft;
vertices[topLeft + 1].dx = vertices[bottomLeft + 1].dx = -delta;
appendQuad(&indices, topLeft + 1, topLeft, bottomLeft + 1, bottomLeft);
}
if (isRight) {
vertices[topRight].dx = vertices[bottomRight].dx = -rightDx;
vertices[topRight].du = vertices[bottomRight].du = -rightDu;
vertices[topRight + 1].dx = vertices[bottomRight + 1].dx = deltaRight;
vertices[topRight + 1].dx = vertices[bottomRight + 1].dx = delta;
appendQuad(&indices, topRight, topRight + 1, bottomRight, bottomRight + 1);
}
}
......
......@@ -62,7 +62,6 @@ public:
virtual void setSubSourceRect(const QRectF &rect);
virtual void setTexture(QSGTexture *t);
virtual void setAntialiasing(bool antialiasing);
virtual void setAntialiasing(AntialiasingFlags antialiasing);
virtual void setMirror(bool mirror);
virtual void update();
......@@ -85,11 +84,11 @@ private:
QSGTextureMaterial m_materialO;
QSGSmoothTextureMaterial m_smoothMaterial;
uint m_antialiasing : 1;
uint m_mirror : 1;
uint m_dirtyGeometry : 1;
QSGGeometry m_geometry;
AntialiasingFlags m_antialiasing;
};
QT_END_NAMESPACE
......
......@@ -399,176 +399,6 @@ void QSGSharedDistanceFieldGlyphCache::unregisterOwnerElement(QQuickItem *ownerE
}
}
#if defined(QSGSHAREDDISTANCEFIELDGLYPHCACHE_DEBUG_)
# include <QtOpenGL/private/qglextensions_p.h>
void QSGSharedDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width, int height)
{
GLuint fboId;
glGenFramebuffers(1, &fboId);
GLuint tmpTexture = 0;
glGenTextures(1, &tmpTexture);
glBindTexture(GL_TEXTURE_2D, tmpTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId);
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
tmpTexture, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureId);
glDisable(GL_STENCIL_TEST);
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_BLEND);
GLfloat textureCoordinateArray[8];
textureCoordinateArray[0] = 0.0f;
textureCoordinateArray[1] = 0.0f;
textureCoordinateArray[2] = 1.0f;
textureCoordinateArray[3] = 0.0f;
textureCoordinateArray[4] = 1.0f;
textureCoordinateArray[5] = 1.0f;
textureCoordinateArray[6] = 0.0f;
textureCoordinateArray[7] = 1.0f;
GLfloat vertexCoordinateArray[8];
vertexCoordinateArray[0] = -1.0f;
vertexCoordinateArray[1] = -1.0f;
vertexCoordinateArray[2] = 1.0f;
vertexCoordinateArray[3] = -1.0f;
vertexCoordinateArray[4] = 1.0f;
vertexCoordinateArray[5] = 1.0f;
vertexCoordinateArray[6] = -1.0f;
vertexCoordinateArray[7] = 1.0f;
glViewport(0, 0, width, height);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray);
{
static const char vertexShaderSource[] =
"attribute highp vec4 vertexCoordsArray; \n"
"attribute highp vec2 textureCoordArray; \n"
"varying highp vec2 textureCoords; \n"
"void main(void) \n"
"{ \n"
" gl_Position = vertexCoordsArray; \n"
" textureCoords = textureCoordArray; \n"
"} \n";
static const char fragmentShaderSource[] =
"varying highp vec2 textureCoords; \n"
"uniform sampler2D texture; \n"
"void main() \n"
"{ \n"
" gl_FragColor = texture2D(texture, textureCoords); \n"
"} \n";
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
if (vertexShader == 0 || fragmentShader == 0) {
GLenum error = glGetError();
qWarning("SharedGraphicsCacheServer::setupShaderPrograms: Failed to create shaders. (GL error: %x)",
error);
return;
}
glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
glCompileShader(vertexShader);
GLint len = 1;
glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &len);
char infoLog[2048];
glGetShaderInfoLog(vertexShader, 2048, NULL, infoLog);
if (qstrlen(infoLog) > 0) {
qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems compiling vertex shader:\n %s",
infoLog);
//return;
}
glCompileShader(fragmentShader);
glGetShaderInfoLog(fragmentShader, 2048, NULL, infoLog);
if (qstrlen(infoLog) > 0) {
qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems compiling fragent shader:\n %s",
infoLog);
//return;
}
GLuint shaderProgram = glCreateProgram();
glAttachShader(shaderProgram, vertexShader);
glAttachShader(shaderProgram, fragmentShader);
glBindAttribLocation(shaderProgram, 0, "vertexCoordsArray");
glBindAttribLocation(shaderProgram, 1, "textureCoordArray");
glLinkProgram(shaderProgram);
glGetProgramInfoLog(shaderProgram, 2048, NULL, infoLog);
if (qstrlen(infoLog) > 0) {
qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems linking shaders:\n %s",
infoLog);
//return;
}
glUseProgram(shaderProgram);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
int textureUniformLocation = glGetUniformLocation(shaderProgram, "_qt_texture");
glUniform1i(textureUniformLocation, 0);
}
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
{
GLenum error = glGetError();
if (error != GL_NO_ERROR) {
qWarning("SharedGraphicsCacheServer::readBackBuffer: glDrawArrays reported error 0x%x",
error);
}
}
uchar *data = new uchar[width * height * 4];
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
QImage image(width, height, QImage::Format_ARGB32);
quint32 *dest = reinterpret_cast<quint32 *>(image.bits());
for (int i=0; i<width*height; ++i)
dest[i] = qRgba(0xff, 0xff, 0xff, data[i]);
QByteArray fileName = m_cacheId + ' ' + QByteArray::number(textureId);
fileName = fileName.replace('/', '_').replace(' ', '_') + ".png";
image.save(QString::fromLocal8Bit(fileName));
{
GLenum error = glGetError();
if (error != GL_NO_ERROR) {
qWarning("SharedGraphicsCacheServer::readBackBuffer: glReadPixels reported error 0x%x",
error);
}
}
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDeleteFramebuffers(1, &fboId);
glDeleteTextures(1, &tmpTexture);
delete[] data;
}
#endif
namespace {
struct TextureContent {
QSize size;
......@@ -683,9 +513,6 @@ void QSGSharedDistanceFieldGlyphCache::processPendingGlyphs()
texture.textureId = m_sharedGraphicsCache->textureIdForBuffer(it.key());
texture.size = m_sharedGraphicsCache->sizeOfBuffer(it.key());
#if defined(QSGSHAREDDISTANCEFIELDGLYPHCACHE_DEBUG_)
saveTexture(texture.textureId, texture.size.width(), texture.size.height());
#endif
setGlyphsTexture(it.value().glyphs, texture);
++it;
......