Temp fix for buffer destruction bug
This commit is contained in:
@@ -58,13 +58,13 @@ Rectangle
|
|||||||
|
|
||||||
property var pack: wallpaper.configuration.shader_package
|
property var pack: wallpaper.configuration.shader_package
|
||||||
|
|
||||||
onPackChanged: () =>
|
// onPackChanged: () =>
|
||||||
{
|
// {
|
||||||
if(mainItem.ready)
|
// if(mainItem.ready)
|
||||||
{
|
// {
|
||||||
shaderPackModel.loadJson(pack)
|
// shaderPackModel.loadJson(pack)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
id: mainItem
|
id: mainItem
|
||||||
color: "black"
|
color: "black"
|
||||||
@@ -81,15 +81,6 @@ Rectangle
|
|||||||
id: shaderPackModel
|
id: shaderPackModel
|
||||||
onJsonChanged: () =>
|
onJsonChanged: () =>
|
||||||
{
|
{
|
||||||
// clean up old channels
|
|
||||||
while(data.channels.length > 0)
|
|
||||||
data.channels.pop().destroy()
|
|
||||||
|
|
||||||
bufferA.source = ""
|
|
||||||
bufferB.source = ""
|
|
||||||
bufferC.source = ""
|
|
||||||
bufferD.source = ""
|
|
||||||
|
|
||||||
// Handle the JSON change if needed
|
// Handle the JSON change if needed
|
||||||
mainItem.parsePack(shaderPackModel.json);
|
mainItem.parsePack(shaderPackModel.json);
|
||||||
}
|
}
|
||||||
@@ -113,11 +104,15 @@ Rectangle
|
|||||||
// This channel must be set to a shader source file that has been pre-compiled to a QSB Fragment Shader
|
// This channel must be set to a shader source file that has been pre-compiled to a QSB Fragment Shader
|
||||||
ShaderChannel
|
ShaderChannel
|
||||||
{
|
{
|
||||||
ShaderChannel { id: bufferA; visible: false; anchors.fill: parent }
|
property var bufferA
|
||||||
ShaderChannel { id: bufferB; visible: false; anchors.fill: parent }
|
property var bufferB
|
||||||
ShaderChannel { id: bufferC; visible: false; anchors.fill: parent }
|
property var bufferC
|
||||||
ShaderChannel { id: bufferD; visible: false; anchors.fill: parent }
|
property var bufferD
|
||||||
|
|
||||||
|
// ShaderChannel { id: bufferA; visible: false; anchors.fill: parent }
|
||||||
|
// ShaderChannel { id: bufferB; visible: false; anchors.fill: parent }
|
||||||
|
// ShaderChannel { id: bufferC; visible: false; anchors.fill: parent }
|
||||||
|
// ShaderChannel { id: bufferD; visible: false; anchors.fill: parent }
|
||||||
iTime: mainItem.iTime
|
iTime: mainItem.iTime
|
||||||
iMouse: mainItem.iMouse
|
iMouse: mainItem.iMouse
|
||||||
iResolution: mainItem.iResolution
|
iResolution: mainItem.iResolution
|
||||||
@@ -183,10 +178,10 @@ Rectangle
|
|||||||
// Load the default shader pack configuration on component completion
|
// Load the default shader pack configuration on component completion
|
||||||
Component.onCompleted:
|
Component.onCompleted:
|
||||||
{
|
{
|
||||||
data.buffers.set("{bufferA}", bufferA)
|
data.buffers.set("{bufferA}", channelOutput.bufferA)
|
||||||
data.buffers.set("{bufferB}", bufferB)
|
data.buffers.set("{bufferB}", channelOutput.bufferB)
|
||||||
data.buffers.set("{bufferC}", bufferC)
|
data.buffers.set("{bufferC}", channelOutput.bufferC)
|
||||||
data.buffers.set("{bufferD}", bufferD)
|
data.buffers.set("{bufferD}", channelOutput.bufferD)
|
||||||
|
|
||||||
if(wallpaper.configuration.shader_package)
|
if(wallpaper.configuration.shader_package)
|
||||||
shaderPackModel.loadJson(wallpaper.configuration.shader_package);
|
shaderPackModel.loadJson(wallpaper.configuration.shader_package);
|
||||||
@@ -233,13 +228,12 @@ Rectangle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recursive helper function to parse channels
|
// Recursive helper function to parse channels
|
||||||
function parseChannel(channel, json, typeDefault = 2)
|
function parseChannel(channel, json, typeDefault = 2, autodestroy = true)
|
||||||
{
|
{
|
||||||
var source = getFilePath(json.source)
|
var source = getFilePath(json.source)
|
||||||
|
|
||||||
channel.frameBufferChannel = json.frame_buffer_channel !== undefined ? json.frame_buffer_channel : -1
|
channel.frameBufferChannel = json.frame_buffer_channel !== undefined ? json.frame_buffer_channel : -1
|
||||||
channel.type = json.type !== undefined ? json.type : typeDefault
|
channel.type = json.type !== undefined ? json.type : typeDefault
|
||||||
//channel.anchors.fill = channel.parent
|
|
||||||
channel.visible = false
|
channel.visible = false
|
||||||
channel.iMouse = Qt.binding(() => { return mainItem.iMouse; })
|
channel.iMouse = Qt.binding(() => { return mainItem.iMouse; })
|
||||||
channel.iTime = Qt.binding(() => { return mainItem.iTime; })
|
channel.iTime = Qt.binding(() => { return mainItem.iTime; })
|
||||||
@@ -251,15 +245,6 @@ Rectangle
|
|||||||
channel.width = Qt.binding(() => channel.iResolution.x)
|
channel.width = Qt.binding(() => channel.iResolution.x)
|
||||||
channel.height = Qt.binding(() => channel.iResolution.y)
|
channel.height = Qt.binding(() => channel.iResolution.y)
|
||||||
|
|
||||||
// channel.iChannelResolution = Qt.binding(() => {
|
|
||||||
// return [
|
|
||||||
// Qt.vector3d(json.resolution_x || mainItem.width, json.resolution_y || mainItem.height, 1.0),
|
|
||||||
// Qt.vector3d(json.resolution_x || mainItem.width, json.resolution_y || mainItem.height, 1.0),
|
|
||||||
// Qt.vector3d(json.resolution_x || mainItem.width, json.resolution_y || mainItem.height, 1.0),
|
|
||||||
// Qt.vector3d(json.resolution_x || mainItem.width, json.resolution_y || mainItem.height, 1.0)
|
|
||||||
// ];
|
|
||||||
// });
|
|
||||||
|
|
||||||
channel.iChannelTime = Qt.binding(() => {
|
channel.iChannelTime = Qt.binding(() => {
|
||||||
return [
|
return [
|
||||||
mainItem.iTime * channel.iTimeScale,
|
mainItem.iTime * channel.iTimeScale,
|
||||||
@@ -291,7 +276,6 @@ Rectangle
|
|||||||
if (component.status === Component.Ready) {
|
if (component.status === Component.Ready) {
|
||||||
channel.iChannel0 = component.createObject(mainItem, { })
|
channel.iChannel0 = component.createObject(mainItem, { })
|
||||||
parseChannel(channel.iChannel0, json.channel0)
|
parseChannel(channel.iChannel0, json.channel0)
|
||||||
data.channels.push(channel.iChannel0) // save for destroying
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -314,8 +298,6 @@ Rectangle
|
|||||||
if (component.status === Component.Ready) {
|
if (component.status === Component.Ready) {
|
||||||
channel.iChannel1 = component.createObject(mainItem, { })
|
channel.iChannel1 = component.createObject(mainItem, { })
|
||||||
parseChannel(channel.iChannel1, json.channel1)
|
parseChannel(channel.iChannel1, json.channel1)
|
||||||
|
|
||||||
data.channels.push(channel.iChannel1) // save for destroying
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -338,8 +320,6 @@ Rectangle
|
|||||||
if (component.status === Component.Ready) {
|
if (component.status === Component.Ready) {
|
||||||
channel.iChannel2 = component.createObject(mainItem, { })
|
channel.iChannel2 = component.createObject(mainItem, { })
|
||||||
parseChannel(channel.iChannel2, json.channel2)
|
parseChannel(channel.iChannel2, json.channel2)
|
||||||
|
|
||||||
data.channels.push(channel.iChannel2) // save for destroying
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -362,31 +342,50 @@ Rectangle
|
|||||||
if (component.status === Component.Ready) {
|
if (component.status === Component.Ready) {
|
||||||
channel.iChannel3 = component.createObject(mainItem, { })
|
channel.iChannel3 = component.createObject(mainItem, { })
|
||||||
parseChannel(channel.iChannel3, json.channel3)
|
parseChannel(channel.iChannel3, json.channel3)
|
||||||
|
|
||||||
data.channels.push(channel.iChannel3) // save for destroying
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
console.log('Uknown channel type 3 ' + typeof json.channel3)
|
console.log('Uknown channel type 3 ' + typeof json.channel3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(autodestroy)
|
||||||
|
data.channels.push(channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to parse the pack.json file and set the properties of the ShaderChannel
|
// Function to parse the pack.json file and set the properties of the ShaderChannel
|
||||||
function parsePack(json)
|
function parsePack(json)
|
||||||
{
|
{
|
||||||
|
// clean up old channels
|
||||||
|
while(data.channels.length > 0)
|
||||||
|
data.channels.pop().destroy()
|
||||||
|
|
||||||
var pack = JSON.parse(json);
|
var pack = JSON.parse(json);
|
||||||
var currentChannel = null;
|
var currentChannel = null;
|
||||||
|
|
||||||
if (pack.bufferA)
|
var component = Qt.createComponent("./ShaderChannel.qml")
|
||||||
parseChannel(bufferA, pack.bufferA, 2);
|
|
||||||
if (pack.bufferB)
|
|
||||||
parseChannel(bufferB, pack.bufferB, 2);
|
|
||||||
if (pack.bufferC)
|
|
||||||
parseChannel(bufferC, pack.bufferC, 2);
|
|
||||||
if (pack.bufferD)
|
|
||||||
parseChannel(bufferD, pack.bufferD, 2);
|
|
||||||
|
|
||||||
parseChannel(channelOutput, pack, 2)
|
if (component.status === Component.Ready) {
|
||||||
|
channelOutput.bufferA = component.createObject(channelOutput, { visible: false })
|
||||||
|
channelOutput.bufferB = component.createObject(channelOutput, { visible: false })
|
||||||
|
channelOutput.bufferC = component.createObject(channelOutput, { visible: false })
|
||||||
|
channelOutput.bufferD = component.createObject(channelOutput, { visible: false })
|
||||||
|
data.buffers.set("{bufferA}", channelOutput.bufferA)
|
||||||
|
data.buffers.set("{bufferB}", channelOutput.bufferB)
|
||||||
|
data.buffers.set("{bufferC}", channelOutput.bufferC)
|
||||||
|
data.buffers.set("{bufferD}", channelOutput.bufferD)
|
||||||
|
//parseChannel(channel.iChannel0, json.channel0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pack.bufferA)
|
||||||
|
parseChannel(channelOutput.bufferA, pack.bufferA, 2);
|
||||||
|
if (pack.bufferB)
|
||||||
|
parseChannel(channelOutput.bufferB, pack.bufferB, 2);
|
||||||
|
if (pack.bufferC)
|
||||||
|
parseChannel(channelOutput.bufferC, pack.bufferC, 2);
|
||||||
|
if (pack.bufferD)
|
||||||
|
parseChannel(channelOutput.bufferD, pack.bufferD, 2);
|
||||||
|
|
||||||
|
parseChannel(channelOutput, pack, 2, false)
|
||||||
|
|
||||||
channelOutput.source = getFilePath(pack.source); // Set the shader source file
|
channelOutput.source = getFilePath(pack.source); // Set the shader source file
|
||||||
channelOutput.type = ShaderChannel.Type.ShaderChannel; // Set the shader
|
channelOutput.type = ShaderChannel.Type.ShaderChannel; // Set the shader
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ Item
|
|||||||
hideSource: true
|
hideSource: true
|
||||||
width: channel.iResolution.x
|
width: channel.iResolution.x
|
||||||
height: channel.iResolution.y
|
height: channel.iResolution.y
|
||||||
|
visible: false
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderEffectSource
|
ShaderEffectSource
|
||||||
@@ -310,6 +311,7 @@ Item
|
|||||||
hideSource: true
|
hideSource: true
|
||||||
width: channel.iResolution.x
|
width: channel.iResolution.x
|
||||||
height: channel.iResolution.y
|
height: channel.iResolution.y
|
||||||
|
visible: false
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderEffectSource
|
ShaderEffectSource
|
||||||
@@ -327,6 +329,7 @@ Item
|
|||||||
hideSource: true
|
hideSource: true
|
||||||
width: channel.iResolution.x
|
width: channel.iResolution.x
|
||||||
height: channel.iResolution.y
|
height: channel.iResolution.y
|
||||||
|
visible: false
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderEffectSource
|
ShaderEffectSource
|
||||||
@@ -344,6 +347,7 @@ Item
|
|||||||
hideSource: true
|
hideSource: true
|
||||||
width: channel.iResolution.x
|
width: channel.iResolution.x
|
||||||
height: channel.iResolution.y
|
height: channel.iResolution.y
|
||||||
|
visible: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// recursive frame buffer
|
// recursive frame buffer
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ WallpaperItem
|
|||||||
{
|
{
|
||||||
property int resolution_x: wallpaper.configuration.resolution_x
|
property int resolution_x: wallpaper.configuration.resolution_x
|
||||||
property int resolution_y: wallpaper.configuration.resolution_y
|
property int resolution_y: wallpaper.configuration.resolution_y
|
||||||
|
property string shaderPack: wallpaper.configuration.shader_package
|
||||||
property bool changing: false
|
property bool changing: false
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -93,6 +94,7 @@ WallpaperItem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// band-aid section
|
||||||
onResolution_xChanged: () =>
|
onResolution_xChanged: () =>
|
||||||
{
|
{
|
||||||
if(changing)
|
if(changing)
|
||||||
@@ -126,5 +128,22 @@ WallpaperItem
|
|||||||
|
|
||||||
changing = false
|
changing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onShaderPackChanged: () =>
|
||||||
|
{
|
||||||
|
if(changing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
changing = true
|
||||||
|
|
||||||
|
pageLoader.sourceComponent = null
|
||||||
|
|
||||||
|
if(wallpaper.configuration.komplex_mode === 0)
|
||||||
|
pageLoader.sourceComponent = shaderToyContent
|
||||||
|
else
|
||||||
|
pageLoader.sourceComponent = packContent
|
||||||
|
|
||||||
|
changing = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user