aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Gubarkov <nikita.gubarkov@jetbrains.com>2024-04-24 01:50:44 +0200
committerSergey Shelomentsev <sergey.shelomentsev@jetbrains.com>2024-05-03 14:11:41 +0300
commitc4ab0f5fd4f6772560c2390a54a8a3f23c7889df (patch)
treee9f3929dbcc6c6a9c2834fdec571e56588307d12
parentdcd8968436417e124b1e79461cd12481b0a8b9c8 (diff)
downloadJetBrainsRuntime-c4ab0f5fd4f6772560c2390a54a8a3f23c7889df.tar.gz
JBR-7046 Tolerate subpixelResolution=0 in Metal and OGLjbr-release-17.0.11b1207.20jb17.0.11-b1207.20
-rw-r--r--src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m28
-rw-r--r--src/java.desktop/share/native/common/java2d/opengl/OGLTextRenderer.c28
2 files changed, 20 insertions, 36 deletions
diff --git a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m
index 3e78ed5a9c9..b5e3b416800 100644
--- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m
+++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m
@@ -660,19 +660,17 @@ MTLTR_DrawGlyphList(JNIEnv *env, MTLContext *mtlc, BMTLSDOps *dstOps,
int ry = ginfo->subpixelResolutionY;
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphx, rx);
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphy, ry);
- int subx = 0, suby = 0;
- // see DrawGlyphList.c FLOOR_ASSIGN & getSubpixelGlyphImage
- if (glyphx >= 0.0f && glyphy >= 0.0f) {
- x = (int) glyphx;
- y = (int) glyphy;
- subx = ((int) (glyphx * (float) rx)) % rx;
- suby = ((int) (glyphy * (float) ry)) % ry;
+ float fx = floor(glyphx);
+ float fy = floor(glyphy);
+ x = (int) fx;
+ y = (int) fy;
+ int subimage;
+ if ((rx == 1 && ry == 1) || rx <= 0 || ry <= 0) {
+ subimage = 0;
} else {
- float fx = floor(glyphx), fy = floor(glyphy);
- x = (int) fx;
- y = (int) fy;
- subx = (int) ((glyphx - fx) * (float) rx);
- suby = (int) ((glyphy - fy) * (float) ry);
+ int subx = (int) ((glyphx - fx) * (float) rx);
+ int suby = (int) ((glyphy - fy) * (float) ry);
+ subimage = subx + suby * rx;
}
if (ginfo->image == NULL) {
@@ -684,12 +682,6 @@ MTLTR_DrawGlyphList(JNIEnv *env, MTLContext *mtlc, BMTLSDOps *dstOps,
J2dTraceLn1(J2D_TRACE_INFO, "rowBytes = %d", ginfo->rowBytes);
if (ginfo->format == sun_font_StrikeCache_PIXEL_FORMAT_GREYSCALE) {
// grayscale or monochrome glyph data
- int subimage;
- if ((rx == 1 && ry == 1) || rx <= 0 || ry <= 0) {
- subimage = 0;
- } else {
- subimage = subx + suby * rx;
- }
if (ginfo->width <= MTLTR_CACHE_CELL_WIDTH &&
ginfo->height <= MTLTR_CACHE_CELL_HEIGHT)
{
diff --git a/src/java.desktop/share/native/common/java2d/opengl/OGLTextRenderer.c b/src/java.desktop/share/native/common/java2d/opengl/OGLTextRenderer.c
index 9e907c553dd..0cf7db85b56 100644
--- a/src/java.desktop/share/native/common/java2d/opengl/OGLTextRenderer.c
+++ b/src/java.desktop/share/native/common/java2d/opengl/OGLTextRenderer.c
@@ -1297,19 +1297,17 @@ OGLTR_DrawGlyphList(JNIEnv *env, OGLContext *oglc, OGLSDOps *dstOps,
int ry = ginfo->subpixelResolutionY;
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphx, rx);
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphy, ry);
- int subx = 0, suby = 0;
- // see DrawGlyphList.c FLOOR_ASSIGN & getSubpixelGlyphImage
- if (glyphx >= 0.0f && glyphy >= 0.0f) {
- x = (int) glyphx;
- y = (int) glyphy;
- subx = ((int) (glyphx * (float) rx)) % rx;
- suby = ((int) (glyphy * (float) ry)) % ry;
+ float fx = floor(glyphx);
+ float fy = floor(glyphy);
+ x = (int) fx;
+ y = (int) fy;
+ int subimage;
+ if ((rx == 1 && ry == 1) || rx <= 0 || ry <= 0) {
+ subimage = 0;
} else {
- float fx = floor(glyphx), fy = floor(glyphy);
- x = (int) fx;
- y = (int) fy;
- subx = (int) ((glyphx - fx) * (float) rx);
- suby = (int) ((glyphy - fy) * (float) ry);
+ int subx = (int) ((glyphx - fx) * (float) rx);
+ int suby = (int) ((glyphy - fy) * (float) ry);
+ subimage = subx + suby * rx;
}
if (ginfo->image == NULL) {
@@ -1321,12 +1319,6 @@ OGLTR_DrawGlyphList(JNIEnv *env, OGLContext *oglc, OGLSDOps *dstOps,
OGLContext_InitGrayRenderHints(env, oglc);
}
// grayscale or monochrome glyph data
- int subimage;
- if ((rx == 1 && ry == 1) || rx <= 0 || ry <= 0) {
- subimage = 0;
- } else {
- subimage = subx + suby * rx;
- }
if (ginfo->width <= OGLTR_CACHE_CELL_WIDTH &&
ginfo->height <= OGLTR_CACHE_CELL_HEIGHT)
{