public int CompareTo(object obj)
 {
     if (obj is int)
     {
         return(BufferIndex.CompareTo((int)obj));
     }
     return(BufferIndex.CompareTo(((Mark)obj).BufferIndex));
 }
Beispiel #2
0
 internal void SetAccessControlAllowOrigin(BufferIndex index)
 {
     if (index.Length == 0)
     {
         Flag &= ResponseFlag.All ^ ResponseFlag.AccessControlAllowOrigin;
     }
     else
     {
         AccessControlAllowOrigin = index;
         Flag |= ResponseFlag.AccessControlAllowOrigin;
     }
 }
Beispiel #3
0
        /// <summary>
        /// This is used by the transparency z-order sorting.
        ///
        /// Therefore highest z-values (which are in the back) come
        /// first as they need to be drawn before front ones.
        /// </summary>
        public int CompareTo(DrawCommand other)
        {
            if (other == null)
            {
                return(1);
            }

            if (Z == other.Z)
            {
                return(BufferIndex.CompareTo(other.BufferIndex));
            }

            // This is equal to the greater check.
            return(other.Z.CompareTo(Z));
        }
Beispiel #4
0
        private void SetVisionIndex(BufferIndex index)
        {
            switch (index)
            {
            case BufferIndex.RightCell:
                optionBox1.Checked = true;
                break;

            case BufferIndex.MiddleCell:
                optionBox2.Checked = true;
                break;

            case BufferIndex.LeftCell:
                optionBox3.Checked = true;
                break;

            case BufferIndex.Test:
                optionBox4.Checked = true;
                break;
            }
        }
        private unsafe void Read(int column, int row, int width, int height, float *buffer, int skipRows, int skipColumns, int bufferWidth, int bufferHeight)
        {
            BufferIndex index = new BufferIndex();

            index.Buffer = buffer;
            index.Row    = skipRows;
            index.Height = bufferHeight;
            index.Width  = bufferWidth;

            int targetColumn = column + width;
            int targetRow    = row + height;

            int currentColumn = column;

            index.Column = skipColumns;

            //currentColumn < 0
            for (; currentColumn < 0 && currentColumn < targetColumn;
                 ++currentColumn, ++index.Column)
            {
                index.Row = skipRows;

                for (int currentRow = row;
                     currentRow < targetRow;
                     ++currentRow, ++index.Row)
                {
                    SetValue(ref index, 0);
                }
            }

            //currentcolumn in range
            for (; currentColumn < this.width && currentColumn < targetColumn;
                 ++currentColumn, ++index.Column)
            {
                index.Row = skipRows;
                int currentRow = row;

                //currentRow < 0
                for (; currentRow < 0 && currentRow < targetRow;
                     ++currentRow, ++index.Row)
                {
                    SetValue(ref index, 0);
                }

                //currentRow in range
                if (currentRow < targetRow)                       //check whether there is need to seek
                {
                    Seek(currentColumn, currentRow);
                    for (; currentRow < this.height && currentRow < targetRow;
                         ++currentRow, ++index.Row)
                    {
                        SetValue(ref index, reader.ReadSingle());
                    }

                    //currentRow >= height
                    for (; currentRow < targetRow;
                         ++currentRow, ++index.Row)
                    {
                        SetValue(ref index, 0);
                    }
                }
            }

            //currentColumn >= width
            for (; currentColumn < targetColumn;
                 ++currentColumn, ++index.Column)
            {
                index.Row = skipRows;

                for (int currentRow = row;
                     currentRow < targetRow;
                     ++currentRow, ++index.Row)
                {
                    SetValue(ref index, 0);
                }
            }
        }
 private unsafe void SetValue(ref BufferIndex index, float value)
 {
     index.Buffer[(index.Row + index.Height) % index.Height * index.Width + (index.Column + index.Width) % index.Width] = value;
 }
