🪲 Fix some effects on GNOME 48
This commit is contained in:
@@ -20,8 +20,6 @@ import * as utils from '../utils.js';
|
|||||||
// preferences process. They are used only in the creator function of the ShaderFactory
|
// preferences process. They are used only in the creator function of the ShaderFactory
|
||||||
// which is only called within GNOME Shell's process.
|
// which is only called within GNOME Shell's process.
|
||||||
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
|
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
|
||||||
const St = await utils.importInShellOnly('gi://St');
|
|
||||||
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
|
|
||||||
const Cogl = await utils.importInShellOnly('gi://Cogl');
|
const Cogl = await utils.importInShellOnly('gi://Cogl');
|
||||||
|
|
||||||
const _ = await utils.importGettext();
|
const _ = await utils.importGettext();
|
||||||
@@ -55,11 +53,7 @@ export default class Effect {
|
|||||||
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
|
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
|
||||||
// Create the texture in the first call.
|
// Create the texture in the first call.
|
||||||
if (!this._shardTexture) {
|
if (!this._shardTexture) {
|
||||||
const shardData = GdkPixbuf.Pixbuf.new_from_resource('/img/shards.png');
|
this._shardTexture = utils.getImageResource('/img/shards.png');
|
||||||
this._shardTexture = new St.ImageContent();
|
|
||||||
this._shardTexture.set_data(shardData.get_pixels(), Cogl.PixelFormat.RGB_888,
|
|
||||||
shardData.width, shardData.height,
|
|
||||||
shardData.rowstride);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store all uniform locations.
|
// Store all uniform locations.
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ import * as utils from '../utils.js';
|
|||||||
// preferences process. They are used only in the creator function of the ShaderFactory
|
// preferences process. They are used only in the creator function of the ShaderFactory
|
||||||
// which is only called within GNOME Shell's process.
|
// which is only called within GNOME Shell's process.
|
||||||
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
|
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
|
||||||
const St = await utils.importInShellOnly('gi://St');
|
|
||||||
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
|
|
||||||
const Cogl = await utils.importInShellOnly('gi://Cogl');
|
|
||||||
|
|
||||||
const _ = await utils.importGettext();
|
const _ = await utils.importGettext();
|
||||||
|
|
||||||
@@ -47,12 +44,7 @@ export default class Effect {
|
|||||||
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
|
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
|
||||||
// Create the texture in the first call.
|
// Create the texture in the first call.
|
||||||
if (!this._fontTexture) {
|
if (!this._fontTexture) {
|
||||||
const fontData = GdkPixbuf.Pixbuf.new_from_resource('/img/matrixFont.png');
|
this._fontTexture = utils.getImageResource('/img/matrixFont.png');
|
||||||
this._fontTexture = new St.ImageContent();
|
|
||||||
this._fontTexture.set_data(
|
|
||||||
fontData.get_pixels(),
|
|
||||||
fontData.has_alpha ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888,
|
|
||||||
fontData.width, fontData.height, fontData.rowstride);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store uniform locations of newly created shaders.
|
// Store uniform locations of newly created shaders.
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import * as utils from '../utils.js';
|
|||||||
// preferences process. They are used only in the creator function of the ShaderFactory
|
// preferences process. They are used only in the creator function of the ShaderFactory
|
||||||
// which is only called within GNOME Shell's process.
|
// which is only called within GNOME Shell's process.
|
||||||
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
|
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
|
||||||
const St = await utils.importInShellOnly('gi://St');
|
|
||||||
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
|
|
||||||
const Cogl = await utils.importInShellOnly('gi://Cogl');
|
const Cogl = await utils.importInShellOnly('gi://Cogl');
|
||||||
|
|
||||||
const _ = await utils.importGettext();
|
const _ = await utils.importGettext();
|
||||||
@@ -45,11 +43,7 @@ export default class Effect {
|
|||||||
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
|
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
|
||||||
// Create the texture in the first call.
|
// Create the texture in the first call.
|
||||||
if (!this._brushTexture) {
|
if (!this._brushTexture) {
|
||||||
const brushData = GdkPixbuf.Pixbuf.new_from_resource('/img/brush.png');
|
this._brushTexture = utils.getImageResource('/img/brush.png', true);
|
||||||
this._brushTexture = new St.ImageContent();
|
|
||||||
this._brushTexture.set_data(brushData.get_pixels(),
|
|
||||||
Cogl.PixelFormat.RGBA_8888_PRE, brushData.width,
|
|
||||||
brushData.height, brushData.rowstride);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store uniform locations of newly created shaders.
|
// Store uniform locations of newly created shaders.
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import * as utils from '../utils.js';
|
|||||||
// preferences process. They are used only in the creator function of the ShaderFactory
|
// preferences process. They are used only in the creator function of the ShaderFactory
|
||||||
// which is only called within GNOME Shell's process.
|
// which is only called within GNOME Shell's process.
|
||||||
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
|
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
|
||||||
const St = await utils.importInShellOnly('gi://St');
|
|
||||||
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
|
|
||||||
const Cogl = await utils.importInShellOnly('gi://Cogl');
|
const Cogl = await utils.importInShellOnly('gi://Cogl');
|
||||||
|
|
||||||
const _ = await utils.importGettext();
|
const _ = await utils.importGettext();
|
||||||
@@ -49,10 +47,7 @@ export default class Effect {
|
|||||||
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
|
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
|
||||||
// Create the texture in the first call.
|
// Create the texture in the first call.
|
||||||
if (!this._dustTexture) {
|
if (!this._dustTexture) {
|
||||||
const dustData = GdkPixbuf.Pixbuf.new_from_resource('/img/dust.png');
|
this._dustTexture = utils.getImageResource('/img/dust.png');
|
||||||
this._dustTexture = new St.ImageContent();
|
|
||||||
this._dustTexture.set_data(dustData.get_pixels(), Cogl.PixelFormat.RGB_888,
|
|
||||||
dustData.width, dustData.height, dustData.rowstride);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store uniform locations of newly created shaders.
|
// Store uniform locations of newly created shaders.
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import * as utils from '../utils.js';
|
|||||||
// preferences process. They are used only in the creator function of the ShaderFactory
|
// preferences process. They are used only in the creator function of the ShaderFactory
|
||||||
// which is only called within GNOME Shell's process.
|
// which is only called within GNOME Shell's process.
|
||||||
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
|
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
|
||||||
const St = await utils.importInShellOnly('gi://St');
|
|
||||||
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
|
|
||||||
const Cogl = await utils.importInShellOnly('gi://Cogl');
|
const Cogl = await utils.importInShellOnly('gi://Cogl');
|
||||||
|
|
||||||
const _ = await utils.importGettext();
|
const _ = await utils.importGettext();
|
||||||
@@ -45,10 +43,7 @@ export default class Effect {
|
|||||||
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
|
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
|
||||||
// Create the texture in the first call.
|
// Create the texture in the first call.
|
||||||
if (!this._clawTexture) {
|
if (!this._clawTexture) {
|
||||||
const clawData = GdkPixbuf.Pixbuf.new_from_resource('/img/claws.png');
|
this._clawTexture = utils.getImageResource('/img/claws.png');
|
||||||
this._clawTexture = new St.ImageContent();
|
|
||||||
this._clawTexture.set_data(clawData.get_pixels(), Cogl.PixelFormat.RGB_888,
|
|
||||||
clawData.width, clawData.height, clawData.rowstride);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store uniform locations of newly created shaders.
|
// Store uniform locations of newly created shaders.
|
||||||
|
|||||||
@@ -20,8 +20,10 @@ import GLib from 'gi://GLib';
|
|||||||
// We import some modules optionally. This file is used in the preferences process as well
|
// We import some modules optionally. This file is used in the preferences process as well
|
||||||
// as in the GNOME Shell process. Some modules are only available or required in one of
|
// as in the GNOME Shell process. Some modules are only available or required in one of
|
||||||
// these processes.
|
// these processes.
|
||||||
|
const GdkPixbuf = await importInShellOnly('gi://GdkPixbuf');
|
||||||
const Clutter = await importInShellOnly('gi://Clutter');
|
const Clutter = await importInShellOnly('gi://Clutter');
|
||||||
const Cogl = await importInShellOnly('gi://Cogl');
|
const Cogl = await importInShellOnly('gi://Cogl');
|
||||||
|
const St = await importInShellOnly('gi://St');
|
||||||
|
|
||||||
// We import the Config module. This is done differently in the GNOME Shell process and in
|
// We import the Config module. This is done differently in the GNOME Shell process and in
|
||||||
// the preferences process.
|
// the preferences process.
|
||||||
@@ -117,6 +119,30 @@ export function getStringResource(path) {
|
|||||||
return new TextDecoder().decode(data.get_data());
|
return new TextDecoder().decode(data.get_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reads the contents of an image file contained in the global resources archive. The data
|
||||||
|
// is returned as a St.ImageContent.
|
||||||
|
export function getImageResource(path, premultiplied=false) {
|
||||||
|
const data = GdkPixbuf.Pixbuf.new_from_resource(path);
|
||||||
|
const texture = St.ImageContent.new_with_preferred_size(data.width, data.height);
|
||||||
|
const format = data.has_alpha ? (premultiplied ? Cogl.PixelFormat.RGBA_8888_PRE : Cogl.PixelFormat.RGBA_8888) : Cogl.PixelFormat.RGB_888;
|
||||||
|
|
||||||
|
// https://gitlab.gnome.org/GNOME/gnome-shell/-/commit/44b84e458a22046fedb85701ea25ad08ecc0d43f
|
||||||
|
if (shellVersionIsAtLeast(48, 'beta')) {
|
||||||
|
texture.set_data(
|
||||||
|
global.stage.context.get_backend().get_cogl_context(),
|
||||||
|
data.get_pixels(),
|
||||||
|
format,
|
||||||
|
data.width, data.height, data.rowstride);
|
||||||
|
} else {
|
||||||
|
texture.set_data(
|
||||||
|
data.get_pixels(),
|
||||||
|
format,
|
||||||
|
data.width, data.height, data.rowstride);
|
||||||
|
}
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
// Executes a command asynchronously and returns the output from 'stdout' on success or
|
// Executes a command asynchronously and returns the output from 'stdout' on success or
|
||||||
// throw an error with output from 'stderr' on failure. If given, input will be passed to
|
// throw an error with output from 'stderr' on failure. If given, input will be passed to
|
||||||
// 'stdin' and cancellable can be used to stop the process before it finishes.
|
// 'stdin' and cancellable can be used to stop the process before it finishes.
|
||||||
|
|||||||
Reference in New Issue
Block a user