Re: Speeding up graphics

From: Dom Lachowicz (domlachowicz_at_yahoo.com)
Date: Sat Dec 13 2003 - 15:12:48 EST

  • Next message: Dom Lachowicz: "Re: Unfinished Find/Replace code available for grabs (or trashcan)"

    I'll take this.

    Dom

    --- Johan_Björk <phearbear_at_home.se> wrote:
    > Hi guys
    >
    > This is the work I did. It uses offscreen buffers on
    > QNX, and blits once
    > all beginDraws() is complete.
    > I would like to put the beginDraw() on more places,
    > "higher" in the
    > hierarchy, to reduce flicker even more. But I
    > really havn't had time to
    > work on this for a while.
    >
    > I won't have time to work more on this patch in the
    > nearest weeks, so if
    > anyone want to use this, please go ahead!
    >
    > /Johan
    >
    > > ? patch
    > ? flepp
    > ? todo
    > ? flepp_beforehugecommit
    > ? src/flepp
    > ? src/BillOfRights.abw
    > ? src/af/gr/st732079
    > ? src/af/gr/cocoa/gr_CocoaImage.c
    > ? src/af/xap/qnx/st100131
    > ? src/text/fmt/xp/draw
    > ? src/wp/ap/qnx/st574129
    > Index: src/af/gr/qnx/gr_QNXGraphics.cpp
    >
    ===================================================================
    > RCS file:
    > /cvsroot/abi/src/af/gr/qnx/gr_QNXGraphics.cpp,v
    > retrieving revision 1.116
    > diff -u -r1.116 gr_QNXGraphics.cpp
    > --- src/af/gr/qnx/gr_QNXGraphics.cpp 12 Nov 2003
    > 21:49:13 -0000 1.116
    > +++ src/af/gr/qnx/gr_QNXGraphics.cpp 13 Dec 2003
    > 19:20:58 -0000
    > @@ -56,6 +56,26 @@
    > {
    > return pszFontFamily;
    > }
    > +
    > +bool GR_QNXGraphics::OSCIsValid() {
    > +if(m_pOSC == NULL)
    > + return false;
    > +
    > +if(m_pDraw->area.size.w != m_pOSC->dim.w ||
    > m_pDraw->area.size.h != m_pOSC->dim.h)
    > +{
    > +PhDCSetCurrent(0);
    > +PhDCRelease(m_pOSC);
    > +m_pOSC =
    >
    PdCreateOffscreenContext(0,m_pDraw->area.size.w,m_pDraw->area.size.h,0);
    > +PtDamageWidget(m_pDraw);
    > +}
    > +/*if(PdIsOffscreenValid(m_pOSC) == -1) {
    > + PhDCRelease((PhDrawContext_t *)m_pOSC);
    > + m_pOSC = NULL;
    > + return false;
    > +}*/
    > +
    > +return true;
    > +}
    > /***
    > Initialization/Teardown for drawing on a widget
    > outside of the normal
    > stream of "damage" events
    > @@ -69,11 +89,21 @@
    > //sometimes abi is stupid and calls a raw draw
    > function without making sure we want to draw it (ie,
    > Left ruler in normal view mode), therefor we do a
    > simple check if our widget is realized or not...
    > if(PtWidgetIsRealized(m_pDraw) == 0) return -1;
    >
    > - m_pGC_old=PgSetGC(m_pGC);
    >
    > + if(OSCIsValid()) {
    > + PtFlush();
    > + if(PhDCSetCurrent(m_pOSC) == NULL)
    > + UT_ASSERT(0); //we don't need a seperate GC as a
    > DC already have one.
    > + } else {
    > + UT_ASSERT(0);
    > + //TODO: try to create a new one!
    > + }
    > //Set the region and the draw offset
    > PgSetRegion(PtWidgetRid(PtFindDisjoint(m_pDraw)));
    >
    > +// m_pGC_old=PgSetGC(m_pGC); //m_pOSC has it's own
    > GC??
    > +
    > +#if 0
    > PtWidgetOffset(m_pDraw, &m_OffsetPoint);
    > m_OffsetPoint.y+=m_pDraw->area.pos.y;
    > m_OffsetPoint.x+=m_pDraw->area.pos.x;
    > @@ -83,7 +113,7 @@
    > trans.x = -m_OffsetPoint.x;
    > trans.y = -m_OffsetPoint.y;
    > PdSetOffscreenTranslation(m_pOSC,&trans);*/
    > -
    > +#endif
    > //Always clip to the canvas
    > PhRect_t _rdraw;
    > PtCalcCanvas(m_pDraw, &_rdraw);
    > @@ -106,7 +136,6 @@
    > PhDeTranslateRect(&_rdraw,&abs);*/
    > PgSetUserClip(&_rdraw);
    >
    > -
    > return 0;
    >
    > }
    > @@ -140,31 +169,38 @@
    >
    > PgContextBlit(m_pOSC,&rect,NULL,&rect2); */
    >
    > +#if 0
    > PgSetUserClip(NULL);
    > PgClearTranslation();
    > -
    > - PgSetGC(m_pGC_old);
    > -// PhDCSetCurrent(m_pOldDC);
    > +#endif
    > + PhDCSetCurrent(0);
    > + PgFlush();
    > +// PgSetGC(m_pGC_old);
    >
    > return 0;
    > }
    >
    >
    > GR_QNXGraphics::GR_QNXGraphics(PtWidget_t * win,
    > PtWidget_t * draw, XAP_App *app)
    > +:
    > + m_pWin(win),
    > + m_pDraw(draw),
    > + m_pFont(NULL),
    > + m_pFontGUI(NULL),
    > + m_pClipList(NULL),
    > + m_iLineWidth(1),
    > + m_currentColor(Pg_BLACK),
    > + m_pPrintContext(NULL),
    > + m_iAscentCache(-1),
    > + m_iDescentCache(-1),
    > + m_iHeightCache(-1)
    > {
    > m_pApp = app;
    > - m_pWin = win;
    > - m_pDraw = draw;
    > - m_pGC = PgCreateGC(0);
    > - m_pFont = NULL;
    > - m_pFontGUI = NULL;
    > - m_pClipList = NULL;
    > - m_iLineWidth = 1;
    > - m_currentColor = Pg_BLACK;
    > - m_pPrintContext = NULL;
    > - m_iAscentCache = m_iDescentCache = m_iHeightCache
    > -1;
    > +// m_pGC = PgCreateGC(0);
    > + memset(&m_DamagedArea,0,sizeof(m_DamagedArea));
    > +
    > + m_pOSC =
    >
    PdCreateOffscreenContext(0,draw->area.size.w,draw->area.size.h,NULL);
    >
    > -// m_pOSC =
    >
    PdCreateOffscreenContext(0,draw->area.size.w,draw->area.size.h,NULL);
    > m_pFontCx = PfAttachCx("/dev/phfont",240000);
    >
    > m_cs = GR_Graphics::GR_COLORSPACE_COLOR;
    > @@ -183,8 +219,10 @@
    > PhImage_t * pImg = (PhImage_t
    > *)m_vSaveRectBuf.getNthItem (i);
    > PgShmemDestroy(pImg);
    > }
    > - PgDestroyGC(m_pGC);
    > -// PhDCRelease(m_pOSC);
    > +// PgDestroyGC(m_pGC);
    > + PtFlush();
    > + PhDCSetCurrent(0); //JIC
    > + PhDCRelease(m_pOSC);
    > PfDetach(m_pFontCx);
    > }
    >
    > @@ -290,6 +328,7 @@
    > int * pCharWidths)
    > {
    > if(pCharWidths == NULL && iLength > 1) {
    > + GR_CaretDisabler caretDisabler(getCaret());
    > static int alloclen;
    > static UT_UCS2Char *ucs2buffer;
    >
    > @@ -303,11 +342,11 @@
    >
    > PhPoint_t pos = {_tduX(xoff),tdu(getFontAscent())
    > + _tduY(yoff)};
    > DRAW_START
    > - GR_CaretDisabler caretDisabler(getCaret());
    > // PgSetTextColor(m_currentColor);
    > // PgSetFont(m_pFont->getDisplayFont());
    > PgDrawText((const char
    >
    *)ucs2buffer,iLength*2,&pos,Pg_TEXT_WIDECHAR|Pg_TEXT_LEFT);
    > DRAW_END
    > +
    >
    setDamage(pos.x,pos.y,tdu(getFontHeight()),m_pDraw->area.size.w);
    > }
    > else
    > for(int i=0;i<iLength;i++) {
    > @@ -329,6 +368,7 @@
    > //PgSetFont(m_pFont->getDisplayFont());
    > PgDrawText((const char
    > *)&ucs2buffer,2,&pos,Pg_TEXT_WIDECHAR|Pg_TEXT_LEFT);
    > DRAW_END
    >
    +setDamage(pos.x,pos.y,tdu(getFontHeight()),m_pDraw->area.size.w);
    > }
    >
    > UT_uint32
    > GR_QNXGraphics::measureUnRemappedChar(const
    > UT_UCSChar
    === message truncated ===

    __________________________________
    Do you Yahoo!?
    Protect your identity with Yahoo! Mail AddressGuard
    http://antispam.yahoo.com/whatsnewfree



    This archive was generated by hypermail 2.1.4 : Sat Dec 13 2003 - 15:12:18 EST