[libbluray-devel] Implement J2SE DVBGraphics.setDVBComposite()

hpi1 git at videolan.org
Mon Oct 20 12:12:15 CEST 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Oct 20 13:10:08 2014 +0300| [619a578cc83319d879e0c24834f2a3a4e6489f53] | committer: hpi1

Implement J2SE DVBGraphics.setDVBComposite()

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=619a578cc83319d879e0c24834f2a3a4e6489f53
---

 .../bdj/java-j2se/org/dvb/ui/DVBGraphicsImpl.java  |   25 ++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/libbluray/bdj/java-j2se/org/dvb/ui/DVBGraphicsImpl.java b/src/libbluray/bdj/java-j2se/org/dvb/ui/DVBGraphicsImpl.java
index f0ac0b9..6600634 100644
--- a/src/libbluray/bdj/java-j2se/org/dvb/ui/DVBGraphicsImpl.java
+++ b/src/libbluray/bdj/java-j2se/org/dvb/ui/DVBGraphicsImpl.java
@@ -19,6 +19,7 @@
 
 package org.dvb.ui;
 
+import java.awt.AlphaComposite;
 import java.awt.Color;
 import java.awt.Composite;
 import java.awt.Font;
@@ -315,25 +316,43 @@ public class DVBGraphicsImpl extends DVBGraphics {
     /*
      * DVBGraphics methods
      */
+
     public int[] getAvailableCompositeRules()
     {
+        /*
         int[] rules = { DVBAlphaComposite.CLEAR, DVBAlphaComposite.SRC,
                         DVBAlphaComposite.SRC_OVER, DVBAlphaComposite.DST_OVER,
                         DVBAlphaComposite.SRC_IN, DVBAlphaComposite.DST_IN,
                         DVBAlphaComposite.SRC_OUT, DVBAlphaComposite.DST_OUT };
+        */
+        int[] rules = {
+            DVBAlphaComposite.CLEAR,
+            DVBAlphaComposite.SRC,
+            DVBAlphaComposite.SRC_OVER };
 
         return rules;
     }
 
     public DVBAlphaComposite getDVBComposite()
     {
-        return alphaComposite;
+        Composite comp = gfx.getComposite();
+        if (!(comp instanceof AlphaComposite))
+            return null;
+        return DVBAlphaComposite.getInstance(
+                        ((AlphaComposite)comp).getRule(),
+                        ((AlphaComposite)comp).getAlpha());
     }
 
     public void setDVBComposite(DVBAlphaComposite comp)
             throws UnsupportedDrawingOperationException
     {
-        this.alphaComposite = comp;
+        if ((comp.getRule() < DVBAlphaComposite.CLEAR) ||
+            (comp.getRule() > DVBAlphaComposite.SRC_OVER)) {
+            org.videolan.Logger.getLogger("DVBGraphics").error("setDVBComposite() FAILED: unsupported rule " + comp.getRule());
+            throw new UnsupportedDrawingOperationException("Unsupported composition rule: " + comp.getRule());
+        }
+
+        gfx.setComposite(AlphaComposite.getInstance(comp.getRule(), comp.getAlpha()));
     }
 
     /*
@@ -509,6 +528,4 @@ public class DVBGraphicsImpl extends DVBGraphics {
     {
         gfx.translate(tx, ty);
     }
-
-    private DVBAlphaComposite alphaComposite = DVBAlphaComposite.Clear;
 }



More information about the libbluray-devel mailing list