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

Unified Diff: ui/gfx/render_text_win.cc

Issue 8515012: Avoid unnecessary work in |RenderTextWin::UpdateLayout()| if there are no runs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/render_text_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_win.cc
===================================================================
--- ui/gfx/render_text_win.cc (revision 109436)
+++ ui/gfx/render_text_win.cc (working copy)
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "base/stl_util.h"
#include "base/string_util.h"
+#include "base/win/scoped_hdc.h"
#include "third_party/skia/include/core/SkTypeface.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/canvas_skia.h"
@@ -316,9 +317,8 @@
void RenderTextWin::UpdateLayout() {
// TODO(msw): Skip complex processing if ScriptIsComplex returns false.
ItemizeLogicalText();
- HDC hdc = CreateCompatibleDC(NULL);
- LayoutVisualText(hdc);
- DeleteDC(hdc);
+ if (!runs_.empty())
+ LayoutVisualText();
}
size_t RenderTextWin::IndexOfAdjacentGrapheme(size_t index, bool next) {
@@ -398,8 +398,9 @@
}
}
-void RenderTextWin::LayoutVisualText(HDC hdc) {
+void RenderTextWin::LayoutVisualText() {
HRESULT hr = E_FAIL;
+ base::win::ScopedCreateDC hdc(CreateCompatibleDC(NULL));
std::vector<internal::TextRun*>::const_iterator run_iter;
for (run_iter = runs_.begin(); run_iter < runs_.end(); ++run_iter) {
internal::TextRun* run = *run_iter;
« no previous file with comments | « ui/gfx/render_text_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698