diff --git a/src/app/modules/gfx.cpp b/src/app/modules/gfx.cpp index f079a5139..b56308505 100644 --- a/src/app/modules/gfx.cpp +++ b/src/app/modules/gfx.cpp @@ -40,6 +40,22 @@ using namespace gfx; namespace { +gfx::Color gridColor1() +{ + if (ui::is_ui_thread() && current_editor) + return color_utils::color_for_ui(current_editor->docPref().bg.color1()); + else + return gfx::rgba(128, 128, 128); +} + +gfx::Color gridColor2() +{ + if (ui::is_ui_thread() && current_editor) + return color_utils::color_for_ui(current_editor->docPref().bg.color2()); + else + return gfx::rgba(192, 192, 192); +} + void draw_checked_grid(ui::Graphics* g, const gfx::Rect& rc, const gfx::Size& tile, @@ -78,9 +94,7 @@ void draw_checked_grid(ui::Graphics* g, const gfx::Rect& rc, const gfx::Size& tile) { - draw_checked_grid(g, rc, tile, - color_utils::color_for_ui(current_editor->docPref().bg.color1()), - color_utils::color_for_ui(current_editor->docPref().bg.color2())); + draw_checked_grid(g, rc, tile, gridColor1(), gridColor2()); } void draw_checked_grid(ui::Graphics* g, @@ -88,9 +102,7 @@ void draw_checked_grid(ui::Graphics* g, const gfx::Size& tile, DocumentPreferences& docPref) { - draw_checked_grid(g, rc, tile, - color_utils::color_for_ui(docPref.bg.color1()), - color_utils::color_for_ui(docPref.bg.color2())); + draw_checked_grid(g, rc, tile, gridColor1(), gridColor2()); } void draw_color(ui::Graphics* g, @@ -192,8 +204,8 @@ void draw_alpha_slider(ui::Graphics* g, for (int x=0; xdocPref().bg.color1()), c, a); - const doc::color_t c2 = doc::rgba_blender_normal(color_utils::color_for_ui(current_editor->docPref().bg.color2()), c, a); + const doc::color_t c1 = doc::rgba_blender_normal(gridColor1(), c, a); + const doc::color_t c2 = doc::rgba_blender_normal(gridColor2(), c, a); const int mid = rc.h/2; const int odd = (x / rc.h) & 1; g->drawVLine( @@ -220,8 +232,8 @@ void draw_alpha_slider(os::Surface* s, os::Paint paint; for (int x=0; xdocPref().bg.color1()), c, a); - const doc::color_t c2 = doc::rgba_blender_normal(color_utils::color_for_ui(current_editor->docPref().bg.color2()), c, a); + const doc::color_t c1 = doc::rgba_blender_normal(gridColor1(), c, a); + const doc::color_t c2 = doc::rgba_blender_normal(gridColor2(), c, a); const int mid = rc.h/2; const int odd = (x / rc.h) & 1;