diff --git a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx index 5e81142fb6..c2497c98ad 100644 --- a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx +++ b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx @@ -26,7 +26,6 @@ #include <Graphic3d_AttribBuffer.hxx> #include <Graphic3d_MutableIndexBuffer.hxx> -#include <NCollection_AlignedAllocator.hxx> #include <TCollection_AsciiString.hxx> #include <stdio.h> @@ -103,7 +102,7 @@ void Graphic3d_ArrayOfPrimitives::init (Graphic3d_TypeOfPrimitiveArray theType, myIndices.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 || (theArrayOptions & Graphic3d_ArrayFlags_AttribsDeinterleaved) != 0) { diff --git a/src/Graphic3d/Graphic3d_Buffer.cxx b/src/Graphic3d/Graphic3d_Buffer.cxx index 47a0114e02..5eb0125df1 100644 --- a/src/Graphic3d/Graphic3d_Buffer.cxx +++ b/src/Graphic3d/Graphic3d_Buffer.cxx @@ -12,14 +12,26 @@ // commercial license or contractual agreement. #include <Graphic3d_Buffer.hxx> + #include <Graphic3d_BoundBuffer.hxx> #include <Graphic3d_MutableIndexBuffer.hxx> +#include <NCollection_AlignedAllocator.hxx> IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Buffer, NCollection_Buffer) IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_IndexBuffer, Graphic3d_Buffer) IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_BoundBuffer, NCollection_Buffer) 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 // purpose : diff --git a/src/Graphic3d/Graphic3d_Buffer.hxx b/src/Graphic3d/Graphic3d_Buffer.hxx index 02f16313ba..8b84192038 100644 --- a/src/Graphic3d/Graphic3d_Buffer.hxx +++ b/src/Graphic3d/Graphic3d_Buffer.hxx @@ -74,6 +74,11 @@ typedef NCollection_Array1<Graphic3d_Attribute> Graphic3d_Array1OfAttribute; class Graphic3d_Buffer : public NCollection_Buffer { DEFINE_STANDARD_RTTIEXT(Graphic3d_Buffer, NCollection_Buffer) +public: + + //! Return default vertex data allocator. + Standard_EXPORT static const Handle(NCollection_BaseAllocator)& DefaultAllocator(); + public: //! Empty constructor. diff --git a/src/Graphic3d/Graphic3d_HatchStyle.cxx b/src/Graphic3d/Graphic3d_HatchStyle.cxx index 6cb6476084..2d0985038a 100644 --- a/src/Graphic3d/Graphic3d_HatchStyle.cxx +++ b/src/Graphic3d/Graphic3d_HatchStyle.cxx @@ -14,7 +14,7 @@ // commercial license or contractual agreement. #include <Graphic3d_HatchStyle.hxx> -#include <NCollection_AlignedAllocator.hxx> + #include <Standard_Atomic.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)"); 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->Allocate (aByteSize); std::memcpy (myPattern->ChangeData(), thePattern->Data(), aByteSize); diff --git a/src/OpenGl/OpenGl_BackgroundArray.cxx b/src/OpenGl/OpenGl_BackgroundArray.cxx index 866514d456..6bd9193068 100644 --- a/src/OpenGl/OpenGl_BackgroundArray.cxx +++ b/src/OpenGl/OpenGl_BackgroundArray.cxx @@ -16,7 +16,6 @@ #include <OpenGl_BackgroundArray.hxx> #include <Aspect_FillMethod.hxx> -#include <NCollection_AlignedAllocator.hxx> #include <OpenGl_Texture.hxx> #include <OpenGl_View.hxx> #include <Graphic3d_TextureParams.hxx> @@ -198,8 +197,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenG if (myAttribs.IsNull()) { - Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16); - myAttribs = new Graphic3d_Buffer (anAlloc); + myAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator()); } if (!myAttribs->Init (4, aGragientAttribInfo, 2)) { @@ -332,8 +330,7 @@ Standard_Boolean OpenGl_BackgroundArray::createTextureArray (const Handle(OpenGl if (myAttribs.IsNull()) { - Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16); - myAttribs = new Graphic3d_Buffer (anAlloc); + myAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator()); } if (!myAttribs->Init (4, aTextureAttribInfo, 2)) { @@ -405,9 +402,8 @@ Standard_Boolean OpenGl_BackgroundArray::createCubeMapArray() const if (myAttribs.IsNull()) { - Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16); - myAttribs = new Graphic3d_Buffer (anAlloc); - myIndices = new Graphic3d_IndexBuffer (anAlloc); + myAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator()); + myIndices = new Graphic3d_IndexBuffer (Graphic3d_Buffer::DefaultAllocator()); } if (!myAttribs->Init (8, aCubeMapAttribInfo, 1) || !myIndices->Init<unsigned short> (14)) diff --git a/src/OpenGl/OpenGl_CappingPlaneResource.cxx b/src/OpenGl/OpenGl_CappingPlaneResource.cxx index 6825aefea1..6b1ce90734 100755 --- a/src/OpenGl/OpenGl_CappingPlaneResource.cxx +++ b/src/OpenGl/OpenGl_CappingPlaneResource.cxx @@ -13,8 +13,8 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include <NCollection_AlignedAllocator.hxx> #include <OpenGl_CappingPlaneResource.hxx> + #include <OpenGl_Context.hxx> #include <OpenGl_Vec.hxx> #include <OpenGl_ShaderManager.hxx> @@ -71,9 +71,7 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d myEquationMod ((unsigned int )-1), myAspectMod ((unsigned int )-1) { - // Fill primitive array - Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16); - Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (anAlloc); + Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (Graphic3d_Buffer::DefaultAllocator()); Graphic3d_Attribute anAttribInfo[] = { { Graphic3d_TOA_POS, Graphic3d_TOD_VEC4 }, diff --git a/src/OpenGl/OpenGl_FrameBuffer.cxx b/src/OpenGl/OpenGl_FrameBuffer.cxx index 50d47ef364..44b94e0903 100644 --- a/src/OpenGl/OpenGl_FrameBuffer.cxx +++ b/src/OpenGl/OpenGl_FrameBuffer.cxx @@ -15,7 +15,6 @@ #include <OpenGl_FrameBuffer.hxx> #include <OpenGl_ArbFBO.hxx> -#include <NCollection_AlignedAllocator.hxx> #include <Standard_Assert.hxx> #include <TCollection_ExtendedString.hxx> @@ -993,9 +992,8 @@ Standard_Boolean OpenGl_FrameBuffer::BufferDump (const Handle(OpenGl_Context)& t if (toConvRgba2Rgb) { - Handle(NCollection_BaseAllocator) anAlloc = new NCollection_AlignedAllocator (16); const Standard_Size aRowSize = theImage.SizeX() * 4; - NCollection_Buffer aRowBuffer (anAlloc); + NCollection_Buffer aRowBuffer (Image_PixMap::DefaultAllocator()); if (!aRowBuffer.Allocate (aRowSize)) { return Standard_False; diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index 88c2519390..9a1a25559c 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -13,12 +13,13 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include <OpenGl_PrimitiveArray.hxx> + #include <OpenGl_Aspects.hxx> #include <OpenGl_Context.hxx> #include <OpenGl_GraphicDriver.hxx> #include <OpenGl_IndexBuffer.hxx> #include <OpenGl_PointSprite.hxx> -#include <OpenGl_PrimitiveArray.hxx> #include <OpenGl_Sampler.hxx> #include <OpenGl_ShaderManager.hxx> #include <OpenGl_ShaderProgram.hxx> @@ -27,7 +28,6 @@ #include <OpenGl_View.hxx> #include <OpenGl_Workspace.hxx> #include <Graphic3d_TextureParams.hxx> -#include <NCollection_AlignedAllocator.hxx> namespace { @@ -1165,7 +1165,7 @@ Standard_Boolean OpenGl_PrimitiveArray::processIndices (const Handle(OpenGl_Cont 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)) { return Standard_False; // failed to initialize attribute array diff --git a/src/OpenGl/OpenGl_VertexBufferCompat.cxx b/src/OpenGl/OpenGl_VertexBufferCompat.cxx index 2ba9a1d1b4..2add516459 100644 --- a/src/OpenGl/OpenGl_VertexBufferCompat.cxx +++ b/src/OpenGl/OpenGl_VertexBufferCompat.cxx @@ -14,9 +14,6 @@ #include <OpenGl_VertexBufferCompat.hxx> -#include <NCollection_AlignedAllocator.hxx> - - IMPLEMENT_STANDARD_RTTIEXT(OpenGl_VertexBufferCompat,OpenGl_VertexBuffer) // ======================================================================= @@ -46,8 +43,7 @@ bool OpenGl_VertexBufferCompat::Create (const Handle(OpenGl_Context)& ) if (myBufferId == NO_BUFFER) { myBufferId = (GLuint )-1; // dummy identifier... - Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16); - myData = new NCollection_Buffer (anAlloc); + myData = new NCollection_Buffer (Graphic3d_Buffer::DefaultAllocator()); } return myBufferId != NO_BUFFER; } diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index bfe72a4278..8ef92f85b1 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -31,7 +31,6 @@ #include <Graphic3d_TextureParams.hxx> #include <Graphic3d_TransformUtils.hxx> -#include <NCollection_AlignedAllocator.hxx> IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient) diff --git a/src/Select3D/Select3D_SensitivePrimitiveArray.cxx b/src/Select3D/Select3D_SensitivePrimitiveArray.cxx index 96e9922087..00939c5c07 100644 --- a/src/Select3D/Select3D_SensitivePrimitiveArray.cxx +++ b/src/Select3D/Select3D_SensitivePrimitiveArray.cxx @@ -15,7 +15,6 @@ #include <Select3D_SensitivePrimitiveArray.hxx> -#include <NCollection_AlignedAllocator.hxx> #include <OSD_Parallel.hxx> #include <Standard_Atomic.hxx> @@ -165,7 +164,7 @@ Select3D_SensitivePrimitiveArray::Select3D_SensitivePrimitiveArray (const Handle myPatchSizeMax (1), myPatchDistance (ShortRealLast()), myIs3d (false), - myBvhIndices (new NCollection_AlignedAllocator(16)), + myBvhIndices (Graphic3d_Buffer::DefaultAllocator()), myMinDepthElem (RealLast()), myMinDepthNode (RealLast()), myMinDepthEdge (RealLast()),