Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
e8f33ac9
Commit
e8f33ac9
authored
May 10, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed memleak, removed excessive recaching, still there is a problem with Cairo caching
parent
e9e4ed42
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
46 deletions
+59
-46
drawframe.cpp
common/drawframe.cpp
+0
-4
drawpanel_gal.cpp
common/drawpanel_gal.cpp
+4
-1
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+24
-16
vbo_item.cpp
common/gal/opengl/vbo_item.cpp
+4
-1
view.cpp
common/view/view.cpp
+23
-20
opengl_gal.h
include/gal/opengl/opengl_gal.h
+1
-2
view.h
include/view/view.h
+3
-2
No files found.
common/drawframe.cpp
View file @
e8f33ac9
...
@@ -947,7 +947,6 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
...
@@ -947,7 +947,6 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
if
(
aEnable
&&
m_galCanvasActive
)
if
(
aEnable
&&
m_galCanvasActive
)
{
{
// When we switch between GAL based canvases, all we need is a refresh
// When we switch between GAL based canvases, all we need is a refresh
view
->
RecacheAllItems
(
true
);
m_galCanvas
->
Refresh
();
m_galCanvas
->
Refresh
();
}
}
...
@@ -981,9 +980,6 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
...
@@ -981,9 +980,6 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
m_auimgr
.
GetPane
(
wxT
(
"DrawFrameGal"
)
).
Show
(
aEnable
);
m_auimgr
.
GetPane
(
wxT
(
"DrawFrameGal"
)
).
Show
(
aEnable
);
m_auimgr
.
Update
();
m_auimgr
.
Update
();
if
(
aEnable
)
view
->
RecacheAllItems
(
true
);
m_galCanvasActive
=
aEnable
;
m_galCanvasActive
=
aEnable
;
#endif
/* KICAD_GAL */
#endif
/* KICAD_GAL */
}
}
common/drawpanel_gal.cpp
View file @
e8f33ac9
...
@@ -71,7 +71,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
...
@@ -71,7 +71,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
m_view
->
SetGAL
(
m_gal
);
m_view
->
SetGAL
(
m_gal
);
// View uses layers to display EDA_ITEMs (item may be displayed on several layers, for example
// View uses layers to display EDA_ITEMs (item may be displayed on several layers, for example
// pad may be shown on pad, pad hole
na
d solder paste layers). There are usual copper layers
// pad may be shown on pad, pad hole
an
d solder paste layers). There are usual copper layers
// (eg. F.Cu, B.Cu, internal and so on) and layers for displaying objects such as texts,
// (eg. F.Cu, B.Cu, internal and so on) and layers for displaying objects such as texts,
// silkscreen, pads, vias, etc.
// silkscreen, pads, vias, etc.
for
(
int
i
=
0
;
i
<
TOTAL_LAYER_COUNT
;
i
++
)
for
(
int
i
=
0
;
i
<
TOTAL_LAYER_COUNT
;
i
++
)
...
@@ -154,7 +154,10 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders )
...
@@ -154,7 +154,10 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders )
m_gal
->
ComputeWorldScreenMatrix
();
m_gal
->
ComputeWorldScreenMatrix
();
if
(
m_view
)
if
(
m_view
)
{
m_view
->
SetGAL
(
m_gal
);
m_view
->
SetGAL
(
m_gal
);
m_view
->
RecacheAllItems
(
true
);
}
wxSize
size
=
GetClientSize
();
wxSize
size
=
GetClientSize
();
m_gal
->
ResizeScreen
(
size
.
GetX
(),
size
.
GetY
()
);
m_gal
->
ResizeScreen
(
size
.
GetX
(),
size
.
GetY
()
);
...
...
common/gal/opengl/opengl_gal.cpp
View file @
e8f33ac9
...
@@ -68,11 +68,12 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
...
@@ -68,11 +68,12 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
isFrameBufferInitialized
=
false
;
isFrameBufferInitialized
=
false
;
isUseShader
=
isUseShaders
;
isUseShader
=
isUseShaders
;
isShaderInitialized
=
false
;
isShaderInitialized
=
false
;
isGroup
Started
=
false
;
isGroup
ing
=
false
;
shaderPath
=
"../../common/gal/opengl/shader/"
;
shaderPath
=
"../../common/gal/opengl/shader/"
;
wxSize
parentSize
=
aParent
->
GetSize
();
wxSize
parentSize
=
aParent
->
GetSize
();
isVboInitialized
=
false
;
isVboInitialized
=
false
;
vboNeedsUpdate
=
false
;
curVboItem
=
NULL
;
curVboItem
=
NULL
;
vboSize
=
0
;
vboSize
=
0
;
...
@@ -110,13 +111,6 @@ OPENGL_GAL::~OPENGL_GAL()
...
@@ -110,13 +111,6 @@ OPENGL_GAL::~OPENGL_GAL()
{
{
glFlush
();
glFlush
();
// Delete the stored display lists
for
(
std
::
deque
<
GLuint
>::
iterator
group
=
displayListsGroup
.
begin
();
group
!=
displayListsGroup
.
end
();
group
++
)
{
glDeleteLists
(
*
group
,
1
);
}
// Delete the buffers
// Delete the buffers
if
(
isFrameBufferInitialized
)
if
(
isFrameBufferInitialized
)
{
{
...
@@ -126,6 +120,12 @@ OPENGL_GAL::~OPENGL_GAL()
...
@@ -126,6 +120,12 @@ OPENGL_GAL::~OPENGL_GAL()
if
(
isVboInitialized
)
if
(
isVboInitialized
)
{
{
std
::
deque
<
VBO_ITEM
*>::
iterator
it
,
end
;
for
(
it
=
vboItems
.
begin
(),
end
=
vboItems
.
end
();
it
!=
end
;
it
++
)
{
delete
*
it
;
}
deleteVertexBufferObjects
();
deleteVertexBufferObjects
();
}
}
...
@@ -514,8 +514,8 @@ void OPENGL_GAL::rebuildVbo()
...
@@ -514,8 +514,8 @@ void OPENGL_GAL::rebuildVbo()
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
vboSize
*
VBO_ITEM
::
IndSize
,
indicesBuffer
,
GL_DYNAMIC_DRAW
);
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
vboSize
*
VBO_ITEM
::
IndSize
,
indicesBuffer
,
GL_DYNAMIC_DRAW
);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
0
);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
0
);
delete
verticesBuffer
;
delete
[]
verticesBuffer
;
delete
indicesBuffer
;
delete
[]
indicesBuffer
;
vboNeedsUpdate
=
false
;
vboNeedsUpdate
=
false
;
...
@@ -607,7 +607,7 @@ inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2
...
@@ -607,7 +607,7 @@ inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2
// XXX Should be improved later.
// XXX Should be improved later.
double
scale
=
0.5
*
lineWidth
/
lineLength
;
double
scale
=
0.5
*
lineWidth
/
lineLength
;
double
scale1pix
=
0.5001
/
worldScale
/
lineLength
;
double
scale1pix
=
0.5001
/
worldScale
/
lineLength
;
if
(
lineWidth
*
worldScale
<
1.0002
&&
!
isGroup
Started
)
if
(
lineWidth
*
worldScale
<
1.0002
&&
!
isGroup
ing
)
{
{
scale
=
scale1pix
;
scale
=
scale1pix
;
}
}
...
@@ -637,7 +637,7 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP
...
@@ -637,7 +637,7 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP
VECTOR2D
startEndVector
=
aEndPoint
-
aStartPoint
;
VECTOR2D
startEndVector
=
aEndPoint
-
aStartPoint
;
double
lineAngle
=
atan2
(
startEndVector
.
y
,
startEndVector
.
x
);
double
lineAngle
=
atan2
(
startEndVector
.
y
,
startEndVector
.
x
);
if
(
isGroup
Started
)
if
(
isGroup
ing
)
{
{
// Angle of a line perpendicular to the segment being drawn
// Angle of a line perpendicular to the segment being drawn
double
beta
=
(
M_PI
/
2.0
)
-
lineAngle
;
double
beta
=
(
M_PI
/
2.0
)
-
lineAngle
;
...
@@ -1464,7 +1464,7 @@ void OPENGL_GAL::Restore()
...
@@ -1464,7 +1464,7 @@ void OPENGL_GAL::Restore()
int
OPENGL_GAL
::
BeginGroup
()
int
OPENGL_GAL
::
BeginGroup
()
{
{
isGroup
Started
=
true
;
isGroup
ing
=
true
;
// There is a new group that is not in VBO yet
// There is a new group that is not in VBO yet
vboNeedsUpdate
=
true
;
vboNeedsUpdate
=
true
;
...
@@ -1482,17 +1482,25 @@ void OPENGL_GAL::EndGroup()
...
@@ -1482,17 +1482,25 @@ void OPENGL_GAL::EndGroup()
{
{
vboSize
+=
curVboItem
->
GetSize
();
vboSize
+=
curVboItem
->
GetSize
();
isGroup
Started
=
false
;
isGroup
ing
=
false
;
}
}
void
OPENGL_GAL
::
DeleteGroup
(
int
aGroupNumber
)
void
OPENGL_GAL
::
DeleteGroup
(
int
aGroupNumber
)
{
{
if
(
aGroupNumber
>=
vboItems
.
size
()
)
{
// This should not happen
wxLogDebug
(
wxT
(
"Tried to delete not existing group"
)
);
return
;
}
std
::
deque
<
VBO_ITEM
*>::
iterator
it
=
vboItems
.
begin
();
std
::
deque
<
VBO_ITEM
*>::
iterator
it
=
vboItems
.
begin
();
std
::
advance
(
it
,
aGroupNumber
);
std
::
advance
(
it
,
aGroupNumber
);
//vboSize -= it->GetSize(); // FIXME?
delete
*
it
;
delete
*
it
;
vboItems
.
erase
(
it
);
//
vboItems.erase( it );
vboNeedsUpdate
=
true
;
vboNeedsUpdate
=
true
;
}
}
...
...
common/gal/opengl/vbo_item.cpp
View file @
e8f33ac9
...
@@ -46,6 +46,9 @@ VBO_ITEM::~VBO_ITEM()
...
@@ -46,6 +46,9 @@ VBO_ITEM::~VBO_ITEM()
{
{
if
(
m_vertices
)
if
(
m_vertices
)
delete
m_vertices
;
delete
m_vertices
;
if
(
m_indices
)
delete
m_indices
;
}
}
...
@@ -76,7 +79,7 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
...
@@ -76,7 +79,7 @@ void VBO_ITEM::PushVertex( const GLfloat* aVertex )
m_indices
=
newIndices
;
m_indices
=
newIndices
;
// Add the new vertex
// Add the new vertex
newI
ndices
[
m_size
]
=
m_offset
+
m_size
;
m_i
ndices
[
m_size
]
=
m_offset
+
m_size
;
m_size
++
;
m_size
++
;
m_isDirty
=
true
;
m_isDirty
=
true
;
...
...
common/view/view.cpp
View file @
e8f33ac9
...
@@ -208,9 +208,9 @@ void VIEW::SetGAL( GAL* aGal )
...
@@ -208,9 +208,9 @@ void VIEW::SetGAL( GAL* aGal )
if
(
m_painter
)
if
(
m_painter
)
m_painter
->
SetGAL
(
m_gal
);
m_painter
->
SetGAL
(
m_gal
);
//
items need to be recached after changing GAL
//
clear group numbers, so everything is going to be recached
//
if( m_useGroups )
if
(
m_useGroups
)
//RecacheAllItems
();
clearGroupCache
();
// force the new GAL to display the current viewport.
// force the new GAL to display the current viewport.
SetCenter
(
m_center
);
SetCenter
(
m_center
);
...
@@ -387,7 +387,6 @@ struct VIEW::drawItem
...
@@ -387,7 +387,6 @@ struct VIEW::drawItem
aItem
->
setGroup
(
currentLayer
,
group
);
aItem
->
setGroup
(
currentLayer
,
group
);
view
->
m_painter
->
Draw
(
static_cast
<
EDA_ITEM
*>
(
aItem
),
currentLayer
);
view
->
m_painter
->
Draw
(
static_cast
<
EDA_ITEM
*>
(
aItem
),
currentLayer
);
gal
->
EndGroup
();
gal
->
EndGroup
();
//gal->DrawGroup( group );
}
}
}
}
else
if
(
aItem
->
ViewIsVisible
()
)
else
if
(
aItem
->
ViewIsVisible
()
)
...
@@ -460,20 +459,24 @@ struct VIEW::recacheItem
...
@@ -460,20 +459,24 @@ struct VIEW::recacheItem
void
operator
()(
VIEW_ITEM
*
aItem
)
void
operator
()(
VIEW_ITEM
*
aItem
)
{
{
//
aItem->deleteGroups();
//
Remove previously cached group
/*
int prevGroup = aItem->getGroup( layer );
int
prevGroup
=
aItem
->
getGroup
(
layer
);
if( prevGroup
!= -1
)
if
(
prevGroup
>=
0
)
{
{
gal
->
DeleteGroup
(
prevGroup
);
gal
->
DeleteGroup
(
prevGroup
);
}
*/
}
if
(
immediately
)
if
(
immediately
)
{
{
int
group
=
gal
->
BeginGroup
();
int
group
=
gal
->
BeginGroup
();
aItem
->
setGroup
(
layer
,
group
);
view
->
m_painter
->
Draw
(
static_cast
<
EDA_ITEM
*>
(
aItem
),
layer
);
view
->
m_painter
->
Draw
(
static_cast
<
EDA_ITEM
*>
(
aItem
),
layer
);
aItem
->
setGroup
(
layer
,
group
);
gal
->
EndGroup
();
gal
->
EndGroup
();
}
}
else
{
aItem
->
setGroup
(
layer
,
-
1
);
}
}
}
VIEW
*
view
;
VIEW
*
view
;
...
@@ -565,12 +568,6 @@ struct VIEW::clearItemCache
...
@@ -565,12 +568,6 @@ struct VIEW::clearItemCache
{
{
if
(
aItem
->
storesGroups
()
)
if
(
aItem
->
storesGroups
()
)
{
{
std
::
vector
<
int
>
groups
=
aItem
->
getAllGroups
();
for
(
std
::
vector
<
int
>::
iterator
i
=
groups
.
begin
();
i
!=
groups
.
end
();
i
++
)
{
view
->
GetGAL
()
->
DeleteGroup
(
*
i
);
}
aItem
->
deleteGroups
();
aItem
->
deleteGroups
();
}
}
}
}
...
@@ -581,6 +578,9 @@ struct VIEW::clearItemCache
...
@@ -581,6 +578,9 @@ struct VIEW::clearItemCache
void
VIEW
::
clearGroupCache
()
void
VIEW
::
clearGroupCache
()
{
{
if
(
!
m_useGroups
)
return
;
BOX2I
r
;
BOX2I
r
;
r
.
SetMaximum
();
r
.
SetMaximum
();
...
@@ -596,22 +596,25 @@ void VIEW::clearGroupCache()
...
@@ -596,22 +596,25 @@ void VIEW::clearGroupCache()
void
VIEW
::
RecacheAllItems
(
bool
aImmediately
)
void
VIEW
::
RecacheAllItems
(
bool
aImmediately
)
{
{
if
(
!
m_useGroups
)
return
;
BOX2I
r
;
BOX2I
r
;
r
.
SetMaximum
();
r
.
SetMaximum
();
wxLogDebug
(
wxT
(
"RecacheAllItems::immediately: %u"
),
aImmediately
);
//if( aImmediately )
if
(
aImmediately
)
m_gal
->
BeginDrawing
();
m_gal
->
BeginDrawing
();
wxLogDebug
(
wxT
(
"RecacheAllItems::immediately: %u"
),
aImmediately
);
for
(
LayerMapIter
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
for
(
LayerMapIter
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
{
{
VIEW_LAYER
*
l
=
&
(
(
*
i
).
second
);
VIEW_LAYER
*
l
=
&
(
(
*
i
).
second
);
recacheItem
visitor
(
this
,
m_gal
,
l
->
id
,
aImmediately
);
recacheItem
visitor
(
this
,
m_gal
,
l
->
id
,
aImmediately
);
l
->
items
->
Query
(
r
,
visitor
);
l
->
items
->
Query
(
r
,
visitor
);
}
;
}
if
(
aImmediately
)
//
if( aImmediately )
m_gal
->
EndDrawing
();
m_gal
->
EndDrawing
();
}
}
include/gal/opengl/opengl_gal.h
View file @
e8f33ac9
...
@@ -339,7 +339,6 @@ private:
...
@@ -339,7 +339,6 @@ private:
GLuint
displayListsArcs
;
///< Arc display list
GLuint
displayListsArcs
;
///< Arc display list
GLuint
displayListCircle
;
///< Circle display list
GLuint
displayListCircle
;
///< Circle display list
GLuint
displayListSemiCircle
;
///< Semi circle display list
GLuint
displayListSemiCircle
;
///< Semi circle display list
std
::
deque
<
GLuint
>
displayListsGroup
;
///< List of display lists used for groups
// Vertex buffer objects related fields
// Vertex buffer objects related fields
std
::
deque
<
VBO_ITEM
*>
vboItems
;
///< Stores informations about VBO objects
std
::
deque
<
VBO_ITEM
*>
vboItems
;
///< Stores informations about VBO objects
...
@@ -382,7 +381,7 @@ private:
...
@@ -382,7 +381,7 @@ private:
bool
isShaderInitialized
;
///< Was the shader initialized?
bool
isShaderInitialized
;
///< Was the shader initialized?
bool
isShaderEnabled
;
///< Are the shaders enabled?
bool
isShaderEnabled
;
///< Are the shaders enabled?
bool
isUseShader
;
///< Should the shaders be used?
bool
isUseShader
;
///< Should the shaders be used?
bool
isGroup
Started
;
///< Was a group started?
bool
isGroup
ing
;
///< Was a group started?
int
currentShader
;
///< ID of the shader currently in use
int
currentShader
;
///< ID of the shader currently in use
std
::
string
shaderPath
;
std
::
string
shaderPath
;
...
...
include/view/view.h
View file @
e8f33ac9
...
@@ -355,14 +355,15 @@ private:
...
@@ -355,14 +355,15 @@ private:
///* Sorts m_orderedLayers when layer rendering order has changed
///* Sorts m_orderedLayers when layer rendering order has changed
void
sortLayers
();
void
sortLayers
();
///* Clears cached GAL display lists
///* Clears cached GAL group numbers (*ONLY* numbers stored in VIEW_ITEMs, not group objects
///* used by GAL)
void
clearGroupCache
();
void
clearGroupCache
();
/// Determines rendering order of layers. Used in display order sorting function.
/// Determines rendering order of layers. Used in display order sorting function.
static
bool
compareRenderingOrder
(
VIEW_LAYER
*
i
,
VIEW_LAYER
*
j
)
static
bool
compareRenderingOrder
(
VIEW_LAYER
*
i
,
VIEW_LAYER
*
j
)
{
{
return
i
->
renderingOrder
>
j
->
renderingOrder
;
return
i
->
renderingOrder
>
j
->
renderingOrder
;
}
;
}
/// Contains set of possible displayed layers and its properties
/// Contains set of possible displayed layers and its properties
LayerMap
m_layers
;
LayerMap
m_layers
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment