Exemplo n.º 1
0
int init_eglpbuffer(/*out*/eglpbuffer_t * eglpbuf, struct opengl_display_t * egldisp, struct opengl_config_t * eglconf, uint32_t width, uint32_t height)
{
   int err;
   EGLint attr[] = {
      EGL_HEIGHT, height > INT32_MAX ? INT32_MAX : (int32_t)height,
      EGL_WIDTH,  width  > INT32_MAX ? INT32_MAX : (int32_t)width,
      EGL_NONE
   };
   EGLSurface surface = eglCreatePbufferSurface(egldisp, eglconf, attr);

   if (EGL_NO_SURFACE == surface) {
      goto ONERR;
   }

   *eglpbuf = surface;

   return 0;
ONERR:
   err = convert2errno_egl(eglGetError());
   TRACEEXIT_ERRLOG(err);
   return err;
}
Exemplo n.º 2
0
int free_eglpbuffer(eglpbuffer_t * eglpbuf, struct opengl_display_t * egldisp)
{
   int err;

   if (*eglpbuf) {
      EGLBoolean isDestoyed = eglDestroySurface(egldisp, *eglpbuf);

      *eglpbuf = 0;

      if (EGL_FALSE == isDestoyed) {
         err = convert2errno_egl(eglGetError());
         goto ONERR;
      }

      if (PROCESS_testerrortimer(&s_eglpbuffer_errtimer, &err)) goto ONERR;
   }

   return 0;
ONERR:
   TRACEEXITFREE_ERRLOG(err);
   return err;
}
Exemplo n.º 3
0
EGLWindowTransportSurface::EGLWindowTransportSurface(SurfaceAttributes attributes)
    : GLTransportSurface(attributes)
{
    m_configSelector = adoptPtr(new EGLConfigSelector(attributes, NativeWrapper::nativeDisplay()));
    m_sharedDisplay = m_configSelector->display();

    if (m_sharedDisplay == EGL_NO_DISPLAY) {
        m_configSelector = nullptr;
        return;
    }

    EGLConfig config = m_configSelector->surfaceContextConfig();

    if (!config) {
        destroy();
        return;
    }

    EGLint visualId = m_configSelector->nativeVisualId(config);

    if (visualId == -1) {
        destroy();
        return;
    }

    NativeWrapper::createOffScreenWindow(&m_bufferHandle, (attributes & GLPlatformSurface::SupportAlpha), visualId);

    if (!m_bufferHandle) {
        destroy();
        return;
    }

    m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_configSelector->surfaceContextConfig(), (EGLNativeWindowType)m_bufferHandle, 0);

    if (m_drawable == EGL_NO_SURFACE) {
        LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
        destroy();
    }
}
Exemplo n.º 4
0
static void
egl_perror(const char *msg) {
    static const char *errmsg[] = {
        "function succeeded",
        "EGL is not initialized, or could not be initialized, for the specified display",
        "cannot access a requested resource",
        "failed to allocate resources for the requested operation",
        "an unrecognized attribute or attribute value was passed in an attribute list",
        "an EGLConfig argument does not name a valid EGLConfig",
        "an EGLContext argument does not name a valid EGLContext",
        "the current surface of the calling thread is no longer valid",
        "an EGLDisplay argument does not name a valid EGLDisplay",
        "arguments are inconsistent",
        "an EGLNativePixmapType argument does not refer to a valid native pixmap",
        "an EGLNativeWindowType argument does not refer to a valid native window",
        "one or more argument values are invalid",
        "an EGLSurface argument does not name a valid surface configured for rendering",
        "a power management event has occurred",
    };

    fprintf(stderr, "%s: %s\n", msg, errmsg[eglGetError() - EGL_SUCCESS]);
}
EGLint GLContext::Resume(ANativeWindow *window) {
  if (egl_context_initialized_ == false) {
    Init(window, msaa_size_);
    return EGL_SUCCESS;
  }

  int32_t original_widhth = screen_width_;
  int32_t original_height = screen_height_;

  //Create surface
  window_ = window;
  surface_ = eglCreateWindowSurface(display_, config_, window_, NULL);
  eglQuerySurface(display_, surface_, EGL_WIDTH, &screen_width_);
  eglQuerySurface(display_, surface_, EGL_HEIGHT, &screen_height_);

  if (screen_width_ != original_widhth || screen_height_ != original_height) {
    //Screen resized
    LOGI("Screen resized");
  }

  if (eglMakeCurrent(display_, surface_, surface_, context_) == EGL_TRUE)
    return EGL_SUCCESS;

  EGLint err = eglGetError();
  LOGW("Unable to eglMakeCurrent %d", err);

  if (err == EGL_CONTEXT_LOST) {
    //Recreate context
    LOGI("Re-creating egl context");
    InitEGLContext();
  } else {
    //Recreate surface
    Terminate();
    InitEGLSurface();
    InitEGLContext();
  }

  return err;
}
    virtual void SetUp() {
        // static const EGLint SURFACE_ATTRIBS[] = {
        //     EGL_NONE
        // };

        mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
        ASSERT_NE(EGL_NO_DISPLAY, mEglDisplay);

        EGLint major, minor;
        ASSERT_TRUE(eglInitialize(mEglDisplay, &major, &minor));

        EGLint numConfigs = 0;
        ASSERT_TRUE(eglChooseConfig(mEglDisplay, getConfigAttribs(),
                &mEglConfig, 1, &numConfigs));
        ASSERT_GE(1, numConfigs);
        ASSERT_NE((EGLConfig)0, mEglConfig);

        mEglWindowSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig,
                GLTestHelper::getWindow(), getWindowSurfaceAttribs());
        ASSERT_EQ(EGL_SUCCESS, eglGetError());
        ASSERT_NE(EGL_NO_SURFACE, mEglWindowSurface);
    }
