Skip to content

Commit

Permalink
Don't offset pixel copy roots by location in window
Browse files Browse the repository at this point in the history
The root is always at 0,0.

PiperOrigin-RevId: 634080781
  • Loading branch information
paulsowden authored and Copybara-Service committed May 16, 2024
1 parent f2460c5 commit afe2dc6
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,7 @@ protected static void request(
if (srcRect != null && srcRect.isEmpty()) {
throw new IllegalArgumentException("sourceRect is empty");
}
View view = source.getDecorView();
Rect adjustedSrcRect = null;
if (srcRect != null) {
adjustedSrcRect = new Rect(srcRect);
int[] locationInWindow = new int[2];
view.getLocationInWindow(locationInWindow);
// offset the srcRect by the decor view's location in the window
adjustedSrcRect.offset(-locationInWindow[0], -locationInWindow[1]);
}
takeScreenshot(view, dest, adjustedSrcRect);
takeScreenshot(source.getDecorView(), dest, srcRect);
alertFinished(listener, listenerThread, PixelCopy.SUCCESS);
}

Expand Down

0 comments on commit afe2dc6

Please sign in to comment.