summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorreduz <juan@okamstudio.com>2015-12-26 15:18:01 -0300
committerreduz <juan@okamstudio.com>2015-12-26 15:18:01 -0300
commitddd66c890420e0849700ae30c0411004671bd954 (patch)
tree58e389b9dcacce9ed709cf65f4a9fc49b44275b1 /scene
parent9d9520f227d58c2499e906d72002cf631e40f4c8 (diff)
small optimization improvement to rich text label tables
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/rich_text_label.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index c8ac816ffd..0db85981f7 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -475,6 +475,7 @@ if (m_height > line_height) {\
int vseparation=get_constant("table_vseparation");
Color ccolor = _find_color(table,p_base_color);
Vector2 draw_ofs = Point2(wofs,y);
+ int max_y=get_size().height;
if (p_mode==PROCESS_CACHE) {
@@ -562,13 +563,22 @@ if (m_height > line_height) {\
int yofs=0;
+ int lines_h = frame->lines[frame->lines.size()-1].height_accum_cache - (frame->lines[0].height_accum_cache - frame->lines[0].height_cache);
+ int lines_ofs = p_ofs.y+offset.y+draw_ofs.y;
+
+ bool visible = lines_ofs < get_size().height && lines_ofs+lines_h >=0;
+
for(int i=0;i<frame->lines.size();i++) {
- if (p_mode==PROCESS_DRAW) {
- _process_line(frame,p_ofs+offset+draw_ofs+Vector2(0,yofs),ly,table->columns[column].width,i,PROCESS_DRAW,cfont,ccolor);
- } else if (p_mode==PROCESS_POINTER) {
- _process_line(frame,p_ofs+offset+draw_ofs+Vector2(0,yofs),ly,table->columns[column].width,i,PROCESS_POINTER,cfont,ccolor,p_click_pos,r_click_item,r_click_char,r_outside);
+
+ if (visible) {
+ if (p_mode==PROCESS_DRAW) {
+ _process_line(frame,p_ofs+offset+draw_ofs+Vector2(0,yofs),ly,table->columns[column].width,i,PROCESS_DRAW,cfont,ccolor);
+ } else if (p_mode==PROCESS_POINTER) {
+ _process_line(frame,p_ofs+offset+draw_ofs+Vector2(0,yofs),ly,table->columns[column].width,i,PROCESS_POINTER,cfont,ccolor,p_click_pos,r_click_item,r_click_char,r_outside);
+ }
}
+
yofs+=frame->lines[i].height_cache;
if (p_mode==PROCESS_CACHE) {
frame->lines[i].height_accum_cache=offset.y+draw_ofs.y+frame->lines[i].height_cache;