⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dri_util.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
     * buffer and that the buffer may be shared by other child     * windows.  When our window share the window pixmap with its     * parent, drawable config events doesn't affect the front buffer.     * We only care about the last such event in the buffer; in fact,     * older events will refer to invalid buffer objects.*/    if (last_ba)       (*psp->DriverAPI.HandleBufferAttach)(pdp, pcp, last_ba);    /* If there was a drawable config event in the buffer and it     * changed the size of the window, all buffer auxillary buffer     * attachments prior to that are invalid (as opposed to the front     * buffer case discussed above).  In that case we can start     * looking for buffer attachment after the last drawable config     * event.  If there is no drawable config event in this batch of     * events, we have to assume that the last batch might have had     * one and process all buffer attach events.*/    if (last_dc && changed)       tail = (unsigned char *) last_dc - data;    else       tail = pdp->dri2.tail;    for ( ; tail != end; tail += size) {       ba = (__DRIBufferAttachEvent *) (data + (tail & mask));       size = DRI2_EVENT_SIZE(ba->event_header);       if (DRI2_EVENT_TYPE(ba->event_header) != DRI2_EVENT_BUFFER_ATTACH)	  continue;       if (ba->drawable != pdp->dri2.drawable_id)	  continue;       if (last_ba == ba)	  continue;       (*psp->DriverAPI.HandleBufferAttach)(pdp, pcp, ba);       changed = 1;    }    pdp->dri2.tail = tail;    return changed || last_ba;}/*@}*//*****************************************************************//** \name GLX callbacks                                          *//*****************************************************************//*@{*/static void driReportDamage(__DRIdrawable *pdp,			    struct drm_clip_rect *pClipRects, int numClipRects){    __DRIscreen *psp = pdp->driScreenPriv;    /* Check that we actually have the new damage report method */    if (psp->dri2.enabled) {	(*psp->dri2.loader->postDamage)(pdp,					pClipRects,					numClipRects,					pdp->loaderPrivate);    } else if (psp->damage) {	/* Report the damage.  Currently, all our drivers draw	 * directly to the front buffer, so we report the damage there	 * rather than to the backing storein (if any).	 */	(*psp->damage->reportDamage)(pdp,				     pdp->x, pdp->y,				     pClipRects, numClipRects,				     GL_TRUE, pdp->loaderPrivate);    }}/** * Swap buffers. * * \param drawablePrivate opaque pointer to the per-drawable private info. *  * \internal * This function calls __DRIdrawablePrivate::swapBuffers. *  * Is called directly from glXSwapBuffers(). */static void driSwapBuffers(__DRIdrawable *dPriv){    __DRIscreen *psp = dPriv->driScreenPriv;    if (!dPriv->numClipRects)        return;    if (psp->dri2.enabled)       __driParseEvents(NULL, dPriv);    psp->DriverAPI.SwapBuffers(dPriv);    driReportDamage(dPriv, dPriv->pClipRects, dPriv->numClipRects);}static int driDrawableGetMSC( __DRIscreen *sPriv, __DRIdrawable *dPriv,			      int64_t *msc ){    return sPriv->DriverAPI.GetDrawableMSC(sPriv, dPriv, msc);}static int driWaitForMSC(__DRIdrawable *dPriv, int64_t target_msc,			 int64_t divisor, int64_t remainder,			 int64_t * msc, int64_t * sbc){    __DRIswapInfo  sInfo;    int  status;    status = dPriv->driScreenPriv->DriverAPI.WaitForMSC( dPriv, target_msc,                                                         divisor, remainder,                                                         msc );    /* GetSwapInfo() may not be provided by the driver if GLX_SGI_video_sync     * is supported but GLX_OML_sync_control is not.  Therefore, don't return     * an error value if GetSwapInfo() is not implemented.    */    if ( status == 0         && dPriv->driScreenPriv->DriverAPI.GetSwapInfo ) {        status = dPriv->driScreenPriv->DriverAPI.GetSwapInfo( dPriv, & sInfo );        *sbc = sInfo.swap_count;    }    return status;}const __DRImediaStreamCounterExtension driMediaStreamCounterExtension = {    { __DRI_MEDIA_STREAM_COUNTER, __DRI_MEDIA_STREAM_COUNTER_VERSION },    driWaitForMSC,    driDrawableGetMSC,};static void driCopySubBuffer(__DRIdrawable *dPriv,			      int x, int y, int w, int h){    drm_clip_rect_t rect;    rect.x1 = x;    rect.y1 = dPriv->h - y - h;    rect.x2 = x + w;    rect.y2 = rect.y1 + h;    driReportDamage(dPriv, &rect, 1);    dPriv->driScreenPriv->DriverAPI.CopySubBuffer(dPriv, x, y, w, h);}const __DRIcopySubBufferExtension driCopySubBufferExtension = {    { __DRI_COPY_SUB_BUFFER, __DRI_COPY_SUB_BUFFER_VERSION },    driCopySubBuffer};static void driSetSwapInterval(__DRIdrawable *dPriv, unsigned int interval){    dPriv->swap_interval = interval;}static unsigned int driGetSwapInterval(__DRIdrawable *dPriv){    return dPriv->swap_interval;}const __DRIswapControlExtension driSwapControlExtension = {    { __DRI_SWAP_CONTROL, __DRI_SWAP_CONTROL_VERSION },    driSetSwapInterval,    driGetSwapInterval};/** * This is called via __DRIscreenRec's createNewDrawable pointer. */static __DRIdrawable *driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config,		     drm_drawable_t hwDrawable, int renderType,		     const int *attrs, void *data){    __DRIdrawable *pdp;    /* Since pbuffers are not yet supported, no drawable attributes are     * supported either.     */    (void) attrs;    pdp = _mesa_malloc(sizeof *pdp);    if (!pdp) {	return NULL;    }    pdp->loaderPrivate = data;    pdp->hHWDrawable = hwDrawable;    pdp->refcount = 0;    pdp->pStamp = NULL;    pdp->lastStamp = 0;    pdp->index = 0;    pdp->x = 0;    pdp->y = 0;    pdp->w = 0;    pdp->h = 0;    pdp->numClipRects = 0;    pdp->numBackClipRects = 0;    pdp->pClipRects = NULL;    pdp->pBackClipRects = NULL;    pdp->vblSeq = 0;    pdp->vblFlags = 0;    pdp->driScreenPriv = psp;    pdp->driContextPriv = &psp->dummyContextPriv;    if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->modes,					renderType == GLX_PIXMAP_BIT)) {       _mesa_free(pdp);       return NULL;    }    pdp->msc_base = 0;    /* This special default value is replaced with the configured     * default value when the drawable is first bound to a direct     * rendering context.      */    pdp->swap_interval = (unsigned)-1;    return pdp;}static __DRIdrawable *dri2CreateNewDrawable(__DRIscreen *screen, const __DRIconfig *config,		      unsigned int drawable_id, unsigned int head, void *data){    __DRIdrawable *pdraw;    pdraw = driCreateNewDrawable(screen, config, 0, 0, NULL, data);    if (!pdraw)    	return NULL;    pdraw->dri2.drawable_id = drawable_id;    pdraw->dri2.tail = head;    pdraw->pBackClipRects = _mesa_malloc(sizeof *pdraw->pBackClipRects);    return pdraw;}static voiddriDestroyDrawable(__DRIdrawable *pdp){    __DRIscreenPrivate *psp;    if (pdp) {	psp = pdp->driScreenPriv;        (*psp->DriverAPI.DestroyBuffer)(pdp);	if (pdp->pClipRects) {	    _mesa_free(pdp->pClipRects);	    pdp->pClipRects = NULL;	}	if (pdp->pBackClipRects) {	    _mesa_free(pdp->pBackClipRects);	    pdp->pBackClipRects = NULL;	}	_mesa_free(pdp);    }}/*@}*//*****************************************************************//** \name Context handling functions                             *//*****************************************************************//*@{*//** * Destroy the per-context private information. *  * \internal * This function calls __DriverAPIRec::DestroyContext on \p contextPrivate, calls * drmDestroyContext(), and finally frees \p contextPrivate. */static voiddriDestroyContext(__DRIcontext *pcp){    if (pcp) {	(*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp);	_mesa_free(pcp);    }}/** * Create the per-drawable private driver information. *  * \param render_type   Type of rendering target.  \c GLX_RGBA is the only *                      type likely to ever be supported for direct-rendering. * \param shared        Context with which to share textures, etc. or NULL * * \returns An opaque pointer to the per-context private information on *          success, or \c NULL on failure. *  * \internal * This function allocates and fills a __DRIcontextPrivateRec structure.  It * performs some device independent initialization and passes all the * relevent information to __DriverAPIRec::CreateContext to create the * context. * */static __DRIcontext *driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,		    int render_type, __DRIcontext *shared, 		    drm_context_t hwContext, void *data){    __DRIcontext *pcp;    void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;    pcp = _mesa_malloc(sizeof *pcp);    if (!pcp)	return NULL;    pcp->driScreenPriv = psp;    pcp->driDrawablePriv = NULL;    /* When the first context is created for a screen, initialize a "dummy"     * context.     */    if (!psp->dri2.enabled && !psp->dummyContextPriv.driScreenPriv) {        psp->dummyContextPriv.hHWContext = psp->pSAREA->dummy_context;        psp->dummyContextPriv.driScreenPriv = psp;        psp->dummyContextPriv.driDrawablePriv = NULL;        psp->dummyContextPriv.driverPrivate = NULL;	/* No other fields should be used! */    }    pcp->hHWContext = hwContext;    if ( !(*psp->DriverAPI.CreateContext)(&config->modes, pcp, shareCtx) ) {        _mesa_free(pcp);        return NULL;    }    return pcp;}static __DRIcontext *dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,		      __DRIcontext *shared, void *data){    drm_context_t hwContext;    DRM_CAS_RESULT(ret);    /* DRI2 doesn't use kernel with context IDs, we just need an ID that's     * different from the kernel context ID to make drmLock() happy. */    do {	hwContext = screen->dri2.lock->next_id;	DRM_CAS(&screen->dri2.lock->next_id, hwContext, hwContext + 1, ret);    } while (ret);    return driCreateNewContext(screen, config, 0, shared, hwContext, data);}static intdriCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask){    return GL_FALSE;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -