当前位置: 首页>>代码示例>>Java>>正文


Java VolatileImage.flush方法代码示例

本文整理汇总了Java中java.awt.image.VolatileImage.flush方法的典型用法代码示例。如果您正苦于以下问题:Java VolatileImage.flush方法的具体用法?Java VolatileImage.flush怎么用?Java VolatileImage.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.VolatileImage的用法示例。


在下文中一共展示了VolatileImage.flush方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAvailableAcceleratedMemory

import java.awt.image.VolatileImage; //导入方法依赖的package包/类
/**
 * Gets the availableAcceleratedMemory attribute of the YassSheet object
 *
 * @return The availableAcceleratedMemory value
 */
public int getAvailableAcceleratedMemory() {
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    try {
        GraphicsDevice[] gs = ge.getScreenDevices();

        // Get current amount of available memory in bytes for each screen
        for (GraphicsDevice g : gs) {
            // Workaround; see description
            VolatileImage im = g.getDefaultConfiguration()
                    .createCompatibleVolatileImage(1, 1);

            // Retrieve available free accelerated image memory
            int bytes = g.getAvailableAcceleratedMemory();

            // Release the temporary volatile image
            im.flush();

            return bytes;
        }
    } catch (HeadlessException e) {
        // Is thrown if there are no screen devices
    }
    return 0;
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:31,代码来源:YassSheet.java

示例2: main

import java.awt.image.VolatileImage; //导入方法依赖的package包/类
public static void main(final String[] args) {
    final GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsConfiguration gc =
            ge.getDefaultScreenDevice().getDefaultConfiguration();
    final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
    final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();

    sg2d.constrain(0, 61, 100, 100);
    final AffineTransform expected = sg2d.cloneTransform();
    sg2d.setTransform(sg2d.getTransform());
    final AffineTransform actual = sg2d.cloneTransform();
    sg2d.dispose();
    vi.flush();
    if (!expected.equals(actual)) {
        System.out.println("Expected = " + expected);
        System.out.println("Actual = " + actual);
        throw new RuntimeException("Wrong transform");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:TransformSetGet.java

示例3: getVolatileOffscreenBuffer

import java.awt.image.VolatileImage; //导入方法依赖的package包/类
/**
* Return a volatile offscreen buffer that should be used as a
* double buffer with the specified component <code>c</code>.
* The image returned will be an instance of VolatileImage, or null
* if a VolatileImage object could not be instantiated.
* This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
* This happens when the maximum double buffer size has been set for this
* repaint manager.
*
* @see java.awt.image.VolatileImage
* @since 1.4
*/
 public Image getVolatileOffscreenBuffer(Component c,
                                         int proposedWidth,int proposedHeight) {
     RepaintManager delegate = getDelegate(c);
     if (delegate != null) {
         return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                     proposedHeight);
     }

     // If the window is non-opaque, it's double-buffered at peer's level
     Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
     if (!w.isOpaque()) {
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
             return null;
         }
     }

     GraphicsConfiguration config = c.getGraphicsConfiguration();
     if (config == null) {
         config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                         getDefaultScreenDevice().getDefaultConfiguration();
     }
     Dimension maxSize = getDoubleBufferMaximumSize();
     int width = proposedWidth < 1 ? 1 :
         (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
     int height = proposedHeight < 1 ? 1 :
         (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
     VolatileImage image = volatileMap.get(config);
     if (image == null || image.getWidth() < width ||
                          image.getHeight() < height) {
         if (image != null) {
             image.flush();
         }
         image = config.createCompatibleVolatileImage(width, height,
                                                      volatileBufferType);
         volatileMap.put(config, image);
     }
     return image;
 }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:52,代码来源:RepaintManager.java

示例4: getVolatileOffscreenBuffer

import java.awt.image.VolatileImage; //导入方法依赖的package包/类
/**
 * Return a volatile offscreen buffer that should be used as a
 * double buffer with the specified component <code>c</code>.
 * The image returned will be an instance of VolatileImage, or null
 * if a VolatileImage object could not be instantiated.
 * This buffer might be smaller than <code>(proposedWidth,proposedHeight)</code>.
 * This happens when the maximum double buffer size has been set for this
 * repaint manager.
 *
 * @param c the component
 * @param proposedWidth the width of the buffer
 * @param proposedHeight the height of the buffer
 *
 * @return the volatile image
 * @see java.awt.image.VolatileImage
 * @since 1.4
 */
public Image getVolatileOffscreenBuffer(Component c,
                                        int proposedWidth,int proposedHeight) {
    RepaintManager delegate = getDelegate(c);
    if (delegate != null) {
        return delegate.getVolatileOffscreenBuffer(c, proposedWidth,
                                                    proposedHeight);
    }

    // If the window is non-opaque, it's double-buffered at peer's level
    Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
    if (!w.isOpaque()) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
            return null;
        }
    }

    GraphicsConfiguration config = c.getGraphicsConfiguration();
    if (config == null) {
        config = GraphicsEnvironment.getLocalGraphicsEnvironment().
                        getDefaultScreenDevice().getDefaultConfiguration();
    }
    Dimension maxSize = getDoubleBufferMaximumSize();
    int width = proposedWidth < 1 ? 1 :
        (proposedWidth > maxSize.width? maxSize.width : proposedWidth);
    int height = proposedHeight < 1 ? 1 :
        (proposedHeight > maxSize.height? maxSize.height : proposedHeight);
    VolatileImage image = volatileMap.get(config);
    if (image == null || image.getWidth() < width ||
                         image.getHeight() < height) {
        if (image != null) {
            image.flush();
        }
        image = config.createCompatibleVolatileImage(width, height,
                                                     volatileBufferType);
        volatileMap.put(config, image);
    }
    return image;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:57,代码来源:RepaintManager.java

示例5: replaceSurfaceData

import java.awt.image.VolatileImage; //导入方法依赖的package包/类
/**
 * Multi-buffer version of replaceSurfaceData.  This version is called
 * by createBuffers(), which needs to acquire the same locks in the same
 * order, but also needs to perform additional functions inside the
 * locks.
 */
public void replaceSurfaceData(int newNumBackBuffers,
                               BufferCapabilities caps)
{
    SurfaceData oldData = null;
    VolatileImage oldBB = null;
    synchronized(((Component)target).getTreeLock()) {
        synchronized(this) {
            if (pData == 0) {
                return;
            }
            numBackBuffers = newNumBackBuffers;
            ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
            oldData = surfaceData;
            mgr.dropScreenSurface(oldData);
            createScreenSurface(true);
            if (oldData != null) {
                oldData.invalidate();
            }

            oldBB = backBuffer;
            if (numBackBuffers > 0) {
                // set the caps first, they're used when creating the bb
                backBufferCaps = caps;
                Win32GraphicsConfig gc =
                    (Win32GraphicsConfig)getGraphicsConfiguration();
                backBuffer = gc.createBackBuffer(this);
            } else if (backBuffer != null) {
                backBufferCaps = null;
                backBuffer = null;
            }
        }
    }
    // it would be better to do this before we create new ones,
    // but then we'd run into deadlock issues
    if (oldData != null) {
        oldData.flush();
        // null out the old data to make it collected faster
        oldData = null;
    }
    if (oldBB != null) {
        oldBB.flush();
        // null out the old data to make it collected faster
        oldData = null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:52,代码来源:WComponentPeer.java

示例6: main

import java.awt.image.VolatileImage; //导入方法依赖的package包/类
public static void main(final String[] args) throws IOException {
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsConfiguration gc = ge.getDefaultScreenDevice()
                                 .getDefaultConfiguration();
    AffineTransform at;
    for (int size : SIZES) {
        at = AffineTransform.getScaleInstance(size, size);
        for (Shape clip : SHAPES) {
            clip = at.createTransformedShape(clip);
            for (Shape to : SHAPES) {
                to = at.createTransformedShape(to);
                // Prepare test images
                BufferedImage snapshot;
                BufferedImage bi = getBufferedImage(size);
                VolatileImage vi = getVolatileImage(gc, size);
                while (true) {
                    vi.validate(gc);
                    Graphics2D g2d = vi.createGraphics();
                    g2d.setColor(Color.GREEN);
                    g2d.fillRect(0, 0, size, size);
                    g2d.dispose();
                    if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
                        continue;
                    }
                    draw(clip, to, bi, vi);
                    snapshot = vi.getSnapshot();
                    if (vi.contentsLost()) {
                        continue;
                    }
                    break;
                }
                // Prepare gold images
                BufferedImage goldvi = getCompatibleImage(gc, size);
                BufferedImage goldbi = getBufferedImage(size);
                draw(clip, to, goldbi, goldvi);
                validate(snapshot, goldvi);
                vi.flush();
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:43,代码来源:IncorrectClipXorModeSW2Surface.java

示例7: main

import java.awt.image.VolatileImage; //导入方法依赖的package包/类
public static void main(final String[] args) throws IOException {
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsConfiguration gc = ge.getDefaultScreenDevice()
            .getDefaultConfiguration();
    AffineTransform at;
    for (int size : SIZES) {
        at = AffineTransform.getScaleInstance(size, size);
        for (Shape clip : SHAPES) {
            clip = at.createTransformedShape(clip);
            for (Shape to : SHAPES) {
                to = at.createTransformedShape(to);
                // Prepare test images
                BufferedImage snapshot;
                VolatileImage source = getVolatileImage(gc, size);
                VolatileImage target = getVolatileImage(gc, size);
                int attempt = 0;
                while (true) {
                    if (++attempt > 10) {
                        throw new RuntimeException("Too many attempts: " + attempt);
                    }
                    // Prepare source images
                    source.validate(gc);
                    Graphics2D g2d = source.createGraphics();
                    g2d.setColor(Color.RED);
                    g2d.fillRect(0, 0, size, size);
                    g2d.dispose();
                    if (source.validate(gc) != VolatileImage.IMAGE_OK) {
                        continue;
                    }
                    // Prepare target images
                    target.validate(gc);
                    g2d = target.createGraphics();
                    g2d.setColor(Color.GREEN);
                    g2d.fillRect(0, 0, size, size);
                    g2d.dispose();
                    if (target.validate(gc) != VolatileImage.IMAGE_OK) {
                        continue;
                    }

                    draw(clip, to, source, target);
                    snapshot = target.getSnapshot();
                    if (source.contentsLost() || target.contentsLost()) {
                        continue;
                    }
                    break;
                }
                // Prepare gold images
                BufferedImage goldS = getSourceGold(gc, size);
                BufferedImage goldT = getTargetGold(gc, size);
                draw(clip, to, goldS, goldT);
                validate(snapshot, goldT);
                source.flush();
                target.flush();
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:59,代码来源:IncorrectClipXorModeSurface2Surface.java


注:本文中的java.awt.image.VolatileImage.flush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。