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

Unified Diff: ui/gfx/render_text_mac.mm

Issue 1925033002: RenderText: Don't default-construct gfx::Fonts unnecessarily (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove gfx::Font from RTM completely Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/render_text_mac.h ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_mac.mm
diff --git a/ui/gfx/render_text_mac.mm b/ui/gfx/render_text_mac.mm
index 915f51f927a75e665124221256000cce10843102..5a4e5b115b99aa6f1033438e549d602e954e9a76 100644
--- a/ui/gfx/render_text_mac.mm
+++ b/ui/gfx/render_text_mac.mm
@@ -118,7 +118,8 @@ std::vector<RenderText::FontSpan> RenderTextMac::GetFontSpansForTesting() {
for (size_t i = 0; i < runs_.size(); ++i) {
const CFRange cf_range = CTRunGetStringRange(runs_[i].ct_run);
const Range range(cf_range.location, cf_range.location + cf_range.length);
- spans.push_back(RenderText::FontSpan(runs_[i].font, range));
+ spans.push_back(RenderText::FontSpan(
+ gfx::Font(base::mac::CFToNSCast(runs_[i].ct_font.get())), range));
}
return spans;
@@ -210,9 +211,7 @@ void RenderTextMac::DrawVisualText(internal::SkiaTextRenderer* renderer) {
for (size_t i = 0; i < runs_.size(); ++i) {
const TextRun& run = runs_[i];
renderer->SetForegroundColor(run.foreground);
-
- CTFontRef ct_font = static_cast<CTFontRef>(run.font.GetNativeFont());
- renderer->SetTextSize(CTFontGetSize(ct_font));
+ renderer->SetTextSize(CTFontGetSize(run.ct_font));
// The painter adds its own ref. So don't |release()| it from the ref ptr in
// TextRun.
@@ -236,7 +235,7 @@ RenderTextMac::TextRun::TextRun()
strike(false),
diagonal_strike(false) {}
-RenderTextMac::TextRun::TextRun(const TextRun& other) = default;
+RenderTextMac::TextRun::TextRun(TextRun&& other) = default;
RenderTextMac::TextRun::~TextRun() {}
@@ -379,7 +378,7 @@ void RenderTextMac::ComputeRuns() {
continue;
}
- runs_.push_back(TextRun());
+ runs_.emplace_back();
TextRun* run = &runs_.back();
run->ct_run = ct_run;
run->origin = run_origin;
@@ -414,7 +413,7 @@ void RenderTextMac::ComputeRuns() {
CFDictionaryRef attributes = CTRunGetAttributes(ct_run);
CTFontRef ct_font = base::mac::GetValueFromDictionary<CTFontRef>(
attributes, kCTFontAttributeName);
- run->font = Font(static_cast<NSFont*>(ct_font));
+ run->ct_font.reset(ct_font, base::scoped_policy::RETAIN);
run->typeface.reset(SkCreateTypefaceFromCTFont(ct_font));
const CGColorRef foreground = base::mac::GetValueFromDictionary<CGColorRef>(
« no previous file with comments | « ui/gfx/render_text_mac.h ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698