[Redbutton-devel] SF.net SVN: redbutton: [127] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2006-06-29 13:25:21
|
Revision: 127 Author: skilvington Date: 2006-06-29 06:25:13 -0700 (Thu, 29 Jun 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=127&view=rev Log Message: ----------- only refresh MHEG overlay when we have finished drawing it Modified Paths: -------------- redbutton-browser/trunk/MHEGDisplay.c redbutton-browser/trunk/MHEGDisplay.h redbutton-browser/trunk/MHEGEngine.c redbutton-browser/trunk/TODO Modified: redbutton-browser/trunk/MHEGDisplay.c =================================================================== --- redbutton-browser/trunk/MHEGDisplay.c 2006-06-28 16:27:17 UTC (rev 126) +++ redbutton-browser/trunk/MHEGDisplay.c 2006-06-29 13:25:13 UTC (rev 127) @@ -80,7 +80,6 @@ XGCValues gcvals; XRenderPictFormat *pic_format; XRenderPictureAttributes pa; - Pixmap overlay; Pixmap textfg; /* fake argc, argv for XtDisplayInitialize */ int argc = 0; @@ -227,8 +226,10 @@ /* create a 32-bit XRender Picture to draw the MHEG objects on */ pic_format = XRenderFindStandardFormat(d->dpy, PictStandardARGB32); - overlay = XCreatePixmap(d->dpy, d->win, d->xres, d->yres, 32); - d->overlay_pic = XRenderCreatePicture(d->dpy, overlay, pic_format, 0, NULL); + d->next_overlay = XCreatePixmap(d->dpy, d->win, d->xres, d->yres, 32); + d->next_overlay_pic = XRenderCreatePicture(d->dpy, d->next_overlay, pic_format, 0, NULL); + d->used_overlay = XCreatePixmap(d->dpy, d->win, d->xres, d->yres, 32); + d->used_overlay_pic = XRenderCreatePicture(d->dpy, d->used_overlay, pic_format, 0, NULL); /* a 1x1 Picture to hold the text foreground colour */ textfg = XCreatePixmap(d->dpy, d->win, 1, 1, 32); @@ -238,6 +239,9 @@ /* a GC to draw on the Window */ d->win_gc = XCreateGC(d->dpy, d->win, 0, &gcvals); + /* a GC to XCopyArea next_overlay to used_overlay (need to avoid any XRender clip mask on next_overlay) */ + d->overlay_gc = XCreateGC(d->dpy, d->next_overlay, 0, &gcvals); + /* get the window on the screen */ XMapWindow(d->dpy, d->win); @@ -371,10 +375,10 @@ /* * if video is being displayed, the current frame will already be in d->contents - * (drawn by the video thread or VideoClass_render) + * (drawn by the video thread) * overlay the MHEG objects onto the video in d->contents */ - XRenderComposite(d->dpy, PictOpOver, d->overlay_pic, None, d->contents_pic, x, y, x, y, x, y, w, h); + XRenderComposite(d->dpy, PictOpOver, d->used_overlay_pic, None, d->contents_pic, x, y, x, y, x, y, w, h); /* copy the Window contents onto the screen */ XCopyArea(d->dpy, d->contents, d->win, d->win_gc, x, y, w, h, x, y); @@ -383,6 +387,15 @@ } /* + * all these drawing routines draw onto next_overlay_pic + * all coords should be in the range 0-MHEG_XRES, 0-MHEG_YRES + * the drawing routines themselves will scale the coords to full screen if needed + * you have to call MHEGDisplay_useOverlay() when you have finished drawing + * this copies next_overlay onto used_overlay + * used_overlay_pic is composited onto any video and put on the screen by MHEGDisplay_refresh() + */ + +/* * set the clip rectangle for all subsequent drawing on the overlay * coords should be in the range 0-MHEG_XRES, 0-MHEG_YRES */ @@ -398,9 +411,7 @@ clip.width = (box->x_length * d->xres) / MHEG_XRES; clip.height = (box->y_length * d->yres) / MHEG_YRES; -/* TODO */ -/* this will effect the XRenderComposite() call in _refresh() */ - XRenderSetPictureClipRectangles(d->dpy, d->overlay_pic, 0, 0, &clip, 1); + XRenderSetPictureClipRectangles(d->dpy, d->next_overlay_pic, 0, 0, &clip, 1); return; } @@ -412,7 +423,7 @@ void MHEGDisplay_unsetClipRectangle(MHEGDisplay *d) { - XRenderSetPictureClipRectangles(d->dpy, d->overlay_pic, 0, 0, NULL, 0); + XRenderSetPictureClipRectangles(d->dpy, d->next_overlay_pic, 0, 0, NULL, 0); return; } @@ -449,7 +460,7 @@ printf("TODO: LineStyle %d\n", style); /* draw a rectangle */ - XRenderFillRectangle(d->dpy, PictOpOver, d->overlay_pic, &rcol, x, y, w, h); + XRenderFillRectangle(d->dpy, PictOpOver, d->next_overlay_pic, &rcol, x, y, w, h); return; } @@ -486,7 +497,7 @@ printf("TODO: LineStyle %d\n", style); /* draw a rectangle */ - XRenderFillRectangle(d->dpy, PictOpOver, d->overlay_pic, &rcol, x, y, w, h); + XRenderFillRectangle(d->dpy, PictOpOver, d->next_overlay_pic, &rcol, x, y, w, h); return; } @@ -515,7 +526,7 @@ w = (box->x_length * d->xres) / MHEG_XRES; h = (box->y_length * d->yres) / MHEG_YRES; - XRenderFillRectangle(d->dpy, PictOpOver, d->overlay_pic, &rcol, x, y, w, h); + XRenderFillRectangle(d->dpy, PictOpOver, d->next_overlay_pic, &rcol, x, y, w, h); return; } @@ -539,7 +550,7 @@ w = (box->x_length * d->xres) / MHEG_XRES; h = (box->y_length * d->yres) / MHEG_YRES; - XRenderFillRectangle(d->dpy, PictOpSrc, d->overlay_pic, &rcol, x, y, w, h); + XRenderFillRectangle(d->dpy, PictOpSrc, d->next_overlay_pic, &rcol, x, y, w, h); return; } @@ -570,7 +581,7 @@ dst_x = (dst->x_position * d->xres) / MHEG_XRES; dst_y = (dst->y_position * d->yres) / MHEG_YRES; - XRenderComposite(d->dpy, PictOpOver, bitmap->image_pic, None, d->overlay_pic, + XRenderComposite(d->dpy, PictOpOver, bitmap->image_pic, None, d->next_overlay_pic, src_x, src_y, src_x, src_y, dst_x, dst_y, w, h); @@ -670,7 +681,7 @@ /* round up/down the X coord */ scrn_x = (x * d->xres) / MHEG_XRES; scrn_x = (scrn_x + (face->units_per_EM / 2)) / face->units_per_EM; - XftGlyphRender(d->dpy, PictOpOver, d->textfg_pic, font->font, d->overlay_pic, + XftGlyphRender(d->dpy, PictOpOver, d->textfg_pic, font->font, d->next_overlay_pic, 0, 0, orig_x + scrn_x, y, &glyph, 1); face = XftLockFace(font->font); @@ -690,6 +701,20 @@ } /* + * copy the contents of next_overlay onto used_overlay + * ie all drawing done since the last call to this will appear on the screen at the next refresh() + */ + +void +MHEGDisplay_useOverlay(MHEGDisplay *d) +{ + /* avoid any XRender clip mask */ + XCopyArea(d->dpy, d->next_overlay, d->used_overlay, d->overlay_gc, 0, 0, d->xres, d->yres, 0, 0); + + return; +} + +/* * convert the given PNG data to an internal format * returns NULL on error */ Modified: redbutton-browser/trunk/MHEGDisplay.h =================================================================== --- redbutton-browser/trunk/MHEGDisplay.h 2006-06-28 16:27:17 UTC (rev 126) +++ redbutton-browser/trunk/MHEGDisplay.h 2006-06-29 13:25:13 UTC (rev 127) @@ -47,7 +47,11 @@ Colormap cmap; /* None, unless we needed to create a Colormap for our Visual */ Pixmap contents; /* current contents of the Window */ Picture contents_pic; /* XRender wrapper for the contents, this is what we composite on */ - Picture overlay_pic; /* draw MHEG objects on here and overlay it on any video */ + Pixmap next_overlay; /* all MHEG objects are drawn on next_overlay */ + Picture next_overlay_pic; /* via this XRender wrapper */ + Pixmap used_overlay; /* when MHEGDisplay_useOverlay() is called, next_overlay is copied here */ + Picture used_overlay_pic; /* used_overlay_pic is composited onto the video */ + GC overlay_gc; /* GC to XCopyArea next_overlay to used_overlay */ Picture textfg_pic; /* 1x1 solid foreground colour for text */ MHEGKeyMapEntry *keymap; /* keyboard mapping */ } MHEGDisplay; @@ -62,6 +66,7 @@ /* drawing routines */ void MHEGDisplay_setClipRectangle(MHEGDisplay *, XYPosition *, OriginalBoxSize *); void MHEGDisplay_unsetClipRectangle(MHEGDisplay *); + void MHEGDisplay_drawHoriLine(MHEGDisplay *, XYPosition *, unsigned int, int, int, MHEGColour *); void MHEGDisplay_drawVertLine(MHEGDisplay *, XYPosition *, unsigned int, int, int, MHEGColour *); void MHEGDisplay_fillTransparentRectangle(MHEGDisplay *, XYPosition *, OriginalBoxSize *); @@ -69,6 +74,8 @@ void MHEGDisplay_drawBitmap(MHEGDisplay *, XYPosition *, OriginalBoxSize *, MHEGBitmap *, XYPosition *); void MHEGDisplay_drawTextElement(MHEGDisplay *, XYPosition *, MHEGFont *, MHEGTextElement *, bool); +void MHEGDisplay_useOverlay(MHEGDisplay *); + /* convert PNG and MPEG I-frames to internal format */ MHEGBitmap *MHEGDisplay_newPNGBitmap(MHEGDisplay *, OctetString *); MHEGBitmap *MHEGDisplay_newMPEGBitmap(MHEGDisplay *, OctetString *); Modified: redbutton-browser/trunk/MHEGEngine.c =================================================================== --- redbutton-browser/trunk/MHEGEngine.c 2006-06-28 16:27:17 UTC (rev 126) +++ redbutton-browser/trunk/MHEGEngine.c 2006-06-29 13:25:13 UTC (rev 127) @@ -649,13 +649,6 @@ if(app->inst.LockCount > 0) return; -/**************************************************************************************/ -/* could do: */ -/* MHEGDisplay_setClipRectangle(pos, box); */ -/* rather than relying on every _render() method to make sure they dont draw outside the area */ -/* we also need to make sure the _render methods dont draw outside their own bounding boxes */ -/**************************************************************************************/ - /* any undrawn on background is black */ MHEGColour_black(&black); MHEGDisplay_fillRectangle(&engine.display, pos, box, &black); @@ -673,6 +666,9 @@ stack = stack->next; } + /* use the new objects we have just drawn */ + MHEGDisplay_useOverlay(&engine.display); + /* refresh the screen */ MHEGDisplay_refresh(&engine.display, pos, box); Modified: redbutton-browser/trunk/TODO =================================================================== --- redbutton-browser/trunk/TODO 2006-06-28 16:27:17 UTC (rev 126) +++ redbutton-browser/trunk/TODO 2006-06-29 13:25:13 UTC (rev 127) @@ -1,3 +1,7 @@ +use setClipRectangle on the intersection area in each _render() method +(remember to unsetClipRectangle at the end of _render) + + if openStream fails - need to make sure either: contents picture gets filled with black, or VideoClass_render does not make a transparent rectangle in the overlay picture This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |