Makefile.am (gtk_awt_peer_sources): Add GtkVolatileImage.java.
2005-05-06 Thomas Fitzsimmons <fitzsim@redhat.com> * Makefile.am (gtk_awt_peer_sources): Add GtkVolatileImage.java. * Makefile.in: Regenerate. * gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java (createCompatibleVolatileImage(int,int)): Implement. (createCompatibleVolatileImage(int,int,ImageCapabilities)): Likewise. * gnu/java/awt/peer/gtk/GtkComponentPeer.java (backBuffer, caps): New fields. (createVolatileImage): Implement. (createBuffers): Likewise. (getBackBuffer): Likewise. (flip): Likewise. (destroyBuffers): Likewise. * gnu/java/awt/peer/gtk/GtkVolatileImage.java: New file. * java/awt/Canvas.java (CanvasBltBufferStrategy): New class. (CanvasFlipBufferStrategy): Likewise. (createBufferStrategy(int)): New method. (createBufferStrategy(int,BufferCapabilities)): Likewise. * java/awt/Component.java (BltBufferStrategy): Implement and document class. (FlipBufferStrategy): Likewise. * java/awt/Window.java (WindowBltBufferStrategy): New class. (WindowFlipBufferStrategy): Likewise. (createBufferStrategy(int)): New method. (createBufferStrategy(int,BufferCapabilities)): Likewise. (getBufferStrategy): Likewise. * java/awt/BufferCapabilities.java (BufferCapabilities): Rename front to frontCaps and back to backCaps. From-SVN: r99336
This commit is contained in:
committed by
Thomas Fitzsimmons
parent
91a01f21ab
commit
2ed0018eb4
@@ -178,6 +178,157 @@ public class Canvas
|
||||
return accessibleContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* A BltBufferStrategy for canvases.
|
||||
*/
|
||||
private class CanvasBltBufferStrategy extends BltBufferStrategy
|
||||
{
|
||||
/**
|
||||
* Creates a block transfer strategy for this canvas.
|
||||
*
|
||||
* @param numBuffers the number of buffers in this strategy
|
||||
* @param accelerated true if the buffer should be accelerated,
|
||||
* false otherwise
|
||||
*/
|
||||
CanvasBltBufferStrategy(int numBuffers, boolean accelerated)
|
||||
{
|
||||
super(numBuffers,
|
||||
new BufferCapabilities(new ImageCapabilities(accelerated),
|
||||
new ImageCapabilities(accelerated),
|
||||
BufferCapabilities.FlipContents.COPIED));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A FlipBufferStrategy for canvases.
|
||||
*/
|
||||
private class CanvasFlipBufferStrategy extends FlipBufferStrategy
|
||||
{
|
||||
/**
|
||||
* Creates a flip buffer strategy for this canvas.
|
||||
*
|
||||
* @param numBuffers the number of buffers in this strategy
|
||||
*
|
||||
* @throws AWTException if the requested number of buffers is not
|
||||
* supported
|
||||
*/
|
||||
CanvasFlipBufferStrategy(int numBuffers)
|
||||
throws AWTException
|
||||
{
|
||||
super(numBuffers,
|
||||
new BufferCapabilities(new ImageCapabilities(true),
|
||||
new ImageCapabilities(true),
|
||||
BufferCapabilities.FlipContents.COPIED));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a buffering strategy that manages how this canvas is
|
||||
* repainted. This method attempts to create the optimum strategy
|
||||
* based on the desired number of buffers. Hardware or software
|
||||
* acceleration may be used.
|
||||
*
|
||||
* createBufferStrategy attempts different levels of optimization,
|
||||
* but guarantees that some strategy with the requested number of
|
||||
* buffers will be created even if it is not optimal. First it
|
||||
* attempts to create a page flipping strategy, then an accelerated
|
||||
* blitting strategy, then an unaccelerated blitting strategy.
|
||||
*
|
||||
* Calling this method causes any existing buffer strategy to be
|
||||
* destroyed.
|
||||
*
|
||||
* @param numBuffers the number of buffers in this strategy
|
||||
*
|
||||
* @throws IllegalArgumentException if requested number of buffers
|
||||
* is less than one
|
||||
* @throws IllegalStateException if this canvas is not displayable
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public void createBufferStrategy(int numBuffers)
|
||||
{
|
||||
if (numBuffers < 1)
|
||||
throw new IllegalArgumentException("Canvas.createBufferStrategy: number"
|
||||
+ " of buffers is less than one");
|
||||
|
||||
if (!isDisplayable())
|
||||
throw new IllegalStateException("Canvas.createBufferStrategy: canvas is"
|
||||
+ " not displayable");
|
||||
|
||||
// try a flipping strategy
|
||||
try
|
||||
{
|
||||
bufferStrategy = new CanvasFlipBufferStrategy(numBuffers);
|
||||
return;
|
||||
}
|
||||
catch (AWTException e)
|
||||
{
|
||||
}
|
||||
|
||||
// try an accelerated blitting strategy
|
||||
try
|
||||
{
|
||||
bufferStrategy = new CanvasBltBufferStrategy(numBuffers, true);
|
||||
}
|
||||
catch (AWTException e)
|
||||
{
|
||||
}
|
||||
|
||||
// fall back to an unaccelerated blitting strategy
|
||||
try
|
||||
{
|
||||
bufferStrategy = new CanvasBltBufferStrategy(numBuffers, false);
|
||||
}
|
||||
catch (AWTException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a buffering strategy that manages how this canvas is
|
||||
* repainted. This method attempts to create a strategy based on
|
||||
* the specified capabilities and throws an exception if the
|
||||
* requested strategy is not supported.
|
||||
*
|
||||
* Calling this method causes any existing buffer strategy to be
|
||||
* destroyed.
|
||||
*
|
||||
* @param numBuffers the number of buffers in this strategy
|
||||
* @param caps the requested buffering capabilities
|
||||
*
|
||||
* @throws AWTException if the requested capabilities are not
|
||||
* supported
|
||||
* @throws IllegalArgumentException if requested number of buffers
|
||||
* is less than one or if caps is null
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public void createBufferStrategy(int numBuffers,
|
||||
BufferCapabilities caps)
|
||||
{
|
||||
if (numBuffers < 1)
|
||||
throw new IllegalArgumentException("Canvas.createBufferStrategy: number"
|
||||
+ " of buffers is less than one");
|
||||
|
||||
if (caps == null)
|
||||
throw new IllegalArgumentException("Canvas.createBufferStrategy:"
|
||||
+ " capabilities object is null");
|
||||
|
||||
// a flipping strategy was requested
|
||||
if (caps.isPageFlipping())
|
||||
{
|
||||
try
|
||||
{
|
||||
bufferStrategy = new CanvasFlipBufferStrategy(numBuffers);
|
||||
}
|
||||
catch (AWTException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
bufferStrategy = new CanvasBltBufferStrategy(numBuffers, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the buffer strategy used by the canvas.
|
||||
*
|
||||
@@ -211,5 +362,4 @@ public class Canvas
|
||||
/* Call the paint method */
|
||||
paint(graphics);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user