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

Side by Side Diff: Source/platform/fonts/Font.cpp

Issue 692643007: [TextBlob] Plumb a Font param for setupPaint(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 256
257 if (glyphOverflow) 257 if (glyphOverflow)
258 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow) ; 258 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow) ;
259 return result; 259 return result;
260 } 260 }
261 261
262 namespace { 262 namespace {
263 263
264 template <bool hasOffsets> 264 template <bool hasOffsets>
265 bool buildTextBlobInternal(const GlyphBuffer& glyphBuffer, SkScalar initialAdvan ce, 265 bool buildTextBlobInternal(const GlyphBuffer& glyphBuffer, SkScalar initialAdvan ce,
266 const SkRect* bounds, bool couldUseLCD, SkTextBlobBuilder& builder) 266 const SkRect* bounds, bool couldUseLCD, SkTextBlobBuilder& builder, const Fo nt& font)
267 { 267 {
268 SkScalar x = initialAdvance; 268 SkScalar x = initialAdvance;
269 unsigned i = 0; 269 unsigned i = 0;
270 while (i < glyphBuffer.size()) { 270 while (i < glyphBuffer.size()) {
271 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i); 271 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i);
272 272
273 // FIXME: Handle vertical text. 273 // FIXME: Handle vertical text.
274 if (fontData->platformData().orientation() == Vertical) 274 if (fontData->platformData().orientation() == Vertical)
275 return false; 275 return false;
276 276
277 // FIXME: FontPlatformData makes some decisions on the device scale 277 // FIXME: FontPlatformData makes some decisions on the device scale
278 // factor, which is found via the GraphicsContext. This should be fixed 278 // factor, which is found via the GraphicsContext. This should be fixed
279 // to avoid correctness problems here. 279 // to avoid correctness problems here.
280 SkPaint paint; 280 SkPaint paint;
281 fontData->platformData().setupPaint(&paint); 281 fontData->platformData().setupPaint(&paint, 0, &font);
282 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 282 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
283 283
284 // FIXME: this should go away after the big LCD cleanup. 284 // FIXME: this should go away after the big LCD cleanup.
285 paint.setLCDRenderText(paint.isLCDRenderText() && couldUseLCD); 285 paint.setLCDRenderText(paint.isLCDRenderText() && couldUseLCD);
286 286
287 unsigned start = i++; 287 unsigned start = i++;
288 while (i < glyphBuffer.size() && glyphBuffer.fontDataAt(i) == fontData) 288 while (i < glyphBuffer.size() && glyphBuffer.fontDataAt(i) == fontData)
289 i++; 289 i++;
290 unsigned count = i - start; 290 unsigned count = i - start;
291 291
(...skipping 25 matching lines...) Expand all
317 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, float initia lAdvance, 317 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, float initia lAdvance,
318 const FloatRect& bounds, bool couldUseLCD) const 318 const FloatRect& bounds, bool couldUseLCD) const
319 { 319 {
320 ASSERT(RuntimeEnabledFeatures::textBlobEnabled()); 320 ASSERT(RuntimeEnabledFeatures::textBlobEnabled());
321 321
322 SkTextBlobBuilder builder; 322 SkTextBlobBuilder builder;
323 SkScalar advance = SkFloatToScalar(initialAdvance); 323 SkScalar advance = SkFloatToScalar(initialAdvance);
324 SkRect skBounds = bounds; 324 SkRect skBounds = bounds;
325 325
326 bool success = glyphBuffer.hasOffsets() ? 326 bool success = glyphBuffer.hasOffsets() ?
327 buildTextBlobInternal<true>(glyphBuffer, advance, &skBounds, couldUseLCD , builder) : 327 buildTextBlobInternal<true>(glyphBuffer, advance, &skBounds, couldUseLCD , builder, *this) :
328 buildTextBlobInternal<false>(glyphBuffer, advance, &skBounds, couldUseLC D, builder); 328 buildTextBlobInternal<false>(glyphBuffer, advance, &skBounds, couldUseLC D, builder, *this);
329 return success ? adoptRef(builder.build()) : nullptr; 329 return success ? adoptRef(builder.build()) : nullptr;
330 } 330 }
331 331
332 static inline FloatRect pixelSnappedSelectionRect(FloatRect rect) 332 static inline FloatRect pixelSnappedSelectionRect(FloatRect rect)
333 { 333 {
334 // Using roundf() rather than ceilf() for the right edge as a compromise to 334 // Using roundf() rather than ceilf() for the right edge as a compromise to
335 // ensure correct caret positioning. 335 // ensure correct caret positioning.
336 float roundedX = roundf(rect.x()); 336 float roundedX = roundf(rect.x());
337 return FloatRect(roundedX, rect.y(), roundf(rect.maxX() - roundedX), rect.he ight()); 337 return FloatRect(roundedX, rect.y(), roundf(rect.maxX() - roundedX), rect.he ight());
338 } 338 }
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 if (delta <= 0) 1096 if (delta <= 0)
1097 break; 1097 break;
1098 } 1098 }
1099 } 1099 }
1100 } 1100 }
1101 1101
1102 return offset; 1102 return offset;
1103 } 1103 }
1104 1104
1105 } // namespace blink 1105 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698