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

Side by Side Diff: ui/gfx/render_text_win.cc

Issue 9323011: Cache a screen compatible DC to avoid re-creating it excessively. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: . Created 8 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/gfx/screen.h » ('j') | ui/gfx/screen.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/render_text_win.h" 5 #include "ui/gfx/render_text_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/break_iterator.h" 9 #include "base/i18n/break_iterator.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "base/win/scoped_hdc.h"
15 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/canvas_skia.h" 15 #include "ui/gfx/canvas_skia.h"
17 #include "ui/gfx/platform_font.h" 16 #include "ui/gfx/platform_font.h"
17 #include "ui/gfx/screen.h"
18 18
19 namespace { 19 namespace {
20 20
21 // The maximum supported number of Uniscribe runs; a SCRIPT_ITEM is 8 bytes. 21 // The maximum supported number of Uniscribe runs; a SCRIPT_ITEM is 8 bytes.
22 // TODO(msw): Review memory use/failure? Max string length? Alternate approach? 22 // TODO(msw): Review memory use/failure? Max string length? Alternate approach?
23 const int kGuessItems = 100; 23 const int kGuessItems = 100;
24 const int kMaxItems = 10000; 24 const int kMaxItems = 10000;
25 25
26 // The maximum supported number of Uniscribe glyphs; a glyph is 1 word. 26 // The maximum supported number of Uniscribe glyphs; a glyph is 1 word.
27 // TODO(msw): Review memory use/failure? Max string length? Alternate approach? 27 // TODO(msw): Review memory use/failure? Max string length? Alternate approach?
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 script_item++; 589 script_item++;
590 if (script_item_end >= style_range_end) 590 if (script_item_end >= style_range_end)
591 style++; 591 style++;
592 run->range.set_end(run_break); 592 run->range.set_end(run_break);
593 runs_.push_back(run); 593 runs_.push_back(run);
594 } 594 }
595 } 595 }
596 596
597 void RenderTextWin::LayoutVisualText() { 597 void RenderTextWin::LayoutVisualText() {
598 HRESULT hr = E_FAIL; 598 HRESULT hr = E_FAIL;
599 base::win::ScopedCreateDC hdc(CreateCompatibleDC(NULL)); 599 HDC hdc = Screen::GetCompatibleDC();
600 std::vector<internal::TextRun*>::const_iterator run_iter; 600 std::vector<internal::TextRun*>::const_iterator run_iter;
601 for (run_iter = runs_.begin(); run_iter < runs_.end(); ++run_iter) { 601 for (run_iter = runs_.begin(); run_iter < runs_.end(); ++run_iter) {
602 internal::TextRun* run = *run_iter; 602 internal::TextRun* run = *run_iter;
603 size_t run_length = run->range.length(); 603 size_t run_length = run->range.length();
604 const wchar_t* run_text = &(text()[run->range.start()]); 604 const wchar_t* run_text = &(text()[run->range.start()]);
605 bool tried_fallback = false; 605 bool tried_fallback = false;
606 606
607 // Select the font desired for glyph generation. 607 // Select the font desired for glyph generation.
608 SelectObject(hdc, run->font.GetNativeFont()); 608 SelectObject(hdc, run->font.GetNativeFont());
609 609
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 internal::TextRun* run) { 735 internal::TextRun* run) {
736 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD); 736 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD);
737 return SelectionModel(caret, caret, SelectionModel::LEADING); 737 return SelectionModel(caret, caret, SelectionModel::LEADING);
738 } 738 }
739 739
740 RenderText* RenderText::CreateRenderText() { 740 RenderText* RenderText::CreateRenderText() {
741 return new RenderTextWin; 741 return new RenderTextWin;
742 } 742 }
743 743
744 } // namespace gfx 744 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/screen.h » ('j') | ui/gfx/screen.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698