public void clipSourceDest(CPRect srcRect, CPRect dstRect) {
		// FIXME:
		// /!\ dstRect bottom and right are ignored and instead we clip
		// against the width, height of the layer. :/
		//

		// this version would be enough in most cases (when we don't need
		// srcRect bottom and right to be clipped)
		// it's left here in case it's needed to make a faster version
		// of this function
		// dstRect.right = Math.min(width, dstRect.left + srcRect.getWidth());
		// dstRect.bottom = Math.min(height, dstRect.top + srcRect.getHeight());

		// new dest bottom/right
		dstRect.right = dstRect.left + srcRect.getWidth();
		if (dstRect.right > width) {
			srcRect.right -= dstRect.right - width;
			dstRect.right = width;
		}

		dstRect.bottom = dstRect.top + srcRect.getHeight();
		if (dstRect.bottom > height) {
			srcRect.bottom -= dstRect.bottom - height;
			dstRect.bottom = height;
		}

		// new src top/left
		if (dstRect.left < 0) {
			srcRect.left -= dstRect.left;
			dstRect.left = 0;
		}

		if (dstRect.top < 0) {
			srcRect.top -= dstRect.top;
			dstRect.top = 0;
		}
	}