Skip to content

Commit

Permalink
remove dead code, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Plantier authored and chearon committed Jan 11, 2025
1 parent 2402410 commit 6dd4624
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/CanvasRenderingContext2d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1011,14 +1011,18 @@ Context2d::GetImageData(const Napi::CallbackInfo& info) {
sh = -sh;
}

// Width and height to actually copy
int cw = sw;
int ch = sh;
// Offsets in the destination image
int ox = 0;
int oy = 0;

// Clamp the copy width and height if the copy would go outside the image
if (sx + sw > width) cw = width - sx;
if (sy + sh > height) ch = height - sy;

// Clamp the copy origin if the copy would go outside the image
if (sx < 0) {
ox = -sx;
cw += sx;
Expand All @@ -1030,10 +1034,6 @@ Context2d::GetImageData(const Napi::CallbackInfo& info) {
sy = 0;
}

// WebKit/moz functionality. node-canvas used to return in either case.
if (sw <= 0) sw = 1;
if (sh <= 0) sh = 1;

int srcStride = canvas->stride();
int bpp = srcStride / width;
int size = sw * sh * bpp;
Expand Down

0 comments on commit 6dd4624

Please sign in to comment.