Пример #1
0
jboolean
worldofgoo_CallBooleanMethodV(JNIEnv* p0, jobject p1, jmethodID p2, va_list p3)
{
    printf("worldofgoo_CallBooleanMethodV(%s)\n", p2->name);
    if (strcmp(p2->name, "isGlThread") == 0) {
        printf("isGlThread: %x\n", eglGetCurrentContext());
        return eglGetCurrentContext() != 0;
    }
    return 0;
}
Пример #2
0
static bool
test_invalid_context(unsigned w, unsigned h, int fd, unsigned stride,
		unsigned offset)
{
	EGLImageKHR img;
	EGLint attr[] = {
		EGL_WIDTH, w,
		EGL_HEIGHT, h,
		EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888,
		EGL_DMA_BUF_PLANE0_FD_EXT, fd,
		EGL_DMA_BUF_PLANE0_OFFSET_EXT, offset,
		EGL_DMA_BUF_PLANE0_PITCH_EXT, stride,
		EGL_NONE
	};

	/**
	 * The spec says:
	 *
	 *     "If <target> is EGL_LINUX_DMA_BUF_EXT, <dpy> must be a valid
	 *      display, <ctx> must be EGL_NO_CONTEXT, and <buffer> must be
	 *      NULL, cast into the type EGLClientBuffer."
	 */
	img = eglCreateImageKHR(eglGetCurrentDisplay(), eglGetCurrentContext(),
			EGL_LINUX_DMA_BUF_EXT, (EGLClientBuffer)NULL, attr);

	if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) {
		if (img)
			eglDestroyImageKHR(eglGetCurrentDisplay(), img);
		return false;
	}

	return true;
}
Пример #3
0
status_t GLConsumer::checkAndUpdateEglStateLocked(bool contextCheck) {
    EGLDisplay dpy = eglGetCurrentDisplay();
    EGLContext ctx = eglGetCurrentContext();

    if (!contextCheck) {
        // if this is the first time we're called, mEglDisplay/mEglContext have
        // never been set, so don't error out (below).
        if (mEglDisplay == EGL_NO_DISPLAY) {
            mEglDisplay = dpy;
        }
        if (mEglContext == EGL_NO_DISPLAY) {
            mEglContext = ctx;
        }
    }

    if (mEglDisplay != dpy || dpy == EGL_NO_DISPLAY) {
        ST_LOGE("checkAndUpdateEglState: invalid current EGLDisplay");
        return INVALID_OPERATION;
    }

    if (mEglContext != ctx || ctx == EGL_NO_CONTEXT) {
        ST_LOGE("checkAndUpdateEglState: invalid current EGLContext");
        return INVALID_OPERATION;
    }

    mEglDisplay = dpy;
    mEglContext = ctx;
    return NO_ERROR;
}
Пример #4
0
void dreamTriInit(int width, int height)
{
  // Configure Regal to log to file in /sdcard (disabled by default in this sample)
  // Note that for your own projects WRITE_EXTERNAL_STORAGE permission needs to be added to your AndroidManifest.xml
  setenv("REGAL_LOG_ALL", "0", 1);
  setenv("REGAL_LOG_ERROR", "1", 1);
  setenv("REGAL_LOG_FILE", "/sdcard/dreamri.log", 1);

  // This is not necessary when the EGL context is created natively, but is here as a reminder
  // to do register the EGL context with Regal when it is created by a Java thread. 
  RegalMakeCurrent(eglGetCurrentContext());

  glClearColor(0.0f, 0.0f, 0.0f, 0.5f);

  // avoid unlikely divide by zero
  if (height==0)
  {
    height=1;
  }

  float aspect = float(width)/float(height);

  glViewport(0, 0, width, height);
  glMatrixMode( GL_PROJECTION );
  glLoadIdentity();
  if( aspect > 1 ) {
    glFrustum( -0.1 * aspect, 0.1 * aspect, -0.1, 0.1, 0.1, 100.0 );
  } else {
    glFrustum( -0.1, 0.1, -0.1 / aspect, 0.1 / aspect, 0.1, 100.0 );
  }
  glMatrixMode( GL_MODELVIEW );
  glLoadIdentity();
}
Пример #5
0
void Thread::InitMainThread()
{
    mainThreadId = gettid();

    currentContext = eglGetCurrentContext();
    if(currentContext == EGL_NO_CONTEXT)
    {
		Logger::Error("[Thread::InitMainThread] EGL_NO_CONTEXT");
    }

    currentDisplay = eglGetCurrentDisplay();
	if (currentDisplay == EGL_NO_DISPLAY)
	{
		Logger::Error("[Thread::InitMainThread] EGL_NO_DISPLAY");
	}

    currentDrawSurface = eglGetCurrentSurface(EGL_DRAW);
    if(currentDrawSurface == EGL_NO_SURFACE)
    {
		Logger::Error("[Thread::InitMainThread] EGL_NO_SURFACE | EGL_DRAW");
    }

    currentReadSurface = eglGetCurrentSurface(EGL_READ);
    if(currentReadSurface == EGL_NO_SURFACE)
    {
		Logger::Error("[Thread::InitMainThread] EGL_NO_SURFACE | EGL_READ");
    }


    Logger::Info("[Thread::InitMainThread] %ld", mainThreadId);
}
// Helper function
EGLenum currentEglApi()
{
    EGLenum api = 0;
    if (EGL_NO_CONTEXT != eglGetCurrentContext())
        api = eglQueryAPI();
    return api;
}
Пример #7
0
JNIEXPORT void JNICALL Java_com_regal_dreamtri_DreamtriLib_init(JNIEnv *env, jobject obj,  jint width, jint height)
{
  // Configure Regal to log to file in /sdcard (disabled by default in this sample)
  // Note that for your own projects WRITE_EXTERNAL_STORAGE permission needs to be added to your AndroidManifest.xml
  setenv("REGAL_LOG_ALL", "0", 1);
  setenv("REGAL_LOG_ERROR", "1", 1);
  setenv("REGAL_LOG_FILE", "/sdcard/dreamri.log", 1);

  // Because teh EGL context was created by a Java thread, we need to register it with Regal.
  RegalMakeCurrent(eglGetCurrentContext());

  g_x = 0.0f;

  // Avoid unlikely divide by 0
  if (height==0)
    height=1;

  float aspect = float(width)/float(height);

  glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
  glViewport(0, 0, width, height);
  glMatrixMode( GL_PROJECTION );
  glLoadIdentity();
  if( aspect > 1 ) {
    glFrustum( -0.1 * aspect, 0.1 * aspect, -0.1, 0.1, 0.1, 100.0 );
  } else {
    glFrustum( -0.1, 0.1, -0.1 / aspect, 0.1 / aspect, 0.1, 100.0 );
  }
  glMatrixMode( GL_MODELVIEW );
  glLoadIdentity();
}
TInt CEGLGraphicsInterface::BindClientBuffer(TUint aBuffer)
    {
    // Save current context and surfaces
    iSavedContext = eglGetCurrentContext();
    iSavedDrawSurface = eglGetCurrentSurface(EGL_DRAW);
    iSavedReadSurface = eglGetCurrentSurface(EGL_READ);
    
    if ( eglMakeCurrent( iEglDisplay,  EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ) == EGL_FALSE )
        {
        return MapEGLErrorCodeToSymbian(eglGetError());
        }

    const EGLint attribList2[] = {  EGL_NONE };
    iEglPbufSurface = eglCreatePbufferFromClientBuffer(iEglDisplay, EGL_OPENVG_IMAGE, (EGLClientBuffer)aBuffer,  iConfig, attribList2);
    
    if ( iEglPbufSurface == EGL_NO_SURFACE )
        {
        return MapEGLErrorCodeToSymbian(eglGetError());
        }

    if ( eglMakeCurrent( iEglDisplay,    iEglPbufSurface ,  iEglPbufSurface ,iEglContext ) == EGL_FALSE )
        {
        return MapEGLErrorCodeToSymbian(eglGetError());
        }
    return KErrNone;
    }
