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
8c37e708
Commit
8c37e708
authored
Aug 07, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Different approach to item recaching.
parent
ee80c7f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
48 deletions
+65
-48
view.cpp
common/view/view.cpp
+57
-47
view_item.cpp
common/view/view_item.cpp
+1
-0
view.h
include/view/view.h
+7
-1
No files found.
common/view/view.cpp
View file @
8c37e708
...
...
@@ -324,7 +324,7 @@ struct VIEW::updateItemsColor
const
COLOR4D
color
=
painter
->
GetColor
(
aItem
,
layer
);
int
group
=
aItem
->
getGroup
(
layer
);
if
(
group
>
0
)
if
(
group
>
=
0
)
gal
->
ChangeGroupColor
(
group
,
color
);
}
...
...
@@ -539,8 +539,8 @@ void VIEW::redrawRect( const BOX2I& aRect )
m_gal
->
SetTarget
(
l
->
target
);
m_gal
->
SetLayerDepth
(
l
->
renderingOrder
);
l
->
items
->
Query
(
aRect
,
drawFunc
);
l
->
isDirty
=
false
;
}
l
->
isDirty
=
false
;
}
}
...
...
@@ -638,49 +638,6 @@ VECTOR2D VIEW::GetScreenPixelSize() const
}
void
VIEW
::
invalidateItem
(
VIEW_ITEM
*
aItem
,
int
aUpdateFlags
)
{
int
layer_indices
[
VIEW_MAX_LAYERS
],
layer_count
;
aItem
->
ViewGetLayers
(
layer_indices
,
layer_count
);
for
(
int
i
=
0
;
i
<
layer_count
;
i
++
)
{
// Iterate through the layers used by the item
if
(
m_layers
.
find
(
layer_indices
[
i
]
)
!=
m_layers
.
end
()
)
{
VIEW_LAYER
*
l
=
&
m_layers
[
layer_indices
[
i
]];
// Mark the area occupied by the item as dirty
l
->
dirtyExtents
=
l
->
isDirty
?
aItem
->
ViewBBox
()
:
l
->
dirtyExtents
.
Merge
(
aItem
->
ViewBBox
()
);
l
->
isDirty
=
true
;
// If geometry has to be updated, then we need to reinsert the item
if
(
aUpdateFlags
&
VIEW_ITEM
::
GEOMETRY
)
{
l
->
items
->
Remove
(
aItem
);
l
->
items
->
Insert
(
aItem
);
}
}
}
// Remove all the groups, so the item will be recached
if
(
aItem
->
storesGroups
()
)
{
// Clear the cached groups stored in GAL
std
::
vector
<
int
>
groups
=
aItem
->
getAllGroups
();
for
(
std
::
vector
<
int
>::
iterator
i
=
groups
.
begin
();
i
!=
groups
.
end
();
i
++
)
{
m_gal
->
DeleteGroup
(
*
i
);
}
aItem
->
deleteGroups
();
}
}
struct
VIEW
::
clearLayerCache
{
clearLayerCache
(
VIEW
*
aView
)
:
...
...
@@ -715,14 +672,67 @@ void VIEW::clearGroupCache()
}
void
VIEW
::
invalidateItem
(
VIEW_ITEM
*
aItem
,
int
aUpdateFlags
)
{
int
layers
[
VIEW_MAX_LAYERS
],
layers_count
;
aItem
->
ViewGetLayers
(
layers
,
layers_count
);
// Iterate through layers used by the item and recache it immediately
for
(
int
i
=
0
;
i
<
layers_count
;
i
++
)
{
if
(
aUpdateFlags
==
VIEW_ITEM
::
APPEARANCE
)
{
updateItemAppearance
(
aItem
,
layers
[
i
]
);
}
else
if
(
aUpdateFlags
==
VIEW_ITEM
::
GEOMETRY
)
{
updateItemGeometry
(
aItem
,
layers
[
i
]);
}
// Mark those layers as dirty, so the VIEW will be refreshed
m_layers
[
layers
[
i
]].
isDirty
=
true
;
}
}
void
VIEW
::
updateItemAppearance
(
VIEW_ITEM
*
aItem
,
int
aLayer
)
{
wxASSERT
(
(
unsigned
)
aLayer
<
m_layers
.
size
()
);
// Obtain the color that should be used for coloring the item on the specific layerId
const
COLOR4D
color
=
m_painter
->
GetColor
(
aItem
,
aLayer
);
int
group
=
aItem
->
getGroup
(
aLayer
);
// Change the color, only if it has group assigned
if
(
group
>=
0
)
m_gal
->
ChangeGroupColor
(
group
,
color
);
}
void
VIEW
::
updateItemGeometry
(
VIEW_ITEM
*
aItem
,
int
aLayer
)
{
wxASSERT
(
(
unsigned
)
aLayer
<
m_layers
.
size
()
);
VIEW_LAYER
&
l
=
m_layers
.
at
(
aLayer
);
m_gal
->
SetTarget
(
l
.
target
);
m_gal
->
SetLayerDepth
(
l
.
renderingOrder
);
// Redraw the item from scratch
int
group
=
m_gal
->
BeginGroup
();
aItem
->
setGroup
(
aLayer
,
group
);
m_painter
->
Draw
(
static_cast
<
EDA_ITEM
*>
(
aItem
),
aLayer
);
m_gal
->
EndGroup
();
}
bool
VIEW
::
areRequiredLayersEnabled
(
int
aLayerId
)
const
{
wxASSERT
(
(
unsigned
)
aLayerId
<
m_layers
.
size
()
);
std
::
set
<
int
>::
iterator
it
,
it_end
;
for
(
it
=
m_layers
.
at
(
aLayerId
).
requiredLayers
.
begin
(),
it_end
=
m_layers
.
at
(
aLayerId
).
requiredLayers
.
end
();
it
!=
it_end
;
++
it
)
for
(
it
=
m_layers
.
at
(
aLayerId
).
requiredLayers
.
begin
(),
it
_end
=
m_layers
.
at
(
aLayerId
).
requiredLayers
.
end
();
it
!=
it_end
;
++
it
)
{
// That is enough if just one layer is not enabled
if
(
!
m_layers
.
at
(
*
it
).
enabled
)
...
...
common/view/view_item.cpp
View file @
8c37e708
...
...
@@ -125,6 +125,7 @@ void VIEW_ITEM::setGroup( int aLayer, int aId )
void
VIEW_ITEM
::
deleteGroups
()
{
delete
[]
m_groups
;
m_groups
=
NULL
;
m_groupsSize
=
0
;
}
...
...
include/view/view.h
View file @
8c37e708
...
...
@@ -369,7 +369,7 @@ public:
* Tells if the VIEW is dynamic (ie. can be changed, for example displaying PCBs in a window)
* or static (that cannot be modified, eg. displaying image/PDF).
*/
bool
IsDynamic
()
const
{
return
m_dynamic
;
}
bool
IsDynamic
()
const
{
return
m_dynamic
;
}
/**
* Function IsDirty()
...
...
@@ -427,6 +427,12 @@ private:
///* used by GAL)
void
clearGroupCache
();
/// Updates colors that are used for an item to be drawn
void
updateItemAppearance
(
VIEW_ITEM
*
aItem
,
int
aLayer
);
/// Updates all informations needed to draw an item
void
updateItemGeometry
(
VIEW_ITEM
*
aItem
,
int
aLayer
);
/// Determines rendering order of layers. Used in display order sorting function.
static
bool
compareRenderingOrder
(
VIEW_LAYER
*
i
,
VIEW_LAYER
*
j
)
{
...
...
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