1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 
  27 package java.awt;
  28 
  29 import java.awt.image.ColorModel;
  30 
  31 import sun.awt.AWTAccessor;
  32 import sun.awt.AppContext;
  33 import sun.awt.SunToolkit;
  34 
  35 /**
  36  * The <code>GraphicsDevice</code> class describes the graphics devices
  37  * that might be available in a particular graphics environment.  These
  38  * include screen and printer devices. Note that there can be many screens
  39  * and many printers in an instance of {@link GraphicsEnvironment}. Each
  40  * graphics device has one or more {@link GraphicsConfiguration} objects
  41  * associated with it.  These objects specify the different configurations
  42  * in which the <code>GraphicsDevice</code> can be used.
  43  * <p>
  44  * In a multi-screen environment, the <code>GraphicsConfiguration</code>
  45  * objects can be used to render components on multiple screens.  The
  46  * following code sample demonstrates how to create a <code>JFrame</code>
  47  * object for each <code>GraphicsConfiguration</code> on each screen
  48  * device in the <code>GraphicsEnvironment</code>:
  49  * <pre>
  50  *   GraphicsEnvironment ge = GraphicsEnvironment.
  51  *   getLocalGraphicsEnvironment();
  52  *   GraphicsDevice[] gs = ge.getScreenDevices();
  53  *   for (int j = 0; j < gs.length; j++) {
  54  *      GraphicsDevice gd = gs[j];
  55  *      GraphicsConfiguration[] gc =
  56  *      gd.getConfigurations();
  57  *      for (int i=0; i < gc.length; i++) {
  58  *         JFrame f = new
  59  *         JFrame(gs[j].getDefaultConfiguration());
  60  *         Canvas c = new Canvas(gc[i]);
  61  *         Rectangle gcBounds = gc[i].getBounds();
  62  *         int xoffs = gcBounds.x;
  63  *         int yoffs = gcBounds.y;
  64  *         f.getContentPane().add(c);
  65  *         f.setLocation((i*50)+xoffs, (i*60)+yoffs);
  66  *         f.show();
  67  *      }
  68  *   }
  69  * </pre>
  70  * <p>
  71  * For more information on full-screen exclusive mode API, see the
  72  * <a href="http://docs.oracle.com/javase/tutorial/extra/fullscreen/index.html">
  73  * Full-Screen Exclusive Mode API Tutorial</a>.
  74  *
  75  * @see GraphicsEnvironment
  76  * @see GraphicsConfiguration
  77  */
  78 public abstract class GraphicsDevice {
  79 
  80     private Window fullScreenWindow;
  81     private AppContext fullScreenAppContext; // tracks which AppContext
  82                                              // created the FS window
  83     // this lock is used for making synchronous changes to the AppContext's
  84     // current full screen window
  85     private final Object fsAppContextLock = new Object();
  86 
  87     private Rectangle windowedModeBounds;
  88 
  89     /**
  90      * This is an abstract class that cannot be instantiated directly.
  91      * Instances must be obtained from a suitable factory or query method.
  92      * @see GraphicsEnvironment#getScreenDevices
  93      * @see GraphicsEnvironment#getDefaultScreenDevice
  94      * @see GraphicsConfiguration#getDevice
  95      */
  96     protected GraphicsDevice() {
  97     }
  98 
  99     /**
 100      * Device is a raster screen.
 101      */
 102     public final static int TYPE_RASTER_SCREEN          = 0;
 103 
 104     /**
 105      * Device is a printer.
 106      */
 107     public final static int TYPE_PRINTER                = 1;
 108 
 109     /**
 110      * Device is an image buffer.  This buffer can reside in device
 111      * or system memory but it is not physically viewable by the user.
 112      */
 113     public final static int TYPE_IMAGE_BUFFER           = 2;
 114 
 115     /**
 116      * Kinds of translucency supported by the underlying system.
 117      *
 118      * @see #isWindowTranslucencySupported
 119      *
 120      * @since 1.7
 121      */
 122     public static enum WindowTranslucency {
 123         /**
 124          * Represents support in the underlying system for windows each pixel
 125          * of which is guaranteed to be either completely opaque, with
 126          * an alpha value of 1.0, or completely transparent, with an alpha
 127          * value of 0.0.
 128          */
 129         PERPIXEL_TRANSPARENT,
 130         /**
 131          * Represents support in the underlying system for windows all of
 132          * the pixels of which have the same alpha value between or including
 133          * 0.0 and 1.0.
 134          */
 135         TRANSLUCENT,
 136         /**
 137          * Represents support in the underlying system for windows that
 138          * contain or might contain pixels with arbitrary alpha values
 139          * between and including 0.0 and 1.0.
 140          */
 141         PERPIXEL_TRANSLUCENT;
 142     }
 143 
 144     /**
 145      * Returns the type of this <code>GraphicsDevice</code>.
 146      * @return the type of this <code>GraphicsDevice</code>, which can
 147      * either be TYPE_RASTER_SCREEN, TYPE_PRINTER or TYPE_IMAGE_BUFFER.
 148      * @see #TYPE_RASTER_SCREEN
 149      * @see #TYPE_PRINTER
 150      * @see #TYPE_IMAGE_BUFFER
 151      */
 152     public abstract int getType();
 153 
 154     /**
 155      * Returns the identification string associated with this
 156      * <code>GraphicsDevice</code>.
 157      * <p>
 158      * A particular program might use more than one
 159      * <code>GraphicsDevice</code> in a <code>GraphicsEnvironment</code>.
 160      * This method returns a <code>String</code> identifying a
 161      * particular <code>GraphicsDevice</code> in the local
 162      * <code>GraphicsEnvironment</code>.  Although there is
 163      * no public method to set this <code>String</code>, a programmer can
 164      * use the <code>String</code> for debugging purposes.  Vendors of
 165      * the Java&trade; Runtime Environment can
 166      * format the return value of the <code>String</code>.  To determine
 167      * how to interpret the value of the <code>String</code>, contact the
 168      * vendor of your Java Runtime.  To find out who the vendor is, from
 169      * your program, call the
 170      * {@link System#getProperty(String) getProperty} method of the
 171      * System class with "java.vendor".
 172      * @return a <code>String</code> that is the identification
 173      * of this <code>GraphicsDevice</code>.
 174      */
 175     public abstract String getIDstring();
 176 
 177     /**
 178      * Returns all of the <code>GraphicsConfiguration</code>
 179      * objects associated with this <code>GraphicsDevice</code>.
 180      * @return an array of <code>GraphicsConfiguration</code>
 181      * objects that are associated with this
 182      * <code>GraphicsDevice</code>.
 183      */
 184     public abstract GraphicsConfiguration[] getConfigurations();
 185 
 186     /**
 187      * Returns the default <code>GraphicsConfiguration</code>
 188      * associated with this <code>GraphicsDevice</code>.
 189      * @return the default <code>GraphicsConfiguration</code>
 190      * of this <code>GraphicsDevice</code>.
 191      */
 192     public abstract GraphicsConfiguration getDefaultConfiguration();
 193 
 194     /**
 195      * Returns the "best" configuration possible that passes the
 196      * criteria defined in the {@link GraphicsConfigTemplate}.
 197      * @param gct the <code>GraphicsConfigTemplate</code> object
 198      * used to obtain a valid <code>GraphicsConfiguration</code>
 199      * @return a <code>GraphicsConfiguration</code> that passes
 200      * the criteria defined in the specified
 201      * <code>GraphicsConfigTemplate</code>.
 202      * @see GraphicsConfigTemplate
 203      */
 204     public GraphicsConfiguration
 205            getBestConfiguration(GraphicsConfigTemplate gct) {
 206         GraphicsConfiguration[] configs = getConfigurations();
 207         return gct.getBestConfiguration(configs);
 208     }
 209 
 210     /**
 211      * Returns <code>true</code> if this <code>GraphicsDevice</code>
 212      * supports full-screen exclusive mode.
 213      * If a SecurityManager is installed, its
 214      * <code>checkPermission</code> method will be called
 215      * with <code>AWTPermission("fullScreenExclusive")</code>.
 216      * <code>isFullScreenSupported</code> returns true only if
 217      * that permission is granted.
 218      * @return whether full-screen exclusive mode is available for
 219      * this graphics device
 220      * @see java.awt.AWTPermission
 221      * @since 1.4
 222      */
 223     public boolean isFullScreenSupported() {
 224         return false;
 225     }
 226 
 227     /**
 228      * Enter full-screen mode, or return to windowed mode.  The entered
 229      * full-screen mode may be either exclusive or simulated.  Exclusive
 230      * mode is only available if <code>isFullScreenSupported</code>
 231      * returns <code>true</code>.
 232      * <p>
 233      * Exclusive mode implies:
 234      * <ul>
 235      * <li>Windows cannot overlap the full-screen window.  All other application
 236      * windows will always appear beneath the full-screen window in the Z-order.
 237      * <li>There can be only one full-screen window on a device at any time,
 238      * so calling this method while there is an existing full-screen Window
 239      * will cause the existing full-screen window to
 240      * return to windowed mode.
 241      * <li>Input method windows are disabled.  It is advisable to call
 242      * <code>Component.enableInputMethods(false)</code> to make a component
 243      * a non-client of the input method framework.
 244      * </ul>
 245      * <p>
 246      * The simulated full-screen mode places and resizes the window to the maximum
 247      * possible visible area of the screen. However, the native windowing system
 248      * may modify the requested geometry-related data, so that the {@code Window} object
 249      * is placed and sized in a way that corresponds closely to the desktop settings.
 250      * <p>
 251      * When entering full-screen mode, if the window to be used as a
 252      * full-screen window is not visible, this method will make it visible.
 253      * It will remain visible when returning to windowed mode.
 254      * <p>
 255      * When entering full-screen mode, all the translucency effects are reset for
 256      * the window. Its shape is set to {@code null}, the opacity value is set to
 257      * 1.0f, and the background color alpha is set to 255 (completely opaque).
 258      * These values are not restored when returning to windowed mode.
 259      * <p>
 260      * It is unspecified and platform-dependent how decorated windows operate
 261      * in full-screen mode. For this reason, it is recommended to turn off
 262      * the decorations in a {@code Frame} or {@code Dialog} object by using the
 263      * {@code setUndecorated} method.
 264      * <p>
 265      * When returning to windowed mode from an exclusive full-screen window,
 266      * any display changes made by calling {@code setDisplayMode} are
 267      * automatically restored to their original state.
 268      *
 269      * @param w a window to use as the full-screen window; {@code null}
 270      * if returning to windowed mode.  Some platforms expect the
 271      * fullscreen window to be a top-level component (i.e., a {@code Frame});
 272      * therefore it is preferable to use a {@code Frame} here rather than a
 273      * {@code Window}.
 274      *
 275      * @see #isFullScreenSupported
 276      * @see #getFullScreenWindow
 277      * @see #setDisplayMode
 278      * @see Component#enableInputMethods
 279      * @see Component#setVisible
 280      * @see Frame#setUndecorated
 281      * @see Dialog#setUndecorated
 282      *
 283      * @since 1.4
 284      */
 285     public void setFullScreenWindow(Window w) {
 286         if (w != null) {
 287             if (w.getShape() != null) {
 288                 w.setShape(null);
 289             }
 290             if (w.getOpacity() < 1.0f) {
 291                 w.setOpacity(1.0f);
 292             }
 293             if (!w.isOpaque()) {
 294                 Color bgColor = w.getBackground();
 295                 bgColor = new Color(bgColor.getRed(), bgColor.getGreen(),
 296                                     bgColor.getBlue(), 255);
 297                 w.setBackground(bgColor);
 298             }
 299             // Check if this window is in fullscreen mode on another device.
 300             final GraphicsConfiguration gc = w.getGraphicsConfiguration();
 301             if (gc != null && gc.getDevice() != this
 302                     && gc.getDevice().getFullScreenWindow() == w) {
 303                 gc.getDevice().setFullScreenWindow(null);
 304             }
 305         }
 306         if (fullScreenWindow != null && windowedModeBounds != null) {
 307             // if the window went into fs mode before it was realized it may
 308             // have (0,0) dimensions
 309             if (windowedModeBounds.width  == 0) windowedModeBounds.width  = 1;
 310             if (windowedModeBounds.height == 0) windowedModeBounds.height = 1;
 311             fullScreenWindow.setBounds(windowedModeBounds);
 312         }
 313         // Set the full screen window
 314         synchronized (fsAppContextLock) {
 315             // Associate fullscreen window with current AppContext
 316             if (w == null) {
 317                 fullScreenAppContext = null;
 318             } else {
 319                 fullScreenAppContext = AppContext.getAppContext();
 320             }
 321             fullScreenWindow = w;
 322         }
 323         if (fullScreenWindow != null) {
 324             windowedModeBounds = fullScreenWindow.getBounds();
 325             // Note that we use the graphics configuration of the device,
 326             // not the window's, because we're setting the fs window for
 327             // this device.
 328             final GraphicsConfiguration gc = getDefaultConfiguration();
 329             final Rectangle screenBounds = gc.getBounds();
 330             if (SunToolkit.isDispatchThreadForAppContext(fullScreenWindow)) {
 331                 // Update graphics configuration here directly and do not wait
 332                 // asynchronous notification from the peer. Note that
 333                 // setBounds() will reset a GC, if it was set incorrectly.
 334                 fullScreenWindow.setGraphicsConfiguration(gc);
 335             }
 336             fullScreenWindow.setBounds(screenBounds.x, screenBounds.y,
 337                                        screenBounds.width, screenBounds.height);
 338             fullScreenWindow.setVisible(true);
 339             fullScreenWindow.toFront();
 340         }
 341     }
 342 
 343     /**
 344      * Returns the {@code Window} object representing the
 345      * full-screen window if the device is in full-screen mode.
 346      *
 347      * @return the full-screen window, or {@code null} if the device is
 348      * not in full-screen mode. The {@code Window} object can differ
 349      * from the object previously set by {@code setFullScreenWindow}.
 350      * @see #setFullScreenWindow(Window)
 351      * @since 1.4
 352      */
 353     public Window getFullScreenWindow() {
 354         Window returnWindow = null;
 355         synchronized (fsAppContextLock) {
 356             // Only return a handle to the current fs window if we are in the
 357             // same AppContext that set the fs window
 358             if (fullScreenAppContext == AppContext.getAppContext()) {
 359                 returnWindow = fullScreenWindow;
 360             }
 361         }
 362         return returnWindow;
 363     }
 364 
 365     /**
 366      * Returns <code>true</code> if this <code>GraphicsDevice</code>
 367      * supports low-level display changes.
 368      * On some platforms low-level display changes may only be allowed in
 369      * full-screen exclusive mode (i.e., if {@link #isFullScreenSupported()}
 370      * returns {@code true} and the application has already entered
 371      * full-screen mode using {@link #setFullScreenWindow}).
 372      * @return whether low-level display changes are supported for this
 373      * graphics device.
 374      * @see #isFullScreenSupported
 375      * @see #setDisplayMode
 376      * @see #setFullScreenWindow
 377      * @since 1.4
 378      */
 379     public boolean isDisplayChangeSupported() {
 380         return false;
 381     }
 382 
 383     /**
 384      * Sets the display mode of this graphics device. This is only allowed
 385      * if {@link #isDisplayChangeSupported()} returns {@code true} and may
 386      * require first entering full-screen exclusive mode using
 387      * {@link #setFullScreenWindow} providing that full-screen exclusive mode is
 388      * supported (i.e., {@link #isFullScreenSupported()} returns
 389      * {@code true}).
 390      * <p>
 391      *
 392      * The display mode must be one of the display modes returned by
 393      * {@link #getDisplayModes()}, with one exception: passing a display mode
 394      * with {@link DisplayMode#REFRESH_RATE_UNKNOWN} refresh rate will result in
 395      * selecting a display mode from the list of available display modes with
 396      * matching width, height and bit depth.
 397      * However, passing a display mode with {@link DisplayMode#BIT_DEPTH_MULTI}
 398      * for bit depth is only allowed if such mode exists in the list returned by
 399      * {@link #getDisplayModes()}.
 400      * <p>
 401      * Example code:
 402      * <pre><code>
 403      * Frame frame;
 404      * DisplayMode newDisplayMode;
 405      * GraphicsDevice gd;
 406      * // create a Frame, select desired DisplayMode from the list of modes
 407      * // returned by gd.getDisplayModes() ...
 408      *
 409      * if (gd.isFullScreenSupported()) {
 410      *     gd.setFullScreenWindow(frame);
 411      * } else {
 412      *    // proceed in non-full-screen mode
 413      *    frame.setSize(...);
 414      *    frame.setLocation(...);
 415      *    frame.setVisible(true);
 416      * }
 417      *
 418      * if (gd.isDisplayChangeSupported()) {
 419      *     gd.setDisplayMode(newDisplayMode);
 420      * }
 421      * </code></pre>
 422      *
 423      * @param dm The new display mode of this graphics device.
 424      * @exception IllegalArgumentException if the <code>DisplayMode</code>
 425      * supplied is <code>null</code>, or is not available in the array returned
 426      * by <code>getDisplayModes</code>
 427      * @exception UnsupportedOperationException if
 428      * <code>isDisplayChangeSupported</code> returns <code>false</code>
 429      * @see #getDisplayMode
 430      * @see #getDisplayModes
 431      * @see #isDisplayChangeSupported
 432      * @since 1.4
 433      */
 434     public void setDisplayMode(DisplayMode dm) {
 435         throw new UnsupportedOperationException("Cannot change display mode");
 436     }
 437 
 438     /**
 439      * Returns the current display mode of this
 440      * <code>GraphicsDevice</code>.
 441      * The returned display mode is allowed to have a refresh rate
 442      * {@link DisplayMode#REFRESH_RATE_UNKNOWN} if it is indeterminate.
 443      * Likewise, the returned display mode is allowed to have a bit depth
 444      * {@link DisplayMode#BIT_DEPTH_MULTI} if it is indeterminate or if multiple
 445      * bit depths are supported.
 446      * @return the current display mode of this graphics device.
 447      * @see #setDisplayMode(DisplayMode)
 448      * @since 1.4
 449      */
 450     public DisplayMode getDisplayMode() {
 451         GraphicsConfiguration gc = getDefaultConfiguration();
 452         Rectangle r = gc.getBounds();
 453         ColorModel cm = gc.getColorModel();
 454         return new DisplayMode(r.width, r.height, cm.getPixelSize(), 0);
 455     }
 456 
 457     /**
 458      * Returns all display modes available for this
 459      * <code>GraphicsDevice</code>.
 460      * The returned display modes are allowed to have a refresh rate
 461      * {@link DisplayMode#REFRESH_RATE_UNKNOWN} if it is indeterminate.
 462      * Likewise, the returned display modes are allowed to have a bit depth
 463      * {@link DisplayMode#BIT_DEPTH_MULTI} if it is indeterminate or if multiple
 464      * bit depths are supported.
 465      * @return all of the display modes available for this graphics device.
 466      * @since 1.4
 467      */
 468     public DisplayMode[] getDisplayModes() {
 469         return new DisplayMode[] { getDisplayMode() };
 470     }
 471 
 472     /**
 473      * This method returns the number of bytes available in
 474      * accelerated memory on this device.
 475      * Some images are created or cached
 476      * in accelerated memory on a first-come,
 477      * first-served basis.  On some operating systems,
 478      * this memory is a finite resource.  Calling this method
 479      * and scheduling the creation and flushing of images carefully may
 480      * enable applications to make the most efficient use of
 481      * that finite resource.
 482      * <br>
 483      * Note that the number returned is a snapshot of how much
 484      * memory is available; some images may still have problems
 485      * being allocated into that memory.  For example, depending
 486      * on operating system, driver, memory configuration, and
 487      * thread situations, the full extent of the size reported
 488      * may not be available for a given image.  There are further
 489      * inquiry methods on the {@link ImageCapabilities} object
 490      * associated with a VolatileImage that can be used to determine
 491      * whether a particular VolatileImage has been created in accelerated
 492      * memory.
 493      * @return number of bytes available in accelerated memory.
 494      * A negative return value indicates that the amount of accelerated memory
 495      * on this GraphicsDevice is indeterminate.
 496      * @see java.awt.image.VolatileImage#flush
 497      * @see ImageCapabilities#isAccelerated
 498      * @since 1.4
 499      */
 500     public int getAvailableAcceleratedMemory() {
 501         return -1;
 502     }
 503 
 504     /**
 505      * Returns whether the given level of translucency is supported by
 506      * this graphics device.
 507      *
 508      * @param translucencyKind a kind of translucency support
 509      * @return whether the given translucency kind is supported
 510      *
 511      * @since 1.7
 512      */
 513     public boolean isWindowTranslucencySupported(WindowTranslucency translucencyKind) {
 514         switch (translucencyKind) {
 515             case PERPIXEL_TRANSPARENT:
 516                 return isWindowShapingSupported();
 517             case TRANSLUCENT:
 518                 return isWindowOpacitySupported();
 519             case PERPIXEL_TRANSLUCENT:
 520                 return isWindowPerpixelTranslucencySupported();
 521         }
 522         return false;
 523     }
 524 
 525     /**
 526      * Returns whether the windowing system supports changing the shape
 527      * of top-level windows.
 528      * Note that this method may sometimes return true, but the native
 529      * windowing system may still not support the concept of
 530      * shaping (due to the bugs in the windowing system).
 531      */
 532     static boolean isWindowShapingSupported() {
 533         Toolkit curToolkit = Toolkit.getDefaultToolkit();
 534         if (!(curToolkit instanceof SunToolkit)) {
 535             return false;
 536         }
 537         return ((SunToolkit)curToolkit).isWindowShapingSupported();
 538     }
 539 
 540     /**
 541      * Returns whether the windowing system supports changing the opacity
 542      * value of top-level windows.
 543      * Note that this method may sometimes return true, but the native
 544      * windowing system may still not support the concept of
 545      * translucency (due to the bugs in the windowing system).
 546      */
 547     static boolean isWindowOpacitySupported() {
 548         Toolkit curToolkit = Toolkit.getDefaultToolkit();
 549         if (!(curToolkit instanceof SunToolkit)) {
 550             return false;
 551         }
 552         return ((SunToolkit)curToolkit).isWindowOpacitySupported();
 553     }
 554 
 555     boolean isWindowPerpixelTranslucencySupported() {
 556         /*
 557          * Per-pixel alpha is supported if all the conditions are TRUE:
 558          *    1. The toolkit is a sort of SunToolkit
 559          *    2. The toolkit supports translucency in general
 560          *        (isWindowTranslucencySupported())
 561          *    3. There's at least one translucency-capable
 562          *        GraphicsConfiguration
 563          */
 564         Toolkit curToolkit = Toolkit.getDefaultToolkit();
 565         if (!(curToolkit instanceof SunToolkit)) {
 566             return false;
 567         }
 568         if (!((SunToolkit)curToolkit).isWindowTranslucencySupported()) {
 569             return false;
 570         }
 571 
 572         // TODO: cache translucency capable GC
 573         return getTranslucencyCapableGC() != null;
 574     }
 575 
 576     GraphicsConfiguration getTranslucencyCapableGC() {
 577         // If the default GC supports translucency return true.
 578         // It is important to optimize the verification this way,
 579         // see CR 6661196 for more details.
 580         GraphicsConfiguration defaultGC = getDefaultConfiguration();
 581         if (defaultGC.isTranslucencyCapable()) {
 582             return defaultGC;
 583         }
 584 
 585         // ... otherwise iterate through all the GCs.
 586         GraphicsConfiguration[] configs = getConfigurations();
 587         for (int j = 0; j < configs.length; j++) {
 588             if (configs[j].isTranslucencyCapable()) {
 589                 return configs[j];
 590             }
 591         }
 592 
 593         return null;
 594     }
 595 }