Skip to content

Commit 039d465

Browse files
committed
Calculate y-coordinate of PE line once per PE when painting EMOs and UserEvents
Previously every EMO and UserEvent was recalculating the y coordinate for its PE when painting itself even though this value is the same for every object on a given PE. Profiliing showed that this was a source of great overhead which this change fixes.
1 parent 9aaa5b5 commit 039d465

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/projections/Tools/Timeline/EntryMethodObject.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ public boolean isDisplayed() {
812812
}
813813

814814

815-
public boolean paintMe(Graphics2D g2d, int actualDisplayWidth, MainPanel.MaxFilledX maxFilledX){
815+
public boolean paintMe(Graphics2D g2d, final int actualDisplayWidth, final int topCoord, MainPanel.MaxFilledX maxFilledX){
816816
boolean paintedEP = false;
817817
// If it is hidden, we may not display it
818818
if(!isDisplayed()){
@@ -829,9 +829,6 @@ public boolean paintMe(Graphics2D g2d, int actualDisplayWidth, MainPanel.MaxFill
829829
if(beginTime < data.startTime())
830830
leftCoord = data.timeToScreenPixelLeft(data.startTime(), actualDisplayWidth);
831831

832-
int topCoord = data.entryMethodLocationTop(pe);
833-
// int height = data.entryMethodLocationHeight();
834-
835832
// Determine the coordinates and sizes of the components of the graphical representation of the object
836833
int rectWidth = Math.max(1, rightCoord - leftCoord + 1);
837834
int rectHeight = data.barheight();

src/projections/Tools/Timeline/MainPanel.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,11 @@ public long paintAll(Graphics2D g){
249249
// Saves the furthest right position EPs and msg lines have been drawn in
250250
// order to optimize performance by only drawing when new pixels will be colored in
251251
MaxFilledX maxFilledX = new MaxFilledX();
252+
final int topCoord = data.entryMethodLocationTop(pe);
252253

253254
while(iter.hasNext()){
254255
EntryMethodObject o = iter.next();
255-
if(o.paintMe((Graphics2D) g, getWidth(), maxFilledX)) {
256+
if(o.paintMe((Graphics2D) g, getWidth(), topCoord, maxFilledX)) {
256257
count1++;
257258
}
258259
}
@@ -270,11 +271,13 @@ public long paintAll(Graphics2D g){
270271
for(Integer pe : pesToRender){
271272
Query1D<UserEventObject> l = data.allUserEventObjects.get(pe);
272273

274+
final int bottomCoord = data.userEventLocationBottom(pe);
275+
273276
if(l != null){ // FIXME: this shouldn't be here but is to fix a race condition with reloading ranges once something is displayed
274277
Iterator<UserEventObject> iter = l.iterator(leftClipTime, rightClipTime);
275278
while(iter.hasNext()){
276279
UserEventObject o = iter.next();
277-
o.paintMe((Graphics2D) g, getWidth(), data);
280+
o.paintMe((Graphics2D) g, getWidth(), data, bottomCoord);
278281
count2 ++;
279282
}
280283
}

src/projections/Tools/Timeline/UserEventObject.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public int getNestedID() {
115115
return nestedID;
116116
}
117117

118-
protected void paintMe(Graphics2D g, int actualDisplayWidth, Data data) {
118+
protected void paintMe(Graphics2D g, int actualDisplayWidth, Data data, final int baseBottomCoord) {
119119

120120
if(data.userEventIsHiddenID(userEventID)){
121121
return;
@@ -135,9 +135,9 @@ protected void paintMe(Graphics2D g, int actualDisplayWidth, Data data) {
135135

136136
if(width < 1)
137137
width = 1;
138-
139-
int topCoord = data.userEventLocationBottom(pe) - (1+nestedRow) * data.singleUserEventRectHeight();
138+
140139
int height = data.singleUserEventRectHeight();
140+
int topCoord = baseBottomCoord - (1+nestedRow) * height;
141141
int bottomCoord = topCoord+height-1;
142142

143143
Color c = getColor(data);

0 commit comments

Comments
 (0)