Skip to content

Commit

Permalink
8324559: Improve 2D image handling
Browse files Browse the repository at this point in the history
Reviewed-by: mbalao, andrew
Backport-of: 1a5a44019871c411148ca85d0491cc68d2256e4e
  • Loading branch information
Yuri Nesterenko authored and gnu-andrew committed Jul 6, 2024
1 parent 36768ad commit bc1e0de
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions jdk/src/share/native/sun/java2d/loops/MaskFill.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2024, 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
Expand Down Expand Up @@ -467,7 +467,7 @@ storePgram(EdgeInfo *pLeftEdge, EdgeInfo *pRightEdge,
#define INSERT_ACCUM(pACCUM, IMIN, IMAX, X0, Y0, X1, Y1, CX1, CX2, MULT) \
do { \
jdouble xmid = ((X0) + (X1)) * 0.5; \
if (xmid <= (CX2)) { \
if (xmid < (CX2)) { \
jdouble sliceh = ((Y1) - (Y0)); \
jdouble slicearea; \
jint i; \
Expand Down Expand Up @@ -556,7 +556,7 @@ fillAAPgram(NativePrimitive *pPrim, SurfaceDataRasInfo *pRasInfo,
jint cy2 = pRasInfo->bounds.y2;
jint width = cx2 - cx1;
EdgeInfo edges[4];
jfloat localaccum[MASK_BUF_LEN + 1];
jfloat localaccum[MASK_BUF_LEN + 2];
jfloat *pAccum;

if (!storePgram(edges + 0, edges + 2,
Expand All @@ -568,12 +568,12 @@ fillAAPgram(NativePrimitive *pPrim, SurfaceDataRasInfo *pRasInfo,
}

pAccum = ((width > MASK_BUF_LEN)
? malloc((width + 1) * sizeof(jfloat))
? malloc((width + 2) * sizeof(jfloat))
: localaccum);
if (pAccum == NULL) {
return;
}
memset(pAccum, 0, (width+1) * sizeof(jfloat));
memset(pAccum, 0, (width + 2) * sizeof(jfloat));

while (cy1 < cy2) {
jint lmin, lmax, rmin, rmax;
Expand Down Expand Up @@ -794,7 +794,7 @@ drawAAPgram(NativePrimitive *pPrim, SurfaceDataRasInfo *pRasInfo,
jint cy2 = pRasInfo->bounds.y2;
jint width = cx2 - cx1;
EdgeInfo edges[8];
jfloat localaccum[MASK_BUF_LEN + 1];
jfloat localaccum[MASK_BUF_LEN + 2];
jfloat *pAccum;

if (!storePgram(edges + 0, edges + 6,
Expand All @@ -815,12 +815,12 @@ drawAAPgram(NativePrimitive *pPrim, SurfaceDataRasInfo *pRasInfo,
JNI_TRUE);

pAccum = ((width > MASK_BUF_LEN)
? malloc((width + 1) * sizeof(jfloat))
? malloc((width + 2) * sizeof(jfloat))
: localaccum);
if (pAccum == NULL) {
return;
}
memset(pAccum, 0, (width+1) * sizeof(jfloat));
memset(pAccum, 0, (width + 2) * sizeof(jfloat));

while (cy1 < cy2) {
jint lmin, lmax, rmin, rmax;
Expand Down

0 comments on commit bc1e0de

Please sign in to comment.