Skip to content

Commit 6dd4624

Browse files
Philippe Plantierchearon
authored andcommitted
remove dead code, add comments
1 parent 2402410 commit 6dd4624

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/CanvasRenderingContext2d.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,14 +1011,18 @@ Context2d::GetImageData(const Napi::CallbackInfo& info) {
10111011
sh = -sh;
10121012
}
10131013

1014+
// Width and height to actually copy
10141015
int cw = sw;
10151016
int ch = sh;
1017+
// Offsets in the destination image
10161018
int ox = 0;
10171019
int oy = 0;
10181020

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

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

1033-
// WebKit/moz functionality. node-canvas used to return in either case.
1034-
if (sw <= 0) sw = 1;
1035-
if (sh <= 0) sh = 1;
1036-
10371037
int srcStride = canvas->stride();
10381038
int bpp = srcStride / width;
10391039
int size = sw * sh * bpp;

0 commit comments

Comments
 (0)