modules/graphics/src/main/java/com/sun/prism/d3d/D3DSwapChain.java

Print this page




  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.prism.d3d;
  27 
  28 import com.sun.glass.ui.Screen;
  29 import com.sun.javafx.geom.Rectangle;
  30 import com.sun.prism.CompositeMode;
  31 import com.sun.prism.Graphics;
  32 import com.sun.prism.Presentable;
  33 import com.sun.prism.PresentableState;
  34 import com.sun.prism.RTTexture;
  35 
  36 class D3DSwapChain
  37     extends D3DResource
  38     implements D3DRenderTarget, Presentable, D3DContextSource {
  39 
  40     private final D3DRTTexture texBackBuffer;
  41     private final float pixelScaleFactor;

  42 
  43     D3DSwapChain(D3DContext context, long pResource, D3DRTTexture rtt, float pixelScale) {
  44         super(new D3DRecord(context, pResource));
  45         texBackBuffer = rtt;
  46         pixelScaleFactor = pixelScale;

  47     }
  48 
  49     @Override
  50     public void dispose() {
  51         texBackBuffer.dispose();
  52         super.dispose();
  53     }
  54 
  55     @Override
  56     public boolean prepare(Rectangle dirtyregion) {
  57         D3DContext context = getContext();
  58         context.flushVertexBuffer();
  59         D3DGraphics g = (D3DGraphics) D3DGraphics.create(this, context);
  60         if (g == null) {
  61             return false;
  62         }
  63         int sw = texBackBuffer.getContentWidth();
  64         int sh = texBackBuffer.getContentHeight();
  65         int dw = this.getContentWidth();
  66         int dh = this.getContentHeight();


 102         return getPhysicalHeight();
 103     }
 104 
 105     public int getContentX() {
 106         return 0;
 107     }
 108 
 109     public int getContentY() {
 110         return 0;
 111     }
 112 
 113     private static native int nPresent(long context, long pSwapChain);
 114 
 115     public D3DContext getContext() {
 116         return d3dResRecord.getContext();
 117     }
 118 
 119     public boolean lockResources(PresentableState pState) {
 120         if (pState.getRenderWidth() != texBackBuffer.getContentWidth() ||
 121             pState.getRenderHeight() != texBackBuffer.getContentHeight() ||
 122             pState.getRenderScale() != pixelScaleFactor)

 123         {
 124             return true;
 125         }
 126         texBackBuffer.lock();
 127         return texBackBuffer.isSurfaceLost();
 128     }
 129 
 130     public Graphics createGraphics() {
 131         Graphics g = D3DGraphics.create(texBackBuffer, getContext());
 132         g.scale(pixelScaleFactor, pixelScaleFactor);
 133         return g;
 134     }
 135 
 136     public RTTexture getRTTBackBuffer() {
 137         return texBackBuffer;
 138     }
 139 
 140     public Screen getAssociatedScreen() {
 141         return getContext().getAssociatedScreen();
 142     }
 143 
 144     public float getPixelScaleFactor() {
 145         return pixelScaleFactor;






 146     }
 147 
 148     public boolean isOpaque() {
 149         return texBackBuffer.isOpaque();
 150     }
 151 
 152     public void setOpaque(boolean opaque) {
 153         texBackBuffer.setOpaque(opaque);
 154     }
 155 
 156     public boolean isMSAA() {
 157         return texBackBuffer != null ? texBackBuffer.isMSAA() : false;
 158     }
 159 }


  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.prism.d3d;
  27 
  28 import com.sun.glass.ui.Screen;
  29 import com.sun.javafx.geom.Rectangle;
  30 import com.sun.prism.CompositeMode;
  31 import com.sun.prism.Graphics;
  32 import com.sun.prism.Presentable;
  33 import com.sun.prism.PresentableState;
  34 import com.sun.prism.RTTexture;
  35 
  36 class D3DSwapChain
  37     extends D3DResource
  38     implements D3DRenderTarget, Presentable, D3DContextSource {
  39 
  40     private final D3DRTTexture texBackBuffer;
  41     private final float pixelScaleFactorX;
  42     private final float pixelScaleFactorY;
  43 
  44     D3DSwapChain(D3DContext context, long pResource, D3DRTTexture rtt, float pixelScaleX, float pixelScaleY) {
  45         super(new D3DRecord(context, pResource));
  46         texBackBuffer = rtt;
  47         pixelScaleFactorX = pixelScaleX;
  48         pixelScaleFactorY = pixelScaleY;
  49     }
  50 
  51     @Override
  52     public void dispose() {
  53         texBackBuffer.dispose();
  54         super.dispose();
  55     }
  56 
  57     @Override
  58     public boolean prepare(Rectangle dirtyregion) {
  59         D3DContext context = getContext();
  60         context.flushVertexBuffer();
  61         D3DGraphics g = (D3DGraphics) D3DGraphics.create(this, context);
  62         if (g == null) {
  63             return false;
  64         }
  65         int sw = texBackBuffer.getContentWidth();
  66         int sh = texBackBuffer.getContentHeight();
  67         int dw = this.getContentWidth();
  68         int dh = this.getContentHeight();


 104         return getPhysicalHeight();
 105     }
 106 
 107     public int getContentX() {
 108         return 0;
 109     }
 110 
 111     public int getContentY() {
 112         return 0;
 113     }
 114 
 115     private static native int nPresent(long context, long pSwapChain);
 116 
 117     public D3DContext getContext() {
 118         return d3dResRecord.getContext();
 119     }
 120 
 121     public boolean lockResources(PresentableState pState) {
 122         if (pState.getRenderWidth() != texBackBuffer.getContentWidth() ||
 123             pState.getRenderHeight() != texBackBuffer.getContentHeight() ||
 124             pState.getRenderScaleX() != pixelScaleFactorX ||
 125             pState.getRenderScaleY() != pixelScaleFactorY)
 126         {
 127             return true;
 128         }
 129         texBackBuffer.lock();
 130         return texBackBuffer.isSurfaceLost();
 131     }
 132 
 133     public Graphics createGraphics() {
 134         Graphics g = D3DGraphics.create(texBackBuffer, getContext());
 135         g.scale(pixelScaleFactorX, pixelScaleFactorY);
 136         return g;
 137     }
 138 
 139     public RTTexture getRTTBackBuffer() {
 140         return texBackBuffer;
 141     }
 142 
 143     public Screen getAssociatedScreen() {
 144         return getContext().getAssociatedScreen();
 145     }
 146 
 147     @Override
 148     public float getPixelScaleFactorX() {
 149         return pixelScaleFactorX;
 150     }
 151 
 152     @Override
 153     public float getPixelScaleFactorY() {
 154         return pixelScaleFactorY;
 155     }
 156 
 157     public boolean isOpaque() {
 158         return texBackBuffer.isOpaque();
 159     }
 160 
 161     public void setOpaque(boolean opaque) {
 162         texBackBuffer.setOpaque(opaque);
 163     }
 164 
 165     public boolean isMSAA() {
 166         return texBackBuffer != null ? texBackBuffer.isMSAA() : false;
 167     }
 168 }