void TilesManager::updateTilesIfContextVerified()
{
    EGLContext ctx = eglGetCurrentContext();
    GLUtils::checkEglError("contextChanged");
    if (ctx != m_eglContext) {
        if (m_eglContext != EGL_NO_CONTEXT) {
            // A change in EGL context is an unexpected error, but we don't want to
            // crash or ANR. Therefore, abandon the Surface Texture and GL resources;
            // they'll be recreated later in setupDrawing. (We can't delete them
            // since the context is gone)
            ALOGE("Unexpected : EGLContext changed! current %x , expected %x",
                  ctx, m_eglContext);
            transferQueue()->resetQueue();
            shader()->forceNeedsInit();
            videoLayerManager()->forceNeedsInit();
            markAllGLTexturesZero();
        } else {
            // This is the first time we went into this new EGL context.
            // We will have the GL resources to be re-inited and we can't update
            // dirty tiles yet.
            ALOGD("new EGLContext from framework: %x ", ctx);
        }
    } else {
        // Here before we draw, update the Tile which has updated content.
        // Inside this function, just do GPU blits from the transfer queue into
        // the Tiles' texture.
        transferQueue()->updateDirtyTiles();
        // Clean up GL textures for video layer.
        videoLayerManager()->deleteUnusedTextures();
    }
    m_eglContext = ctx;
    return;
}
Пример #10
0
void PlatformGetNewRenderQuery(GLuint* OutQuery, uint64* OutQueryContext)
{
	if (!ReleasedQueriesGuard)
	{
		ReleasedQueriesGuard = new FCriticalSection;
	}

	{
		FScopeLock Lock(ReleasedQueriesGuard);

#ifdef UE_BUILD_DEBUG
		check(OutQuery && OutQueryContext);
#endif

		EGLContext Context = eglGetCurrentContext();
		check(Context);

		GLuint NewQuery = 0;

		/*
		 * Note, not reusing queries, because timestamp and occlusion are different
		 */

		if (!NewQuery)
		{
			FOpenGL::GenQueries(1, &NewQuery);
		}

		*OutQuery = NewQuery;
		*OutQueryContext = (uint64)Context;
	}
}
Пример #11
0
void SurfaceOpenVG::makeResourceCreationContextCurrent()
{
#if PLATFORM(EGL)
    ASSERT(m_eglContext != EGL_NO_CONTEXT);

    SurfaceOpenVG* shared = sharedSurface();

    eglBindAPI(EGL_OPENVG_API);
    ASSERT_EGL_NO_ERROR();
    EGLContext currentContext = eglGetCurrentContext();
    ASSERT_EGL_NO_ERROR();

    // The shared surface might not be current, but the shared context is.
    // A proper OpenVG implementation stores all resources in the context,
    // and none in the surface, so we don't need to do anything here.
    if (currentContext == shared->m_eglContext)
        return;

    // The shared surface is not usually used for any productive work,
    // any other surface (i.e. this) is more likely to be painted on.
    if (m_eglContext == shared->m_eglContext) {
        makeCurrent(DontApplyPainterState);
        return;
    }

    shared->makeCurrent(DontApplyPainterState);
#endif
}
Пример #12
0
static void
_glitz_egl_make_current (void *abstract_drawable,
			 void *abstract_context)
{
    glitz_egl_context_t  *context = (glitz_egl_context_t *) abstract_context;
    glitz_egl_surface_t *drawable = (glitz_egl_surface_t *) abstract_drawable;
    glitz_egl_display_info_t *display_info =
	drawable->screen_info->display_info;

    if (drawable->base.width  != drawable->width ||
	drawable->base.height != drawable->height)
	_glitz_egl_drawable_update_size (drawable,
					 drawable->base.width,
					 drawable->base.height);

    if ((eglGetCurrentContext () != context->egl_context) ||
	(eglGetCurrentSurface ( EGL_READ ) != drawable->egl_surface))
    {
	if (display_info->thread_info->cctx)
	{
	    glitz_context_t *ctx = display_info->thread_info->cctx;

	    if (ctx->lose_current)
		ctx->lose_current (ctx->closure);
	}

	eglMakeCurrent (display_info->egl_display, drawable->egl_surface,
			drawable->egl_surface, context->egl_context);
    }

    display_info->thread_info->cctx = &context->base;
}
Пример #13
0
status_t GLConsumer::detachFromContext() {
    ATRACE_CALL();
#ifndef MTK_DEFAULT_AOSP
    ST_LOGI("detachFromContext");
#else
    ST_LOGV("detachFromContext");
#endif
    Mutex::Autolock lock(mMutex);

    if (mAbandoned) {
        ST_LOGE("detachFromContext: abandoned GLConsumer");
        return NO_INIT;
    }

    if (!mAttached) {
        ST_LOGE("detachFromContext: GLConsumer is not attached to a "
                "context");
        return INVALID_OPERATION;
    }

    EGLDisplay dpy = eglGetCurrentDisplay();
    EGLContext ctx = eglGetCurrentContext();

    if (mEglDisplay != dpy && mEglDisplay != EGL_NO_DISPLAY) {
        ST_LOGE("detachFromContext: invalid current EGLDisplay");
        return INVALID_OPERATION;
    }

    if (mEglContext != ctx && mEglContext != EGL_NO_CONTEXT) {
        ST_LOGE("detachFromContext: invalid current EGLContext");
        return INVALID_OPERATION;
    }

    if (dpy != EGL_NO_DISPLAY && ctx != EGL_NO_CONTEXT) {
        status_t err = syncForReleaseLocked(dpy);
        if (err != OK) {
            return err;
        }

        glDeleteTextures(1, &mTexName);
    }

    // Because we're giving up the EGLDisplay we need to free all the EGLImages
    // that are associated with it.  They'll be recreated when the
    // GLConsumer gets attached to a new OpenGL ES context (and thus gets a
    // new EGLDisplay).
    for (int i =0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
        EGLImageKHR img = mEglSlots[i].mEglImage;
        if (img != EGL_NO_IMAGE_KHR) {
            eglDestroyImageKHR(mEglDisplay, img);
            mEglSlots[i].mEglImage = EGL_NO_IMAGE_KHR;
        }
    }

    mEglDisplay = EGL_NO_DISPLAY;
    mEglContext = EGL_NO_CONTEXT;
    mAttached = false;

    return OK;
}
Пример #14
0
void
GtkOvgGlue::prepDrawingArea(GtkWidget *drawing_area)
{
    GNASH_REPORT_FUNCTION;

    _drawing_area = drawing_area;
    
    // Disable double buffering, otherwise gtk tries to update widget
    // contents from its internal offscreen buffer at the end of expose event
    gtk_widget_set_double_buffered(_drawing_area, FALSE);

    // EGL needs to be bound to the type of client. The possible
    // clients are OpenVG, OpenGLES1, and OpenGLES2.
    if (_device->getType() == renderer::GnashDevice::EGL) {
        renderer::EGLDevice *egl = (renderer::EGLDevice*)_device.get();
        egl->bindClient(renderer::GnashDevice::OPENVG);
    }
    

    // Attach the window to the low level device
    long xid = GDK_WINDOW_XID(gtk_widget_get_window(drawing_area));
    _device->attachWindow(static_cast<renderer::GnashDevice::native_window_t>
                          (xid));

    //vgLoadIdentity();

#if 0
    renderer::EGLDevice *egl = (renderer::EGLDevice*)_device.get();
    egl->printEGLSurface(eglGetCurrentSurface(EGL_DRAW));
    egl->printEGLContext(eglGetCurrentContext());
#endif
}
Пример #15
0
QString QGLInfo::reportEGLConfigInfo() const
{
#if !defined(QT_NO_EGL)
    QString d;
    QEglProperties props;
    EGLint count = 0;
    EGLDisplay dpy = eglGetCurrentDisplay();
    EGLContext ctx = eglGetCurrentContext();
    EGLint cfgnum = 0;
    if (eglQueryContext(dpy, ctx, EGL_CONFIG_ID, &cfgnum)) {
        d += QString("Window configuration in use: ") + QString::number(cfgnum) +
             QLatin1String("\n\n");
    }
    if (!eglGetConfigs(dpy, 0, 0, &count) || count < 1)
        return d;
    EGLConfig *configs = new EGLConfig [count];
    eglGetConfigs(dpy, configs, count, &count);
    for (EGLint index = 0; index < count; ++index) {
        props = QEglProperties(configs[index]);
        d += props.toString() + QLatin1String("\n\n");
    }
    delete [] configs;
    return d;
#else
    return QString();
#endif
}
Пример #16
0
JNIEXPORT void JNICALL Java_com_uob_achohan_hdr_MyGLRenderer_initCL(JNIEnv* jenv, jobject obj, jint width, jint height, jint in_tex, jint out_tex) {
	filter = new ReinhardGlobal(0.18f, 1.1f);
	filter->setStatusCallback(updateStatus);

	EGLDisplay mEglDisplay;
	EGLContext mEglContext;

	if ((mEglDisplay = eglGetCurrentDisplay()) == EGL_NO_DISPLAY) {
		status("eglGetCurrentDisplay() returned error %d", eglGetError());
	}

	if ((mEglContext = eglGetCurrentContext()) == EGL_NO_CONTEXT) {
		status("eglGetCurrentContext() returned error %d", eglGetError());
	}

	cl_prop[0] = CL_GL_CONTEXT_KHR;
	cl_prop[1] = (cl_context_properties) mEglContext;
	cl_prop[2] = CL_EGL_DISPLAY_KHR;
	cl_prop[3] = (cl_context_properties) mEglDisplay;
	cl_prop[4] = CL_CONTEXT_PLATFORM;
	cl_prop[6] = 0;

	params.opengl = true;

	filter->setImageSize(width, height);
	filter->setImageTextures(in_tex, out_tex);
	filter->setupOpenCL(cl_prop, params);

	return;
}
Пример #17
0
static void
gdk_x11_gl_context_dispose (GObject *gobject)
{
  GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (gobject);

  if (context_wayland->egl_context != NULL)
    {
      GdkGLContext *context = GDK_GL_CONTEXT (gobject);
      GdkWindow *window = gdk_gl_context_get_window (context);
      GdkDisplay *display = gdk_window_get_display (window);
      GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);

      if (eglGetCurrentContext () == context_wayland->egl_context)
        eglMakeCurrent(display_wayland->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
                       EGL_NO_CONTEXT);

      GDK_NOTE (OPENGL, g_print ("Destroying EGL context\n"));

      eglDestroyContext (display_wayland->egl_display,
                         context_wayland->egl_context);
      context_wayland->egl_context = NULL;
    }

  G_OBJECT_CLASS (gdk_wayland_gl_context_parent_class)->dispose (gobject);
}
Пример #18
0
int Java_org_yabause_android_YabauseRunnable_initViewport()
{
   int error;
   char * buf;

   g_Display = eglGetCurrentDisplay();
   g_Surface = eglGetCurrentSurface(EGL_READ);
   g_Context = eglGetCurrentContext();

   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrthof(0, 320, 224, 0, 1, 0);
   
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();

   glMatrixMode(GL_TEXTURE);
   glLoadIdentity();
   
   glDisable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   
   yprintf(glGetString(GL_VENDOR));
   yprintf(glGetString(GL_RENDERER));
   yprintf(glGetString(GL_VERSION));
   yprintf(glGetString(GL_EXTENSIONS));
   yprintf(eglQueryString(g_Display,EGL_EXTENSIONS));
   eglSwapInterval(g_Display,0);
   eglMakeCurrent(g_Display,EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT);
   return 0;
}
/* EGLContext eglGetCurrentContext ( void ) */
static jobject
android_eglGetCurrentContext
  (JNIEnv *_env, jobject _this) {
    EGLContext _returnValue = (EGLContext) 0;
    _returnValue = eglGetCurrentContext();
    return toEGLHandle(_env, eglcontextClass, eglcontextConstructor, _returnValue);
}
Пример #20
0
void initCL()
{
    dumpCLinfo();

    EGLDisplay mEglDisplay = eglGetCurrentDisplay();
    if (mEglDisplay == EGL_NO_DISPLAY)
        LOGE("initCL: eglGetCurrentDisplay() returned 'EGL_NO_DISPLAY', error = %x", eglGetError());

    EGLContext mEglContext = eglGetCurrentContext();
    if (mEglContext == EGL_NO_CONTEXT)
        LOGE("initCL: eglGetCurrentContext() returned 'EGL_NO_CONTEXT', error = %x", eglGetError());

    cl_context_properties props[] =
    {   CL_GL_CONTEXT_KHR,   (cl_context_properties) mEglContext,
        CL_EGL_DISPLAY_KHR,  (cl_context_properties) mEglDisplay,
        CL_CONTEXT_PLATFORM, 0,
        0 };

    try
    {
        cl::Platform p = cl::Platform::getDefault();
        std::string ext = p.getInfo<CL_PLATFORM_EXTENSIONS>();
        if(ext.find("cl_khr_gl_sharing") == std::string::npos)
            LOGE("Warning: CL-GL sharing isn't supported by PLATFORM");
        props[5] = (cl_context_properties) p();

        theContext = cl::Context(CL_DEVICE_TYPE_GPU, props);
        std::vector<cl::Device> devs = theContext.getInfo<CL_CONTEXT_DEVICES>();
        LOGD("Context returned %d devices, taking the 1st one", devs.size());
        ext = devs[0].getInfo<CL_DEVICE_EXTENSIONS>();
        if(ext.find("cl_khr_gl_sharing") == std::string::npos)
            LOGE("Warning: CL-GL sharing isn't supported by DEVICE");

        theQueue = cl::CommandQueue(theContext, devs[0]);

        cl::Program::Sources src(1, std::make_pair(oclProgI2I, sizeof(oclProgI2I)));
        theProgI2I = cl::Program(theContext, src);
        theProgI2I.build(devs);

        cv::ocl::attachContext(p.getInfo<CL_PLATFORM_NAME>(), p(), theContext(), devs[0]());
        if( cv::ocl::useOpenCL() )
            LOGD("OpenCV+OpenCL works OK!");
        else
            LOGE("Can't init OpenCV with OpenCL TAPI");
    }
    catch(cl::Error& e)
    {
        LOGE("cl::Error: %s (%d)", e.what(), e.err());
    }
    catch(std::exception& e)
    {
        LOGE("std::exception: %s", e.what());
    }
    catch(...)
    {
        LOGE( "OpenCL info: unknown error while initializing OpenCL stuff" );
    }
    LOGD("initCL completed");
}
status_t SurfaceTexture::doGLFenceWaitLocked() const {

    EGLDisplay dpy = eglGetCurrentDisplay();
    EGLContext ctx = eglGetCurrentContext();

    if (mEglDisplay != dpy || mEglDisplay == EGL_NO_DISPLAY) {
        ST_LOGE("doGLFenceWait: invalid current EGLDisplay");
        return INVALID_OPERATION;
    }

    if (mEglContext != ctx || mEglContext == EGL_NO_CONTEXT) {
        ST_LOGE("doGLFenceWait: invalid current EGLContext");
        return INVALID_OPERATION;
    }

    if (mCurrentFence != NULL) {
        if (useWaitSync) {
            // Create an EGLSyncKHR from the current fence.
            int fenceFd = mCurrentFence->dup();
            if (fenceFd == -1) {
                ST_LOGE("doGLFenceWait: error dup'ing fence fd: %d", errno);
                return -errno;
            }
            EGLint attribs[] = {
                EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fenceFd,
                EGL_NONE
            };
            EGLSyncKHR sync = eglCreateSyncKHR(dpy,
                    EGL_SYNC_NATIVE_FENCE_ANDROID, attribs);
            if (sync == EGL_NO_SYNC_KHR) {
                close(fenceFd);
                ST_LOGE("doGLFenceWait: error creating EGL fence: %#x",
                        eglGetError());
                return UNKNOWN_ERROR;
            }

            // XXX: The spec draft is inconsistent as to whether this should
            // return an EGLint or void.  Ignore the return value for now, as
            // it's not strictly needed.
            eglWaitSyncANDROID(dpy, sync, 0);
            EGLint eglErr = eglGetError();
            eglDestroySyncKHR(dpy, sync);
            if (eglErr != EGL_SUCCESS) {
                ST_LOGE("doGLFenceWait: error waiting for EGL fence: %#x",
                        eglErr);
                return UNKNOWN_ERROR;
            }
        } else {
            status_t err = mCurrentFence->waitForever(1000,
                    "SurfaceTexture::doGLFenceWaitLocked");
            if (err != NO_ERROR) {
                ST_LOGE("doGLFenceWait: error waiting for fence: %d", err);
                return err;
            }
        }
    }

    return NO_ERROR;
}
Пример #22
0
RendererES3::RendererES3()
    :   mEglContext(eglGetCurrentContext()),
        mProgram(0),
        mVBState(0)
{
    for (int i = 0; i < VB_COUNT; i++)
        mVB[i] = 0;
}
Пример #23
0
void GLHelper::AssertValidContext()
{
    EGLContext cntx = eglGetCurrentContext();
    if (cntx != GLHelper::_eglPBufferContext && cntx != GLHelper::_eglSurfaceContext)
    {
        U_THROW(::g::Uno::Exception::New2(uNewStringUtf8("GLHelper::AssertValidContext: Invalid GL context. Not our pbuffer context or surface context",92)));
    }
}
Пример #24
0
    Window* WindowImpl::getCurrentContextWindow()
    {
        auto itr = ns_windowRefs.find(eglGetCurrentContext());

        if (itr != ns_windowRefs.end())
            return itr->second;

        return nullptr;
    }
