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
e9e4ed42
Commit
e9e4ed42
authored
Apr 30, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved recaching (all items when a board is loaded), still needs some fixing (mem leak).
parent
191cb40e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
22 deletions
+61
-22
drawframe.cpp
common/drawframe.cpp
+7
-2
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+6
-11
view.cpp
common/view/view.cpp
+37
-6
view.h
include/view/view.h
+8
-3
basepcbframe.cpp
pcbnew/basepcbframe.cpp
+3
-0
No files found.
common/drawframe.cpp
View file @
e9e4ed42
...
...
@@ -941,17 +941,19 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
void
EDA_DRAW_FRAME
::
UseGalCanvas
(
bool
aEnable
)
{
#ifdef KICAD_GAL
KiGfx
::
VIEW
*
view
=
m_galCanvas
->
GetView
();
KiGfx
::
GAL
*
gal
=
m_galCanvas
->
GetGAL
();
if
(
aEnable
&&
m_galCanvasActive
)
{
// When we switch between GAL based canvases, all we need is a refresh
view
->
RecacheAllItems
(
true
);
m_galCanvas
->
Refresh
();
}
if
(
!
(
aEnable
^
m_galCanvasActive
)
)
return
;
KiGfx
::
VIEW
*
view
=
m_galCanvas
->
GetView
();
KiGfx
::
GAL
*
gal
=
m_galCanvas
->
GetGAL
();
double
zoomFactor
=
gal
->
GetWorldScale
()
/
gal
->
GetZoomFactor
();
// Display the same view after canvas switching
...
...
@@ -979,6 +981,9 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
m_auimgr
.
GetPane
(
wxT
(
"DrawFrameGal"
)
).
Show
(
aEnable
);
m_auimgr
.
Update
();
if
(
aEnable
)
view
->
RecacheAllItems
(
true
);
m_galCanvasActive
=
aEnable
;
#endif
/* KICAD_GAL */
}
common/gal/opengl/opengl_gal.cpp
View file @
e9e4ed42
...
...
@@ -403,7 +403,10 @@ void OPENGL_GAL::BeginDrawing()
SetFillColor
(
fillColor
);
SetStrokeColor
(
strokeColor
);
isDeleteSavedPixels
=
true
;
vboNeedsUpdate
=
false
;
// If any of VBO items is dirty - recache everything
if
(
vboNeedsUpdate
)
rebuildVbo
();
}
...
...
@@ -455,13 +458,6 @@ void OPENGL_GAL::blitMainTexture( bool aIsClearFrameBuffer )
void
OPENGL_GAL
::
EndDrawing
()
{
// If any of VBO items is dirty - recache everything
if
(
vboNeedsUpdate
)
{
rebuildVbo
();
vboNeedsUpdate
=
false
;
}
// Draw the remaining contents, blit the main texture to the screen, swap the buffers
glFlush
();
blitMainTexture
(
true
);
...
...
@@ -521,6 +517,8 @@ void OPENGL_GAL::rebuildVbo()
delete
verticesBuffer
;
delete
indicesBuffer
;
vboNeedsUpdate
=
false
;
#ifdef __WXDEBUG__
prof_end
(
&
totalTime
);
...
...
@@ -1484,9 +1482,6 @@ void OPENGL_GAL::EndGroup()
{
vboSize
+=
curVboItem
->
GetSize
();
// TODO this has to be removed in final version
rebuildVbo
();
isGroupStarted
=
false
;
}
...
...
common/view/view.cpp
View file @
e9e4ed42
...
...
@@ -209,8 +209,8 @@ void VIEW::SetGAL( GAL* aGal )
m_painter
->
SetGAL
(
m_gal
);
// items need to be recached after changing GAL
if
(
m_useGroups
)
r
ecacheAllItems
();
//
if( m_useGroups )
//R
ecacheAllItems();
// force the new GAL to display the current viewport.
SetCenter
(
m_center
);
...
...
@@ -387,7 +387,7 @@ struct VIEW::drawItem
aItem
->
setGroup
(
currentLayer
,
group
);
view
->
m_painter
->
Draw
(
static_cast
<
EDA_ITEM
*>
(
aItem
),
currentLayer
);
gal
->
EndGroup
();
gal
->
DrawGroup
(
group
);
//
gal->DrawGroup( group );
}
}
else
if
(
aItem
->
ViewIsVisible
()
)
...
...
@@ -453,10 +453,33 @@ struct VIEW::unlinkItem
struct
VIEW
::
recacheItem
{
recacheItem
(
VIEW
*
aView
,
GAL
*
aGal
,
int
aLayer
,
bool
aImmediately
)
:
view
(
aView
),
gal
(
aGal
),
layer
(
aLayer
),
immediately
(
aImmediately
)
{
}
void
operator
()(
VIEW_ITEM
*
aItem
)
{
aItem
->
deleteGroups
();
//aItem->deleteGroups();
/*int prevGroup = aItem->getGroup( layer );
if( prevGroup != -1 )
{
gal->DeleteGroup( prevGroup );
}*/
if
(
immediately
)
{
int
group
=
gal
->
BeginGroup
();
aItem
->
setGroup
(
layer
,
group
);
view
->
m_painter
->
Draw
(
static_cast
<
EDA_ITEM
*>
(
aItem
),
layer
);
gal
->
EndGroup
();
}
}
VIEW
*
view
;
GAL
*
gal
;
int
layer
;
bool
immediately
;
};
...
...
@@ -571,16 +594,24 @@ void VIEW::clearGroupCache()
}
void
VIEW
::
recacheAllItems
(
)
void
VIEW
::
RecacheAllItems
(
bool
aImmediately
)
{
BOX2I
r
;
r
.
SetMaximum
();
wxLogDebug
(
wxT
(
"RecacheAllItems::immediately: %u"
),
aImmediately
);
if
(
aImmediately
)
m_gal
->
BeginDrawing
();
for
(
LayerMapIter
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
{
VIEW_LAYER
*
l
=
&
(
(
*
i
).
second
);
recacheItem
visitor
;
recacheItem
visitor
(
this
,
m_gal
,
l
->
id
,
aImmediately
)
;
l
->
items
->
Query
(
r
,
visitor
);
};
if
(
aImmediately
)
m_gal
->
EndDrawing
();
}
include/view/view.h
View file @
e9e4ed42
...
...
@@ -294,6 +294,14 @@ public:
*/
void
PartialRedraw
();
/**
* Function RecacheAllItems()
* Rebuilds GAL display lists.
* @param aForceNow decides if every item should be instantly recached. Otherwise items are
* going to be recached when they become visible.
*/
void
RecacheAllItems
(
bool
aForceNow
=
false
);
/**
* Function IsDynamic()
* Tells if the VIEW is dynamic (ie. can be changed, for example displaying PCBs in a window)
...
...
@@ -350,9 +358,6 @@ private:
///* Clears cached GAL display lists
void
clearGroupCache
();
///* Rebuilds GAL display lists
void
recacheAllItems
();
/// Determines rendering order of layers. Used in display order sorting function.
static
bool
compareRenderingOrder
(
VIEW_LAYER
*
i
,
VIEW_LAYER
*
j
)
{
...
...
pcbnew/basepcbframe.cpp
View file @
e9e4ed42
...
...
@@ -243,8 +243,11 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
view
->
SetTopLayer
(
m_Pcb
->
GetLayer
()
);
if
(
m_galCanvasActive
)
{
view
->
RecacheAllItems
(
true
);
m_galCanvas
->
Refresh
();
}
}
#endif
}
...
...
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