GithubHelp home page GithubHelp logo

JRE 15.0.2+10, JavaFx, embedded ARM Raspberry Pi 3: setting opacity(0) fails when using hardware accelerated pipeline about liberica HOT 3 CLOSED

bell-sw avatar bell-sw commented on June 12, 2024
JRE 15.0.2+10, JavaFx, embedded ARM Raspberry Pi 3: setting opacity(0) fails when using hardware accelerated pipeline

from liberica.

Comments (3)

AlexanderScherbatiy avatar AlexanderScherbatiy commented on June 12, 2024

Setting opacity on a Stage in Monocle on Raspberry Pi 3 is no-op because there is no a window which is drawn on a desktop.
Monocle draws a scene directly to the screen: MonocleWindow._setAlpha()

I wrote a simple sample where toggle buttons are used to set VBox and Stage opacity and run in on Rasperry Pi 3B+.

sudo java -Dprism.verbose=true -Djavafx.platform=monocle -Dprism.verbose=es2 JavaFXSample

Setting opacity for VBox where all components are placed makes all components transparent.
Could the workaround where opacity is set not to the stage but to a pane which contains all components work for your application?

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.ToggleButton;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;


public class JavaFXSample extends Application {

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Sample");

        Label label = new Label("Set opacity:");

        ToggleButton noneOpacity = new ToggleButton("None");
        ToggleButton vboxOpacity = new ToggleButton("VBox");
        ToggleButton stageOpacity = new ToggleButton("Stage");

        ToggleGroup toggleGroup = new ToggleGroup();

        noneOpacity.setToggleGroup(toggleGroup);
        vboxOpacity.setToggleGroup(toggleGroup);
        stageOpacity.setToggleGroup(toggleGroup);
        noneOpacity.setSelected(true);

        VBox vbox = new VBox(10, label, noneOpacity, vboxOpacity, stageOpacity);

        noneOpacity.setOnAction(event -> {
            vbox.setOpacity(1.0);
            primaryStage.setOpacity(1.0);
        });

        vboxOpacity.setOnAction(event -> {
            primaryStage.setOpacity(1.0);
            vbox.setOpacity(0.3);
        });

        stageOpacity.setOnAction(event -> {
            vbox.setOpacity(1.0);
            primaryStage.setOpacity(0.3);
        });

        Scene scene = new Scene(vbox, 400, 300);

        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        Application.launch(args);
    }
}

from liberica.

freddieFishCake avatar freddieFishCake commented on June 12, 2024

Thanks Alex,
your example gave me good hints to get the transparency working for my use case.
:-)

This what worked for me:
` @OverRide

public void start(Stage primaryStage) throws IOException {

// Even in direct frame buffer mode we need to set this in addition to setting the background-color style of the stackPane

primaryStage.initStyle(StageStyle.TRANSPARENT);

StackPane pane = new StackPane();

// This only seems to work when combined with stage.initStyle(StageStyle.TRANSPARENT)

pane.setStyle("-fx-background-color: transparent;");

ImageView imageView = getTestImage();

pane.getChildren().add(imageView);

`

from liberica.

freddieFishCake avatar freddieFishCake commented on June 12, 2024

Oops, I may have spoken too soon - I realised that my test was using the default (software) pipeline .. as soon as I switched to hardware accelerated I got the opaque black rectangle again.
I will distill the app down to the simplest possible example and get back to you.

from liberica.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.