Skip to content

Commit c5bb71f

Browse files
committed
Remove native screenshot repaint toggle
1 parent 4b06eec commit c5bb71f

File tree

5 files changed

+2
-43
lines changed

5 files changed

+2
-43
lines changed

CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,20 +1214,6 @@ public void screenshot(SuccessCallback<Image> callback) {
12141214
callback.onSucess(img);
12151215
}
12161216

1217-
/**
1218-
* Indicates whether the Codename One implementation expects caller-side painting to run
1219-
* after a native screenshot has been captured. Implementations that composite peer
1220-
* components into the screenshot can override this to {@code false} so downstream code
1221-
* won't immediately repaint the captured image and accidentally hide native peers.
1222-
*
1223-
* @param screenshot the screenshot image produced by {@link #screenshot(SuccessCallback)}
1224-
* @return {@code true} if the caller should repaint Codename One components onto the
1225-
* screenshot, {@code false} otherwise.
1226-
*/
1227-
public boolean shouldPaintNativeScreenshot(Image screenshot) {
1228-
return true;
1229-
}
1230-
12311217
/**
12321218
* Returns true if the platform supports a native image cache. The native image cache
12331219
* is different than just {@link FileSystemStorage#hasCachesDir()}. A native image cache

CodenameOne/src/com/codename1/ui/Display.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5013,21 +5013,6 @@ public void screenshot(SuccessCallback<Image> callback) {
50135013
impl.screenshot(callback);
50145014
}
50155015

5016-
/**
5017-
* Indicates whether callers should repaint Codename One components onto a screenshot image
5018-
* returned from {@link #screenshot(SuccessCallback)}. Platforms that already composite
5019-
* peer components into the native screenshot can return {@code false} to keep the captured
5020-
* pixels intact.
5021-
*
5022-
* @param screenshot the image returned from {@link #screenshot(SuccessCallback)}.
5023-
* @return {@code true} if the caller should repaint Codename One components onto the
5024-
* screenshot, {@code false} otherwise.
5025-
*/
5026-
public boolean shouldPaintNativeScreenshot(Image screenshot) {
5027-
return impl.shouldPaintNativeScreenshot(screenshot);
5028-
}
5029-
5030-
50315016
/**
50325017
* Convenience method to schedule a task to run on the EDT after {@literal timeout}ms.
50335018
*

Ports/iOSPort/src/com/codename1/impl/ios/IOSImplementation.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ public void addCookie(Cookie c) {
300300
}
301301

302302
private static SuccessCallback<Image> screenshotCallback;
303-
private static volatile boolean lastScreenshotHasNativePeers;
304-
305303
@Override
306304
public void screenshot(final SuccessCallback<Image> callback) {
307305
if (callback == null) {
@@ -338,7 +336,6 @@ static void onScreenshot(final byte[] imageData) {
338336
final SuccessCallback<Image> callback = screenshotCallback;
339337
screenshotCallback = null;
340338
if (callback == null) {
341-
lastScreenshotHasNativePeers = false;
342339
return;
343340
}
344341

@@ -368,7 +365,6 @@ public void run() {
368365
}
369366

370367
if (image != null && image.getGraphics() != null) {
371-
lastScreenshotHasNativePeers = true;
372368
callback.onSucess(image);
373369
return;
374370
}
@@ -377,19 +373,11 @@ public void run() {
377373
Log.e(t);
378374
}
379375
}
380-
lastScreenshotHasNativePeers = false;
381376
callback.onSucess(null);
382377
}
383378
});
384379
}
385380

386-
@Override
387-
public boolean shouldPaintNativeScreenshot(Image screenshot) {
388-
boolean shouldPaint = !lastScreenshotHasNativePeers;
389-
lastScreenshotHasNativePeers = false;
390-
return shouldPaint;
391-
}
392-
393381
/**
394382
* Used to enable/disable native cookies from native code.
395383
* @param cookiesArray

docs/demos/common/src/test/java/com/codenameone/developerguide/animations/AnimationDemosScreenshotTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private Image capture(Form form) {
112112
throw new IllegalStateException("Timed out waiting for native screenshot result.");
113113
}
114114

115-
if (screenshot.getGraphics() != null && display.shouldPaintNativeScreenshot(screenshot)) {
115+
if (screenshot.getGraphics() != null) {
116116
form.paintComponent(screenshot.getGraphics(), true);
117117
}
118118

scripts/device-runner-app/tests/Cn1ssDeviceRunnerHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static boolean emitCurrentFormScreenshot(String testName) {
6262
return false;
6363
}
6464
Image screenshot = img[0];
65-
if (Display.getInstance().shouldPaintNativeScreenshot(screenshot)) {
65+
if (screenshot.getGraphics() != null) {
6666
current.paintComponent(screenshot.getGraphics(), true);
6767
}
6868
try {

0 commit comments

Comments
 (0)