mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0032153: Visualization, Graphic3d_ArrayOfPrimitives - share common allocator
Added method Graphic3d_Buffer::DefaultAllocator(), which is now used across code.
This commit is contained in:
parent
4bf072e4eb
commit
02a2beaad9
@ -26,7 +26,6 @@
|
|||||||
#include <Graphic3d_AttribBuffer.hxx>
|
#include <Graphic3d_AttribBuffer.hxx>
|
||||||
#include <Graphic3d_MutableIndexBuffer.hxx>
|
#include <Graphic3d_MutableIndexBuffer.hxx>
|
||||||
|
|
||||||
#include <NCollection_AlignedAllocator.hxx>
|
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -103,7 +102,7 @@ void Graphic3d_ArrayOfPrimitives::init (Graphic3d_TypeOfPrimitiveArray theType,
|
|||||||
myIndices.Nullify();
|
myIndices.Nullify();
|
||||||
myBounds.Nullify();
|
myBounds.Nullify();
|
||||||
|
|
||||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
const Handle(NCollection_BaseAllocator)& anAlloc = Graphic3d_Buffer::DefaultAllocator();
|
||||||
if ((theArrayOptions & Graphic3d_ArrayFlags_AttribsMutable) != 0
|
if ((theArrayOptions & Graphic3d_ArrayFlags_AttribsMutable) != 0
|
||||||
|| (theArrayOptions & Graphic3d_ArrayFlags_AttribsDeinterleaved) != 0)
|
|| (theArrayOptions & Graphic3d_ArrayFlags_AttribsDeinterleaved) != 0)
|
||||||
{
|
{
|
||||||
|
@ -12,14 +12,26 @@
|
|||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
#include <Graphic3d_Buffer.hxx>
|
#include <Graphic3d_Buffer.hxx>
|
||||||
|
|
||||||
#include <Graphic3d_BoundBuffer.hxx>
|
#include <Graphic3d_BoundBuffer.hxx>
|
||||||
#include <Graphic3d_MutableIndexBuffer.hxx>
|
#include <Graphic3d_MutableIndexBuffer.hxx>
|
||||||
|
#include <NCollection_AlignedAllocator.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Buffer, NCollection_Buffer)
|
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Buffer, NCollection_Buffer)
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_IndexBuffer, Graphic3d_Buffer)
|
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_IndexBuffer, Graphic3d_Buffer)
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_BoundBuffer, NCollection_Buffer)
|
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_BoundBuffer, NCollection_Buffer)
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_MutableIndexBuffer, Graphic3d_IndexBuffer)
|
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_MutableIndexBuffer, Graphic3d_IndexBuffer)
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : DefaultAllocator
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
const Handle(NCollection_BaseAllocator)& Graphic3d_Buffer::DefaultAllocator()
|
||||||
|
{
|
||||||
|
static const Handle(NCollection_BaseAllocator) THE_ALLOC = new NCollection_AlignedAllocator (16);
|
||||||
|
return THE_ALLOC;
|
||||||
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : DumpJson
|
// function : DumpJson
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@ -74,6 +74,11 @@ typedef NCollection_Array1<Graphic3d_Attribute> Graphic3d_Array1OfAttribute;
|
|||||||
class Graphic3d_Buffer : public NCollection_Buffer
|
class Graphic3d_Buffer : public NCollection_Buffer
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_Buffer, NCollection_Buffer)
|
DEFINE_STANDARD_RTTIEXT(Graphic3d_Buffer, NCollection_Buffer)
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Return default vertex data allocator.
|
||||||
|
Standard_EXPORT static const Handle(NCollection_BaseAllocator)& DefaultAllocator();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Empty constructor.
|
//! Empty constructor.
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
#include <Graphic3d_HatchStyle.hxx>
|
#include <Graphic3d_HatchStyle.hxx>
|
||||||
#include <NCollection_AlignedAllocator.hxx>
|
|
||||||
#include <Standard_Atomic.hxx>
|
#include <Standard_Atomic.hxx>
|
||||||
#include <Standard_ProgramError.hxx>
|
#include <Standard_ProgramError.hxx>
|
||||||
|
|
||||||
@ -496,7 +496,7 @@ Graphic3d_HatchStyle::Graphic3d_HatchStyle (const Handle(Image_PixMap)& thePatte
|
|||||||
"Hatch pattern must be a 32*32 bitmap (Image_Format_Gray format)");
|
"Hatch pattern must be a 32*32 bitmap (Image_Format_Gray format)");
|
||||||
|
|
||||||
const Standard_Size aByteSize = thePattern->SizeBytes();
|
const Standard_Size aByteSize = thePattern->SizeBytes();
|
||||||
Handle(NCollection_AlignedAllocator) anAllocator = new NCollection_AlignedAllocator (16);
|
const Handle(NCollection_BaseAllocator)& anAllocator = Image_PixMap::DefaultAllocator();
|
||||||
myPattern = new NCollection_Buffer (anAllocator);
|
myPattern = new NCollection_Buffer (anAllocator);
|
||||||
myPattern->Allocate (aByteSize);
|
myPattern->Allocate (aByteSize);
|
||||||
std::memcpy (myPattern->ChangeData(), thePattern->Data(), aByteSize);
|
std::memcpy (myPattern->ChangeData(), thePattern->Data(), aByteSize);
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include <OpenGl_BackgroundArray.hxx>
|
#include <OpenGl_BackgroundArray.hxx>
|
||||||
|
|
||||||
#include <Aspect_FillMethod.hxx>
|
#include <Aspect_FillMethod.hxx>
|
||||||
#include <NCollection_AlignedAllocator.hxx>
|
|
||||||
#include <OpenGl_Texture.hxx>
|
#include <OpenGl_Texture.hxx>
|
||||||
#include <OpenGl_View.hxx>
|
#include <OpenGl_View.hxx>
|
||||||
#include <Graphic3d_TextureParams.hxx>
|
#include <Graphic3d_TextureParams.hxx>
|
||||||
@ -198,8 +197,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG
|
|||||||
|
|
||||||
if (myAttribs.IsNull())
|
if (myAttribs.IsNull())
|
||||||
{
|
{
|
||||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
myAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator());
|
||||||
myAttribs = new Graphic3d_Buffer (anAlloc);
|
|
||||||
}
|
}
|
||||||
if (!myAttribs->Init (4, aGragientAttribInfo, 2))
|
if (!myAttribs->Init (4, aGragientAttribInfo, 2))
|
||||||
{
|
{
|
||||||
@ -332,8 +330,7 @@ Standard_Boolean OpenGl_BackgroundArray::createTextureArray (const Handle(OpenGl
|
|||||||
|
|
||||||
if (myAttribs.IsNull())
|
if (myAttribs.IsNull())
|
||||||
{
|
{
|
||||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
myAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator());
|
||||||
myAttribs = new Graphic3d_Buffer (anAlloc);
|
|
||||||
}
|
}
|
||||||
if (!myAttribs->Init (4, aTextureAttribInfo, 2))
|
if (!myAttribs->Init (4, aTextureAttribInfo, 2))
|
||||||
{
|
{
|
||||||
@ -405,9 +402,8 @@ Standard_Boolean OpenGl_BackgroundArray::createCubeMapArray() const
|
|||||||
|
|
||||||
if (myAttribs.IsNull())
|
if (myAttribs.IsNull())
|
||||||
{
|
{
|
||||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
myAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator());
|
||||||
myAttribs = new Graphic3d_Buffer (anAlloc);
|
myIndices = new Graphic3d_IndexBuffer (Graphic3d_Buffer::DefaultAllocator());
|
||||||
myIndices = new Graphic3d_IndexBuffer (anAlloc);
|
|
||||||
}
|
}
|
||||||
if (!myAttribs->Init (8, aCubeMapAttribInfo, 1)
|
if (!myAttribs->Init (8, aCubeMapAttribInfo, 1)
|
||||||
|| !myIndices->Init<unsigned short> (14))
|
|| !myIndices->Init<unsigned short> (14))
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
#include <NCollection_AlignedAllocator.hxx>
|
|
||||||
#include <OpenGl_CappingPlaneResource.hxx>
|
#include <OpenGl_CappingPlaneResource.hxx>
|
||||||
|
|
||||||
#include <OpenGl_Context.hxx>
|
#include <OpenGl_Context.hxx>
|
||||||
#include <OpenGl_Vec.hxx>
|
#include <OpenGl_Vec.hxx>
|
||||||
#include <OpenGl_ShaderManager.hxx>
|
#include <OpenGl_ShaderManager.hxx>
|
||||||
@ -71,9 +71,7 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d
|
|||||||
myEquationMod ((unsigned int )-1),
|
myEquationMod ((unsigned int )-1),
|
||||||
myAspectMod ((unsigned int )-1)
|
myAspectMod ((unsigned int )-1)
|
||||||
{
|
{
|
||||||
// Fill primitive array
|
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator());
|
||||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
|
||||||
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (anAlloc);
|
|
||||||
Graphic3d_Attribute anAttribInfo[] =
|
Graphic3d_Attribute anAttribInfo[] =
|
||||||
{
|
{
|
||||||
{ Graphic3d_TOA_POS, Graphic3d_TOD_VEC4 },
|
{ Graphic3d_TOA_POS, Graphic3d_TOD_VEC4 },
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <OpenGl_FrameBuffer.hxx>
|
#include <OpenGl_FrameBuffer.hxx>
|
||||||
#include <OpenGl_ArbFBO.hxx>
|
#include <OpenGl_ArbFBO.hxx>
|
||||||
|
|
||||||
#include <NCollection_AlignedAllocator.hxx>
|
|
||||||
#include <Standard_Assert.hxx>
|
#include <Standard_Assert.hxx>
|
||||||
#include <TCollection_ExtendedString.hxx>
|
#include <TCollection_ExtendedString.hxx>
|
||||||
|
|
||||||
@ -993,9 +992,8 @@ Standard_Boolean OpenGl_FrameBuffer::BufferDump (const Handle(OpenGl_Context)& t
|
|||||||
|
|
||||||
if (toConvRgba2Rgb)
|
if (toConvRgba2Rgb)
|
||||||
{
|
{
|
||||||
Handle(NCollection_BaseAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
|
||||||
const Standard_Size aRowSize = theImage.SizeX() * 4;
|
const Standard_Size aRowSize = theImage.SizeX() * 4;
|
||||||
NCollection_Buffer aRowBuffer (anAlloc);
|
NCollection_Buffer aRowBuffer (Image_PixMap::DefaultAllocator());
|
||||||
if (!aRowBuffer.Allocate (aRowSize))
|
if (!aRowBuffer.Allocate (aRowSize))
|
||||||
{
|
{
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
@ -13,12 +13,13 @@
|
|||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
|
#include <OpenGl_PrimitiveArray.hxx>
|
||||||
|
|
||||||
#include <OpenGl_Aspects.hxx>
|
#include <OpenGl_Aspects.hxx>
|
||||||
#include <OpenGl_Context.hxx>
|
#include <OpenGl_Context.hxx>
|
||||||
#include <OpenGl_GraphicDriver.hxx>
|
#include <OpenGl_GraphicDriver.hxx>
|
||||||
#include <OpenGl_IndexBuffer.hxx>
|
#include <OpenGl_IndexBuffer.hxx>
|
||||||
#include <OpenGl_PointSprite.hxx>
|
#include <OpenGl_PointSprite.hxx>
|
||||||
#include <OpenGl_PrimitiveArray.hxx>
|
|
||||||
#include <OpenGl_Sampler.hxx>
|
#include <OpenGl_Sampler.hxx>
|
||||||
#include <OpenGl_ShaderManager.hxx>
|
#include <OpenGl_ShaderManager.hxx>
|
||||||
#include <OpenGl_ShaderProgram.hxx>
|
#include <OpenGl_ShaderProgram.hxx>
|
||||||
@ -27,7 +28,6 @@
|
|||||||
#include <OpenGl_View.hxx>
|
#include <OpenGl_View.hxx>
|
||||||
#include <OpenGl_Workspace.hxx>
|
#include <OpenGl_Workspace.hxx>
|
||||||
#include <Graphic3d_TextureParams.hxx>
|
#include <Graphic3d_TextureParams.hxx>
|
||||||
#include <NCollection_AlignedAllocator.hxx>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -1165,7 +1165,7 @@ Standard_Boolean OpenGl_PrimitiveArray::processIndices (const Handle(OpenGl_Cont
|
|||||||
|
|
||||||
if (myAttribs->NbElements > std::numeric_limits<GLushort>::max())
|
if (myAttribs->NbElements > std::numeric_limits<GLushort>::max())
|
||||||
{
|
{
|
||||||
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (new NCollection_AlignedAllocator (16));
|
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator());
|
||||||
if (!anAttribs->Init (myIndices->NbElements, myAttribs->AttributesArray(), myAttribs->NbAttributes))
|
if (!anAttribs->Init (myIndices->NbElements, myAttribs->AttributesArray(), myAttribs->NbAttributes))
|
||||||
{
|
{
|
||||||
return Standard_False; // failed to initialize attribute array
|
return Standard_False; // failed to initialize attribute array
|
||||||
|
@ -14,9 +14,6 @@
|
|||||||
|
|
||||||
#include <OpenGl_VertexBufferCompat.hxx>
|
#include <OpenGl_VertexBufferCompat.hxx>
|
||||||
|
|
||||||
#include <NCollection_AlignedAllocator.hxx>
|
|
||||||
|
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_VertexBufferCompat,OpenGl_VertexBuffer)
|
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_VertexBufferCompat,OpenGl_VertexBuffer)
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@ -46,8 +43,7 @@ bool OpenGl_VertexBufferCompat::Create (const Handle(OpenGl_Context)& )
|
|||||||
if (myBufferId == NO_BUFFER)
|
if (myBufferId == NO_BUFFER)
|
||||||
{
|
{
|
||||||
myBufferId = (GLuint )-1; // dummy identifier...
|
myBufferId = (GLuint )-1; // dummy identifier...
|
||||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
myData = new NCollection_Buffer (Graphic3d_Buffer::DefaultAllocator());
|
||||||
myData = new NCollection_Buffer (anAlloc);
|
|
||||||
}
|
}
|
||||||
return myBufferId != NO_BUFFER;
|
return myBufferId != NO_BUFFER;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include <Graphic3d_TextureParams.hxx>
|
#include <Graphic3d_TextureParams.hxx>
|
||||||
#include <Graphic3d_TransformUtils.hxx>
|
#include <Graphic3d_TransformUtils.hxx>
|
||||||
#include <NCollection_AlignedAllocator.hxx>
|
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient)
|
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient)
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#include <Select3D_SensitivePrimitiveArray.hxx>
|
#include <Select3D_SensitivePrimitiveArray.hxx>
|
||||||
|
|
||||||
#include <NCollection_AlignedAllocator.hxx>
|
|
||||||
#include <OSD_Parallel.hxx>
|
#include <OSD_Parallel.hxx>
|
||||||
#include <Standard_Atomic.hxx>
|
#include <Standard_Atomic.hxx>
|
||||||
|
|
||||||
@ -165,7 +164,7 @@ Select3D_SensitivePrimitiveArray::Select3D_SensitivePrimitiveArray (const Handle
|
|||||||
myPatchSizeMax (1),
|
myPatchSizeMax (1),
|
||||||
myPatchDistance (ShortRealLast()),
|
myPatchDistance (ShortRealLast()),
|
||||||
myIs3d (false),
|
myIs3d (false),
|
||||||
myBvhIndices (new NCollection_AlignedAllocator(16)),
|
myBvhIndices (Graphic3d_Buffer::DefaultAllocator()),
|
||||||
myMinDepthElem (RealLast()),
|
myMinDepthElem (RealLast()),
|
||||||
myMinDepthNode (RealLast()),
|
myMinDepthNode (RealLast()),
|
||||||
myMinDepthEdge (RealLast()),
|
myMinDepthEdge (RealLast()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user