jdk/src/java.desktop/windows/classes/sun/java2d/opengl/WGLSurfaceData.java
changeset 34394 259d6e4e0978
parent 31661 a5cb86f2253b
equal deleted inserted replaced
34393:171a07c89136 34394:259d6e4e0978
    29 import java.awt.GraphicsConfiguration;
    29 import java.awt.GraphicsConfiguration;
    30 import java.awt.GraphicsDevice;
    30 import java.awt.GraphicsDevice;
    31 import java.awt.GraphicsEnvironment;
    31 import java.awt.GraphicsEnvironment;
    32 import java.awt.Image;
    32 import java.awt.Image;
    33 import java.awt.Rectangle;
    33 import java.awt.Rectangle;
       
    34 import java.awt.geom.AffineTransform;
    34 import java.awt.image.ColorModel;
    35 import java.awt.image.ColorModel;
    35 import sun.awt.SunToolkit;
    36 import sun.awt.SunToolkit;
       
    37 import sun.awt.Win32GraphicsDevice;
    36 import sun.awt.windows.WComponentPeer;
    38 import sun.awt.windows.WComponentPeer;
    37 import sun.java2d.SurfaceData;
    39 import sun.java2d.SurfaceData;
    38 
    40 
    39 public abstract class WGLSurfaceData extends OGLSurfaceData {
    41 public abstract class WGLSurfaceData extends OGLSurfaceData {
    40 
    42 
    41     protected WComponentPeer peer;
    43     protected WComponentPeer peer;
    42     private WGLGraphicsConfig graphicsConfig;
    44     private WGLGraphicsConfig graphicsConfig;
       
    45     protected double scaleX = 1;
       
    46     protected double scaleY = 1;
    43 
    47 
    44     private native void initOps(long pConfigInfo, WComponentPeer peer,
    48     private native void initOps(long pConfigInfo, WComponentPeer peer,
    45                                 long hwnd);
    49                                 long hwnd);
    46 
    50 
    47     protected WGLSurfaceData(WComponentPeer peer, WGLGraphicsConfig gc,
    51     protected WGLSurfaceData(WComponentPeer peer, WGLGraphicsConfig gc,
    48                              ColorModel cm, int type)
    52                              ColorModel cm, int type)
    49     {
    53     {
    50         super(gc, cm, type);
    54         super(gc, cm, type);
    51         this.peer = peer;
    55         this.peer = peer;
    52         this.graphicsConfig = gc;
    56         this.graphicsConfig = gc;
       
    57         Win32GraphicsDevice device = gc.getDevice();
       
    58         this.scaleX = type == TEXTURE ? 1 : device.getDefaultScaleX();
       
    59         this.scaleY = type == TEXTURE ? 1 : device.getDefaultScaleY();
    53 
    60 
    54         long pConfigInfo = gc.getNativeConfigInfo();
    61         long pConfigInfo = gc.getNativeConfigInfo();
    55         long hwnd = peer != null ? peer.getHWnd() : 0L;
    62         long hwnd = peer != null ? peer.getHWnd() : 0L;
    56 
    63 
    57         initOps(pConfigInfo, peer, hwnd);
    64         initOps(pConfigInfo, peer, hwnd);
       
    65     }
       
    66 
       
    67     @Override
       
    68     public double getDefaultScaleX() {
       
    69         return scaleX;
       
    70     }
       
    71 
       
    72     @Override
       
    73     public double getDefaultScaleY() {
       
    74         return scaleY;
    58     }
    75     }
    59 
    76 
    60     public GraphicsConfiguration getDeviceConfiguration() {
    77     public GraphicsConfiguration getDeviceConfiguration() {
    61         return graphicsConfig;
    78         return graphicsConfig;
    62     }
    79     }
   146         }
   163         }
   147 
   164 
   148         public Rectangle getBounds() {
   165         public Rectangle getBounds() {
   149             Rectangle r = peer.getBounds();
   166             Rectangle r = peer.getBounds();
   150             r.x = r.y = 0;
   167             r.x = r.y = 0;
       
   168             r.width = (int) Math.ceil(r.width * scaleX);
       
   169             r.height = (int) Math.ceil(r.height * scaleY);
   151             return r;
   170             return r;
   152         }
   171         }
   153 
   172 
   154         /**
   173         /**
   155          * Returns destination Component associated with this SurfaceData.
   174          * Returns destination Component associated with this SurfaceData.
   206                                        Image image, ColorModel cm,
   225                                        Image image, ColorModel cm,
   207                                        int type)
   226                                        int type)
   208         {
   227         {
   209             super(peer, gc, cm, type);
   228             super(peer, gc, cm, type);
   210 
   229 
   211             this.width = width;
   230             this.width = (int) Math.ceil(width * scaleX);
   212             this.height = height;
   231             this.height = (int) Math.ceil(height * scaleY);
   213             offscreenImage = image;
   232             offscreenImage = image;
   214 
   233 
   215             initSurface(width, height);
   234             initSurface(this.width, this.height);
   216         }
   235         }
   217 
   236 
   218         public SurfaceData getReplacement() {
   237         public SurfaceData getReplacement() {
   219             return restoreContents(offscreenImage);
   238             return restoreContents(offscreenImage);
   220         }
   239         }
   221 
   240 
   222         public Rectangle getBounds() {
   241         public Rectangle getBounds() {
   223             if (type == FLIP_BACKBUFFER) {
   242             if (type == FLIP_BACKBUFFER) {
   224                 Rectangle r = peer.getBounds();
   243                 Rectangle r = peer.getBounds();
       
   244                 r.width = (int) Math.ceil(r.width * scaleX);
       
   245                 r.height = (int) Math.ceil(r.height * scaleY);
   225                 r.x = r.y = 0;
   246                 r.x = r.y = 0;
   226                 return r;
   247                 return r;
   227             } else {
   248             } else {
   228                 return new Rectangle(width, height);
   249                 return new Rectangle(width, height);
   229             }
   250             }