Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4730,19 +4730,21 @@ void apply() {

private void setClipping(long clipRgn) {
checkNonDisposed();
storeAndApplyOperationForExistingHandle(new SetClippingRegionOperation(clipRgn));
setClippingRegion(clipRgn);
}

private class SetClippingRegionOperation extends Operation {
private final long clipRgn;
private final Region clipRgn;

SetClippingRegionOperation(long clipRgn) {
this.clipRgn = clipRgn;
SetClippingRegionOperation(Region clipRgn) {
this.clipRgn = clipRgn != null ? clipRgn.copy() : null;
registerForDisposal(this.clipRgn);
}

@Override
void apply() {
setClippingRegion(clipRgn);
// Reset clipping if clipRgn is null.
setClippingRegion(clipRgn != null ? Region.win32_getHandle(clipRgn, getZoom()) : 0);
}
}

Expand Down Expand Up @@ -4880,7 +4882,7 @@ void apply() {
public void setClipping (Rectangle rect) {
checkNonDisposed();
if (rect == null) {
setClipping(0);
storeAndApplyOperationForExistingHandle(new SetClippingRegionOperation(null));
} else {
storeAndApplyOperationForExistingHandle(new SetClippingOperation(rect));
}
Expand All @@ -4905,7 +4907,7 @@ public void setClipping (Rectangle rect) {
public void setClipping (Region region) {
checkNonDisposed();
if (region != null && region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
setClipping(region != null ? Region.win32_getHandle(region, getZoom()) : 0);
storeAndApplyOperationForExistingHandle(new SetClippingRegionOperation(region));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,12 @@ private RegionHandle getRegionHandle(int zoom) {
return zoomToHandle.get(zoom);
}

Region copy() {
Region region = new Region();
region.operations.addAll(operations);
return region;
}

/**
* <b>IMPORTANT:</b> This method is not part of the public
* API for Image. It is marked public only so that it
Expand Down
Loading