Example #1
0
Display *Display::getDisplay(EGLNativeDisplayType displayId, const AttributeMap &attribMap)
{
    // Initialize the global platform if not already
    InitDefaultPlatformImpl();

    Display *display = NULL;

    DisplayMap *displays = GetDisplayMap();
    DisplayMap::const_iterator iter = displays->find(displayId);
    if (iter != displays->end())
    {
        display = iter->second;
    }

    if (display == nullptr)
    {
        // Validate the native display
        if (!Display::isValidNativeDisplay(displayId))
        {
            return NULL;
        }

        display = new Display(displayId);
        displays->insert(std::make_pair(displayId, display));
    }

    // Apply new attributes if the display is not initialized yet.
    if (!display->isInitialized())
    {
        rx::DisplayImpl* impl = CreateDisplayImpl(attribMap);
        display->setAttributes(impl, attribMap);
    }

    return display;
}
Example #2
0
Error Display::initialize()
{
    // Re-initialize default platform if it's needed
    InitDefaultPlatformImpl();

    SCOPED_ANGLE_HISTOGRAM_TIMER("GPU.ANGLE.DisplayInitializeMS");
    TRACE_EVENT0("gpu.angle", "egl::Display::initialize");

    ASSERT(mImplementation != nullptr);

    if (isInitialized())
    {
        return Error(EGL_SUCCESS);
    }

    Error error = mImplementation->initialize(this);
    if (error.isError())
    {
        // Log extended error message here
        std::stringstream errorStream;
        errorStream << "ANGLE Display::initialize error " << error.getID() << ": "
                    << error.getMessage();
        ANGLEPlatformCurrent()->logError(errorStream.str().c_str());
        return error;
    }

    mCaps = mImplementation->getCaps();

    mConfigSet = mImplementation->generateConfigs();
    if (mConfigSet.size() == 0)
    {
        mImplementation->terminate();
        return Error(EGL_NOT_INITIALIZED);
    }

    initDisplayExtensions();
    initVendorString();

    if (mDisplayExtensions.deviceQuery)
    {
        rx::DeviceImpl *impl = nullptr;
        error = mImplementation->getDevice(&impl);
        if (error.isError())
        {
            return error;
        }
        mDevice = new Device(this, impl);
    }
    else
    {
        mDevice = nullptr;
    }

    mInitialized = true;

    return Error(EGL_SUCCESS);
}
Example #3
0
Error Display::initialize()
{
    // Re-initialize default platform if it's needed
    InitDefaultPlatformImpl();

    double createDeviceBegin = ANGLEPlatformCurrent()->currentTime();

    TRACE_EVENT0("gpu.angle", "egl::Display::initialize");

    ASSERT(mImplementation != nullptr);

    if (isInitialized())
    {
        return Error(EGL_SUCCESS);
    }

    Error error = mImplementation->initialize(this);
    if (error.isError())
    {
        return error;
    }

    mCaps = mImplementation->getCaps();

    mConfigSet = mImplementation->generateConfigs();
    if (mConfigSet.size() == 0)
    {
        mImplementation->terminate();
        return Error(EGL_NOT_INITIALIZED);
    }

    initDisplayExtensions();
    initVendorString();

    if (mDisplayExtensions.deviceQuery)
    {
        rx::DeviceImpl *impl = nullptr;
        error = mImplementation->getDevice(&impl);
        if (error.isError())
        {
            return error;
        }
        mDevice = new Device(this, impl);
    }
    else
    {
        mDevice = nullptr;
    }

    mInitialized = true;

    double displayInitializeSec = ANGLEPlatformCurrent()->currentTime() - createDeviceBegin;
    int displayInitializeMS = static_cast<int>(displayInitializeSec * 1000);
    ANGLE_HISTOGRAM_TIMES("GPU.ANGLE.DisplayInitializeMS", displayInitializeMS);

    return Error(EGL_SUCCESS);
}
Example #4
0
Display *Display::GetDisplayFromDevice(void *native_display)
{
    // Initialize the global platform if not already
    InitDefaultPlatformImpl();

    Display *display = nullptr;

    Device *eglDevice = reinterpret_cast<Device *>(native_display);
    ASSERT(Device::IsValidDevice(eglDevice));

    ANGLEPlatformDisplayMap *anglePlatformDisplays   = GetANGLEPlatformDisplayMap();
    DevicePlatformDisplayMap *devicePlatformDisplays = GetDevicePlatformDisplayMap();

    // First see if this eglDevice is in use by a Display created using ANGLE platform
    for (auto &displayMapEntry : *anglePlatformDisplays)
    {
        egl::Display *iterDisplay = displayMapEntry.second;
        if (iterDisplay->getDevice() == eglDevice)
        {
            display = iterDisplay;
        }
    }

    if (display == nullptr)
    {
        // See if the eglDevice is in use by a Display created using the DEVICE platform
        DevicePlatformDisplayMap::const_iterator iter = devicePlatformDisplays->find(eglDevice);
        if (iter != devicePlatformDisplays->end())
        {
            display = iter->second;
        }
    }

    if (display == nullptr)
    {
        // Otherwise create a new Display
        display = new Display(EGL_PLATFORM_DEVICE_EXT, 0, eglDevice);
        devicePlatformDisplays->insert(std::make_pair(eglDevice, display));
    }

    // Apply new attributes if the display is not initialized yet.
    if (!display->isInitialized())
    {
        rx::DisplayImpl *impl = CreateDisplayFromDevice(eglDevice);
        display->setAttributes(impl, egl::AttributeMap());
    }

    return display;
}
Example #5
0
Display *Display::GetDisplayFromAttribs(void *native_display, const AttributeMap &attribMap)
{
    // Initialize the global platform if not already
    InitDefaultPlatformImpl();

    Display *display = nullptr;

    EGLNativeDisplayType displayId = reinterpret_cast<EGLNativeDisplayType>(native_display);

    ANGLEPlatformDisplayMap *displays            = GetANGLEPlatformDisplayMap();
    ANGLEPlatformDisplayMap::const_iterator iter = displays->find(displayId);
    if (iter != displays->end())
    {
        display = iter->second;
    }

    if (display == nullptr)
    {
        // Validate the native display
        if (!Display::isValidNativeDisplay(displayId))
        {
            return NULL;
        }

        display = new Display(EGL_PLATFORM_ANGLE_ANGLE, displayId, nullptr);
        displays->insert(std::make_pair(displayId, display));
    }

    // Apply new attributes if the display is not initialized yet.
    if (!display->isInitialized())
    {
        rx::DisplayImpl *impl = CreateDisplayFromAttribs(attribMap);
        if (impl == nullptr)
        {
            // No valid display implementation for these attributes
            return nullptr;
        }

        display->setAttributes(impl, attribMap);
    }

    return display;
}
Example #6
0
Error Display::initialize()
{
    // Re-initialize default platform if it's needed
    InitDefaultPlatformImpl();

    SCOPED_ANGLE_HISTOGRAM_TIMER("GPU.ANGLE.DisplayInitializeMS");
    TRACE_EVENT0("gpu.angle", "egl::Display::initialize");

    ASSERT(mImplementation != nullptr);

    if (isInitialized())
    {
        return egl::Error(EGL_SUCCESS);
    }

    Error error = mImplementation->initialize(this);
    if (error.isError())
    {
        // Log extended error message here
        std::stringstream errorStream;
        errorStream << "ANGLE Display::initialize error " << error.getID() << ": "
                    << error.getMessage();
        ANGLEPlatformCurrent()->logError(errorStream.str().c_str());
        return error;
    }

    mCaps = mImplementation->getCaps();

    mConfigSet = mImplementation->generateConfigs();
    if (mConfigSet.size() == 0)
    {
        mImplementation->terminate();
        return Error(EGL_NOT_INITIALIZED);
    }

    initDisplayExtensions();
    initVendorString();

    // Populate the Display's EGLDeviceEXT if the Display wasn't created using one
    if (mPlatform != EGL_PLATFORM_DEVICE_EXT)
    {
        if (mDisplayExtensions.deviceQuery)
        {
            rx::DeviceImpl *impl = nullptr;
            ANGLE_TRY(mImplementation->getDevice(&impl));
            ANGLE_TRY(Device::CreateDevice(this, impl, &mDevice));
        }
        else
        {
            mDevice = nullptr;
        }
    }
    else
    {
        // For EGL_PLATFORM_DEVICE_EXT, mDevice should always be populated using
        // an external device
        ASSERT(mDevice != nullptr);
    }

    mInitialized = true;

    return egl::Error(EGL_SUCCESS);
}