318 }
319
320 public Presentable createPresentable(PresentableState pState) {
321 if (PrismSettings.verbose && context.isLost()) {
322 System.err.println("SwapChain allocation while the device is lost");
323 }
324
325 long pResource = nCreateSwapChain(context.getContextHandle(),
326 pState.getNativeView(),
327 PrismSettings.isVsyncEnabled);
328
329 if (pResource != 0L) {
330 int width = pState.getRenderWidth();
331 int height = pState.getRenderHeight();
332 D3DRTTexture rtt = createRTTexture(width, height, WrapMode.CLAMP_NOT_NEEDED, pState.isMSAA());
333 if (PrismSettings.dirtyOptsEnabled) {
334 rtt.contentsUseful();
335 }
336
337 if (rtt != null) {
338 return new D3DSwapChain(context, pResource, rtt, pState.getRenderScale());
339 }
340
341 D3DResourceFactory.nReleaseResource(context.getContextHandle(), pResource);
342 }
343 return null;
344
345 }
346
347 private static ByteBuffer getBuffer(InputStream is) {
348 if (is == null) {
349 throw new RuntimeException("InputStream must be non-null");
350 }
351 try {
352 int len = 4096;
353 byte[] data = new byte[len];
354 BufferedInputStream bis = new BufferedInputStream(is, len);
355 int offset = 0;
356 int readBytes = -1;
357 while ((readBytes = bis.read(data, offset, len - offset)) != -1) {
358 offset += readBytes;
|
318 }
319
320 public Presentable createPresentable(PresentableState pState) {
321 if (PrismSettings.verbose && context.isLost()) {
322 System.err.println("SwapChain allocation while the device is lost");
323 }
324
325 long pResource = nCreateSwapChain(context.getContextHandle(),
326 pState.getNativeView(),
327 PrismSettings.isVsyncEnabled);
328
329 if (pResource != 0L) {
330 int width = pState.getRenderWidth();
331 int height = pState.getRenderHeight();
332 D3DRTTexture rtt = createRTTexture(width, height, WrapMode.CLAMP_NOT_NEEDED, pState.isMSAA());
333 if (PrismSettings.dirtyOptsEnabled) {
334 rtt.contentsUseful();
335 }
336
337 if (rtt != null) {
338 return new D3DSwapChain(context, pResource, rtt, pState.getRenderScaleX(), pState.getRenderScaleY());
339 }
340
341 D3DResourceFactory.nReleaseResource(context.getContextHandle(), pResource);
342 }
343 return null;
344
345 }
346
347 private static ByteBuffer getBuffer(InputStream is) {
348 if (is == null) {
349 throw new RuntimeException("InputStream must be non-null");
350 }
351 try {
352 int len = 4096;
353 byte[] data = new byte[len];
354 BufferedInputStream bis = new BufferedInputStream(is, len);
355 int offset = 0;
356 int readBytes = -1;
357 while ((readBytes = bis.read(data, offset, len - offset)) != -1) {
358 offset += readBytes;
|