Beispiel #7
0
        /// <summary>
        /// HTTP请求处理[TRY]
        /// </summary>
        /// <param name="socket">HTTP套接字</param>
        public override unsafe void Request(Http.SocketBase socket)
        {
            Http.Header header = socket.HttpHeader;
            if (((uint)header.ContentLength | (uint)header.IsBoundary) == 0)
            {
                Http.Response            response = Http.Response.Get();
                SubBuffer.PoolBufferFull buffer   = header.Buffer;
                byte[]      domain = socket.IsSsl ? sslLocationDomain : locationDomain, bufferArray = buffer.Buffer;
                BufferIndex uri    = header.UriIndex;
                int         length = domain.Length + uri.Length;
                if (uri.Length != 0)
                {
                    if (bufferArray[buffer.StartIndex + uri.StartIndex] == '/')
                    {
                        uri.Next();
                        if (uri.Length == 0)
                        {
                            goto END;
                        }
                        --length;
                    }
                    if (length <= header.HeaderEndIndex)
                    {
                        int startIndex = uri.StartIndex - domain.Length;
                        if (startIndex >= 0)
                        {
                            Buffer.BlockCopy(domain, 0, bufferArray, startIndex += buffer.StartIndex, domain.Length);
                            response.SetLocation(bufferArray, startIndex, length, locationState);
                        }
                        else
                        {
                            Buffer.BlockCopy(bufferArray, buffer.StartIndex + uri.StartIndex, bufferArray, buffer.StartIndex + domain.Length, uri.Length);
                            Buffer.BlockCopy(domain, 0, bufferArray, buffer.StartIndex, domain.Length);
                            response.SetLocation(bufferArray, buffer.StartIndex, length, locationState);
                        }
                        socket.ResponseIdentity(ref response);
                        return;
                        //int endIndex = uri.EndIndex;
                        //if (header.HeaderEndIndex - endIndex - 7 >= length)
                        //{
                        //    fixed (byte* bufferFixed = bufferArray)
                        //    {
                        //        byte* bufferStart = bufferFixed + buffer.StartIndex, write = bufferStart + endIndex;
                        //        Memory.SimpleCopyNotNull64(domain, write, domain.Length);
                        //        Memory.SimpleCopyNotNull64(bufferStart + uri.StartIndex, write + domain.Length, uri.Length);
                        //    }
                        //    response.SetLocation(bufferArray, buffer.StartIndex + endIndex, length, locationState);
                        //    socket.Response(socketIdentity, ref response);
                        //    return;
                        //}
                    }
                }
END:
                response.SetLocation(domain, locationState);
                socket.ResponseIdentity(ref response);
            }
            else
            {
                socket.ResponseErrorIdentity(Http.ResponseState.BadRequest400);
            }
        }
Beispiel #8
0
        private unsafe void Read(int column, int row, int width, int height, float* buffer, int skipRows, int skipColumns, int bufferWidth, int bufferHeight)
        {
            BufferIndex index = new BufferIndex();
                index.Buffer = buffer;
                index.Row = skipRows;
                index.Height = bufferHeight;
                index.Width = bufferWidth;

                int targetColumn = column + width;
                int targetRow = row + height;

                int currentColumn = column;
                index.Column = skipColumns;

                //currentColumn < 0
                for (; currentColumn < 0 && currentColumn < targetColumn;
                     ++currentColumn, ++index.Column)
                {
                    index.Row = skipRows;

                    for (int currentRow = row;
                         currentRow < targetRow;
                         ++currentRow, ++index.Row)
                    {
                        SetValue(ref index, 0);
                    }
                }

                //currentcolumn in range
                for (; currentColumn < this.width && currentColumn < targetColumn;
                     ++currentColumn, ++index.Column)
                {
                    index.Row = skipRows;
                    int currentRow = row;

                    //currentRow < 0
                    for (; currentRow < 0 && currentRow < targetRow;
                         ++currentRow, ++index.Row)
                    {
                        SetValue(ref index, 0);
                    }

                    //currentRow in range
                    if(currentRow < targetRow)//check whether there is need to seek
                    {
                        Seek(currentColumn, currentRow);
                        for (; currentRow < this.height && currentRow < targetRow;
                             ++currentRow, ++index.Row)
                        {
                            SetValue(ref index, reader.ReadSingle());
                        }

                        //currentRow >= height
                        for (; currentRow < targetRow;
                             ++currentRow, ++index.Row)
                        {
                            SetValue(ref index, 0);
                        }
                    }
                }

                //currentColumn >= width
                for (; currentColumn < targetColumn;
                     ++currentColumn, ++index.Column)
                {
                    index.Row = skipRows;

                    for (int currentRow = row;
                         currentRow < targetRow;
                         ++currentRow, ++index.Row)
                    {
                        SetValue(ref index, 0);
                    }
                }
        }
Beispiel #9
0
 private unsafe void SetValue(ref BufferIndex index, float value)
 {
     index.Buffer[(index.Row + index.Height) % index.Height * index.Width + (index.Column + index.Width) % index.Width] = value;
 }