Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 8 | #include "SkTypeface_remote.h" |
Mike Klein | fc6cf92 | 2018-05-23 00:16:47 +0000 | [diff] [blame] | 9 | #include "SkPaint.h" |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 10 | #include "SkRemoteGlyphCache.h" |
| 11 | #include "SkStrikeCache.h" |
| 12 | #include "SkTraceEvent.h" |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 13 | |
| 14 | SkScalerContextProxy::SkScalerContextProxy(sk_sp<SkTypeface> tf, |
| 15 | const SkScalerContextEffects& effects, |
| 16 | const SkDescriptor* desc, |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 17 | sk_sp<SkStrikeClient::DiscardableHandleManager> manager) |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame^] | 18 | : SkScalerContext{std::move(tf), effects, desc} |
| 19 | , fDiscardableManager{std::move(manager)} {} |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 20 | |
| 21 | unsigned SkScalerContextProxy::generateGlyphCount() { |
| 22 | SK_ABORT("Should never be called."); |
| 23 | return 0; |
| 24 | } |
| 25 | |
| 26 | uint16_t SkScalerContextProxy::generateCharToGlyph(SkUnichar) { |
| 27 | SK_ABORT("Should never be called."); |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | void SkScalerContextProxy::generateAdvance(SkGlyph* glyph) { |
| 32 | this->generateMetrics(glyph); |
| 33 | } |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 34 | |
| 35 | void SkScalerContextProxy::generateMetrics(SkGlyph* glyph) { |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 36 | TRACE_EVENT1("skia", "generateMetrics", "rec", TRACE_STR_COPY(this->getRec().dump().c_str())); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame^] | 37 | if (this->getProxyTypeface()->isLogging()) { |
| 38 | SkDebugf("GlyphCacheMiss generateMetrics: %s\n", this->getRec().dump().c_str()); |
| 39 | } |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 40 | |
| 41 | fDiscardableManager->NotifyCacheMiss(SkStrikeClient::CacheMissType::kGlyphMetrics); |
| 42 | glyph->zeroMetrics(); |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | void SkScalerContextProxy::generateImage(const SkGlyph& glyph) { |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 46 | TRACE_EVENT1("skia", "generateImage", "rec", TRACE_STR_COPY(this->getRec().dump().c_str())); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame^] | 47 | if (this->getProxyTypeface()->isLogging()) { |
| 48 | SkDebugf("GlyphCacheMiss generateImage: %s\n", this->getRec().dump().c_str()); |
| 49 | } |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 50 | |
| 51 | fDiscardableManager->NotifyCacheMiss(SkStrikeClient::CacheMissType::kGlyphImage); |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 52 | } |
| 53 | |
Ben Wagner | 5ddb308 | 2018-03-29 11:18:06 -0400 | [diff] [blame] | 54 | bool SkScalerContextProxy::generatePath(SkGlyphID glyphID, SkPath* path) { |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 55 | TRACE_EVENT1("skia", "generatePath", "rec", TRACE_STR_COPY(this->getRec().dump().c_str())); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame^] | 56 | if (this->getProxyTypeface()->isLogging()) { |
| 57 | SkDebugf("GlyphCacheMiss generatePath: %s\n", this->getRec().dump().c_str()); |
| 58 | } |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 59 | |
| 60 | fDiscardableManager->NotifyCacheMiss(SkStrikeClient::CacheMissType::kGlyphPath); |
Khushal | 2d2fedd | 2018-05-16 16:07:24 -0700 | [diff] [blame] | 61 | return false; |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | void SkScalerContextProxy::generateFontMetrics(SkPaint::FontMetrics* metrics) { |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 65 | TRACE_EVENT1( |
| 66 | "skia", "generateFontMetrics", "rec", TRACE_STR_COPY(this->getRec().dump().c_str())); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame^] | 67 | if (this->getProxyTypeface()->isLogging()) { |
| 68 | SkDebugf("GlyphCacheMiss generateFontMetrics: %s\n", this->getRec().dump().c_str()); |
| 69 | SkDEBUGCODE(SkStrikeCache::Dump()); |
| 70 | } |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 71 | |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 72 | fDiscardableManager->NotifyCacheMiss(SkStrikeClient::CacheMissType::kFontMetrics); |
| 73 | sk_bzero(metrics, sizeof(*metrics)); |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 74 | } |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame^] | 75 | |
| 76 | SkTypefaceProxy* SkScalerContextProxy::getProxyTypeface() const { |
| 77 | return (SkTypefaceProxy*)this->getTypeface(); |
| 78 | } |