aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/src/observer_perf_wx.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2012-02-21 11:43:08 +0100
committerDan Gudmundsson <[email protected]>2012-02-21 15:06:43 +0100
commitf413a27b73d1e0ceaf0d31fc9615208f11645108 (patch)
tree5a40727d3f846829db0a06b8040f584e3a09e425 /lib/observer/src/observer_perf_wx.erl
parent5584462be1c6dce1990a9031c0e43a89e758a263 (diff)
downloadotp-f413a27b73d1e0ceaf0d31fc9615208f11645108.tar.gz
otp-f413a27b73d1e0ceaf0d31fc9615208f11645108.tar.bz2
otp-f413a27b73d1e0ceaf0d31fc9615208f11645108.zip
[observer] Windows double buffer fixes
DC's and GC's is not double buffered by default on windows, and there is a separate erase event which causes awful flickering when constant updating a window. Hack around wx (to be able to use wxBufferPaintDC), to avoid flickering on windows. This works on windows because there (and only there) wxGC:create/1 also takes a memoryDC as argument.
Diffstat (limited to 'lib/observer/src/observer_perf_wx.erl')
-rw-r--r--lib/observer/src/observer_perf_wx.erl59
1 files changed, 39 insertions, 20 deletions
diff --git a/lib/observer/src/observer_perf_wx.erl b/lib/observer/src/observer_perf_wx.erl
index c4659d1ea1..0de9785fb9 100644
--- a/lib/observer/src/observer_perf_wx.erl
+++ b/lib/observer/src/observer_perf_wx.erl
@@ -61,15 +61,15 @@ init([Notebook, Parent]) ->
try
Panel = wxPanel:new(Notebook),
Main = wxBoxSizer:new(?wxVERTICAL),
-
- CPU = wxPanel:new(Panel, [{winid, ?RQ_W}, {style,?wxFULL_REPAINT_ON_RESIZE}]),
+ Style = ?wxFULL_REPAINT_ON_RESIZE bor ?wxCLIP_CHILDREN,
+ CPU = wxPanel:new(Panel, [{winid, ?RQ_W}, {style,Style}]),
wxWindow:setBackgroundColour(CPU, ?wxWHITE),
wxSizer:add(Main, CPU, [{flag, ?wxEXPAND bor ?wxALL},
{proportion, 1}, {border, 5}]),
MemIO = wxBoxSizer:new(?wxHORIZONTAL),
- MEM = wxPanel:new(Panel, [{winid, ?MEM_W}, {style,?wxFULL_REPAINT_ON_RESIZE}]),
+ MEM = wxPanel:new(Panel, [{winid, ?MEM_W}, {style,Style}]),
wxWindow:setBackgroundColour(MEM, ?wxWHITE),
- IO = wxPanel:new(Panel, [{winid, ?IO_W}, {style,?wxFULL_REPAINT_ON_RESIZE}]),
+ IO = wxPanel:new(Panel, [{winid, ?IO_W}, {style,Style}]),
wxWindow:setBackgroundColour(IO, ?wxWHITE),
wxSizer:add(MemIO, MEM, [{flag, ?wxEXPAND bor ?wxLEFT},
{proportion, 1}, {border, 5}]),
@@ -82,20 +82,31 @@ init([Notebook, Parent]) ->
wxPanel:connect(CPU, paint, [callback]),
wxPanel:connect(IO, paint, [callback]),
wxPanel:connect(MEM, paint, [callback]),
+ case os:type() of
+ {win32, _} -> %% Ignore erase on windows
+ wxPanel:connect(CPU, erase_background, [{callback, fun(_,_) -> ok end}]),
+ wxPanel:connect(IO, erase_background, [{callback, fun(_,_) -> ok end}]),
+ wxPanel:connect(MEM, erase_background, [{callback, fun(_,_) -> ok end}]);
+ _ -> ok
+ end,
UseGC = haveGC(Panel),
- Font = case UseGC of
- true ->
- %% Def font is really small when using Graphics contexts for some reason
- %% Hardcode it
- wxFont:new(12,?wxFONTFAMILY_DECORATIVE,?wxFONTSTYLE_NORMAL,?wxFONTWEIGHT_BOLD);
- false ->
- DefFont = wxSystemSettings:getFont(?wxSYS_DEFAULT_GUI_FONT),
- DefSize = wxFont:getPointSize(DefFont),
- DefFamily = wxFont:getFamily(DefFont),
- wxFont:new(DefSize, DefFamily, ?wxFONTSTYLE_NORMAL, ?wxFONTWEIGHT_BOLD)
- end,
- SmallFont = wxFont:new(10, ?wxFONTFAMILY_DECORATIVE, ?wxFONTSTYLE_NORMAL, ?wxFONTWEIGHT_NORMAL),
+ {Font, SmallFont}
+ = case os:type() of
+ {unix, _} when UseGC ->
+ %% Def font is really small when using Graphics contexts for some reason
+ %% Hardcode it
+ F = wxFont:new(12,?wxFONTFAMILY_DECORATIVE,?wxFONTSTYLE_NORMAL,?wxFONTWEIGHT_BOLD),
+ SF = wxFont:new(10, ?wxFONTFAMILY_DECORATIVE, ?wxFONTSTYLE_NORMAL, ?wxFONTWEIGHT_NORMAL),
+ {F, SF};
+ _ ->
+ DefFont = wxSystemSettings:getFont(?wxSYS_DEFAULT_GUI_FONT),
+ DefSize = wxFont:getPointSize(DefFont),
+ DefFamily = wxFont:getFamily(DefFont),
+ F = wxFont:new(DefSize, DefFamily, ?wxFONTSTYLE_NORMAL, ?wxFONTWEIGHT_BOLD),
+ SF = wxFont:new(DefSize-1, DefFamily, ?wxFONTSTYLE_NORMAL, ?wxFONTWEIGHT_NORMAL),
+ {F, SF}
+ end,
BlackPen = wxPen:new({0,0,0}, [{width, 2}]),
Pens = [wxPen:new(Col, [{width, 2}]) || Col <- tuple_to_list(colors())],
process_flag(trap_exit, true),
@@ -135,10 +146,18 @@ handle_sync_event(#wx{obj=Panel, event = #wxPaint{}},_,
Panel =:= element(?MEM_W, Windows) -> ?MEM_W;
Panel =:= element(?IO_W, Windows) -> ?IO_W
end,
- DC = wxPaintDC:new(Panel),
- GC = case UseGC of
- true -> ?wxGC:create(DC);
- false -> DC
+ IsWindows = element(1, os:type()) =:= win32,
+
+ DC = if IsWindows ->
+ %% Ugly hack to aviod flickering on windows, works on windows only
+ %% But the other platforms are doublebuffered by default
+ wx:typeCast(wxBufferedPaintDC:new(Panel), wxPaintDC);
+ true ->
+ wxPaintDC:new(Panel)
+ end,
+ IsWindows andalso wxDC:clear(DC),
+ GC = if UseGC -> ?wxGC:create(DC);
+ true -> DC
end,
%% Nothing is drawn until wxPaintDC is destroyed.
try