8323390: Enhance mask blit functionality
Reviewed-by: prr, rhalade, psadhukhan
This commit is contained in:
parent
8cc84bf71e
commit
13341ca702
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -2150,27 +2150,33 @@ public final class SunGraphics2D
|
|||||||
}
|
}
|
||||||
|
|
||||||
Blit ob = lastCAblit;
|
Blit ob = lastCAblit;
|
||||||
if (dy == 0 && dx > 0 && dx < w) {
|
try {
|
||||||
while (w > 0) {
|
if (dy == 0 && dx > 0 && dx < w) {
|
||||||
int partW = Math.min(w, dx);
|
while (w > 0) {
|
||||||
w -= partW;
|
int partW = Math.min(w, dx);
|
||||||
int sx = x + w;
|
w -= partW;
|
||||||
ob.Blit(theData, theData, comp, clip,
|
int sx = Math.addExact(x, w);
|
||||||
sx, y, sx+dx, y+dy, partW, h);
|
ob.Blit(theData, theData, comp, clip,
|
||||||
|
sx, y, sx+dx, y+dy, partW, h);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if (dy > 0 && dy < h && dx > -w && dx < w) {
|
||||||
|
while (h > 0) {
|
||||||
|
int partH = Math.min(h, dy);
|
||||||
|
h -= partH;
|
||||||
|
int sy = Math.addExact(y, h);
|
||||||
|
ob.Blit(theData, theData, comp, clip,
|
||||||
|
x, sy, Math.addExact(x, dx), sy+dy, w, partH);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ob.Blit(theData, theData, comp, clip, x, y,
|
||||||
|
Math.addExact(x, dx), Math.addExact(y, dy), w, h);
|
||||||
|
} catch (ArithmeticException ex) {
|
||||||
|
// We are hitting integer overflow in Math.addExact()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dy > 0 && dy < h && dx > -w && dx < w) {
|
|
||||||
while (h > 0) {
|
|
||||||
int partH = Math.min(h, dy);
|
|
||||||
h -= partH;
|
|
||||||
int sy = y + h;
|
|
||||||
ob.Blit(theData, theData, comp, clip,
|
|
||||||
x, sy, x+dx, sy+dy, w, partH);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ob.Blit(theData, theData, comp, clip, x, y, x+dx, y+dy, w, h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -32,6 +32,7 @@
|
|||||||
#define _Included_SurfaceData
|
#define _Included_SurfaceData
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -53,6 +54,14 @@ typedef struct {
|
|||||||
|
|
||||||
#define SD_RASINFO_PRIVATE_SIZE 64
|
#define SD_RASINFO_PRIVATE_SIZE 64
|
||||||
|
|
||||||
|
#define UNSAFE_TO_ADD(a, b) \
|
||||||
|
(((a >= 0) && (b >= 0) && (a > (INT_MAX - b))) || \
|
||||||
|
((a < 0) && (b < 0) && (a < (INT_MIN - b)))) \
|
||||||
|
|
||||||
|
#define UNSAFE_TO_SUB(a, b) \
|
||||||
|
(((b >= 0) && (a < 0) && (a < (INT_MIN + b))) || \
|
||||||
|
((b < 0) && (a >= 0) && (-b > (INT_MAX - a)))) \
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The SurfaceDataRasInfo structure is used to pass in and return various
|
* The SurfaceDataRasInfo structure is used to pass in and return various
|
||||||
* pieces of information about the destination drawable. In particular:
|
* pieces of information about the destination drawable. In particular:
|
||||||
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -68,14 +68,28 @@ Java_sun_java2d_loops_MaskBlit_MaskBlit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (width <= 0 || height <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
srcInfo.bounds.x1 = srcx;
|
srcInfo.bounds.x1 = srcx;
|
||||||
srcInfo.bounds.y1 = srcy;
|
srcInfo.bounds.y1 = srcy;
|
||||||
|
if (UNSAFE_TO_ADD(srcx, width) ||
|
||||||
|
UNSAFE_TO_ADD(srcy, height) ||
|
||||||
|
UNSAFE_TO_ADD(dstx, width) ||
|
||||||
|
UNSAFE_TO_ADD(dsty, height)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
srcInfo.bounds.x2 = srcx + width;
|
srcInfo.bounds.x2 = srcx + width;
|
||||||
srcInfo.bounds.y2 = srcy + height;
|
srcInfo.bounds.y2 = srcy + height;
|
||||||
dstInfo.bounds.x1 = dstx;
|
dstInfo.bounds.x1 = dstx;
|
||||||
dstInfo.bounds.y1 = dsty;
|
dstInfo.bounds.y1 = dsty;
|
||||||
dstInfo.bounds.x2 = dstx + width;
|
dstInfo.bounds.x2 = dstx + width;
|
||||||
dstInfo.bounds.y2 = dsty + height;
|
dstInfo.bounds.y2 = dsty + height;
|
||||||
|
if (UNSAFE_TO_SUB(srcx, dstx) ||
|
||||||
|
UNSAFE_TO_SUB(srcy, dsty)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
srcx -= dstx;
|
srcx -= dstx;
|
||||||
srcy -= dsty;
|
srcy -= dsty;
|
||||||
SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds);
|
SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user