Exemplo n.º 7
0
/**
 * \brief Destroy the context.
 *
 * This function is called after power events and at shutdown.
 */
void Main::destroyContext()
{
    assert(eglContext != EGL_NO_CONTEXT);

    // Make sure the context is not current.
    if (eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) == EGL_FALSE)
    {
        EGLint error = eglGetError();
        if (error == EGL_CONTEXT_LOST)
        {
            Platform::displayMessage("Power event when trying to initialize.  I don't know how to handle this.");
            return;
        }
        Platform::fatalError("eglMakeCurrent failed in Graphics::initializeOpenglState.  Maybe this is normal when power events occur.");
        return;
    }

    // Destroy the context.
    eglDestroyContext(eglDisplay, eglContext);
    checkEglError("eglDestroyContext");
    eglContext = EGL_NO_CONTEXT;
}
Exemplo n.º 8
0
// simple support, only for rgba images
PBO& PBO::setup(int nWidth, int nHeight, GLenum nColorType) {
	width = nWidth;
	height = nHeight;
	color_type = nColorType;
	buffer_size = width * height * 4;
	unbind(); // see note in header.
	glBindTexture(GL_TEXTURE_2D, texture_id); eglGetError();
	glEnable(GL_TEXTURE_2D); eglGetError();
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); eglGetError();
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); eglGetError();
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); eglGetError();
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); eglGetError();
	glTexImage2D(
		 GL_TEXTURE_2D, 0
		,GL_RGBA, width, height, 0
        ,color_type, GL_UNSIGNED_BYTE, NULL
	);eglGetError();
	//unbind();
	return *this;
}
EGLint GLContext::Swap() {
  bool b = eglSwapBuffers(display_, surface_);
  if (!b) {
    EGLint err = eglGetError();
    if (err == EGL_BAD_SURFACE) {
      //Recreate surface
      InitEGLSurface();
      err = EGL_SUCCESS; //Still consider glContext is valid
    } else if (err == EGL_CONTEXT_LOST || err == EGL_BAD_CONTEXT) {
      //Context has been lost!!
      context_valid_ = false;
      Terminate();
      InitEGLContext();
    }

    return err;
  }
  if (restoreInterval_ && swapInterval_ != SWAPINTERVAL_DEFAULT) {
    eglSwapInterval(display_, swapInterval_); //Restore Swap interval
  }
  return EGL_SUCCESS;
}
int MinutesPerGameRenderer::initGL() {

    GLThread::instance()->resize(m_width,m_height);

    //Query width and height of the window surface created by utility code
    EGLint surface_width, surface_height;

    eglQuerySurface(egl_disp, egl_surf, EGL_WIDTH, &surface_width);
    eglQuerySurface(egl_disp, egl_surf, EGL_HEIGHT, &surface_height);

    EGLint err = eglGetError();
    if (err != 0x3000) {
        fprintf(stderr, "Unable to query EGL surface dimensions\n");
        return EXIT_FAILURE;
    }

    glShadeModel(GL_SMOOTH);
    qDebug() << __LINE__ <<"=" << glGetError();
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    qDebug() << __LINE__ <<"=" << glGetError();

    glViewport(0, 0, surface_width, surface_height);
    qDebug() << __LINE__ <<"=" << glGetError();
    glMatrixMode(GL_PROJECTION);
    qDebug() << __LINE__ <<"=" << glGetError();
    glLoadIdentity();

    glOrthof(0.0f, (float) (surface_width) / (float) (surface_height), 0.0f, 1.0f, -1.0f, 1.0f);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glTranslatef((float) (surface_width) / (float) (surface_height) / 2, 0.5f, 0.5f);

    glScalef(0.5f, 0.5f, 0.0f);

    return EXIT_SUCCESS;
}
Exemplo n.º 11
0
static const gchar *
gst_gl_context_egl_get_error_string (void)
{
  EGLint nErr = eglGetError ();

  switch (nErr) {
    case EGL_SUCCESS:
      return "EGL_SUCCESS";
    case EGL_BAD_DISPLAY:
      return "EGL_BAD_DISPLAY";
    case EGL_NOT_INITIALIZED:
      return "EGL_NOT_INITIALIZED";
    case EGL_BAD_ACCESS:
      return "EGL_BAD_ACCESS";
    case EGL_BAD_ALLOC:
      return "EGL_BAD_ALLOC";
    case EGL_BAD_ATTRIBUTE:
      return "EGL_BAD_ATTRIBUTE";
    case EGL_BAD_CONFIG:
      return "EGL_BAD_CONFIG";
    case EGL_BAD_CONTEXT:
      return "EGL_BAD_CONTEXT";
    case EGL_BAD_CURRENT_SURFACE:
      return "EGL_BAD_CURRENT_SURFACE";
    case EGL_BAD_MATCH:
      return "EGL_BAD_MATCH";
    case EGL_BAD_NATIVE_PIXMAP:
      return "EGL_BAD_NATIVE_PIXMAP";
    case EGL_BAD_NATIVE_WINDOW:
      return "EGL_BAD_NATIVE_WINDOW";
    case EGL_BAD_PARAMETER:
      return "EGL_BAD_PARAMETER";
    case EGL_BAD_SURFACE:
      return "EGL_BAD_SURFACE";
    default:
      return "unknown";
  }
}
Exemplo n.º 12
0
/*******************************************************************************
 * Function Name  : StringFrom_eglGetError
 * Returns        : A string
 * Description    : Returns a string representation of an egl error
 *******************************************************************************/
