Skip to content

Commit

Permalink
JBR-7046 Tolerate subpixelResolution=0 in Metal and OGL
Browse files Browse the repository at this point in the history
  • Loading branch information
YaaZ authored and sshelomentsev committed May 3, 2024
1 parent dcd8968 commit c4ab0f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -660,19 +660,17 @@ static void DisableColorGlyphPainting(MTLContext *mtlc) {
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) {
Expand All @@ -684,12 +682,6 @@ static void DisableColorGlyphPainting(MTLContext *mtlc) {
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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
{
Expand Down

0 comments on commit c4ab0f5

Please sign in to comment.