modules/graphics/src/main/java/com/sun/javafx/tk/quantum/ViewPainter.java

Print this page

        

@@ -172,13 +172,14 @@
 
         // This "g" variable might represent the back buffer graphics, or it
         // might be reassigned to the sceneBuffer graphics.
         Graphics g = backBufferGraphics;
         // Take into account the pixel scale factor for retina displays
-        final float pixelScale = getPixelScaleFactor();
+        final float pixelScaleX = getPixelScaleFactorX();
+        final float pixelScaleY = getPixelScaleFactorY();
         // Cache pixelScale in Graphics for use in 3D shaders such as camera and light positions.
-        g.setPixelScaleFactor(pixelScale);
+        g.setPixelScaleFactors(pixelScaleX, pixelScaleY);
 
         // Initialize renderEverything based on various conditions that will cause us to render
         // the entire scene every time.
         boolean renderEverything = overlayRoot != null ||
                 freshBackBuffer ||

@@ -190,12 +191,12 @@
         final boolean showDirtyOpts = PrismSettings.showDirtyRegions || PrismSettings.showOverdraw;
         // If showDirtyOpts is turned on and we're not using a depth buffer
         // then we will render the scene to an intermediate texture, and then at the end we'll
         // draw that intermediate texture to the back buffer.
         if (showDirtyOpts && !sceneState.getScene().getDepthBuffer()) {
-            final int bufferWidth = (int) Math.ceil(width * pixelScale);
-            final int bufferHeight = (int) Math.ceil(height * pixelScale);
+            final int bufferWidth = (int) Math.ceil(width * pixelScaleX);
+            final int bufferHeight = (int) Math.ceil(height * pixelScaleY);
             // Check whether the sceneBuffer texture needs to be reconstructed
             if (sceneBuffer != null) {
                 sceneBuffer.lock();
                 if (sceneBuffer.isSurfaceLost() ||
                         bufferWidth != sceneBuffer.getContentWidth() ||

@@ -217,11 +218,12 @@
                 renderEverything = true;
             }
             sceneBuffer.contentsUseful();
             // Hijack the "g" graphics variable
             g = sceneBuffer.createGraphics();
-            g.scale(pixelScale, pixelScale);
+            g.setPixelScaleFactors(pixelScaleX, pixelScaleY);
+            g.scale(pixelScaleX, pixelScaleY);
         } else if (sceneBuffer != null) {
             // We're in a situation where we have previously rendered to the sceneBuffer, but in
             // this render pass for whatever reason we're going to draw directly to the back buffer.
             // In this case we need to release the sceneBuffer.
             sceneBuffer.dispose();

@@ -310,15 +312,15 @@
                     // Set the clip rectangle using integer bounds since a fractional bounding box will
                     // still require a complete repaint on pixel boundaries
                     dirtyRect.setBounds(dirtyRegion);
                     // TODO I don't understand why this is needed. And if it is, are fractional pixelScale
                     // values OK? And if not, shouldn't pixelScale be an int instead?
-                    if (pixelScale != 1.0f) {
-                        dirtyRect.x *= pixelScale;
-                        dirtyRect.y *= pixelScale;
-                        dirtyRect.width *= pixelScale;
-                        dirtyRect.height *= pixelScale;
+                    if (pixelScaleX != 1.0f || pixelScaleY != 1.0f) {
+                        dirtyRect.x *= pixelScaleX;
+                        dirtyRect.y *= pixelScaleY;
+                        dirtyRect.width *= pixelScaleX;
+                        dirtyRect.height *= pixelScaleY;
                     }
                     g.setClipRect(dirtyRect);
                     g.setClipRectIndex(i);
                     doPaint(g, getRootPath(i));
                 }

@@ -435,12 +437,16 @@
         height = viewHeight = sceneState.getHeight();
 
         return sceneState.isWindowVisible() && !sceneState.isWindowMinimized();
     }
 
-    protected float getPixelScaleFactor() {
-        return presentable == null ? 1.0f : presentable.getPixelScaleFactor();
+    protected float getPixelScaleFactorX() {
+        return presentable == null ? 1.0f : presentable.getPixelScaleFactorX();
+    }
+
+    protected float getPixelScaleFactorY() {
+        return presentable == null ? 1.0f : presentable.getPixelScaleFactorY();
     }
 
     private void doPaint(Graphics g, NodePath renderRootPath) {
         // Null path indicates that occlusion culling is not used
         if (renderRootPath != null) {