コード例 #1
0
void SRRasterization::LineBres(int x0, int y0, SRVertex vertex0, int xEnd, int yEnd, SRVertex vertex1)
{
	int dx = abs(xEnd - x0), dy = abs(yEnd - y0);
	int p = 2 * dy - dx;
	int twoDy = 2 * dy, twoDyMinusDx = 2 * (dy - dx);
	int x, y;
	if (x0 > xEnd)
	{
		x = xEnd;
		y = yEnd;
		xEnd = x0;
	}
	else
	{
		x = x0;
		y = y0;
	}

	HandleFragment(x0, y0, vertex0, xEnd, yEnd, vertex1, x, y);

	while (x < xEnd)
	{
		x++;
		if (p < 0)
		{
			p += twoDy;
		}
		else
		{
			y++;
			p += twoDyMinusDx;
		}

		HandleFragment(x0, y0, vertex0, xEnd, yEnd, vertex1, x, y);
	}
}
コード例 #2
0
ファイル: ip6.cpp プロジェクト: BJangeofan/openthread
ThreadError HandleExtensionHeaders(Message &message, uint8_t &nextHeader, bool receive)
{
    ThreadError error = kThreadError_None;
    ExtensionHeader extensionHeader;

    while (receive == true || nextHeader == kProtoHopOpts)
    {
        VerifyOrExit(message.GetOffset() <= message.GetLength(), error = kThreadError_Drop);

        message.Read(message.GetOffset(), sizeof(extensionHeader), &extensionHeader);

        switch (nextHeader)
        {
        case kProtoHopOpts:
            SuccessOrExit(error = HandleOptions(message));
            break;

        case kProtoFragment:
            SuccessOrExit(error = HandleFragment(message));
            break;

        case kProtoDstOpts:
            SuccessOrExit(error = HandleOptions(message));
            break;

        case kProtoIp6:
        case kProtoRouting:
        case kProtoNone:
            ExitNow(error = kThreadError_Drop);

        default:
            ExitNow();
        }

        nextHeader = extensionHeader.GetNextHeader();
    }

exit:
    return error;
}