/** * Creates a SurfaceData object representing the back buffer of a * double-buffered on-screen Window. */ public static D3DSurfaceData createData(WComponentPeer peer, Image image) { D3DGraphicsConfig gc = getGC(peer); if (gc == null || !peer.isAccelCapable()) { return null; } BufferCapabilities caps = peer.getBackBufferCaps(); VSyncType vSyncType = VSYNC_DEFAULT; if (caps instanceof ExtendedBufferCapabilities) { vSyncType = ((ExtendedBufferCapabilities)caps).getVSync(); } Rectangle r = peer.getBounds(); BufferCapabilities.FlipContents flip = caps.getFlipContents(); int swapEffect; if (flip == FlipContents.COPIED) { swapEffect = SWAP_COPY; } else if (flip == FlipContents.PRIOR) { swapEffect = SWAP_FLIP; } else { // flip == FlipContents.UNDEFINED || .BACKGROUND swapEffect = SWAP_DISCARD; } return new D3DSurfaceData(peer, gc, r.width, r.height, image, peer.getColorModel(), peer.getBackBuffersNum(), swapEffect, vSyncType, FLIP_BACKBUFFER); }
protected D3DSurfaceData(WComponentPeer peer, D3DGraphicsConfig gc, int width, int height, Image image, ColorModel cm, int numBackBuffers, int swapEffect, VSyncType vSyncType, int type) { super(getCustomSurfaceType(type), cm); this.graphicsDevice = gc.getD3DDevice(); this.peer = peer; this.type = type; this.width = width; this.height = height; this.offscreenImage = image; this.backBuffersNum = numBackBuffers; this.swapEffect = swapEffect; this.syncType = vSyncType; initOps(graphicsDevice.getScreen(), width, height); if (type == WINDOW) { // we put the surface into the "lost" // state; it will be restored by the D3DScreenUpdateManager // prior to rendering to it for the first time. This is done // so that vram is not wasted for surfaces never rendered to setSurfaceLost(true); } else { initSurface(); } setBlitProxyKey(gc.getProxyKey()); }
protected D3DSurfaceData(WComponentPeer peer, D3DGraphicsConfig gc, int width, int height, Image image, ColorModel cm, int numBackBuffers, int swapEffect, VSyncType vSyncType, int type) { super(getCustomSurfaceType(type), cm); this.graphicsDevice = gc.getD3DDevice(); this.scaleX = type == TEXTURE ? 1 : graphicsDevice.getDefaultScaleX(); this.scaleY = type == TEXTURE ? 1 : graphicsDevice.getDefaultScaleY(); this.peer = peer; this.type = type; if (scaleX == 1 && scaleY == 1) { this.width = width; this.height = height; } else if (peer instanceof WWindowPeer) { Dimension scaledSize = ((WWindowPeer) peer).getScaledWindowSize(); this.width = scaledSize.width; this.height = scaledSize.height; } else { this.width = (int) Math.ceil(width * scaleX); this.height = (int) Math.ceil(height * scaleY); } this.offscreenImage = image; this.backBuffersNum = numBackBuffers; this.swapEffect = swapEffect; this.syncType = vSyncType; initOps(graphicsDevice.getScreen(), this.width, this.height); if (type == WINDOW) { // we put the surface into the "lost" // state; it will be restored by the D3DScreenUpdateManager // prior to rendering to it for the first time. This is done // so that vram is not wasted for surfaces never rendered to setSurfaceLost(true); } else { initSurface(); } setBlitProxyKey(gc.getProxyKey()); }