예제 #1
0
	bool ZCompare(u16 x, u16 y, u32 z)
	{
		u32 offset = GetDepthOffset(x, y);
		u32 depth = GetPixelDepth(offset);

		bool pass;

		switch (bpmem.zmode.func)
		{
		case ZMode::NEVER:
			pass = false;
			break;
		case ZMode::LESS:
			pass = z < depth;
			break;
		case ZMode::EQUAL:
			pass = z == depth;
			break;
		case ZMode::LEQUAL:
			pass = z <= depth;
			break;
		case ZMode::GREATER:
			pass = z > depth;
			break;
		case ZMode::NEQUAL:
			pass = z != depth;
			break;
		case ZMode::GEQUAL:
			pass = z >= depth;
			break;
		case ZMode::ALWAYS:
			pass = true;
			break;
		default:
			pass = false;
			ERROR_LOG(VIDEO, "Bad Z compare mode %i", (int)bpmem.zmode.func);
		}

		if (pass && bpmem.zmode.updateenable)
		{
			SetPixelDepth(offset, z);
		}

		return pass;
	}
예제 #2
0
NS_IMETHODIMP 
nsScreenOS2 :: GetColorDepth(PRInt32 *aColorDepth)
{
  return GetPixelDepth ( aColorDepth );

} // GetColorDepth
예제 #3
0
NS_IMETHODIMP 
nsScreenWin :: GetColorDepth(int32_t *aColorDepth)
{
  return GetPixelDepth(aColorDepth);

} // GetColorDepth
예제 #4
0
	u32 GetDepth(u16 x, u16 y)
	{
		u32 offset = GetDepthOffset(x, y);
		return GetPixelDepth(offset);
	}
예제 #5
0
EFI_STATUS InitDisplays()
{
    UINTN size = 0;
    EFI_HANDLE* handles = nullptr;
    EFI_STATUS status;

    // LocateHandle() should only be called twice... But I don't want to write it twice :)
    while ((status = BS->LocateHandle(ByProtocol, &g_efiGraphicsOutputProtocolGuid, nullptr, &size, handles)) == EFI_BUFFER_TOO_SMALL)
    {
        handles = (EFI_HANDLE*)realloc(handles, size);
        if (!handles)
        {
            return EFI_OUT_OF_RESOURCES;
        }
    }

    if (EFI_ERROR(status))
    {
        return status;
    }

    const int count = size / sizeof(EFI_HANDLE);

    for (int i = 0; i != count; ++i)
    {
        EFI_DEVICE_PATH_PROTOCOL* dpp = nullptr;
        BS->HandleProtocol(handles[i], &g_efiDevicePathProtocolGuid, (void**)&dpp);

        // If dpp is NULL, this is the "Console Splitter" driver. It is used to draw on all
        // screens at the same time and doesn't represent a real hardware device.
        if (!dpp) continue;

        EFI_GRAPHICS_OUTPUT_PROTOCOL* gop = nullptr;
        BS->HandleProtocol(handles[i], &g_efiGraphicsOutputProtocolGuid, (void**)&gop);

        EFI_EDID_ACTIVE_PROTOCOL* edid = nullptr;
        BS->HandleProtocol(handles[i], &g_efiEdidActiveProtocolGuid, (void**)&edid);

        InitDisplay(gop, edid);

        if (g_bootInfo.framebufferCount < ARRAY_LENGTH(BootInfo::framebuffers))
        {
            Framebuffer* fb = &g_bootInfo.framebuffers[g_bootInfo.framebufferCount];
            auto info = gop->Mode->Info;
            auto pixelFormat = DeterminePixelFormat(info);

            fb->width = info->HorizontalResolution;
            fb->height = info->VerticalResolution;
            fb->pitch = info->PixelsPerScanLine * GetPixelDepth(pixelFormat);
            fb->format = pixelFormat;
            fb->pixels = (uintptr_t)gop->Mode->FrameBufferBase;

            g_bootInfo.framebufferCount += 1;
        }
    }

    free(handles);


    // Initialize the graphics console
    if (g_bootInfo.framebufferCount > 0)
    {
        Framebuffer* fb = g_bootInfo.framebuffers;

        g_frameBuffer.width = fb->width;
        g_frameBuffer.height = fb->height;
        g_frameBuffer.pitch = fb->pitch;
        g_frameBuffer.pixels = (void*)fb->pixels;
        g_frameBuffer.format = fb->format;

        g_graphicsConsole.Initialize(&g_frameBuffer);
        g_graphicsConsole.Clear();

        g_console = &g_graphicsConsole;
    }

    return EFI_SUCCESS;
}