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
39 changes: 39 additions & 0 deletions Ports/Android/src/com/codename1/impl/android/AndroidAsyncView.java
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,45 @@ public String toString() {
});
}

private class SavedAsyncClip {
Rectangle clip;
Path clipP;
GeneralPath clipGP;
boolean clipIsPath;
}

private final java.util.ArrayDeque<SavedAsyncClip> savedClipStack =
new java.util.ArrayDeque<SavedAsyncClip>();

@Override
public void pushClip() {
SavedAsyncClip s = new SavedAsyncClip();
if (clip != null) {
s.clip = new Rectangle(clip);
}
if (clipP != null) {
s.clipP = new Path(clipP);
}
if (clipGP != null) {
s.clipGP = new GeneralPath(clipGP);
}
s.clipIsPath = clipIsPath;
savedClipStack.push(s);
}

@Override
public void popClip() {
if (savedClipStack.isEmpty()) {
return;
}
SavedAsyncClip s = savedClipStack.pop();
clip = s.clip;
clipP = s.clipP;
clipGP = s.clipGP;
clipIsPath = s.clipIsPath;
clipFresh = false;
}


/*
private Matrix getTransformMatrix(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,32 @@ public int getClipY() {
}

private boolean clipSet = false;


// Stack of clipSet values captured by pushClip. Each pushClip adds an
// unpaired canvas.save() so the clip can be widened (restored) on
// popClip. clipSet is reset to false after the push so that a setClip
// inside the push/pop block doesn't restore our pushed save.
private final java.util.ArrayDeque<Boolean> pushedClipSetStack = new java.util.ArrayDeque<Boolean>();

public void pushClip() {
canvas.save();
pushedClipSetStack.push(Boolean.valueOf(clipSet));
clipSet = false;
}

public void popClip() {
if (pushedClipSetStack.isEmpty()) {
return;
}
if (clipSet) {
canvas.restore();
clipSet = false;
}
canvas.restore();
clipSet = pushedClipSetStack.pop().booleanValue();
clipFresh = false;
}

public void setClip(int x, int y, int width, int height) {
//System.out.println("Setting clip "+x+","+y+","+width+", "+height);
if (clipSet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5545,6 +5545,16 @@ public void rotate(Object nativeGraphics, float angle, int x, int y) {
((AndroidGraphics) nativeGraphics).rotate(angle, x, y);
}

@Override
public void pushClip(Object graphics) {
((AndroidGraphics) graphics).pushClip();
}

@Override
public void popClip(Object graphics) {
((AndroidGraphics) graphics).popClip();
}

@Override
public boolean isTranslateMatrixSupported() {
return true;
Expand Down
Binary file modified scripts/android/screenshots/graphics-clip-under-rotation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/android/screenshots/graphics-clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading