Esempio n. 1
0
void Terrain::AddFilter(float* terrainData, float weight)
{
	int i;

	// erode left to right, starting from the beginning
	for(i = 0; i < m_size; i++)
		FilterPass(&terrainData[m_size*i], 1, weight);

	// erode right to left, starting from the end of each row
	for(i = 0; i < m_size; i++)
		FilterPass(&terrainData[m_size*i + m_size-1], -1, weight);

	// erode top to bottm, starting at the beginning of the column
	for(i = 0; i < m_size; i++)
		FilterPass(&terrainData[i], m_size, weight);

	// erode from bottom to top, starting from the end of the column
	for(i = 0; i < m_size; i++)
		FilterPass(&terrainData[m_size*(m_size-1) + i], -m_size, weight);
}
Esempio n. 2
0
NTSTATUS
FilterDispatchIo(
    PDEVICE_OBJECT    DeviceObject,
    PIRP              Irp
    )
/*++

Routine Description:

    This routine is the dispatch routine for non passthru irps.
    We will check the input device object to see if the request
    is meant for the control device object. If it is, we will
    handle and complete the IRP, if not, we will pass it down to 
    the lower driver.
    
Arguments:

    DeviceObject - Pointer to the device object.

    Irp - Pointer to the request packet.

Return Value:

    NT Status code
--*/
{
    PIO_STACK_LOCATION  irpStack;
    NTSTATUS            status;
    PCONTROL_DEVICE_EXTENSION   deviceExtension;
    PCOMMON_DEVICE_DATA commonData;

    PAGED_CODE();

   commonData = (PCOMMON_DEVICE_DATA)DeviceObject->DeviceExtension;


    //
    // Please note that this is a common dispatch point for controlobject and
    // filter deviceobject attached to the pnp stack. 
    //
    if (commonData->Type == DEVICE_TYPE_FIDO) {
        //
        // We will just  the request down as we are not interested in handling
        // requests that come on the PnP stack.
        //
        return FilterPass(DeviceObject, Irp);    
    }
 
    ASSERT(commonData->Type == DEVICE_TYPE_CDO);

    deviceExtension = (PCONTROL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
    
    //
    // Else this is targeted at our control deviceobject so let's handle it.
    // Here we will handle the IOCTl requests that come from the app.
    // We don't have to worry about acquiring remlocks for I/Os that come 
    // on our control object because the I/O manager takes reference on our 
    // deviceobject when it initiates a request to our device and that keeps
    // our driver from unloading when we have pending I/Os. But we still
    // have to watch out for a scenario where another driver can send 
    // requests to our deviceobject directly without opening an handle.
    //
    if (!deviceExtension->Deleted) { //if not deleted
        status = STATUS_SUCCESS;
        Irp->IoStatus.Information = 0;
        irpStack = IoGetCurrentIrpStackLocation (Irp);

        switch (irpStack->MajorFunction) {
            case IRP_MJ_CREATE:
                DebugPrint(("Create \n"));
                break;
                
            case IRP_MJ_CLOSE:
                DebugPrint(("Close \n"));
                break;
                
            case IRP_MJ_CLEANUP:
                DebugPrint(("Cleanup \n"));
                break;
                
             case  IRP_MJ_DEVICE_CONTROL:
                DebugPrint(("DeviceIoControl\n"));
                switch (irpStack->Parameters.DeviceIoControl.IoControlCode) {
                    //
                    //case IOCTL_CUSTOM_CODE: 
                    //
                    default:
                        status = STATUS_INVALID_PARAMETER;
                        break;
                }
            default:
                break;
        }
    } else {
        ASSERTMSG(FALSE, "Requests being sent to a dead device\n");
        status = STATUS_DEVICE_REMOVED;
    }
    Irp->IoStatus.Status = status;
    IoCompleteRequest (Irp, IO_NO_INCREMENT);
    return status;
}