?? gfx_drawcontrol.c.svn-base
字號:
return status;}static inline RMstatus GFXBlendAndScaleRectanglesProperty(struct RUA *pRua, struct GFXEngine_BlendAndScaleRectangles_type *blend_param){ RMstatus status; struct RUAEvent evt; RMuint8 trycount; trycount = 2; // try command only a couple of times then jump out tryagain: status = RUASetProperty(pRua, gdata.gfx, RMGFXEnginePropertyID_BlendAndScaleRectangles, blend_param, sizeof(struct GFXEngine_BlendAndScaleRectangles_type), 0); if (status == RM_PENDING && trycount--) { evt.ModuleID = gdata.gfx; evt.Mask = RUAEVENT_COMMANDCOMPLETION; if (RUAWaitForMultipleEvents(pRua, &evt, 1, TIMEOUT_US, NULL) != RM_OK) { RMDBGLOG((GFXDBG, "gfxBlendAndScale: FAILED WAITING FOR 1 second... TIMING ISSUE?\n")); } goto tryagain; } return status;}static inline RMstatus GFXSCBlendRectangleProperty(struct RUA *pRua, struct GFXEngine_SingleColorBlendRectangles_type *scblend_param){ RMstatus status; struct RUAEvent evt; RMuint8 trycount; trycount = 2; // try command only a couple of times then jump out tryagain: status = RUASetProperty(pRua, gdata.gfx, RMGFXEnginePropertyID_SingleColorBlendRectangles, scblend_param, sizeof(struct GFXEngine_SingleColorBlendRectangles_type), 0); if (status == RM_PENDING && trycount--) { evt.ModuleID = gdata.gfx; evt.Mask = RUAEVENT_COMMANDCOMPLETION; if (RUAWaitForMultipleEvents(pRua, &evt, 1, TIMEOUT_US, NULL) != RM_OK) { RMDBGLOG((GFXDBG, "gfxSCBlend: FAILED WAITING FOR 1 second... TIMING ISSUE?\n")); } goto tryagain; } return status;}//static inline RMuint8 GetTextBufferIndex()//{//// RMuint8 temp = (g_textBufferIndex < MAX_STR_BUFFERS - 1 ? g_textBufferIndex + 1 : 0);// g_textBufferIndex = temp;// return g_textBufferIndex;//}static inline RMuint8 GetBitmapBufferIndex(RMbool whole){ RMuint8 temp; if (whole) temp = (g_bitmapBufferIndex == 0 ? 1 : 0); else temp = (g_bitmapBufferIndex < MAX_DRAWING_BUFFER_PARTS ? g_bitmapBufferIndex + 1 : 0); g_bitmapBufferIndex = temp; return g_bitmapBufferIndex;}//static RMbool GetAlternateIndex(// RMuint8 index,// RMuint8 *newindex,// RMuint32 bmpsize)//{// RMuint8 i, j;// RMuint32 usedbuffer = 0;//// entry* np;////// for(i = index - 1; i > 0; i--){// usedbuffer += g_bitmaps[i].bmp.uiDataSize;// if(CanReuseBuffer(usedbuffer, bmpsize)){// ResetUsedBuffer(usedbuffer);// // clear bmp buffers from here on since may not be first try// for(j = i; j < MAX_BITMAPS; j++){// RMMemset(&g_bitmaps[j], 0, sizeof(RMbitmapdata));// }//// // return new index// *newindex = i;// return TRUE;// }// }//// return FALSE;//}static RMbool CompareTextPalette(struct GFXEngine_Palette_1BPP_type *pal){ if (g_last_palbpp != 1) return FALSE; if (g_lastpal.Palette[0] == pal->Palette[0] && g_lastpal.Palette[1] == pal->Palette[1]) return TRUE; return FALSE;}// only check first 16 colors of 8bpp palettestatic RMbool CompareBitmapPalette(struct GFXEngine_Palette_8BPP_type *pal){ RMuint8 i; if (g_last_palbpp != 8) return FALSE; for (i = 0; i < 16; i++) { if (g_lastpal.Palette[i] != pal->Palette[i]) { return FALSE; } } return TRUE;}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////RMstatus SetOutputSurface(struct RUA *pRua){ struct GFXEngine_ColorFormat_type format_param; struct GFXEngine_Surface_type surface_param; RMstatus status; if (gdata.gfx == 0xff || gdata.osdAddr == 0) return RM_ERROR; format_param.SurfaceID = GFX_SURFACE_ID_NX; format_param.MainMode = EMhwlibColorMode_TrueColor; format_param.SubMode = EMhwlibColorFormat_32BPP; status = GFXColorFormatProperty(pRua, &format_param); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting color format parameters\n")); surface_param.StartAddress = gdata.osdAddr; surface_param.TotalWidth = gdata.osdWidth; surface_param.Tiled = FALSE; surface_param.SurfaceID = GFX_SURFACE_ID_NX; status = GFXSurfaceProperty(pRua, &surface_param); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting surface parameters\n")); return status;}RMstatus SetOutputSurfaceBuffer(struct RUA *pRua, RMuint32 pAddress, RMuint32 width){ struct GFXEngine_ColorFormat_type format_param; struct GFXEngine_Surface_type surface_param; RMstatus status; if (gdata.gfx == 0xff || gdata.osdAddr == 0) return RM_ERROR; format_param.SurfaceID = GFX_SURFACE_ID_NX; format_param.MainMode = EMhwlibColorMode_TrueColor; format_param.SubMode = EMhwlibColorFormat_32BPP; status = GFXColorFormatProperty(pRua, &format_param); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting color format parameters\n")); surface_param.StartAddress = pAddress; surface_param.TotalWidth = width; surface_param.Tiled = FALSE; surface_param.SurfaceID = GFX_SURFACE_ID_NX; status = GFXSurfaceProperty(pRua, &surface_param); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting surface parameters\n")); return status;}RMstatus SetInputSurface(struct RUA *pRua, RMuint32 mode, RMuint32 startAddr, RMuint32 width, RMuint32 surfaceID){ struct GFXEngine_ColorFormat_type format_param; struct GFXEngine_Surface_type surface_param; RMstatus status; if (gdata.gfx == 0xff) return RM_ERROR; format_param.SurfaceID = surfaceID; format_param.MainMode = mode; format_param.SubMode = EMhwlibColorFormat_32BPP; status = GFXColorFormatProperty(pRua, &format_param); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting color format parameters\n")); surface_param.StartAddress = startAddr; surface_param.TotalWidth = width; surface_param.Tiled = FALSE; surface_param.SurfaceID = surfaceID; status = GFXSurfaceProperty(pRua, &surface_param); if (RMFAILED(status)) RMDBGLOG((GFXDBG, "Error setting surface parameters\n")); return status;}RMstatus Fill(struct RUA *pRua, RMint32 x, RMint32 y, RMuint32 width, RMuint32 height, RMuint32 color){ struct GFXEngine_FillRectangle_type fill_param; RMstatus status; fill_param.X = x; fill_param.Y = y; fill_param.Width = width; fill_param.Height = height; fill_param.Color = color; status = GFXFillRectangleProperty(pRua, &fill_param); return status;}RMstatus SCBlendFill(struct RUA *pRua, RMint32 x, RMint32 y, RMuint32 width, RMuint32 height, RMuint32 color, RMuint8 bkgndindex){ struct GFXEngine_SingleColorBlendRectangles_type sc_blend_param; RMstatus status; RMuint32 saddr; RMuint32 swidth; if (gdata.osdOn == TRUE) { // no blending if not background for now!!!!!!!!!!!!!!!!!!!!!!!!!!!! if (g_bitmaps[bkgndindex].pBmpAddr == 0 || bkgndindex != 0) return Fill(pRua, x, y, width, height, color); saddr = g_bitmaps[bkgndindex].pBmpAddr; swidth = g_bitmaps[bkgndindex].bmp.uiWidth; } else { if (gdata.pictureMode && bkgndindex == 0) { saddr = gdata.backBuffer.baseAddr; swidth = gdata.osdWidth; } else return Fill(pRua, x, y, width, height, color); } //setup X status = SetInputSurface(pRua, EMhwlibColorMode_TrueColor, saddr, swidth, GFX_SURFACE_ID_X); if (RMFAILED(status)) return status; sc_blend_param.SrcX = x; sc_blend_param.SrcY = y; sc_blend_param.DstX = x; sc_blend_param.DstY = y; sc_blend_param.Width = width; sc_blend_param.Height = height; sc_blend_param.Color = color; sc_blend_param.SaturateAlpha = FALSE; status = GFXSCBlendRectangleProperty(pRua, &sc_blend_param); return status;}RMstatus RoundRect(struct RUA *pRua, RMint32 x, RMint32 y, RMuint32 width, RMuint32 height, RMuint32 color, RMbool blend, RMuint8 bkgndindex){ RMstatus status = RM_OK; if (blend == FALSE) { // middle area // status = Fill(pRua, x + 3, y + 3, width - 6, height - 6, color); status = Fill(pRua, x, y, width, height, color); if (RMFAILED(status)) return status; // // top // Fill(pRua, x + 2, y + 2, width - 4, 1, color); // Fill(pRua, x + 3, y + 1, width - 6, 1, color); // Fill(pRua, x + 5, y, width - 10, 1, color); // // // bottom // Fill(pRua, x + 2, y + height - 3, width - 4, 1, color); // Fill(pRua, x + 3, y + height - 2, width - 6, 1, color); // Fill(pRua, x + 5, y + height - 1, width - 10, 1, color); // // // left // Fill(pRua, x + 2, y + 2, 1, height - 4, color); // Fill(pRua, x + 1, y + 3, 1, height - 6, color); // Fill(pRua, x, y + 5, 1, height - 10, color); // // // right // Fill(pRua, x + width - 3, y + 2, 1, height - 4, color); // Fill(pRua, x + width - 2, y + 3, 1, height - 6, color); // Fill(pRua, x + width -1, y + 5, 1, height - 10, color); } else { //status = SCBlendFill(pRua, x + 3, y + 3, width - 6, height - 6, color, bkgndindex); status = SCBlendFill(pRua, x, y, width, height, color, bkgndindex); if (RMFAILED(status)) return status; // // top // SCBlendFill(pRua, x + 2, y + 2, width - 4, 1, color, bkgndindex); // SCBlendFill(pRua, x + 3, y + 1, width - 6, 1, color, bkgndindex); // SCBlendFill(pRua, x + 5, y, width - 10, 1, color, bkgndindex); // // // bottom // SCBlendFill(pRua, x + 2, y + height - 3, width - 4, 1, color, bkgndindex); // SCBlendFill(pRua, x + 3, y + height - 2, width - 6, 1, color, bkgndindex); // SCBlendFill(pRua, x + 5, y + height - 1, width - 10, 1, color, bkgndindex); // // // left // SCBlendFill(pRua, x + 2, y + 2, 1, height - 4, color, bkgndindex); // SCBlendFill(pRua, x + 1, y + 3, 1, height - 6, color, bkgndindex); // SCBlendFill(pRua, x, y + 5, 1, height - 10, color, bkgndindex); // // // right // SCBlendFill(pRua, x + width - 3, y + 2, 1, height - 4, color, bkgndindex); // SCBlendFill(pRua, x + width - 2, y + 3, 1, height - 6, color, bkgndindex); // SCBlendFill(pRua, x + width -1, y + 5, 1, height - 10, color, bkgndindex); } return status;}/* draw a outline of a given color*/RMstatus RectOutline(struct RUA *pRua, GFXLib_rect *rect, RMuint32 color, RMbool rounded, RMbool blend, RMuint8 bkgndindex){ if (rounded == 0) { if (blend == FALSE) { // top Fill(pRua, rect->x, rect->y, rect->width, 2, color); // bottom Fill(pRua, rect->x, rect->y + rect->height - 2, rect->width, 2, color); // left Fill(pRua, rect->x, rect->y, 2, rect->height, color); // right Fill(pRua, rect->x + rect->width - 2, rect->y, 2, rect->height, color); } else { // top SCBlendFill(pRua, rect->x, rect->y, rect->width, 2, color, bkgndindex); // bottom SCBlendFill(pRua, rect->x, rect->y + rect->height - 2, rect->width, 2, color, bkgndindex); // left SCBlendFill(pRua, rect->x, rect->y, 2, rect->height, color, bkgndindex); // right SCBlendFill(pRua, rect->x + rect->width - 2, rect->y, 2, rect->height, color, bkgndindex); } return RM_OK; } // draw rounded outline if (blend == FALSE) { // top Fill(pRua, rect->x + 5, rect->y, rect->width - 10, 1, color); Fill(pRua, rect->x + 3, rect->y + 1, rect->width - 6, 1, color); // bottom Fill(pRua, rect->x + 5, rect->y + rect->height - 1, rect->width - 10, 1, color); Fill(pRua, rect->x + 3, rect->y + rect->height - 2, rect->width - 6, 1, color); // left Fill(pRua, rect->x, rect->y + 5, 1, rect->height - 10, color); Fill(pRua, rect->x + 1, rect->y + 3, 1, rect->height - 6, color); // right Fill(pRua, rect->x + rect->width - 1, rect->y + 5, 1, rect->height - 10, color); Fill(pRua, rect->x + rect->width - 4, rect->y + rect->height - 4, 2, 2, color); // upper left corner Fill(pRua, rect->x + 2, rect->y + 2, 2, 2, color); // lower left corner Fill(pRua, rect->x + 2, rect->y + rect->height - 4, 2, 2, color); // upper right corner Fill(pRua, rect->x + rect->width - 4, rect->y + 2, 2, 2, color); // lower right corner Fill(pRua, rect->x + rect->width - 2, rect->y + 3, 1, rect->height - 6, color); } else { // top SCBlendFill(pRua, rect->x + 5, rect->y, rect->width - 10, 1, color, bkgndindex); SCBlendFill(pRua, rect->x + 3, rect->y + 1, rect->width - 6, 1, color, bkgndindex); // bottom SCBlendFill(pRua, rect->x + 5, rect->y + rect->height - 1, rect->width - 10, 1, color, bkgndindex); SCBlendFill(pRua, rect->x + 3, rect->y + rect->height - 2, rect->width - 6, 1, color, bkgndindex); // left SCBlendFill(pRua, rect->x, rect->y + 5, 1, rect->height - 10, color, bkgndindex); SCBlendFill(pRua, rect->x + 1, rect->y + 3, 1, rect->height - 6, color, bkgndindex); // right SCBlendFill(pRua, rect->x + rect->width - 1, rect->y + 5, 1, rect->height - 10, color, bkgndindex); SCBlendFill(pRua, rect->x + rect->width - 4, rect->y + rect->height - 4, 2, 2, color, bkgndindex); // upper left corner SCBlendFill(pRua, rect->x + 2, rect->y + 2, 2, 2, color, bkgndindex); // lower left corner SCBlendFill(pRua, rect->x + 2, rect->y + rect->height - 4, 2, 2, color, bkgndindex); // upper right corner SCBlendFill(pRua, rect->x + rect->width - 4, rect->y + 2, 2, 2, color, bkgndindex); // lower right corner SCBlendFill(pRua, rect->x + rect->width - 2, rect->y + 3, 1, rect->height - 6, color, bkgndindex); } return RM_OK;}// only BMP, PNG, JPEG and GIF supportedRMstatus LoadImage(struct RUA *pRua, RMuint8 bmpindex, RMuint32 *bmpsize){ RMstatus status; if (g_bitmaps[bmpindex].path == NULL) return RM_ERROR; if (isPng(g_bitmaps[bmpindex].path)) { status = load_png(pRua, &g_bitmaps[bmpindex], bmpsize); } else if (isBitmap(g_bitmaps[bmpindex].path)) { status = load_bitmap(pRua, &g_bitmaps[bmpindex], bmpsize);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -