aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-02-22 14:46:11 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-23 19:25:56 +0000
commit108e94a1ab3c72dc346b02294d04e6f15d2fb4b0 (patch)
tree87a1aa145bb37826a49951ab297c17ef9bb6e6c4 /src
parent1022f743758b71bcc476e602679282a0acd64ff1 (diff)
SkScalerContext - make some fields private.
BUG=skia:7515 Change-Id: Id7230db89e47703db465250c8fac99937d69721d Reviewed-on: https://skia-review.googlesource.com/109810 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkGlyphCache.cpp14
-rw-r--r--src/core/SkScalerContext.cpp19
-rw-r--r--src/core/SkScalerContext.h40
-rw-r--r--src/gpu/GrPathRendering.cpp16
4 files changed, 52 insertions, 37 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp
index 16f18639bd..50a1b5fe30 100644
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -391,13 +391,9 @@ void SkGlyphCache::dump() const {
SkString msg;
SkFontStyle style = face->fontStyle();
- msg.printf("cache typeface:%x %25s:(%d,%d,%d) size:%2g [%g %g %g %g] lum:%02X devG:%d pntG:%d cntr:%d glyphs:%3d",
+ msg.printf("cache typeface:%x %25s:(%d,%d,%d)\n %s glyphs:%3d",
face->uniqueID(), name.c_str(), style.weight(), style.width(), style.slant(),
- rec.fTextSize,
- matrix[SkMatrix::kMScaleX], matrix[SkMatrix::kMSkewX],
- matrix[SkMatrix::kMSkewY], matrix[SkMatrix::kMScaleY],
- rec.fLumBits & 0xFF, rec.fDeviceGamma, rec.fPaintGamma, rec.fContrast,
- fGlyphMap.count());
+ rec.dump().c_str(), fGlyphMap.count());
SkDebugf("%s\n", msg.c_str());
}
@@ -557,10 +553,8 @@ static void dump_visitor(const SkGlyphCache& cache, void* context) {
const SkScalerContextRec& rec = cache.getScalerContext()->getRec();
- SkDebugf("[%3d] ID %3d, glyphs %3d, size %g, scale %g, skew %g, [%g %g %g %g]\n",
- index, rec.fFontID, cache.countCachedGlyphs(),
- rec.fTextSize, rec.fPreScaleX, rec.fPreSkewX,
- rec.fPost2x2[0][0], rec.fPost2x2[0][1], rec.fPost2x2[1][0], rec.fPost2x2[1][1]);
+ SkDebugf("index %d\n", index);
+ SkDebugf("%s", rec.dump().c_str());
}
void SkGlyphCache::Dump() {
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index a3d1fbd5d1..a821ec2f5b 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -81,15 +81,9 @@ SkScalerContext::SkScalerContext(sk_sp<SkTypeface> typeface, const SkScalerConte
: SkMaskGamma::PreBlend())
{
#ifdef DUMP_REC
- desc->assertChecksum();
SkDebugf("SkScalerContext checksum %x count %d length %d\n",
desc->getChecksum(), desc->getCount(), desc->getLength());
- SkDebugf(" textsize %g prescale %g preskew %g post [%g %g %g %g]\n",
- rec->fTextSize, rec->fPreScaleX, rec->fPreSkewX, rec->fPost2x2[0][0],
- rec->fPost2x2[0][1], rec->fPost2x2[1][0], rec->fPost2x2[1][1]);
- SkDebugf(" frame %g miter %g hints %d framefill %d format %d join %d cap %d\n",
- rec->fFrameWidth, rec->fMiterLimit, rec->fHints, rec->fFrameAndFill,
- rec->fMaskFormat, rec->fStrokeJoin, rec->fStrokeCap);
+ SkDebugf("%s", fRec.dump().c_str());
SkDebugf(" pathEffect %x maskFilter %x\n",
desc->findEntry(kPathEffect_SkDescriptorTag, nullptr),
desc->findEntry(kMaskFilter_SkDescriptorTag, nullptr));
@@ -1052,8 +1046,6 @@ void SkScalerContext::MakeRecAndEffects(const SkPaint& paint,
rec->setContrast(0.5f);
#endif
- rec->fReservedAlign = 0;
-
// Allow the fonthost to modify our rec before we use it as a key into the
// cache. This way if we're asking for something that they will ignore,
// they can modify our rec up front, so we don't create duplicate cache
@@ -1111,6 +1103,15 @@ void SkScalerContext::MakeRecAndEffects(const SkPaint& paint,
}
}
+SkDescriptor* SkScalerContext::MakeDescriptorForPaths(SkFontID typefaceID,
+ SkAutoDescriptor* ad) {
+ SkScalerContextRec rec;
+ memset(&rec, 0, sizeof(rec));
+ rec.fFontID = typefaceID;
+ rec.fTextSize = SkPaint::kCanonicalTextSizeForPaths;
+ rec.fPreScaleX = rec.fPost2x2[0][0] = rec.fPost2x2[1][1] = SK_Scalar1;
+ return AutoDescriptorGivenRecAndEffects(rec, SkScalerContextEffects(), ad);
+}
SkDescriptor* SkScalerContext::CreateDescriptorAndEffectsUsingPaint(
const SkPaint& paint, const SkSurfaceProps* surfaceProps,
diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h
index 9ad22d24d4..086296d2e4 100644
--- a/src/core/SkScalerContext.h
+++ b/src/core/SkScalerContext.h
@@ -23,6 +23,8 @@ class SkAutoDescriptor;
class SkDescriptor;
class SkMaskFilter;
class SkPathEffect;
+class SkScalerContext;
+class SkScalerContext_DW;
enum SkScalerContextFlags : uint32_t {
kNone = 0,
@@ -54,17 +56,21 @@ enum SkAxisAlignment {
* than a nested struct inside SkScalerContext (where it started).
*/
struct SkScalerContextRec {
+
uint32_t fFontID;
SkScalar fTextSize, fPreScaleX, fPreSkewX;
SkScalar fPost2x2[2][2];
SkScalar fFrameWidth, fMiterLimit;
+private:
//These describe the parameters to create (uniquely identify) the pre-blend.
- uint32_t fLumBits;
- uint8_t fDeviceGamma; //2.6, (0.0, 4.0) gamma, 0.0 for sRGB
- uint8_t fPaintGamma; //2.6, (0.0, 4.0) gamma, 0.0 for sRGB
- uint8_t fContrast; //0.8+1, [0.0, 1.0] artificial contrast
- uint8_t fReservedAlign;
+ uint32_t fLumBits;
+ uint8_t fDeviceGamma; //2.6, (0.0, 4.0) gamma, 0.0 for sRGB
+ uint8_t fPaintGamma; //2.6, (0.0, 4.0) gamma, 0.0 for sRGB
+ uint8_t fContrast; //0.8+1, [0.0, 1.0] artificial contrast
+ const uint8_t fReservedAlign{0};
+
+public:
SkScalar getDeviceGamma() const {
return SkIntToScalar(fDeviceGamma) / (1 << 6);
@@ -110,14 +116,29 @@ struct SkScalerContextRec {
}
uint8_t fMaskFormat;
+private:
uint8_t fStrokeJoin : 4;
uint8_t fStrokeCap : 4;
+
+public:
uint16_t fFlags;
+
// Warning: when adding members note that the size of this structure
// must be a multiple of 4. SkDescriptor requires that its arguments be
// multiples of four and this structure is put in an SkDescriptor in
// SkPaint::MakeRecAndEffects.
+ SkString dump() const {
+ SkString msg;
+ msg.appendf("Rec\n");
+ msg.appendf(" textsize %g prescale %g preskew %g post [%g %g %g %g]\n",
+ fTextSize, fPreScaleX, fPreSkewX, fPost2x2[0][0],
+ fPost2x2[0][1], fPost2x2[1][0], fPost2x2[1][1]);
+ msg.appendf(" frame %g miter %g format %d join %d cap %d flags %#hx\n",
+ fFrameWidth, fMiterLimit, fMaskFormat, fStrokeJoin, fStrokeCap, fFlags);
+ return msg;
+ }
+
void getMatrixFrom2x2(SkMatrix*) const;
void getLocalMatrix(SkMatrix*) const;
void getSingleMatrix(SkMatrix*) const;
@@ -174,10 +195,16 @@ struct SkScalerContextRec {
return static_cast<SkMask::Format>(fMaskFormat);
}
+private:
+ // TODO: get rid of these bad friends.
+ friend class SkScalerContext;
+ friend class SkScalerContext_DW;
+
SkColor getLuminanceColor() const {
return fLumBits;
}
+
void setLuminanceColor(SkColor c) {
fLumBits = c;
}
@@ -282,6 +309,9 @@ public:
SkScalerContextRec* rec,
SkScalerContextEffects* effects);
+ static SkDescriptor* MakeDescriptorForPaths(SkFontID fontID,
+ SkAutoDescriptor* ad);
+
static SkDescriptor* AutoDescriptorGivenRecAndEffects(
const SkScalerContextRec& rec,
const SkScalerContextEffects& effects,
diff --git a/src/gpu/GrPathRendering.cpp b/src/gpu/GrPathRendering.cpp
index f0d5f90ab8..1f15402c06 100644
--- a/src/gpu/GrPathRendering.cpp
+++ b/src/gpu/GrPathRendering.cpp
@@ -86,19 +86,9 @@ sk_sp<GrPathRange> GrPathRendering::createGlyphs(const SkTypeface* typeface,
return this->createPathRange(generator.get(), style);
}
- SkScalerContextRec rec;
- memset(&rec, 0, sizeof(rec));
- rec.fFontID = typeface->uniqueID();
- rec.fTextSize = SkPaint::kCanonicalTextSizeForPaths;
- rec.fPreScaleX = rec.fPost2x2[0][0] = rec.fPost2x2[1][1] = SK_Scalar1;
- // Don't bake stroke information into the glyphs, we'll let the GPU do the stroking.
-
- SkAutoDescriptor ad(sizeof(rec) + SkDescriptor::ComputeOverhead(1));
- SkDescriptor* genericDesc = ad.getDesc();
-
- genericDesc->init();
- genericDesc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
- genericDesc->computeChecksum();
+ SkAutoDescriptor ad;
+ SkDescriptor* genericDesc =
+ SkScalerContext::MakeDescriptorForPaths(typeface->uniqueID(), &ad);
// No effects, so we make a dummy struct
SkScalerContextEffects noEffects;