OLD | NEW |
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 , m_deviceScaleFactor(deviceScaleFactor) | 259 , m_deviceScaleFactor(deviceScaleFactor) |
260 , m_hasVerticalOffsets(buffer.hasVerticalOffsets()) | 260 , m_hasVerticalOffsets(buffer.hasVerticalOffsets()) |
261 , m_index(0) | 261 , m_index(0) |
262 , m_blobCount(0) | 262 , m_blobCount(0) |
263 , m_rotation(buffer.isEmpty() ? NoRotation : computeBlobRotation(buffer.
fontDataAt(0))) | 263 , m_rotation(buffer.isEmpty() ? NoRotation : computeBlobRotation(buffer.
fontDataAt(0))) |
264 { } | 264 { } |
265 | 265 |
266 bool done() const { return m_index >= m_buffer.size(); } | 266 bool done() const { return m_index >= m_buffer.size(); } |
267 unsigned blobCount() const { return m_blobCount; } | 267 unsigned blobCount() const { return m_blobCount; } |
268 | 268 |
269 std::pair<sk_sp<const SkTextBlob>, BlobRotation> next() | 269 std::pair<sk_sp<SkTextBlob>, BlobRotation> next() |
270 { | 270 { |
271 ASSERT(!done()); | 271 ASSERT(!done()); |
272 const BlobRotation currentRotation = m_rotation; | 272 const BlobRotation currentRotation = m_rotation; |
273 | 273 |
274 while (m_index < m_buffer.size()) { | 274 while (m_index < m_buffer.size()) { |
275 const SimpleFontData* fontData = m_buffer.fontDataAt(m_index); | 275 const SimpleFontData* fontData = m_buffer.fontDataAt(m_index); |
276 ASSERT(fontData); | 276 ASSERT(fontData); |
277 | 277 |
278 const BlobRotation newRotation = computeBlobRotation(fontData); | 278 const BlobRotation newRotation = computeBlobRotation(fontData); |
279 if (newRotation != m_rotation) { | 279 if (newRotation != m_rotation) { |
280 // We're switching to an orientation which requires a different
rotation | 280 // We're switching to an orientation which requires a different
rotation |
281 // => emit the pending blob (and start a new one with the new
rotation). | 281 // => emit the pending blob (and start a new one with the new
rotation). |
282 m_rotation = newRotation; | 282 m_rotation = newRotation; |
283 break; | 283 break; |
284 } | 284 } |
285 | 285 |
286 const unsigned start = m_index++; | 286 const unsigned start = m_index++; |
287 while (m_index < m_buffer.size() && m_buffer.fontDataAt(m_index) ==
fontData) | 287 while (m_index < m_buffer.size() && m_buffer.fontDataAt(m_index) ==
fontData) |
288 m_index++; | 288 m_index++; |
289 | 289 |
290 appendRun(start, m_index - start, fontData); | 290 appendRun(start, m_index - start, fontData); |
291 } | 291 } |
292 | 292 |
293 m_blobCount++; | 293 m_blobCount++; |
294 return std::make_pair(sk_sp<const SkTextBlob>(m_builder.build()), curren
tRotation); | 294 return std::make_pair(m_builder.make(), currentRotation); |
295 } | 295 } |
296 | 296 |
297 private: | 297 private: |
298 static BlobRotation computeBlobRotation(const SimpleFontData* font) | 298 static BlobRotation computeBlobRotation(const SimpleFontData* font) |
299 { | 299 { |
300 // For vertical upright text we need to compensate the inherited 90deg C
W rotation | 300 // For vertical upright text we need to compensate the inherited 90deg C
W rotation |
301 // (using a 90deg CCW rotation). | 301 // (using a 90deg CCW rotation). |
302 return (font->platformData().isVerticalAnyUpright() && font->verticalDat
a()) ? | 302 return (font->platformData().isVerticalAnyUpright() && font->verticalDat
a()) ? |
303 CCWRotation : NoRotation; | 303 CCWRotation : NoRotation; |
304 } | 304 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 unsigned m_blobCount; | 343 unsigned m_blobCount; |
344 BlobRotation m_rotation; | 344 BlobRotation m_rotation; |
345 }; | 345 }; |
346 | 346 |
347 } // anonymous namespace | 347 } // anonymous namespace |
348 | 348 |
349 void Font::drawGlyphBuffer(SkCanvas* canvas, const SkPaint& paint, const TextRun
PaintInfo& runInfo, | 349 void Font::drawGlyphBuffer(SkCanvas* canvas, const SkPaint& paint, const TextRun
PaintInfo& runInfo, |
350 const GlyphBuffer& glyphBuffer, const FloatPoint& point, float deviceScaleFa
ctor) const | 350 const GlyphBuffer& glyphBuffer, const FloatPoint& point, float deviceScaleFa
ctor) const |
351 { | 351 { |
352 GlyphBufferBloberizer bloberizer(glyphBuffer, this, deviceScaleFactor); | 352 GlyphBufferBloberizer bloberizer(glyphBuffer, this, deviceScaleFactor); |
353 std::pair<sk_sp<const SkTextBlob>, BlobRotation> blob; | 353 std::pair<sk_sp<SkTextBlob>, BlobRotation> blob; |
354 | 354 |
355 while (!bloberizer.done()) { | 355 while (!bloberizer.done()) { |
356 blob = bloberizer.next(); | 356 blob = bloberizer.next(); |
357 ASSERT(blob.first); | 357 ASSERT(blob.first); |
358 | 358 |
359 SkAutoCanvasRestore autoRestore(canvas, false); | 359 SkAutoCanvasRestore autoRestore(canvas, false); |
360 if (blob.second == CCWRotation) { | 360 if (blob.second == CCWRotation) { |
361 canvas->save(); | 361 canvas->save(); |
362 | 362 |
363 SkMatrix m; | 363 SkMatrix m; |
364 m.setSinCos(-1, 0, point.x(), point.y()); | 364 m.setSinCos(-1, 0, point.x(), point.y()); |
365 canvas->concat(m); | 365 canvas->concat(m); |
366 } | 366 } |
367 | 367 |
368 canvas->drawTextBlob(blob.first.get(), point.x(), point.y(), paint); | 368 canvas->drawTextBlob(blob.first, point.x(), point.y(), paint); |
369 } | 369 } |
370 | 370 |
371 // Cache results when | 371 // Cache results when |
372 // 1) requested by clients, and | 372 // 1) requested by clients, and |
373 // 2) the glyph buffer is encoded as a single blob, and | 373 // 2) the glyph buffer is encoded as a single blob, and |
374 // 3) the blob is not upright/rotated | 374 // 3) the blob is not upright/rotated |
375 if (runInfo.cachedTextBlob && bloberizer.blobCount() == 1 && blob.second ==
NoRotation) { | 375 if (runInfo.cachedTextBlob && bloberizer.blobCount() == 1 && blob.second ==
NoRotation) { |
376 ASSERT(!*runInfo.cachedTextBlob); | 376 ASSERT(!*runInfo.cachedTextBlob); |
377 *runInfo.cachedTextBlob = std::move(blob.first); | 377 *runInfo.cachedTextBlob = std::move(blob.first); |
378 ASSERT(*runInfo.cachedTextBlob); | 378 ASSERT(*runInfo.cachedTextBlob); |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 { | 853 { |
854 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); | 854 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); |
855 } | 855 } |
856 | 856 |
857 bool Font::isFallbackValid() const | 857 bool Font::isFallbackValid() const |
858 { | 858 { |
859 return !m_fontFallbackList || m_fontFallbackList->isValid(); | 859 return !m_fontFallbackList || m_fontFallbackList->isValid(); |
860 } | 860 } |
861 | 861 |
862 } // namespace blink | 862 } // namespace blink |
OLD | NEW |