Пример #25
0
RendererES2::RendererES2()
:   mEglContext(eglGetCurrentContext()),
    mProgram(0),
    mVB(0),
    mPosAttrib(-1),
    mColorAttrib(-1),
    mScaleRotUniform(-1),
    mOffsetUniform(-1)
{}
Пример #26
0
EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void)
{
	EGLContext ctx = eglGetCurrentContext();

	if (ctx != EGL_NO_CONTEXT)
		glFinish();

	return EGL_TRUE;
}
Пример #27
0
void EGLThreadTest::threadingTest()
{
    mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);

    EXPECT_TRUE(mDisplay != EGL_NO_DISPLAY);

    eglInitialize(mDisplay, nullptr, nullptr);
    eglGetCurrentContext();
}
Пример #28
0
static void
_glitz_egl_context_update (glitz_egl_surface_t *drawable,
			   glitz_constraint_t   constraint)
{
    EGLContext egl_context;

    drawable->base.flushed = drawable->base.finished = 0;

    switch (constraint) {
    case GLITZ_NONE:
	break;
    case GLITZ_ANY_CONTEXT_CURRENT: {
	glitz_egl_display_info_t *dinfo = drawable->screen_info->display_info;

	if (dinfo->thread_info->cctx)
	{
	    _glitz_egl_context_make_current (drawable, 0);
	}
	else
	{
	    egl_context = eglGetCurrentContext ();
	    if (egl_context == (EGLContext) 0)
		_glitz_egl_context_make_current (drawable, 0);
	}
    } break;
    case GLITZ_CONTEXT_CURRENT:
	egl_context = eglGetCurrentContext ();
	if (egl_context != drawable->context->egl_context)
	    _glitz_egl_context_make_current (drawable, (egl_context)? 1: 0);
	break;
    case GLITZ_DRAWABLE_CURRENT:
	if (drawable->base.width  != drawable->width ||
	    drawable->base.height != drawable->height)
	    _glitz_egl_drawable_update_size (drawable,
					     drawable->base.width,
					     drawable->base.height);

	egl_context = eglGetCurrentContext ();
	if ((egl_context != drawable->context->egl_context) ||
	    (eglGetCurrentSurface ( 0 ) != drawable->egl_surface))
	    _glitz_egl_context_make_current (drawable, (egl_context)? 1: 0);
	break;
    }
}
Пример #29
0
/*  private native int _getCurrentContext ( ) ; */
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_khronos_egl_EGL10Impl__1getCurrentContext() {

    jint returnValue = (jint)eglGetCurrentContext();
#ifdef DEBUG
    printf("eglGetCurrentContext() = %d\n", returnValue);
#endif

    KNI_ReturnInt(returnValue);
}
Пример #30
0
bool GLContextEGL::makeContextCurrent()
{
    ASSERT(m_context);

    GLContext::makeContextCurrent();
    if (eglGetCurrentContext() == m_context)
        return true;

    return eglMakeCurrent(m_display.eglDisplay(), m_surface, m_surface, m_context);
}