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

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_compatible_dc_win.h » ('j') | ui/gfx/screen_compatible_dc_win.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" 14 #include "ui/gfx/screen_compatible_dc_win.h"
15 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/canvas_skia.h" 16 #include "ui/gfx/canvas_skia.h"
17 #include "ui/gfx/platform_font.h" 17 #include "ui/gfx/platform_font.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;
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 script_item++; 588 script_item++;
589 if (script_item_end >= style_range_end) 589 if (script_item_end >= style_range_end)
590 style++; 590 style++;
591 run->range.set_end(run_break); 591 run->range.set_end(run_break);
592 runs_.push_back(run); 592 runs_.push_back(run);
593 } 593 }
594 } 594 }
595 595
596 void RenderTextWin::LayoutVisualText() { 596 void RenderTextWin::LayoutVisualText() {
597 HRESULT hr = E_FAIL; 597 HRESULT hr = E_FAIL;
598 base::win::ScopedCreateDC hdc(CreateCompatibleDC(NULL)); 598 ScopedTemporaryScreenCompatibleDC hdc;
599 std::vector<internal::TextRun*>::const_iterator run_iter; 599 std::vector<internal::TextRun*>::const_iterator run_iter;
600 for (run_iter = runs_.begin(); run_iter < runs_.end(); ++run_iter) { 600 for (run_iter = runs_.begin(); run_iter < runs_.end(); ++run_iter) {
601 internal::TextRun* run = *run_iter; 601 internal::TextRun* run = *run_iter;
602 size_t run_length = run->range.length(); 602 size_t run_length = run->range.length();
603 const wchar_t* run_text = &(text()[run->range.start()]); 603 const wchar_t* run_text = &(text()[run->range.start()]);
604 bool tried_fallback = false; 604 bool tried_fallback = false;
605 605
606 // Select the font desired for glyph generation. 606 // Select the font desired for glyph generation.
607 SelectObject(hdc, run->font.GetNativeFont()); 607 SelectObject(hdc, run->font.GetNativeFont());
608 608
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 internal::TextRun* run) { 734 internal::TextRun* run) {
735 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD); 735 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD);
736 return SelectionModel(caret, caret, SelectionModel::LEADING); 736 return SelectionModel(caret, caret, SelectionModel::LEADING);
737 } 737 }
738 738
739 RenderText* RenderText::CreateRenderText() { 739 RenderText* RenderText::CreateRenderText() {
740 return new RenderTextWin; 740 return new RenderTextWin;
741 } 741 }
742 742
743 } // namespace gfx 743 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/screen_compatible_dc_win.h » ('j') | ui/gfx/screen_compatible_dc_win.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698