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

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: Fix step one more time 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());
236 // Skia will draw glyphs with respect to the baseline. 235 // Skia will draw glyphs with respect to the baseline.
237 offset.Offset(0, common_baseline_); 236 const SkScalar x = SkIntToScalar(GetTextOffset().x());
Peter Kasting 2012/10/31 01:04:41 Nit: FWIW, I had intended to still have a separate
danakj 2012/10/31 16:55:46 Done.
238 237 const SkScalar y = SkIntToScalar(GetTextOffset().y() + common_baseline_);
239 const SkScalar x = SkIntToScalar(offset.x()); 238 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 239
243 const CFRange empty_cf_range = CFRangeMake(0, 0); 240 const CFRange empty_cf_range = CFRangeMake(0, 0);
244 for (CFIndex i = 0; i < ct_runs_count; ++i) { 241 for (CFIndex i = 0; i < ct_runs_count; ++i) {
245 CTRunRef ct_run = 242 CTRunRef ct_run =
246 base::mac::CFCast<CTRunRef>(CFArrayGetValueAtIndex(ct_runs, i)); 243 base::mac::CFCast<CTRunRef>(CFArrayGetValueAtIndex(ct_runs, i));
247 const size_t glyph_count = CTRunGetGlyphCount(ct_run); 244 const size_t glyph_count = CTRunGetGlyphCount(ct_run);
248 const double run_width = 245 const double run_width =
249 CTRunGetTypographicBounds(ct_run, empty_cf_range, NULL, NULL, NULL); 246 CTRunGetTypographicBounds(ct_run, empty_cf_range, NULL, NULL, NULL);
250 if (glyph_count == 0) { 247 if (glyph_count == 0) {
251 run_origin.offset(run_width, 0); 248 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); 312 run_origin.offset(run_width, 0);
316 } 313 }
317 runs_valid_ = true; 314 runs_valid_ = true;
318 } 315 }
319 316
320 RenderText* RenderText::CreateInstance() { 317 RenderText* RenderText::CreateInstance() {
321 return new RenderTextMac; 318 return new RenderTextMac;
322 } 319 }
323 320
324 } // namespace gfx 321 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698