Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Issue 9323011: Cache a screen compatible DC to avoid re-creating it excessively. (Closed)

Created:
8 years, 10 months ago by Alexei Svitkine (slow)
Modified:
8 years, 10 months ago
Reviewers:
msw, cpu_(ooo_6.6-7.5), sky
CC:
chromium-reviews, tfarina, ben+watch_chromium.org
Visibility:
Public.

Description

Cache a screen compatible DC to avoid re-creating it excessively. Profiling revealed that creating and deleting the DC carries a significant cost. This is an important optimization when you consider the case of ElideRectangleText(), which calls font.GetStringWidth() on many substrings of the input string. Each such call currently creates a temporary DC in RenderTextWin when using canvas_skia_skia.cc. Having a global compatible DC allows all those calls to re-use the same DC instead of creating and deleting them. This needs to be global because CanvasSkia::SizeStringInt() is a static function, so we can't just store it e.g. on the canvas. BUG=105550 TEST=CreateCompatibleDC() and DeleteDC() should disappear from the profiler output when running with use_canvas_skia_skia=1 and rapidly clicking the SSL bubble on paypal.com Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=120594

Patch Set 1 : . #

Total comments: 2

Patch Set 2 : '' #

Total comments: 9

Patch Set 3 : '' #

Patch Set 4 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+163 lines, -7 lines) Patch
M ui/gfx/render_text_win.cc View 1 2 3 6 chunks +7 lines, -7 lines 0 comments Download
A ui/gfx/screen_compatible_dc_win.h View 1 2 3 1 chunk +32 lines, -0 lines 0 comments Download
A ui/gfx/screen_compatible_dc_win.cc View 1 2 1 chunk +122 lines, -0 lines 0 comments Download
M ui/ui.gyp View 1 2 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 16 (0 generated)
Alexei Svitkine (slow)
Hey Scott, Can you take a look at this? After the other performance CLs, this ...
8 years, 10 months ago (2012-02-03 18:09:30 UTC) #1
sky
http://codereview.chromium.org/9323011/diff/2003/ui/gfx/screen.h File ui/gfx/screen.h (right): http://codereview.chromium.org/9323011/diff/2003/ui/gfx/screen.h#newcode68 ui/gfx/screen.h:68: #if defined(OS_WIN) I don't like defining this here. Move ...
8 years, 10 months ago (2012-02-03 18:34:06 UTC) #2
Alexei Svitkine (slow)
Done. Can you take another look?
8 years, 10 months ago (2012-02-03 22:06:51 UTC) #3
sky
http://codereview.chromium.org/9323011/diff/1006/ui/gfx/screen_compatible_dc_win.cc File ui/gfx/screen_compatible_dc_win.cc (right): http://codereview.chromium.org/9323011/diff/1006/ui/gfx/screen_compatible_dc_win.cc#newcode43 ui/gfx/screen_compatible_dc_win.cc:43: LRESULT CALLBACK ListenerWindowProc(HWND hwnd, UINT message, nit: each param ...
8 years, 10 months ago (2012-02-03 23:14:42 UTC) #4
Alexei Svitkine (slow)
http://codereview.chromium.org/9323011/diff/1006/ui/gfx/screen_compatible_dc_win.cc File ui/gfx/screen_compatible_dc_win.cc (right): http://codereview.chromium.org/9323011/diff/1006/ui/gfx/screen_compatible_dc_win.cc#newcode43 ui/gfx/screen_compatible_dc_win.cc:43: LRESULT CALLBACK ListenerWindowProc(HWND hwnd, UINT message, On 2012/02/03 23:14:42, ...
8 years, 10 months ago (2012-02-06 14:37:38 UTC) #5
sky
http://codereview.chromium.org/9323011/diff/1006/ui/gfx/screen_compatible_dc_win.h File ui/gfx/screen_compatible_dc_win.h (right): http://codereview.chromium.org/9323011/diff/1006/ui/gfx/screen_compatible_dc_win.h#newcode22 ui/gfx/screen_compatible_dc_win.h:22: operator HDC() { return hdc_; } On 2012/02/06 14:37:38, ...
8 years, 10 months ago (2012-02-06 16:43:08 UTC) #6
asvitkine_google
> The style guide recommends against it, so I say go with get. Done.
8 years, 10 months ago (2012-02-06 16:47:24 UTC) #7
sky
LGTM
8 years, 10 months ago (2012-02-06 17:00:29 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/asvitkine@chromium.org/9323011/9001
8 years, 10 months ago (2012-02-06 17:33:16 UTC) #9
commit-bot: I haz the power
Change committed as 120594
8 years, 10 months ago (2012-02-06 20:13:37 UTC) #10
cpu_(ooo_6.6-7.5)
1- Are you sure message_only windows get the message you care about? 2- be careful ...
8 years, 10 months ago (2012-02-08 20:50:18 UTC) #11
Alexei Svitkine (slow)
+msw Thanks for checking this over Carlos! On Wed, Feb 8, 2012 at 3:50 PM, ...
8 years, 10 months ago (2012-02-08 22:11:24 UTC) #12
msw
> Hmm... Maybe in this case it's better to just cache it as a static ...
8 years, 10 months ago (2012-02-09 01:49:41 UTC) #13
Alexei Svitkine (slow)
On 2012/02/09 01:49:41, msw wrote: > > Hmm... Maybe in this case it's better to ...
8 years, 10 months ago (2012-02-09 13:55:41 UTC) #14
Alexei Svitkine (slow)
That's not an issue here, since the code calls SelectObject() with the hfont on the ...
8 years, 10 months ago (2012-02-09 13:56:14 UTC) #15
msw
8 years, 10 months ago (2012-02-09 19:05:35 UTC) #16
Then it might be okay to cache a single static HDC. Give it a quick test across
fonts/sizes/resolutions/bit-depths/dpis/etc. in Views examples.

Powered by Google App Engine
This is Rietveld 408576698