if (x<0) x=0; if (y<0) y=0;
void Java_vdr_mhp_awt_MHPNativeGraphics_drawRoundRect(JNIEnv* env, jobject obj, jlong nativeData, jlong nativeFlipData, jint x, jint y, jint width, jint height, jint arcWidth, jint arcHeight) {   IDirectFBSurface *surface=((IDirectFBSurface *)nativeData);   //printf("Java_vdr_mhp_awt_MHPNativeGraphics_fillRoundRect: %dx%d, %dx%d\n", x, y, width, height);      if (width<=0 || height<=0 || arcWidth<0 || arcHeight<0)      return;   if (x<0)      x=0;   if (y<0)      y=0;   if (height<arcHeight || width<arcWidth)      return Java_vdr_mhp_awt_MHPNativeGraphics_drawRect(env, obj, nativeData, nativeFlipData, x,y,width, height);      //libxmi operations   miPixel pixels[2];   miGC *pGC;   miPaintedSet *paintedSet;   miEllipseCache *cache;   miArc arcs[4];      pixels[0]=0; // pixel value for `off' dashes, if drawn   pixels[1]=1; // default pixel for drawing   pGC = miNewGC(2, pixels);   paintedSet = miNewPaintedSet();   cache = miNewEllipseCache();      //upper left corner   arcs[0].x=x;   arcs[0].y=y;   arcs[0].width=arcWidth;   arcs[0].height=arcHeight;   arcs[0].angle1=90*64; //starting angle, in 1/64 degrees, counterclockwise from x-axis   arcs[0].angle2=90*64; //angle range, in 1/64 degrees      //lower left   arcs[1].x=x;   arcs[1].y=y+height-arcHeight;   arcs[1].width=arcWidth;   arcs[1].height=arcHeight;   arcs[1].angle1=180*64;   arcs[1].angle2=90*64;      //uper right   arcs[2].x=x+width-arcWidth;   arcs[2].y=y;   arcs[2].width=arcWidth;   arcs[2].height=arcHeight;   arcs[2].angle1=0*64;   arcs[2].angle2=90*64;      //lower right   arcs[3].x=x+width-arcWidth;   arcs[3].y=y+height-arcHeight;   arcs[3].width=arcWidth;   arcs[3].height=arcHeight;   arcs[3].angle1=0*64;   arcs[3].angle2=-90*64;      miDrawArcs_r(paintedSet, pGC, 4, arcs, cache);     miDeleteEllipseCache(cache);      //do the actual drawing   try {      surface->SetDrawingFlags(DSDRAW_BLEND);            //first draw four normal lines (the corners cut out):      //left      if ((y+height-arcHeight/2)>0)         surface->DrawLine(x, y+arcHeight/2, x, y+height-arcHeight/2);      //upper      if ((x+width-arcWidth/2)>0)         surface->DrawLine(x+arcWidth/2, y, x+width-arcWidth/2, y);      //right      if ((y+height-arcHeight/2)>0)         surface->DrawLine(x+width, y+arcHeight/2, x+width, y+height-arcHeight/2);       //lower      if ((x+width-arcWidth/2)>0)         surface->DrawLine(x+arcWidth/2, y+height, x+width-arcWidth/2, y+height);            //now translate the point structures of the paintedSet to the surface's pixels, i.e., draw the arcs      for (int i = 0; i < paintedSet->ngroups; i++) {         if (paintedSet->groups[i]->group[0].count > 0) {            if (paintedSet->groups[i]->pixel) {               for (int u=0;u<paintedSet->groups[i]->group[0].count;u++) {                                 surface->DrawLine(paintedSet->groups[i]->group[0].points[u].x,                                    paintedSet->groups[i]->group[0].points[u].y,                                    paintedSet->groups[i]->group[0].points[u].x + paintedSet->groups[i]->group[0].widths[u],                                    paintedSet->groups[i]->group[0].points[u].y);               }            }         }      }         } catch (DFBException *e) {      printf("DirectFB: Error %s, %s\n", e->GetAction(), e->GetResult());      miDeleteGC (pGC);      miDeletePaintedSet (paintedSet);      delete e;      return;   }   ((FlipData *)nativeFlipData)->addUpdate(x, y, x+width+1, y+height+1);   miDeleteGC (pGC);   miDeletePaintedSet (paintedSet);}