Skip to content

Commit 87de5b7

Browse files
Alexey Ushakovjayathirthrao
Alexey Ushakov
authored andcommitted
8266040: Lanai: Incorrect calculations of clipping boundaries
Reviewed-by: jdv
1 parent eb8db12 commit 87de5b7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLClip.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ - (void)beginShapeClip:(BMTLSDOps *)dstOps context:(MTLContext *)mtlc {
156156
}
157157

158158
_clipShapeSize = MTLSizeMake(0, 0, 1);
159-
_clipShapeOrigin = MTLOriginMake(0, 0, 0);
159+
// Use out of bounds origin to correctly calculate shape boundaries
160+
_clipShapeOrigin = MTLOriginMake((NSUInteger) dstOps->width, (NSUInteger) dstOps->height, 0);
160161

161162
MTLRenderPassDescriptor* clearPassDescriptor = [MTLRenderPassDescriptor renderPassDescriptor];
162163
// set color buffer properties

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLRenderer.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ void MTLRenderer_FillSpans(MTLContext *mtlc, BMTLSDOps * dstOps, jint spanCount,
470470

471471
jfloat shapeX1 = mtlc.clip.shapeX;
472472
jfloat shapeY1 = mtlc.clip.shapeY;
473-
jfloat shapeX2 = shapeX1 + mtlc.clip.shapeWidth;
474-
jfloat shapeY2 = shapeY1 + mtlc.clip.shapeHeight;
473+
jfloat shapeX2 = (mtlc.clip.shapeWidth > 0)? shapeX1 + mtlc.clip.shapeWidth : 0;
474+
jfloat shapeY2 = (mtlc.clip.shapeHeight > 0)? shapeY1 + mtlc.clip.shapeHeight : 0;
475475

476476
int counter = 0;
477477
for (int i = 0; i < spanCount; i++) {

0 commit comments

Comments
 (0)