1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40: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

@@ -21,18 +21,21 @@
#include <InterfaceGraphic.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_AspectMarker.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_Texture.hxx>
#include <OpenGl_Workspace.hxx>
#include <Graphic3d_TextureParams.hxx>
#if (defined(_WIN32) || defined(__WIN32__)) && defined(HAVE_VIDEOCAPTURE)
#include <OpenGl_AVIWriter.hxx>
#endif
IMPLEMENT_STANDARD_HANDLE(OpenGl_Workspace,OpenGl_Window)
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,OpenGl_Window)
@@ -69,20 +72,20 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay,
Aspect_RenderingContext theGContext,
const Handle(OpenGl_Context)& theShareCtx)
: OpenGl_Window (theDisplay, theCWindow, theGContext, theShareCtx),
myTransientList (0),
NamedStatus (0),
DegenerateModel (0),
SkipRatio (0.F),
HighlightColor (&myDefaultHighlightColor),
//
myIsTransientOpen (Standard_False),
myTransientDrawToFront (Standard_True),
myRetainMode (Standard_False),
myTransientDrawToFront (Standard_True),
myUseTransparency (Standard_False),
myUseZBuffer (Standard_False),
myUseDepthTest (Standard_True),
myUseGLLight (Standard_True),
myBackBufferRestored (Standard_False),
//
NamedStatus (0),
DegenerateModel (0),
SkipRatio (0.F),
HighlightColor (&myDefaultHighlightColor),
AspectLine_set (&myDefaultAspectLine),
AspectLine_applied (NULL),
AspectFace_set (&myDefaultAspectFace),
@@ -434,3 +437,71 @@ Handle(OpenGl_Texture) OpenGl_Workspace::EnableTexture (const Handle(OpenGl_Text
return aPrevTexture;
}
// =======================================================================
// function : Redraw
// purpose :
// =======================================================================
void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView,
const Aspect_CLayer2d& theCUnderLayer,
const Aspect_CLayer2d& theCOverLayer)
{
if (!Activate())
{
return;
}
// release pending GL resources
Handle(OpenGl_Context) aGlCtx = GetGlContext();
aGlCtx->ReleaseDelayed();
// cache render mode state
GLint aRendMode = GL_RENDER;
glGetIntegerv (GL_RENDER_MODE, &aRendMode);
aGlCtx->SetFeedback (aRendMode == GL_FEEDBACK);
Tint toSwap = (aRendMode == GL_RENDER); // swap buffers
GLint aViewPortBack[4];
OpenGl_FrameBuffer* aFrameBuffer = (OpenGl_FrameBuffer* )theCView.ptrFBO;
if (aFrameBuffer != NULL)
{
glGetIntegerv (GL_VIEWPORT, aViewPortBack);
aFrameBuffer->SetupViewport();
aFrameBuffer->BindBuffer (aGlCtx);
toSwap = 0; // no need to swap buffers
}
Redraw1 (theCView, theCUnderLayer, theCOverLayer, toSwap);
if (aFrameBuffer == NULL || !myTransientDrawToFront)
{
RedrawImmediatMode();
}
if (aFrameBuffer != NULL)
{
aFrameBuffer->UnbindBuffer (aGlCtx);
// move back original viewport
glViewport (aViewPortBack[0], aViewPortBack[1], aViewPortBack[2], aViewPortBack[3]);
}
#if (defined(_WIN32) || defined(__WIN32__)) && defined(HAVE_VIDEOCAPTURE)
if (OpenGl_AVIWriter_AllowWriting (theCView.DefWindow.XWindow))
{
GLint params[4];
glGetIntegerv (GL_VIEWPORT, params);
int nWidth = params[2] & ~0x7;
int nHeight = params[3] & ~0x7;
const int nBitsPerPixel = 24;
GLubyte* aDumpData = new GLubyte[nWidth * nHeight * nBitsPerPixel / 8];
glPixelStorei (GL_PACK_ALIGNMENT, 1);
glReadPixels (0, 0, nWidth, nHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, aDumpData);
OpenGl_AVIWriter_AVIWriter (aDumpData, nWidth, nHeight, nBitsPerPixel);
delete[] aDumpData;
}
#endif
// reset render mode state
aGlCtx->SetFeedback (Standard_False);
}