[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paragui-cvs] CVS: paragui/src/font pgfont.cpp,1.3,1.3.2.1 pgfont_impl.c
From: |
Teunis Peters <address@hidden> |
Subject: |
[paragui-cvs] CVS: paragui/src/font pgfont.cpp,1.3,1.3.2.1 pgfont_impl.cpp,1.2,1.2.2.1 |
Date: |
Tue, 18 Jun 2002 18:40:41 -0400 |
Update of /cvsroot/paragui/paragui/src/font
In directory subversions:/tmp/cvs-serv27818/src/font
Modified Files:
Tag: devel-opengl
pgfont.cpp pgfont_impl.cpp
Log Message:
Initial checkin of code by Teunis Peters
Added abstraction layer for display support.
Initial OpenGL testing mode - use SDL_GLSDL to activate
A lot of test code is still present - FIXME
Some demos do not operate at all. Some work barely.
only animation works flawlessly at this time.
Index: pgfont.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/font/pgfont.cpp,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** pgfont.cpp 15 Apr 2002 13:35:35 -0000 1.3
--- pgfont.cpp 18 Jun 2002 22:40:38 -0000 1.3.2.1
***************
*** 31,38 ****
#include "pgfilearchive.h"
#include "facecache.h"
//#define OLD_TEXTRENDERING
! //SDL_Surface* PG_FontEngine::my_charSurface = NULL;
PG_FontEngine::MAP_FONTS PG_FontEngine::my_fontcache;
FT_Library PG_FontEngine::my_library;
--- 31,39 ----
#include "pgfilearchive.h"
#include "facecache.h"
+ #include "pgdraw.h"
//#define OLD_TEXTRENDERING
! //PG_Draw::PG_DrawableSurface* PG_FontEngine::my_charSurface = NULL;
PG_FontEngine::MAP_FONTS PG_FontEngine::my_fontcache;
FT_Library PG_FontEngine::my_library;
***************
*** 121,128 ****
template < class DT >
! inline void BlitTemplate(DT pixels, SDL_Surface* Surface, FT_Bitmap *Bitmap,
int PosX, int PosY, int x0, int x1, int y0, int y1, PG_Font *Param) {
int xw = x1-x0;
! SDL_PixelFormat* format = Surface->format;
Uint8 Rloss = format->Rloss;
Uint8 Gloss = format->Gloss;
--- 122,129 ----
template < class DT >
! inline void BlitTemplate(DT pixels, PG_Draw::PG_DrawableSurface* Surface,
FT_Bitmap *Bitmap, int PosX, int PosY, int x0, int x1, int y0, int y1, PG_Font
*Param) {
int xw = x1-x0;
! SDL_PixelFormat* format = Surface->getScreen()->format;
Uint8 Rloss = format->Rloss;
Uint8 Gloss = format->Gloss;
***************
*** 143,147 ****
Uint8 bpp = format->BytesPerPixel;
! Uint32 pitch = Surface->pitch;
Uint32 src_pitch = Bitmap->pitch;
register Uint8* src_pixels = Bitmap->buffer + x0 + y0*Bitmap->pitch;
--- 144,148 ----
Uint8 bpp = format->BytesPerPixel;
! Uint32 pitch = Surface->getScreen()->pitch;
Uint32 src_pitch = Bitmap->pitch;
register Uint8* src_pixels = Bitmap->buffer + x0 + y0*Bitmap->pitch;
***************
*** 182,186 ****
// Get the pixel
color = *((DT) (dst_pixels));
! if ( Surface->format->BytesPerPixel > 1 ) {
// get the RGBA values
--- 183,187 ----
// Get the pixel
color = *((DT) (dst_pixels));
! if ( Surface->getScreen()->format->BytesPerPixel > 1 ) {
// get the RGBA values
***************
*** 259,263 ****
}
! bool PG_FontEngine::BlitFTBitmap(SDL_Surface *Surface, FT_Bitmap *Bitmap, int
PosX, int PosY, PG_Font *Param, PG_Rect* ClipRect) {
int BitmapRealWidth;
--- 260,264 ----
}
! bool PG_FontEngine::BlitFTBitmap(PG_Draw::PG_DrawableSurface *Surface,
FT_Bitmap *Bitmap, int PosX, int PosY, PG_Font *Param, PG_Rect* ClipRect) {
int BitmapRealWidth;
***************
*** 275,279 ****
// get the cliprectangle of the surface
static PG_Rect srfclip;
! SDL_GetClipRect(Surface, &srfclip);
// the real clipping rectangle = surfaceclip / ClipRect
--- 276,280 ----
// get the cliprectangle of the surface
static PG_Rect srfclip;
! Surface->GetClipRect(srfclip);
// the real clipping rectangle = surfaceclip / ClipRect
***************
*** 311,323 ****
}
! switch(Surface->format->BytesPerPixel) {
case 1:
! BlitTemplate((Uint8*)Surface->pixels, Surface, Bitmap,
PosX, PosY, x0, x1, y0, y1, Param);
break;
case 2:
! BlitTemplate((Uint16*)Surface->pixels, Surface, Bitmap,
PosX, PosY, x0, x1, y0, y1, Param);
break;
case 4:
! BlitTemplate((Uint32*)Surface->pixels, Surface, Bitmap,
PosX, PosY, x0, x1, y0, y1, Param);
break;
}
--- 312,324 ----
}
! switch(Surface->getScreen()->format->BytesPerPixel) {
case 1:
! BlitTemplate((Uint8*)Surface->getScreen()->pixels,
Surface, Bitmap, PosX, PosY, x0, x1, y0, y1, Param);
break;
case 2:
! BlitTemplate((Uint16*)Surface->getScreen()->pixels,
Surface, Bitmap, PosX, PosY, x0, x1, y0, y1, Param);
break;
case 4:
! BlitTemplate((Uint32*)Surface->getScreen()->pixels,
Surface, Bitmap, PosX, PosY, x0, x1, y0, y1, Param);
break;
}
***************
*** 328,332 ****
#else
! bool PG_FontEngine::BlitFTBitmap(SDL_Surface *Surface, FT_Bitmap *Bitmap, int
PosX, int PosY, PG_Font *Param, PG_Rect *ClipRect) {
int x,y;
Uint32 *raw_pixels;
--- 329,334 ----
#else
! bool PG_FontEngine::BlitFTBitmap(PG_Draw::PG_DrawableSurface *Surface,
FT_Bitmap *Bitmap, int PosX, int PosY, PG_Font *Param, PG_Rect *ClipRect) {
! PG_Draw* draw = PG_Draw::GetDefaultDrawable();
int x,y;
Uint32 *raw_pixels;
***************
*** 354,358 ****
if (my_charSurface != NULL) {
if ((my_charSurface->w < BitmapRealWidth)||(my_charSurface->h <
Bitmap->rows)) {
! SDL_FreeSurface(my_charSurface);
my_charSurface = NULL;
}
--- 356,360 ----
if (my_charSurface != NULL) {
if ((my_charSurface->w < BitmapRealWidth)||(my_charSurface->h <
Bitmap->rows)) {
! delete my_charSurface; //
SDL_FreeSurface(my_charSurface);
my_charSurface = NULL;
}
***************
*** 360,364 ****
if (my_charSurface == NULL) {
! my_charSurface = SDL_CreateRGBSurface(SDL_SRCALPHA ,
BitmapRealWidth, Bitmap->rows, 32, 0xff0000, 0xff00, 0xff, 0xff000000);
if (my_charSurface == NULL) {
PG_LogWRN("Can`t get char surface : %s",SDL_GetError());
--- 362,366 ----
if (my_charSurface == NULL) {
! my_charSurface = draw->CreateDrawableSurface(SDL_SRCALPHA ,
BitmapRealWidth, Bitmap->rows, 32, 0xff0000, 0xff00, 0xff, 0xff000000);
if (my_charSurface == NULL) {
PG_LogWRN("Can`t get char surface : %s",SDL_GetError());
***************
*** 368,372 ****
if (Param->Style & PG_FSTYLE_ITALIC) {
! SDL_FillRect(my_charSurface, NULL, 0);
}
--- 370,375 ----
if (Param->Style & PG_FSTYLE_ITALIC) {
! PG_Rect emptyrect;
! my_charSurface->FillRect(emptyrect, 0);
}
***************
*** 411,415 ****
double ioffset = Bitmap->rows *
PG_FITALIC_ANGLE;
! for (y = 0; y < Bitmap->rows; y++,
SrcPix += Bitmap->pitch, ioffset -= PG_FITALIC_ANGLE) {
for (x = 0; x < Bitmap->width;
x++) {
a = *(Uint8
*)(SrcPix++);
--- 414,418 ----
double ioffset = Bitmap->rows *
PG_FITALIC_ANGLE;
! for (y = 0; y < Bitmap->rows; y++,
SrcPix += Bitmap->getScreen()->pitch, ioffset -= PG_FITALIC_ANGLE) {
for (x = 0; x < Bitmap->width;
x++) {
a = *(Uint8
*)(SrcPix++);
***************
*** 419,430 ****
// a = (a *
Param->Alpha) / 255;
! raw_pixels[int(ioffset)
+ x + (my_charSurface->pitch/4)*(y)] = SDL_MapRGBA(my_charSurface->format,
Param->Color.r, Param->Color.g, Param->Color.b, a);
}
SrcPix -= x;
}
} else
! pitch_diff = (my_charSurface->pitch/4);
! for (y = 0; y < Bitmap->rows; y++, SrcPix +=
Bitmap->pitch) {
for (x = 0; x < Bitmap->width; x++) {
a = *(Uint8 *)(SrcPix++);
--- 422,433 ----
// a = (a *
Param->Alpha) / 255;
! raw_pixels[int(ioffset)
+ x + (my_charSurface->getScreen()->pitch/4)*(y)] =
SDL_MapRGBA(my_charSurface->getScreen()->format, Param->Color.r,
Param->Color.g, Param->Color.b, a);
}
SrcPix -= x;
}
} else
! pitch_diff =
(my_charSurface->getScreen()->pitch/4);
! for (y = 0; y < Bitmap->rows; y++, SrcPix +=
Bitmap->getScreen()->pitch) {
for (x = 0; x < Bitmap->width; x++) {
a = *(Uint8 *)(SrcPix++);
***************
*** 437,441 ****
a = (a * Param->Alpha)
/ 255;
! *raw_pixels =
SDL_MapRGBA(my_charSurface->format, Param->Color.r, Param->Color.g,
Param->Color.b, a);
raw_pixels++;
}
--- 440,444 ----
a = (a * Param->Alpha)
/ 255;
! *raw_pixels =
SDL_MapRGBA(my_charSurface->getScreen()->format, Param->Color.r,
Param->Color.g, Param->Color.b, a);
raw_pixels++;
}
***************
*** 453,463 ****
// Final blit
! SDL_Rect BoldTarget = TargetPos;
! SDL_BlitSurface(my_charSurface, &SourcePos, Surface, &TargetPos);
//BOLD
if (Param->Style & PG_FSTYLE_BOLD) {
BoldTarget.x += Param->FaceCache->Bold_Offset;
! SDL_BlitSurface(my_charSurface, &SourcePos, Surface,
&BoldTarget);
}
--- 456,466 ----
// Final blit
! PG_Rect BoldTarget = TargetPos;
! Surface->BlitSurface(my_charSurface, SourcePos, TargetPos);
//BOLD
if (Param->Style & PG_FSTYLE_BOLD) {
BoldTarget.x += Param->FaceCache->Bold_Offset;
! Surface->BlitSurface(my_charSurface, SourcePos, BoldTarget);
}
***************
*** 468,476 ****
! bool PG_FontEngine::RenderText(SDL_Surface *Surface, const PG_Rect& ClipRect,
int BaseLineX, int BaseLineY, const char *Text, PG_Font *ParamIn) {
return RenderText(Surface, (PG_Rect*)&ClipRect, BaseLineX, BaseLineY,
Text, ParamIn);
}
! bool PG_FontEngine::RenderText(SDL_Surface *Surface, PG_Rect *ClipRect, int
BaseLineX, int BaseLineY, const char *Text, PG_Font* font) {
static bool bRecursion = false;
int OriBaseX = BaseLineX;
--- 471,479 ----
! bool PG_FontEngine::RenderText(PG_Draw::PG_DrawableSurface *Surface, const
PG_Rect& ClipRect, int BaseLineX, int BaseLineY, const char *Text, PG_Font
*ParamIn) {
return RenderText(Surface, (PG_Rect*)&ClipRect, BaseLineX, BaseLineY,
Text, ParamIn);
}
! bool PG_FontEngine::RenderText(PG_Draw::PG_DrawableSurface *Surface, PG_Rect
*ClipRect, int BaseLineX, int BaseLineY, const char *Text, PG_Font* font) {
static bool bRecursion = false;
int OriBaseX = BaseLineX;
***************
*** 526,530 ****
//TO-DO : Underline is not transparent !!!! (Fill must be
replaced by Blit)
if (font->GetStyle() & PG_FSTYLE_UNDERLINE) {
! SDL_Rect und_rect;
und_rect.x = OldBaseLineX;
--- 529,533 ----
//TO-DO : Underline is not transparent !!!! (Fill must be
replaced by Blit)
if (font->GetStyle() & PG_FSTYLE_UNDERLINE) {
! PG_Rect und_rect;
und_rect.x = OldBaseLineX;
***************
*** 533,546 ****
und_rect.w = BaseLineX - OldBaseLineX;
! SDL_FillRect(
! Surface,
! &und_rect,
! SDL_MapRGB(
! Surface->format,
! font->GetColor().r,
! font->GetColor().g,
! font->GetColor().b
! )
! );
}
}
--- 536,547 ----
und_rect.w = BaseLineX - OldBaseLineX;
! Surface->FillRect(und_rect,
! SDL_MapRGB(
!
Surface->getScreen()->format,
! font->GetColor().r,
! font->GetColor().g,
! font->GetColor().b
! )
! );
}
}
Index: pgfont_impl.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/font/pgfont_impl.cpp,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** pgfont_impl.cpp 15 Apr 2002 13:31:31 -0000 1.2
--- pgfont_impl.cpp 18 Jun 2002 22:40:38 -0000 1.2.2.1
***************
*** 2,5 ****
--- 2,6 ----
#include "facecache.h"
#include "pgfont.h"
+ #include "pgdraw.h"
struct PG_FontDataInternal {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paragui-cvs] CVS: paragui/src/font pgfont.cpp,1.3,1.3.2.1 pgfont_impl.cpp,1.2,1.2.2.1,
Teunis Peters <address@hidden> <=
- Prev by Date:
[paragui-cvs] CVS: paragui/src Makefile.am,1.3,1.3.2.1
- Next by Date:
[paragui-cvs] CVS: paragui/src/themes theme_priv.cpp,1.3,1.3.2.1 theme_priv.h,1.3,1.3.2.1 themeloader.cpp,1.3,1.3.2.1
- Previous by thread:
[paragui-cvs] CVS: paragui/src Makefile.am,1.3,1.3.2.1
- Next by thread:
[paragui-cvs] CVS: paragui/src/themes theme_priv.cpp,1.3,1.3.2.1 theme_priv.h,1.3,1.3.2.1 themeloader.cpp,1.3,1.3.2.1
- Index(es):