Commit d90bd094 authored by Fawzi Mohamed's avatar Fawzi Mohamed
Browse files

qmljs: tests of the import architecture



First tests using the new qmljs testing architecture

Change-Id: Id88fe53dddbb720c56cd0473e74f476862feb803
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 02bdf30f
......@@ -207,7 +207,11 @@ public:
void joinAllThreads();
QmlJS::Document::Ptr ensuredGetDocumentForPath(const QString &filePath);
static void importScan(QFutureInterface<void> &future,
WorkingCopy workingCopyInternal,
PathsAndLanguages paths,
ModelManagerInterface *modelManager,
bool emitDocChangedOnDisk);
public slots:
virtual void resetCodeModel();
void removeProjectInfo(ProjectExplorer::Project *project);
......@@ -243,11 +247,6 @@ protected:
ModelManagerInterface *modelManager,
QmlJS::Dialect mainLanguage,
bool emitDocChangedOnDisk);
static void importScan(QFutureInterface<void> &future,
WorkingCopy workingCopyInternal,
PathsAndLanguages paths,
ModelManagerInterface *modelManager,
bool emitDocChangedOnDisk);
static void updateCppQmlTypes(QFutureInterface<void> &interface,
ModelManagerInterface *qmlModelManager,
CPlusPlus::Snapshot snapshot,
......
TEMPLATE = subdirs
SUBDIRS += check
SUBDIRS += check \
importscheck
......@@ -2,5 +2,5 @@ import qbs
Project {
name: "QML code model autotests"
references: ["check/check.qbs"]
references: ["check/check.qbs", "importscheck/importscheck.qbs"]
}
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Graphical Effects module.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.0
Item {
id: rootItem
property variant source
property real deviation: (radius + 1) / 3.3333
property real radius: 0.0
property int maximumRadius: 0
property real horizontalStep: 0.0
property real verticalStep: 0.0
property bool transparentBorder: false
property bool cached: false
property bool enableColor: false
property color color: "white"
property real spread: 0.0
property bool enableMask: false
property variant maskSource
SourceProxy {
id: sourceProxy
input: rootItem.source
}
SourceProxy {
id: maskSourceProxy
input: rootItem.maskSource
}
ShaderEffectSource {
id: cacheItem
anchors.fill: rootItem
visible: rootItem.cached
smooth: true
sourceItem: shaderItem
live: true
hideSource: visible
}
ShaderEffect {
id: shaderItem
property variant source: sourceProxy.output
property real deviation: Math.max(0.1, rootItem.deviation)
property real radius: rootItem.radius
property int maxRadius: rootItem.maximumRadius
property bool transparentBorder: rootItem.transparentBorder
property real gaussianSum: 0.0
property real startIndex: 0.0
property real deltaFactor: (2 * radius - 1) / (maxRadius * 2 - 1)
property real expandX: transparentBorder && rootItem.horizontalStep > 0 ? maxRadius / width : 0.0
property real expandY: transparentBorder && rootItem.verticalStep > 0 ? maxRadius / height : 0.0
property variant gwts: []
property variant delta: Qt.vector3d(rootItem.horizontalStep * deltaFactor, rootItem.verticalStep * deltaFactor, startIndex);
property variant factor_0_2: Qt.vector3d(gwts[0], gwts[1], gwts[2]);
property variant factor_3_5: Qt.vector3d(gwts[3], gwts[4], gwts[5]);
property variant factor_6_8: Qt.vector3d(gwts[6], gwts[7], gwts[8]);
property variant factor_9_11: Qt.vector3d(gwts[9], gwts[10], gwts[11]);
property variant factor_12_14: Qt.vector3d(gwts[12], gwts[13], gwts[14]);
property variant factor_15_17: Qt.vector3d(gwts[15], gwts[16], gwts[17]);
property variant factor_18_20: Qt.vector3d(gwts[18], gwts[19], gwts[20]);
property variant factor_21_23: Qt.vector3d(gwts[21], gwts[22], gwts[23]);
property variant factor_24_26: Qt.vector3d(gwts[24], gwts[25], gwts[26]);
property variant factor_27_29: Qt.vector3d(gwts[27], gwts[28], gwts[29]);
property variant factor_30_32: Qt.vector3d(gwts[30], gwts[31], gwts[32]);
property color color: rootItem.color
property real spread: 1.0 - (rootItem.spread * 0.98)
property variant maskSource: maskSourceProxy.output
anchors.fill: rootItem
function gausFunc(x){
//Gaussian function = h(x):=(1/sqrt(2*3.14159*(D^2))) * %e^(-(x^2)/(2*(D^2)));
return (1.0 / Math.sqrt(2 * Math.PI * (Math.pow(shaderItem.deviation, 2)))) * Math.pow(Math.E, -((Math.pow(x, 2)) / (2 * (Math.pow(shaderItem.deviation, 2)))));
}
function updateGaussianWeights() {
gaussianSum = 0.0;
startIndex = -maxRadius + 0.5
var n = new Array(32);
for (var j = 0; j < 32; j++)
n[j] = 0;
var max = maxRadius * 2
var delta = (2 * radius - 1) / (max - 1);
for (var i = 0; i < max; i++) {
n[i] = gausFunc(-radius + 0.5 + i * delta);
gaussianSum += n[i];
}
gwts = n;
}
function buildFragmentShader() {
var shaderSteps = [
"gl_FragColor += texture2D(source, texCoord) * factor_0_2.x; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_0_2.y; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_0_2.z; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_3_5.x; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_3_5.y; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_3_5.z; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_6_8.x; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_6_8.y; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_6_8.z; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_9_11.x; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_9_11.y; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_9_11.z; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_12_14.x; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_12_14.y; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_12_14.z; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_15_17.x; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_15_17.y; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_15_17.z; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_18_20.x; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_18_20.y; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_18_20.z; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_21_23.x; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_21_23.y; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_21_23.z; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_24_26.x; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_24_26.y; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_24_26.z; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_27_29.x; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_27_29.y; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_27_29.z; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_30_32.x; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_30_32.y; texCoord += shift;",
"gl_FragColor += texture2D(source, texCoord) * factor_30_32.z; texCoord += shift;"
]
var shader = fragmentShaderBegin
var samples = maxRadius * 2
if (samples > 32) {
console.log("DirectionalGaussianBlur.qml WARNING: Maximum of blur radius (16) exceeded!")
samples = 32
}
for (var i = 0; i < samples; i++) {
shader += shaderSteps[i]
}
shader += fragmentShaderEnd
var colorizeSteps = ""
var colorizeUniforms = ""
var maskSteps = ""
var maskUniforms = ""
if (enableColor) {
colorizeSteps += "gl_FragColor = mix(vec4(0), color, clamp((gl_FragColor.a - 0.0) / (spread - 0.0), 0.0, 1.0));\n"
colorizeUniforms += "uniform highp vec4 color;\n"
colorizeUniforms += "uniform highp float spread;\n"
}
if (enableMask) {
maskSteps += "shift *= texture2D(maskSource, qt_TexCoord0).a;\n"
maskUniforms += "uniform sampler2D maskSource;\n"
}
shader = shader.replace("PLACEHOLDER_COLORIZE_STEPS", colorizeSteps)
shader = shader.replace("PLACEHOLDER_COLORIZE_UNIFORMS", colorizeUniforms)
shader = shader.replace("PLACEHOLDER_MASK_STEPS", maskSteps)
shader = shader.replace("PLACEHOLDER_MASK_UNIFORMS", maskUniforms)
fragmentShader = shader
}
onDeviationChanged: updateGaussianWeights()
onRadiusChanged: updateGaussianWeights()
onTransparentBorderChanged: {
buildFragmentShader()
updateGaussianWeights()
}
onMaxRadiusChanged: {
buildFragmentShader()
updateGaussianWeights()
}
Component.onCompleted: {
buildFragmentShader()
updateGaussianWeights()
}
property string fragmentShaderBegin: "
varying mediump vec2 qt_TexCoord0;
uniform highp float qt_Opacity;
uniform lowp sampler2D source;
uniform highp vec3 delta;
uniform highp vec3 factor_0_2;
uniform highp vec3 factor_3_5;
uniform highp vec3 factor_6_8;
uniform highp vec3 factor_9_11;
uniform highp vec3 factor_12_14;
uniform highp vec3 factor_15_17;
uniform highp vec3 factor_18_20;
uniform highp vec3 factor_21_23;
uniform highp vec3 factor_24_26;
uniform highp vec3 factor_27_29;
uniform highp vec3 factor_30_32;
uniform highp float gaussianSum;
uniform highp float expandX;
uniform highp float expandY;
PLACEHOLDER_MASK_UNIFORMS
PLACEHOLDER_COLORIZE_UNIFORMS
void main() {
highp vec2 shift = vec2(delta.x, delta.y);
PLACEHOLDER_MASK_STEPS
highp float index = delta.z;
mediump vec2 texCoord = qt_TexCoord0;
texCoord.s = (texCoord.s - expandX) / (1.0 - 2.0 * expandX);
texCoord.t = (texCoord.t - expandY) / (1.0 - 2.0 * expandY);
texCoord += (shift * index);
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
"
property string fragmentShaderEnd: "
gl_FragColor /= gaussianSum;
PLACEHOLDER_COLORIZE_STEPS
gl_FragColor *= qt_Opacity;
}
"
}
}
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Graphical Effects module.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.0
import "private"
/*!
\qmltype Blend
\inqmlmodule QtGraphicalEffects 1.0
\since QtGraphicalEffects 1.0
\inherits QtQuick2::Item
\ingroup qtgraphicaleffects-blend
\brief Merges two source items by using a blend mode.
Blend mode can be selected with the \l{Blend::mode}{mode} property.
\table
\header
\li source
\li foregroundSource
\li Effect applied
\row
\li \image Original_bug.png
\li \image Original_butterfly.png
\li \image Blend_bug_and_butterfly.png
\endtable
\section1 Example
The following example shows how to apply the effect.
\snippet Blend-example.qml example
*/
Item {
id: rootItem
/*!
This property defines the source item that is going to be the base when
\l{Blend::foregroundSource}{foregroundSource} is blended over it.
\note It is not supported to let the effect include itself, for
instance by setting source to the effect's parent.
*/
property variant source
/*!
This property defines the item that is going to be blended over the
\l{Blend::source}{source}.
\note It is not supported to let the effect include itself, for
instance by setting foregroundSource to the effect's parent.
*/
property variant foregroundSource
/*!
This property defines the mode which is used when foregroundSource is
blended over source. Values are case insensitive.
\table
\header
\li mode
\li description
\row
\li normal
\li The pixel component values from foregroundSource are written
over source by using alpha blending.
\row
\li addition
\li The pixel component values from source and foregroundSource are
added together and written.
\row
\li average
\li The pixel component values from source and foregroundSource are
averaged and written.
\row
\li color
\li The lightness value from source is combined with hue and
saturation from foregroundSource and written.
\row
\li colorBurn
\li The darker pixels from source are darkened more, if both source
and foregroundSource pixels are light the result is light.
\row
\li colorDodge
\li The lighter pixels from source are lightened more, if both
source and foregroundSource pixels are dark the result is dark.
\row
\li darken
\li The darker pixel component value from source and
foregroundSource is written.
\row
\li darkerColor
\li The lower luminance pixel rgb-value from source and
foregroundSource is written.
\row
\li difference
\li The absolute pixel component value difference between source and
foregroundSource is written.
\row
\li divide
\li The pixel component values from source is divided by the value
from foregroundSource and written.
\row
\li exclusion
\li The pixel component value difference with reduced contrast
between source and foregroundSource is written.
\row
\li hardLight
\li The pixel component values from source are lightened or darkened
according to foregroundSource values and written.
\row
\li hue
\li The hue value from foregroundSource is combined with saturation
and lightness from source and written.
\row
\li lighten
\li The lightest pixel component value from source and
foregroundSource is written.
\row
\li lighterColor
\li The higher luminance pixel rgb-value from source and
foregroundSource is written.
\row
\li lightness
\li The lightness value from foregroundSource is combined with hue
and saturation from source and written.
\row
\li multiply
\li The pixel component values from source and foregroundSource are
multiplied together and written.
\row
\li negation
\li The inverted absolute pixel component value difference between
source and foregroundSource is written.
\row
\li saturation
\li The saturation value from foregroundSource is combined with hue
and lightness from source and written.
\row
\li screen
\li The pixel values from source and foregroundSource are negated,
then multiplied, negated again, and written.
\row
\li subtract
\li Pixel value from foregroundSource is subracted from source and
written.
\row
\li softLight
\li The pixel component values from source are lightened or darkened
slightly according to foregroundSource values and written.
\endtable
\table
\header
\li Example source
\li Example foregroundSource
\row
\li \image Original_bug.png
\li \image Original_butterfly.png
\endtable
\table
\header
\li Output examples with different mode values
\li
\li
\row
\li \image Blend_mode1.png
\li \image Blend_mode2.png
\li \image Blend_mode3.png
\row
\li \b { mode: normal }
\li \b { mode: addition }
\li \b { mode: average }
\row
\li \image Blend_mode4.png
\li \image Blend_mode5.png
\li \image Blend_mode6.png
\row
\li \b { mode: color }
\li \b { mode: colorBurn }
\li \b { mode: colorDodge }
\row
\li \image Blend_mode7.png
\li \image Blend_mode8.png
\li \image Blend_mode9.png
\row
\li \b { mode: darken }
\li \b { mode: darkerColor }
\li \b { mode: difference }
\row
\li \image Blend_mode10.png
\li \image Blend_mode11.png
\li \image Blend_mode12.png
\row
\li \b { mode: divide }
\li \b { mode: exclusion }
\li \b { mode: hardlight }
\row
\li \image Blend_mode13.png
\li \image Blend_mode14.png
\li \image Blend_mode15.png
\row
\li \b { mode: hue }
\li \b { mode: lighten }
\li \b { mode: lighterColor }
\row
\li \image Blend_mode16.png
\li \image Blend_mode17.png
\li \image Blend_mode18.png
\row
\li \b { mode: lightness }
\li \b { mode: negation }
\li \b { mode: multiply }