1 /*
   2  * Copyright (c) 2012, 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 package sun.lwawt;
  27 
  28 import java.awt.AWTException;
  29 import java.awt.BufferCapabilities;
  30 import java.awt.Component;
  31 import java.awt.Image;
  32 
  33 /**
  34  * As lwawt can be used on different platforms with different graphic
  35  * configurations, the general set of methods is necessary. This interface
  36  * collects the methods that should be provided by GraphicsConfiguration,
  37  * simplifying use by the LWAWT.
  38  *
  39  * @author Sergey Bylokhov
  40  */
  41 public interface LWGraphicsConfig {
  42 
  43     /*
  44      * A GraphicsConfiguration must implements following methods to indicate
  45      * that it imposes certain limitations on the maximum size of supported
  46      * textures.
  47      */
  48 
  49     /**
  50      * Returns the maximum width of any texture image. By default return {@code
  51      * Integer.MAX_VALUE}.
  52      */
  53     int getMaxTextureWidth();
  54 
  55     /**
  56      * Returns the maximum height of any texture image. By default return {@code
  57      * Integer.MAX_VALUE}.
  58      */
  59     int getMaxTextureHeight();
  60 
  61     /*
  62      * The following methods correspond to the multi-buffering methods in
  63      * LWComponentPeer.java.
  64      */
  65 
  66     /**
  67      * Checks that the requested configuration is natively supported; if not, an
  68      * AWTException is thrown.
  69      */
  70     void assertOperationSupported(int numBuffers, BufferCapabilities caps)
  71             throws AWTException;
  72 
  73     /**
  74      * Creates a back buffer for the given peer and returns the image wrapper.
  75      */
  76     Image createBackBuffer(LWComponentPeer<?, ?> peer);
  77 
  78     /**
  79      * Destroys the back buffer object.
  80      */
  81     void destroyBackBuffer(Image backBuffer);
  82 
  83     /**
  84      * Performs the native flip operation for the given target Component. Our
  85      * flip is implemented through normal drawImage() to the graphic object,
  86      * because of our components uses a graphic object of the container(in this
  87      * case we also apply necessary constrains)
  88      */
  89     void flip(LWComponentPeer<?, ?> peer, Image backBuffer, int x1, int y1,
  90               int x2, int y2, BufferCapabilities.FlipContents flipAction);
  91 
  92     /**
  93      * Creates a new hidden-acceleration image of the given width and height
  94      * that is associated with the target Component.
  95      */
  96     Image createAcceleratedImage(Component target, int width, int height);
  97 }