draw border

git-svn-id: svn://kolibrios.org@878 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-10-15 10:31:44 +00:00
parent fb3e9a2b66
commit e50ee3e947
5 changed files with 89 additions and 19 deletions

View File

@ -95,6 +95,7 @@ typedef struct
}; };
}; };
color_t color; color_t color;
color_t border;
}draw_t; }draw_t;
typedef struct typedef struct

View File

@ -70,7 +70,7 @@ int Line(draw_t *draw)
int DrawRect(draw_t* draw) int DrawRect(draw_t* draw)
{ {
int x0, y0, x1, y1; int x0, y0, x1, y1, xend, yend;
local_pixmap_t *dstpixmap; local_pixmap_t *dstpixmap;
clip_t dst_clip; clip_t dst_clip;
@ -80,8 +80,8 @@ int DrawRect(draw_t* draw)
x0 = draw->x0; x0 = draw->x0;
y0 = draw->y0; y0 = draw->y0;
x1 = x0+draw->w-1; x1 = xend = x0 + draw->w - 1;
y1 = y0+draw->h-1; y1 = yend = y0 + draw->h - 1;
dst_clip.xmin = 0; dst_clip.xmin = 0;
dst_clip.ymin = 0; dst_clip.ymin = 0;
@ -119,8 +119,45 @@ int DrawRect(draw_t* draw)
OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color); OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color);
OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM); OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset); OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
OUTREG(R5XX_DST_Y_X,(draw->y0<<16)|draw->x0); OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|h); OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|h);
if( draw->color != draw->border)
{
OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->border);
if( y0 == draw->y0)
{
R5xxFIFOWait(2);
OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
y0++;
h--;
}
if( y1 == yend )
{
R5xxFIFOWait(2);
OUTREG(R5XX_DST_Y_X,(y1<<16)|x0);
OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
h--;
}
if( x0 == draw->x0)
{
R5xxFIFOWait(2);
OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
}
if( x1 == xend)
{
R5xxFIFOWait(2);
OUTREG(R5XX_DST_Y_X,(y0<<16)|x1);
OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
}
};
#else #else
BEGIN_RING(); BEGIN_RING();
OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4)); OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4));

View File

@ -35,6 +35,11 @@ u32_t __stdcall drvEntry(int action)
printf("Can't open /rd/1/drivers/ati2d.log\nExit\n"); printf("Can't open /rd/1/drivers/ati2d.log\nExit\n");
return 0; return 0;
} }
if( GetScreenBpp() != 32)
{
printf("32 bpp dispaly mode required !\nExit\t");
return 0;
}
if((rhdPtr=FindPciDevice())==NULL) if((rhdPtr=FindPciDevice())==NULL)
{ {
@ -106,7 +111,7 @@ int _stdcall srv_2d(ioctl_t *io)
break; break;
case PX_DRAW_RECT: case PX_DRAW_RECT:
if(io->inp_size==6) if(io->inp_size==7)
return DrawRect((draw_t*)inp); return DrawRect((draw_t*)inp);
break; break;

View File

@ -351,14 +351,14 @@ static void load_microcode()
void R5xx2DInit() void R5xx2DInit()
{ {
u32_t base; u32_t base;
int screensize;
int screenpitch;
#ifdef R300_TEST screensize = GetScreenSize();
rhd.displayWidth = 1024; screenpitch = GetScreenPitch();
rhd.displayHeight = 768;
#else rhd.displayWidth = screensize >> 16;
rhd.displayWidth = INREG(D1GRPH_X_END); rhd.displayHeight = screensize & 0xFFFF;
rhd.displayHeight = INREG(D1GRPH_Y_END);
#endif
rhd.__xmin = 0; rhd.__xmin = 0;
rhd.__ymin = 0; rhd.__ymin = 0;
@ -379,7 +379,7 @@ void R5xx2DInit()
dbgprintf("gui_control %x \n", rhd.gui_control); dbgprintf("gui_control %x \n", rhd.gui_control);
rhd.surface_cntl = 0; rhd.surface_cntl = 0;
rhd.dst_pitch_offset = (((rhd.displayWidth * 4) / 64) << 22) | rhd.dst_pitch_offset = ((screenpitch / 64) << 22) |
((rhd.FbIntAddress + rhd.FbScanoutStart) >> 10); ((rhd.FbIntAddress + rhd.FbScanoutStart) >> 10);
dbgprintf("dst_pitch_offset %x \n", rhd.dst_pitch_offset); dbgprintf("dst_pitch_offset %x \n", rhd.dst_pitch_offset);
@ -388,7 +388,7 @@ void R5xx2DInit()
scr_pixmap.width = rhd.displayWidth; scr_pixmap.width = rhd.displayWidth;
scr_pixmap.height = rhd.displayHeight; scr_pixmap.height = rhd.displayHeight;
scr_pixmap.format = PICT_a8r8g8b8; scr_pixmap.format = PICT_a8r8g8b8;
scr_pixmap.pitch = rhd.displayWidth * 4; scr_pixmap.pitch = screenpitch;
scr_pixmap.local = (void*)rhd.FbIntAddress; scr_pixmap.local = (void*)rhd.FbIntAddress;
scr_pixmap.pitch_offset = rhd.dst_pitch_offset; scr_pixmap.pitch_offset = rhd.dst_pitch_offset;
scr_pixmap.mapped = (void*)0; scr_pixmap.mapped = (void*)0;
@ -437,9 +437,6 @@ void R5xx2DInit()
OUTREG(RADEON_CP_CSQ_CNTL, RADEON_CSQ_PRIBM_INDBM); // run OUTREG(RADEON_CP_CSQ_CNTL, RADEON_CSQ_PRIBM_INDBM); // run
// OUTREG(D1CUR_SIZE, (31<<16)|31);
// OUTREG(D1CUR_CONTROL, 0x300);
} }

View File

@ -71,6 +71,36 @@ int dbgprintf(const char* format, ...);
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
extern inline int GetScreenSize()
{
int retval;
asm("int $0x40"
:"=a"(retval)
:"a"(61), "b"(1));
return retval;
}
extern inline int GetScreenBpp()
{
int retval;
asm("int $0x40"
:"=a"(retval)
:"a"(61), "b"(2));
return retval;
}
extern inline int GetScreenPitch()
{
int retval;
asm("int $0x40"
:"=a"(retval)
:"a"(61), "b"(3));
return retval;
}
extern inline u32_t GetPgAddr(void *mem) extern inline u32_t GetPgAddr(void *mem)
{ {
u32_t retval; u32_t retval;