const char *PVRShellInitAPI::StringFrom_eglGetError() const
{
	EGLint nErr = eglGetError();

	switch(nErr)
	{
		case EGL_SUCCESS:
			return "EGL_SUCCESS";
		case EGL_BAD_DISPLAY:
			return "EGL_BAD_DISPLAY";
		case EGL_NOT_INITIALIZED:
			return "EGL_NOT_INITIALIZED";
		case EGL_BAD_ACCESS:
			return "EGL_BAD_ACCESS";
		case EGL_BAD_ALLOC:
			return "EGL_BAD_ALLOC";
		case EGL_BAD_ATTRIBUTE:
			return "EGL_BAD_ATTRIBUTE";
		case EGL_BAD_CONFIG:
			return "EGL_BAD_CONFIG";
		case EGL_BAD_CONTEXT:
			return "EGL_BAD_CONTEXT";
		case EGL_BAD_CURRENT_SURFACE:
			return "EGL_BAD_CURRENT_SURFACE";
		case EGL_BAD_MATCH:
			return "EGL_BAD_MATCH";
		case EGL_BAD_NATIVE_PIXMAP:
			return "EGL_BAD_NATIVE_PIXMAP";
		case EGL_BAD_NATIVE_WINDOW:
			return "EGL_BAD_NATIVE_WINDOW";
		case EGL_BAD_PARAMETER:
			return "EGL_BAD_PARAMETER";
		case EGL_BAD_SURFACE:
			return "EGL_BAD_SURFACE";
		default:
			return "unknown";
	}
}
Exemplo n.º 13
0
EGLSurface createBCMPixmapSurface(EGLDisplay display, EGLConfig config)
{
    EGLint pixel_format = EGL_PIXEL_FORMAT_ARGB_8888_BRCM;
    EGLint rt;
    eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &rt);

    if (rt & EGL_OPENGL_ES_BIT) {
        pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES_BRCM;
        pixel_format |= EGL_PIXEL_FORMAT_GLES_TEXTURE_BRCM;
    }
    if (rt & EGL_OPENGL_ES2_BIT) {
        pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES2_BRCM;
        pixel_format |= EGL_PIXEL_FORMAT_GLES2_TEXTURE_BRCM;
    }
    if (rt & EGL_OPENVG_BIT) {
        pixel_format |= EGL_PIXEL_FORMAT_RENDER_VG_BRCM;
        pixel_format |= EGL_PIXEL_FORMAT_VG_IMAGE_BRCM;
    }
    if (rt & EGL_OPENGL_BIT) {
        pixel_format |= EGL_PIXEL_FORMAT_RENDER_GL_BRCM;
    }

    EGLint pixmap[5];
    pixmap[0] = 0;
    pixmap[1] = 0;
    pixmap[2] = 8;
    pixmap[3] = 8;
    pixmap[4] = pixel_format;

    eglCreateGlobalImageBRCM(8, 8, pixel_format, 0, 8*4, pixmap);

    EGLSurface surface = eglCreatePixmapSurface(display, config, pixmap, 0);
    if ( surface == EGL_NO_SURFACE ) {
        cerr << "Unable to create EGL surface (eglError: " << eglGetError() << ")" << endl;
    }
    return surface;

}
Exemplo n.º 14
0
bool NativeEngine::InitSurface() {
    // need a display
    MY_ASSERT(mEglDisplay != EGL_NO_DISPLAY);

    if (mEglSurface != EGL_NO_SURFACE) {
        // nothing to do
        LOGD("NativeEngine: no need to init surface (already had one).");
        return true;
    }
        
    LOGD("NativeEngine: initializing surface.");
    
    EGLint numConfigs;

    const EGLint attribs[] = {
            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // request OpenGL ES 2.0
            EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
            EGL_BLUE_SIZE, 8,
            EGL_GREEN_SIZE, 8,
            EGL_RED_SIZE, 8,
            EGL_DEPTH_SIZE, 16,
            EGL_NONE
    };

    // since this is a simple sample, we have a trivial selection process. We pick
    // the first EGLConfig that matches:
    eglChooseConfig(mEglDisplay, attribs, &mEglConfig, 1, &numConfigs);

    // create EGL surface
    mEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig, mApp->window, NULL);
    if (mEglSurface == EGL_NO_SURFACE) {
        LOGE("Failed to create EGL surface, EGL error %d", eglGetError());
        return false;
    }

    LOGD("NativeEngine: successfully initialized surface.");
    return true;
}
Exemplo n.º 15
0
EGLImageKHR GLConsumer::createImage(EGLDisplay dpy,
        const sp<GraphicBuffer>& graphicBuffer, const Rect& crop) {
    EGLClientBuffer cbuf = (EGLClientBuffer)graphicBuffer->getNativeBuffer();
    EGLint attrs[] = {
        EGL_IMAGE_PRESERVED_KHR,        EGL_TRUE,
        EGL_IMAGE_CROP_LEFT_ANDROID,    crop.left,
        EGL_IMAGE_CROP_TOP_ANDROID,     crop.top,
        EGL_IMAGE_CROP_RIGHT_ANDROID,   crop.right,
        EGL_IMAGE_CROP_BOTTOM_ANDROID,  crop.bottom,
        EGL_NONE,
    };
    if (!crop.isValid()) {
        // No crop rect to set, so terminate the attrib array before the crop.
        attrs[2] = EGL_NONE;
    } else if (!isEglImageCroppable(crop)) {
        // The crop rect is not at the origin, so we can't set the crop on the
        // EGLImage because that's not allowed by the EGL_ANDROID_image_crop
        // extension.  In the future we can add a layered extension that
        // removes this restriction if there is hardware that can support it.
        attrs[2] = EGL_NONE;
    }
    EGLImageKHR image = eglCreateImageKHR(dpy, EGL_NO_CONTEXT,
            EGL_NATIVE_BUFFER_ANDROID, cbuf, attrs);
    if (image == EGL_NO_IMAGE_KHR) {
        EGLint error = eglGetError();
        ST_LOGE("error creating EGLImage: %#x", error);
    }
#ifndef MTK_DEFAULT_AOSP
    else {
        // add log for eglImage created
        ST_LOGI("[%s]", __func__);
        ALOGD("    GraphicBuffer: gb=%p handle=%p fmt=%d",
            graphicBuffer.get(), graphicBuffer->handle, graphicBuffer->format);
        ALOGD("    EGLImage: dpy=%p, img=%p", mEglDisplay, image);
    }
#endif
    return image;
}
Exemplo n.º 16
0
static EGLenum checkErrorEGL(const char* msg)
{
	GP_ASSERT(msg);
	static const char* errmsg[] =
			{ "EGL function succeeded",
					"EGL is not initialized, or could not be initialized, for the specified display",
					"EGL cannot access a requested resource",
					"EGL failed to allocate resources for the requested operation",
					"EGL fail to access an unrecognized attribute or attribute value was passed in an attribute list",
					"EGLConfig argument does not name a valid EGLConfig",
					"EGLContext argument does not name a valid EGLContext",
					"EGL current surface of the calling thread is no longer valid",
					"EGLDisplay argument does not name a valid EGLDisplay",
					"EGL arguments are inconsistent",
					"EGLNativePixmapType argument does not refer to a valid native pixmap",
					"EGLNativeWindowType argument does not refer to a valid native window",
					"EGL one or more argument values are invalid",
					"EGLSurface argument does not name a valid surface configured for rendering",
					"EGL power management event has occurred", };
	EGLenum error = eglGetError();
	LOGI("%s: %s.", msg, errmsg[error - EGL_SUCCESS]);
	return error;
}
Exemplo n.º 17
0
bool QKmsContext::makeCurrent(QPlatformSurface *surface)
{
    Q_ASSERT(surface->surface()->supportsOpenGL());

    EGLDisplay display = m_device->eglDisplay();
    EGLSurface eglSurface;

    if (surface->surface()->surfaceClass() == QSurface::Window) {
        QPlatformWindow *window = static_cast<QPlatformWindow *>(surface);
        QKmsScreen *screen = static_cast<QKmsScreen *>(QPlatformScreen::platformScreenForWindow(window->window()));
        eglSurface = screen->eglSurface();
        screen->waitForPageFlipComplete();
    } else {
        eglSurface = static_cast<QKmsOffscreenWindow *>(surface)->surface();
    }

    bool ok = eglMakeCurrent(display, eglSurface, eglSurface, m_eglContext);
    if (!ok)
        qWarning("QKmsContext::makeCurrent(): eglError: %x, this: %p",
                 eglGetError(), this);

    return true;
}
Exemplo n.º 18
0
EGLSurface EGLDisplayOpenVG::createPbufferFromClientBuffer(
    EGLClientBuffer clientBuffer, EGLenum bufferType, const EGLConfig& config, EGLint* errorCode)
{
    EGLSurface surface = eglCreatePbufferFromClientBuffer(m_display,
        bufferType, clientBuffer, config, 0 /* attribList */);

    if (errorCode)
        *errorCode = eglGetError();
    else
        ASSERT_EGL_NO_ERROR();

    if (surface == EGL_NO_SURFACE)
        return EGL_NO_SURFACE;

    EGLint surfaceConfigId;
    EGLBoolean success = eglGetConfigAttrib(m_display, config, EGL_CONFIG_ID, &surfaceConfigId);
    ASSERT(success == EGL_TRUE);
    ASSERT(surfaceConfigId != EGL_BAD_ATTRIBUTE);

    ASSERT(!m_surfaceConfigIds.contains(surface));
    m_surfaceConfigIds.set(surface, surfaceConfigId);
    return surface;
}
Exemplo n.º 19
0
Arquivo: common.c Projeto: yesj/J5_A8
static void print_err(char *name)
{
    char *err_str[] = {
          "EGL_SUCCESS",
          "EGL_NOT_INITIALIZED",
          "EGL_BAD_ACCESS",
          "EGL_BAD_ALLOC",
          "EGL_BAD_ATTRIBUTE",    
          "EGL_BAD_CONFIG",
          "EGL_BAD_CONTEXT",   
          "EGL_BAD_CURRENT_SURFACE",
          "EGL_BAD_DISPLAY",
          "EGL_BAD_MATCH",
          "EGL_BAD_NATIVE_PIXMAP",
          "EGL_BAD_NATIVE_WINDOW",
          "EGL_BAD_PARAMETER",
          "EGL_BAD_SURFACE" };

    EGLint ecode = eglGetError();

    printf("'%s': egl error '%s' (0x%x)\n",
           name, err_str[ecode-EGL_SUCCESS], ecode);
}
bool EglManager::makeCurrent(EGLSurface surface, EGLint* errOut) {
    if (isCurrent(surface)) return false;

    if (surface == EGL_NO_SURFACE) {
        // Ensure we always have a valid surface & context
        surface = mPBufferSurface;
    }
    if (!eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
        if (errOut) {
            *errOut = eglGetError();
            ALOGW("Failed to make current on surface %p, error=%s", (void*)surface,
                  egl_error_str(*errOut));
        } else {
            LOG_ALWAYS_FATAL("Failed to make current on surface %p, error=%s", (void*)surface,
                             eglErrorString());
        }
    }
    mCurrentSurface = surface;
    if (Properties::disableVsync) {
        eglSwapInterval(mEglDisplay, 0);
    }
    return true;
}
Exemplo n.º 21
0
const char * EglErrorString()
{
	const EGLint err = eglGetError();
	switch( err )
	{
	case EGL_SUCCESS:			return "EGL_SUCCESS";
	case EGL_NOT_INITIALIZED:	return "EGL_NOT_INITIALIZED";
	case EGL_BAD_ACCESS:		return "EGL_BAD_ACCESS";
	case EGL_BAD_ALLOC:			return "EGL_BAD_ALLOC";
	case EGL_BAD_ATTRIBUTE:		return "EGL_BAD_ATTRIBUTE";
	case EGL_BAD_CONTEXT:		return "EGL_BAD_CONTEXT";
	case EGL_BAD_CONFIG:		return "EGL_BAD_CONFIG";
	case EGL_BAD_CURRENT_SURFACE:return "EGL_BAD_CURRENT_SURFACE";
	case EGL_BAD_DISPLAY:		return "EGL_BAD_DISPLAY";
	case EGL_BAD_SURFACE:		return "EGL_BAD_SURFACE";
	case EGL_BAD_MATCH:			return "EGL_BAD_MATCH";
	case EGL_BAD_PARAMETER:		return "EGL_BAD_PARAMETER";
	case EGL_BAD_NATIVE_PIXMAP:	return "EGL_BAD_NATIVE_PIXMAP";
	case EGL_BAD_NATIVE_WINDOW:	return "EGL_BAD_NATIVE_WINDOW";
	case EGL_CONTEXT_LOST:		return "EGL_CONTEXT_LOST";
	default: return "Unknown egl error code";
	}
}
Exemplo n.º 22
0
Arquivo: dri3.c Projeto: sarnex/wine
/* Destroy the content, except the link and the struct mem */
static void
PRESENTDestroyPixmapContent(Display *dpy, PRESENTPixmapPriv *present_pixmap)
{
    XFreePixmap(dpy, present_pixmap->pixmap);
#ifdef D3DADAPTER9_DRI2
    if (present_pixmap->dri2_info.is_dri2) {
        struct DRI2priv *dri2_priv = present_pixmap->dri2_info.dri2_priv;
        EGLenum current_api;
        current_api = eglQueryAPI();
        eglBindAPI(EGL_OPENGL_API);
        if(eglMakeCurrent(dri2_priv->display, EGL_NO_SURFACE, EGL_NO_SURFACE, dri2_priv->context)) {
            glDeleteFramebuffers(1, &present_pixmap->dri2_info.fbo_read);
            glDeleteFramebuffers(1, &present_pixmap->dri2_info.fbo_write);
            glDeleteTextures(1, &present_pixmap->dri2_info.texture_read);
            glDeleteTextures(1, &present_pixmap->dri2_info.texture_write);
        } else {
            ERR("eglMakeCurrent failed with 0x%0X\n", eglGetError());
        }
        eglMakeCurrent(dri2_priv->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
        eglBindAPI(current_api);
    }
#endif
}
Exemplo n.º 23
0
void QEglFSWindow::create()
{
    if (m_window)
        return;

    if (window()->windowType() == Qt::Desktop) {
        QRect rect(QPoint(), hooks->screenSize());
        QPlatformWindow::setGeometry(rect);
        QWindowSystemInterface::handleGeometryChange(window(), rect);
        return;
    }

    EGLDisplay display = (static_cast<QEglFSScreen *>(window()->screen()->handle()))->display();
    QSurfaceFormat platformFormat = hooks->surfaceFormatFor(window()->requestedFormat());
    EGLConfig config = q_configFromGLFormat(display, platformFormat);
    m_format = q_glFormatFromConfig(display, config);
    m_window = hooks->createNativeWindow(hooks->screenSize(), m_format);
    m_surface = eglCreateWindowSurface(display, config, m_window, NULL);
    if (m_surface == EGL_NO_SURFACE) {
        eglTerminate(display);
        qFatal("EGL Error : Could not create the egl surface: error = 0x%x\n", eglGetError());
    }
}
Exemplo n.º 24
0
void 
eng_window_resurf(Outbuf *gw)
{
   if (gw->surf) return;
   if (getenv("EVAS_GL_INFO")) printf("resurf %p\n", gw);

   gw->egl_surface[0] = 
     eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
                            (EGLNativeWindowType)gw->win, NULL);

   if (gw->egl_surface[0] == EGL_NO_SURFACE)
     {
        ERR("eglCreateWindowSurface() fail for %p. code=%#x",
            gw->win, eglGetError());
        return;
     }

   if (eglMakeCurrent(gw->egl_disp, gw->egl_surface[0], gw->egl_surface[0],
                      gw->egl_context[0]) == EGL_FALSE)
     ERR("eglMakeCurrent() failed!");

   gw->surf = EINA_TRUE;
}
Exemplo n.º 25
0
EGLint GLContext::Swap()
{
    bool b = eglSwapBuffers( display_, surface_ );
    if( !b )
    {
        EGLint err = eglGetError();
        if( err == EGL_BAD_SURFACE )
        {
            //Recreate surface
            InitEGLSurface();
            return EGL_SUCCESS; //Still consider glContext is valid
        }
        else if( err == EGL_CONTEXT_LOST || err == EGL_BAD_CONTEXT )
        {
            //Context has been lost!!
            context_valid_ = false;
            Terminate();
            InitEGLContext();
        }
        return err;
    }
    return EGL_SUCCESS;
}
EGLSurface EGLDisplayOpenVG::createPbufferSurface(const IntSize& size, const EGLConfig& config, EGLint* errorCode)
{
    const EGLint attribList[] = {
        EGL_WIDTH, size.width(),
        EGL_HEIGHT, size.height(),

#ifdef WEBKIT_EGL_SURFACE_DEFAULT_COLORSPACE
        EGL_COLORSPACE, WEBKIT_EGL_SURFACE_DEFAULT_COLORSPACE,
#endif

        // FIXME: make it possible to change alpha format with a setting, as its impact is implementation-specific.
#ifdef EGL_VG_ALPHA_FORMAT // EGL 1.3 and later
        EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE,
#else // EGL 1.2
        EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE,
#endif
        EGL_NONE
    };
    EGLSurface surface = eglCreatePbufferSurface(m_display, config, attribList);

    if (errorCode)
        *errorCode = eglGetError();
    else
        ASSERT_EGL_NO_ERROR();

    if (surface == EGL_NO_SURFACE)
        return EGL_NO_SURFACE;

    EGLint surfaceConfigId;
    EGLBoolean success = eglGetConfigAttrib(m_display, config, EGL_CONFIG_ID, &surfaceConfigId);
    ASSERT(success == EGL_TRUE);
    ASSERT(surfaceConfigId != EGL_BAD_ATTRIBUTE);

    ASSERT(!m_surfaceConfigIds.contains(surface));
    m_surfaceConfigIds.set(surface, surfaceConfigId);
    return surface;
}
Exemplo n.º 27
0
EGLPixmapSurface::EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes surfaceAttributes)
    : EGLOffScreenSurface(surfaceAttributes)
{
    if (!m_configSelector)
        return;

    EGLConfig config = m_configSelector->pixmapContextConfig();

    if (!config) {
        destroy();
        return;
    }

    EGLint visualId = m_configSelector->nativeVisualId(config);

    if (visualId == -1) {
        destroy();
        return;
    }

    NativePixmap pixmap;
    NativeWrapper::createPixmap(&pixmap, visualId, m_configSelector->attributes() & GLPlatformSurface::SupportAlpha);
    m_bufferHandle = pixmap;

    if (!m_bufferHandle) {
        destroy();
        return;
    }

    m_drawable = eglCreatePixmapSurface(m_sharedDisplay, config, static_cast<EGLNativePixmapType>(m_bufferHandle), 0);

    if (m_drawable == EGL_NO_SURFACE) {
        LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
        destroy();
    }
}
Exemplo n.º 28
0
Image::Image(sp<GraphicBuffer> buffer) {
    // Create the EGLImage object that maps the GraphicBuffer
    EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    EGLClientBuffer clientBuffer = (EGLClientBuffer) buffer->getNativeBuffer();
    EGLint attrs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE };

    mImage = eglCreateImageKHR(display, EGL_NO_CONTEXT,
            EGL_NATIVE_BUFFER_ANDROID, clientBuffer, attrs);

    if (mImage == EGL_NO_IMAGE_KHR) {
        ALOGW("Error creating image (%#x)", eglGetError());
        mTexture = 0;
    } else {
        // Create a 2D texture to sample from the EGLImage
        glGenTextures(1, &mTexture);
        Caches::getInstance().bindTexture(mTexture);
        glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, mImage);

        GLenum status = GL_NO_ERROR;
        while ((status = glGetError()) != GL_NO_ERROR) {
            ALOGW("Error creating image (%#x)", status);
        }
    }
}
Exemplo n.º 29
0
void WinEGLView::CreateSurface()
{
	EGLint	surfaceAttributes[16];
	uint i = 0;

	surfaceAttributes[i++] = EGL_NONE;

	if (mIsNeedPixmap)
	{
		mEGLSurface = eglCreatePixmapSurface(mEGLDisplay, mEGLConfig, mBitmapPixmap, surfaceAttributes);
	}
	else
	{
		mEGLSurface = eglCreateWindowSurface(mEGLDisplay, mEGLConfig, mEGLNativeWindow, surfaceAttributes);
		if (mEGLSurface == EGL_NO_SURFACE)
		{
			eglGetError(); // Clear error
			mEGLSurface = eglCreateWindowSurface(mEGLDisplay, mEGLConfig, nullptr, surfaceAttributes);
		}
	}

	MEDUSA_ASSERT_NOT_EQUAL(mEGLSurface, EGL_NO_SURFACE, "");
	MEDUSA_ASSERT_FALSE(GetEGLError(), "");
}
Exemplo n.º 30
0
/**
 * \brief Destroy the context.
 *
 * This function is called after power events and at shutdown.
 * I'm not sure that I am handling power events correctly.
 */
bool Main::destroyContext()
{
    assert(eglContext != EGL_NO_CONTEXT);

    // Make sure the context is not current.
    if (eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) == EGL_FALSE)
    {
        EGLint error = eglGetError();
        if (error == EGL_CONTEXT_LOST)
        {
            std::cout << "WARNING: Power event when trying to initialize.  I don't know how to handle this." << std::endl;
            eglContext = EGL_NO_CONTEXT;
            return true;
        }
        else
        {
            std::cout << "WARNING: eglMakeCurrent failed in Graphics::initializeOpenglState.  Maybe this is normal when power events occur." << std::endl;
            eglContext = EGL_NO_CONTEXT;
            return true;
        }
    }

    // Destroy the context.
    eglDestroyContext(eglDisplay, eglContext);
    if (!checkEglError())
    {
        std::cout << "WARNING: eglDestroyContext failed." << std::endl;
        eglContext = EGL_NO_CONTEXT;
        return true;
    }
    else
    {
        eglContext = EGL_NO_CONTEXT;
        return true;
    }
}