< prev index next >
modules/javafx.graphics/src/main/java/com/sun/javafx/sg/prism/NGCanvas.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -96,12 +96,13 @@
public static final byte ARC_TYPE = ATTR_BASE + 15;
public static final byte FILL_RULE = ATTR_BASE + 16;
public static final byte DASH_ARRAY = ATTR_BASE + 17;
public static final byte DASH_OFFSET = ATTR_BASE + 18;
public static final byte FONT_SMOOTH = ATTR_BASE + 19;
+ public static final byte IMAGE_SMOOTH = ATTR_BASE + 20;
- public static final byte OP_BASE = 20;
+ public static final byte OP_BASE = 25;
public static final byte FILL_RECT = OP_BASE + 0;
public static final byte STROKE_RECT = OP_BASE + 1;
public static final byte CLEAR_RECT = OP_BASE + 2;
public static final byte STROKE_LINE = OP_BASE + 3;
public static final byte FILL_OVAL = OP_BASE + 4;
@@ -332,10 +333,11 @@
private Path2D path;
private NGText ngtext;
private PrismTextLayout textLayout;
private PGFont pgfont;
private int smoothing;
+ private boolean imageSmoothing;
private int align;
private int baseline;
private Affine2D transform;
private Affine2D inverseTransform;
private boolean inversedirty;
@@ -387,10 +389,11 @@
path.setWindingRule(Path2D.WIND_NON_ZERO);
// ngtext stores no state between render operations
// textLayout stores no state between render operations
pgfont = (PGFont) FontHelper.getNativeFont(Font.getDefault());
smoothing = SMOOTH_GRAY;
+ imageSmoothing = true;
align = ALIGN_LEFT;
baseline = VPos.BASELINE.ordinal();
transform.setToScale(highestPixelScale, highestPixelScale);
clipStack.clear();
resetClip(false);
@@ -1001,10 +1004,13 @@
pgfont = (PGFont) buf.getObject();
break;
case FONT_SMOOTH:
smoothing = buf.getUByte();
break;
+ case IMAGE_SMOOTH:
+ imageSmoothing = buf.getBoolean();
+ break;
case TEXT_ALIGN:
align = buf.getUByte();
break;
case TEXT_BASELINE:
baseline = prbases[buf.getUByte()];
@@ -1343,13 +1349,20 @@
}
if (gr != null) {
ResourceFactory factory = gr.getResourceFactory();
Texture tex =
factory.getCachedTexture(img, Texture.WrapMode.CLAMP_TO_EDGE);
+ boolean isSmooth = tex.getLinearFiltering();
+ if (imageSmoothing != isSmooth) {
+ tex.setLinearFiltering(imageSmoothing);
+ }
gr.drawTexture(tex,
dx, dy, dx+dw, dy+dh,
sx, sy, sx+sw, sy+sh);
+ if (imageSmoothing != isSmooth) {
+ tex.setLinearFiltering(isSmooth);
+ }
tex.unlock();
}
break;
}
case FILL_TEXT:
< prev index next >