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

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

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RenderText fixup Created 8 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 unified diff | Download patch | Annotate | Revision Log
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_mac.h" 5 #include "ui/gfx/render_text_mac.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 225 }
226 } 226 }
227 } 227 }
228 228
229 void RenderTextMac::ComputeRuns() { 229 void RenderTextMac::ComputeRuns() {
230 DCHECK(line_); 230 DCHECK(line_);
231 231
232 CFArrayRef ct_runs = CTLineGetGlyphRuns(line_); 232 CFArrayRef ct_runs = CTLineGetGlyphRuns(line_);
233 const CFIndex ct_runs_count = CFArrayGetCount(ct_runs); 233 const CFIndex ct_runs_count = CFArrayGetCount(ct_runs);
234 234
235 Point offset(GetTextOrigin()); 235 gfx::Vector2d text_offset = GetTextOffset();
236
236 // Skia will draw glyphs with respect to the baseline. 237 // Skia will draw glyphs with respect to the baseline.
237 offset.Offset(0, common_baseline_); 238 const SkScalar x = SkIntToScalar(text_offset.x());
238 239 const SkScalar y = SkIntToScalar(text_offset.y() + common_baseline_);
239 const SkScalar x = SkIntToScalar(offset.x()); 240 SkPoint run_origin = SkPoint::Make(x, y);
240 const SkScalar y = SkIntToScalar(offset.y());
241 SkPoint run_origin = SkPoint::Make(offset.x(), offset.y());
242 241
243 const CFRange empty_cf_range = CFRangeMake(0, 0); 242 const CFRange empty_cf_range = CFRangeMake(0, 0);
244 for (CFIndex i = 0; i < ct_runs_count; ++i) { 243 for (CFIndex i = 0; i < ct_runs_count; ++i) {
245 CTRunRef ct_run = 244 CTRunRef ct_run =
246 base::mac::CFCast<CTRunRef>(CFArrayGetValueAtIndex(ct_runs, i)); 245 base::mac::CFCast<CTRunRef>(CFArrayGetValueAtIndex(ct_runs, i));
247 const size_t glyph_count = CTRunGetGlyphCount(ct_run); 246 const size_t glyph_count = CTRunGetGlyphCount(ct_run);
248 const double run_width = 247 const double run_width =
249 CTRunGetTypographicBounds(ct_run, empty_cf_range, NULL, NULL, NULL); 248 CTRunGetTypographicBounds(ct_run, empty_cf_range, NULL, NULL, NULL);
250 if (glyph_count == 0) { 249 if (glyph_count == 0) {
251 run_origin.offset(run_width, 0); 250 run_origin.offset(run_width, 0);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 run_origin.offset(run_width, 0); 314 run_origin.offset(run_width, 0);
316 } 315 }
317 runs_valid_ = true; 316 runs_valid_ = true;
318 } 317 }
319 318
320 RenderText* RenderText::CreateInstance() { 319 RenderText* RenderText::CreateInstance() {
321 return new RenderTextMac; 320 return new RenderTextMac;
322 } 321 }
323 322
324 } // namespace gfx 323 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698