1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-24 13:50:49 +03:00

0023457: Slow text rendering

Added class Font_FTFont wrapper over FreeType face

Unify collections methods NCollection_Array1, NCollection_Sequence, NCollection_Vector:
declare Upper, Lower, First, Last, ChangeFirst, ChangeLast methods for all these collections.

Added method NCollection_DataMap::Find() with check key is bound + retrieve value within single call interface.

OpenGl_Context::ReleaseResource() method now supports lazy release of shared resources.

Added class OpenGl_Font which implements textured fonts support.
Added class OpenGl_TextFormatter for text formatting using OpenGl_Font.

OpenGl_Text was redesigned to use OpenGl_FontFormatter.

OpenGl_FontMgr class was removed.
All methods related to text rendered removed from OpenGl_Display class.

OpenGl_Trihedron and OpenGl_GraduatedTrihedron classes were redesigned
to use OpenGl_Text.

OpenGl_PrinterContext instance was moved to OpenGl_GraphicDriver fields
(eliminated usage of global instance).

Added test cases into 3rdparty/fonts grid to check different font styles
and perform FPS tests (no automated results - requires manual analysis
or snapshots comparisons).

Removed unused CSF_FTGL dependency.
OpenGl_Text::setupMatrix - do not apply floor for myWinZ
This commit is contained in:
kgv
2013-02-08 15:05:16 +04:00
parent 163ef25006
commit a174a3c54f
72 changed files with 5397 additions and 2606 deletions

View File

@@ -27,23 +27,6 @@
IMPLEMENT_STANDARD_HANDLE (OpenGl_Texture, OpenGl_Resource)
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Texture, OpenGl_Resource)
//! Function for getting power of to number larger or equal to input number.
//! @param theNumber number to 'power of two'
//! @param theThreshold upper threshold
//! @return power of two number
inline GLsizei getPowerOfTwo (const GLsizei theNumber,
const GLsizei theThreshold)
{
for (GLsizei p2 = 2; p2 <= theThreshold; p2 <<= 1)
{
if (theNumber <= p2)
{
return p2;
}
}
return theThreshold;
}
// =======================================================================
// function : OpenGl_Texture
// purpose :
@@ -295,8 +278,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
// Trying to create NPOT rextures on such hardware will not fail
// but driver will fall back into software rendering,
const bool toForceP2 = !theCtx->IsGlGreaterEqual (3, 0) && !theCtx->arbNPTW;
const GLsizei aWidthOut = toForceP2 ? getPowerOfTwo (aWidth, aMaxSize) : Min (aWidth, aMaxSize);
const GLsizei aHeightOut = toForceP2 ? getPowerOfTwo (aHeight, aMaxSize) : Min (aHeight, aMaxSize);
const GLsizei aWidthOut = toForceP2 ? OpenGl_Context::GetPowerOfTwo (aWidth, aMaxSize) : Min (aWidth, aMaxSize);
const GLsizei aHeightOut = toForceP2 ? OpenGl_Context::GetPowerOfTwo (aHeight, aMaxSize) : Min (aHeight, aMaxSize);
GLint aTestWidth = 0;
GLint aTestHeight = 0;
@@ -342,6 +325,14 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
glTexImage1D (GL_TEXTURE_1D, 0, aTextureFormat,
aWidthOut, 0,
aPixelFormat, aDataType, aDataPtr);
if (glGetError() != GL_NO_ERROR)
{
Unbind (theCtx);
return false;
}
mySizeX = aWidthOut;
mySizeY = 1;
Unbind (theCtx);
return true;
@@ -386,6 +377,14 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
glTexImage2D (GL_TEXTURE_2D, 0, aTextureFormat,
aWidthOut, aHeightOut, 0,
aPixelFormat, aDataType, aDataPtr);
if (glGetError() != GL_NO_ERROR)
{
Unbind (theCtx);
return false;
}
mySizeX = aWidthOut;
mySizeY = aHeightOut;
Unbind (theCtx);
return true;
@@ -418,6 +417,14 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
glTexImage2D (GL_TEXTURE_2D, 0, aTextureFormat,
aWidthOut, aHeightOut, 0,
aPixelFormat, aDataType, theImage.Data());
if (glGetError() != GL_NO_ERROR)
{
Unbind (theCtx);
return false;
}
mySizeX = aWidthOut;
mySizeY = aHeightOut;
// generate mipmaps
//glHint (GL_GENERATE_MIPMAP_HINT, GL_NICEST);
@@ -431,6 +438,12 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
bool isCreated = gluBuild2DMipmaps (GL_TEXTURE_2D, aTextureFormat,
aWidth, aHeight,
aPixelFormat, aDataType, theImage.Data()) == 0;
if (isCreated)
{
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &mySizeX);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &mySizeY);
}
Unbind (theCtx);
return isCreated;
}