Date:2010-05-01 18:55:11 (7 years 6 months ago)
Author:Lars C.
Commit:a794a1c01a261fc963930304f8013b51b58be754
Message:Cache current icon surface. By doing so we safe a huge number of hash map lookups.

Files: src/link.cpp (4 diffs)
src/link.h (2 diffs)

Change Details

src/link.cpp
3333    iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
3434    iconX = 0;
3535    padding = 0;
36
37    updateSurfaces();
3638}
3739
3840void Link::run() {}
3941
4042void Link::paint() {
41    gmenu2x->sc[getIconPath()]->blit(gmenu2x->s, iconX, rect.y+padding, 32,32);
43    iconSurface->blit(gmenu2x->s, iconX, rect.y+padding, 32,32);
4244    gmenu2x->s->write( gmenu2x->font, getTitle(), iconX+16, rect.y+gmenu2x->skinConfInt["linkHeight"]-padding, SFontHAlignCenter, SFontVAlignBottom );
4345}
4446
...... 
5052    return true;
5153}
5254
55void Link::updateSurfaces()
56{
57    iconSurface = gmenu2x->sc[getIconPath()];
58}
59
5360string Link::getTitle() {
5461    return title;
5562}
...... 
8996
9097    this->icon = icon;
9198    edited = true;
99    updateSurfaces();
92100}
93101
94102string Link::searchIcon() {
...... 
106114        iconPath = icon;
107115    else
108116        iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
117    updateSurfaces();
109118}
110119
111120void Link::setSize(int w, int h) {
src/link.h
2424#include <iostream>
2525
2626#include "button.h"
27#include "surface.h"
2728
2829using std::string;
2930
...... 
4243    bool edited;
4344    string title, description, icon, iconPath;
4445
46    Surface *iconSurface;
47    Surface *icon_hover;
48
4549    void recalcCoordinates();
50    void updateSurfaces();
4651
4752public:
4853    Link(GMenu2X *gmenu2x);

Archive Download the corresponding diff file



interactive