169 int h = Math.max(1, target.getHeight()); 170 return new SunVolatileImage(target, w, h, Boolean.TRUE); 171 } 172 173 /** 174 * Performs the native D3D flip operation for the given target Component. 175 */ 176 @Override 177 public void flip(WComponentPeer peer, 178 Component target, VolatileImage backBuffer, 179 int x1, int y1, int x2, int y2, 180 BufferCapabilities.FlipContents flipAction) 181 { 182 // REMIND: we should actually get a surface data for the 183 // backBuffer's VI 184 SurfaceManager d3dvsm = 185 SurfaceManager.getManager(backBuffer); 186 SurfaceData sd = d3dvsm.getPrimarySurfaceData(); 187 if (sd instanceof D3DSurfaceData) { 188 D3DSurfaceData d3dsd = (D3DSurfaceData)sd; 189 D3DSurfaceData.swapBuffers(d3dsd, x1, y1, x2, y2); 190 } else { 191 // the surface was likely lost could not have been restored 192 Graphics g = peer.getGraphics(); 193 try { 194 g.drawImage(backBuffer, 195 x1, y1, x2, y2, 196 x1, y1, x2, y2, 197 null); 198 } finally { 199 g.dispose(); 200 } 201 } 202 203 if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) { 204 Graphics g = backBuffer.getGraphics(); 205 try { 206 g.setColor(target.getBackground()); 207 g.fillRect(0, 0, 208 backBuffer.getWidth(), 209 backBuffer.getHeight()); | 169 int h = Math.max(1, target.getHeight()); 170 return new SunVolatileImage(target, w, h, Boolean.TRUE); 171 } 172 173 /** 174 * Performs the native D3D flip operation for the given target Component. 175 */ 176 @Override 177 public void flip(WComponentPeer peer, 178 Component target, VolatileImage backBuffer, 179 int x1, int y1, int x2, int y2, 180 BufferCapabilities.FlipContents flipAction) 181 { 182 // REMIND: we should actually get a surface data for the 183 // backBuffer's VI 184 SurfaceManager d3dvsm = 185 SurfaceManager.getManager(backBuffer); 186 SurfaceData sd = d3dvsm.getPrimarySurfaceData(); 187 if (sd instanceof D3DSurfaceData) { 188 D3DSurfaceData d3dsd = (D3DSurfaceData)sd; 189 double scaleX = sd.getDefaultScaleX(); 190 double scaleY = sd.getDefaultScaleY(); 191 if (scaleX > 1 || scaleY > 1) { 192 int sx1 = (int) Math.floor(x1 * scaleX); 193 int sy1 = (int) Math.floor(y1 * scaleY); 194 int sx2 = (int) Math.ceil(x2 * scaleX); 195 int sy2 = (int) Math.ceil(y2 * scaleY); 196 D3DSurfaceData.swapBuffers(d3dsd, sx1, sy1, sx2, sy2); 197 } else { 198 D3DSurfaceData.swapBuffers(d3dsd, x1, y1, x2, y2); 199 } 200 } else { 201 // the surface was likely lost could not have been restored 202 Graphics g = peer.getGraphics(); 203 try { 204 g.drawImage(backBuffer, 205 x1, y1, x2, y2, 206 x1, y1, x2, y2, 207 null); 208 } finally { 209 g.dispose(); 210 } 211 } 212 213 if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) { 214 Graphics g = backBuffer.getGraphics(); 215 try { 216 g.setColor(target.getBackground()); 217 g.fillRect(0, 0, 218 backBuffer.getWidth(), 219 backBuffer.getHeight()); |