summaryrefslogtreecommitdiff
path: root/chromium/third_party/skia/src/utils
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/third_party/skia/src/utils
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/skia/src/utils')
-rw-r--r--chromium/third_party/skia/src/utils/SkCamera.cpp238
-rw-r--r--chromium/third_party/skia/src/utils/SkClipStackUtils.cpp5
-rw-r--r--chromium/third_party/skia/src/utils/SkCustomTypeface.cpp118
-rw-r--r--chromium/third_party/skia/src/utils/SkJSON.cpp46
-rw-r--r--chromium/third_party/skia/src/utils/SkJSON.h72
-rw-r--r--chromium/third_party/skia/src/utils/SkLuaCanvas.cpp4
-rw-r--r--chromium/third_party/skia/src/utils/SkParseColor.cpp363
-rw-r--r--chromium/third_party/skia/src/utils/SkParsePath.cpp2
-rw-r--r--chromium/third_party/skia/src/utils/SkShadowUtils.cpp11
-rw-r--r--chromium/third_party/skia/src/utils/mac/SkCGBase.h37
-rw-r--r--chromium/third_party/skia/src/utils/mac/SkCGGeometry.h52
-rw-r--r--chromium/third_party/skia/src/utils/mac/SkCTFontSmoothBehavior.cpp271
-rw-r--r--chromium/third_party/skia/src/utils/mac/SkCTFontSmoothBehavior.h23
-rw-r--r--chromium/third_party/skia/src/utils/mac/SkStream_mac.cpp8
14 files changed, 745 insertions, 505 deletions
diff --git a/chromium/third_party/skia/src/utils/SkCamera.cpp b/chromium/third_party/skia/src/utils/SkCamera.cpp
index 63d1c804fa4..45e216edb27 100644
--- a/chromium/third_party/skia/src/utils/SkCamera.cpp
+++ b/chromium/third_party/skia/src/utils/SkCamera.cpp
@@ -19,48 +19,6 @@ static SkScalar SkScalarDotDiv(int count, const SkScalar a[], int step_a,
return prod / denom;
}
-static SkScalar SkScalarDot(int count, const SkScalar a[], int step_a,
- const SkScalar b[], int step_b) {
- SkScalar prod = 0;
- for (int i = 0; i < count; i++) {
- prod += a[0] * b[0];
- a += step_a;
- b += step_b;
- }
- return prod;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-SkScalar SkPoint3D::normalize(SkUnit3D* unit) const {
- SkScalar mag = SkScalarSqrt(fX*fX + fY*fY + fZ*fZ);
- if (mag) {
- SkScalar scale = SkScalarInvert(mag);
- unit->fX = fX * scale;
- unit->fY = fY * scale;
- unit->fZ = fZ * scale;
- } else {
- unit->fX = unit->fY = unit->fZ = 0;
- }
- return mag;
-}
-
-SkScalar SkUnit3D::Dot(const SkUnit3D& a, const SkUnit3D& b) {
- return a.fX * b.fX + a.fY * b.fY + a.fZ * b.fZ;
-}
-
-void SkUnit3D::Cross(const SkUnit3D& a, const SkUnit3D& b, SkUnit3D* cross) {
- SkASSERT(cross);
-
- // use x,y,z, in case &a == cross or &b == cross
-
- SkScalar x = a.fY * b.fZ - a.fZ * b.fY;
- SkScalar y = a.fZ * b.fX - a.fX * b.fY;
- SkScalar z = a.fX * b.fY - a.fY * b.fX;
-
- cross->set(x, y, z);
-}
-
///////////////////////////////////////////////////////////////////////////////
SkPatch3D::SkPatch3D() {
@@ -68,141 +26,41 @@ SkPatch3D::SkPatch3D() {
}
void SkPatch3D::reset() {
- fOrigin.set(0, 0, 0);
- fU.set(SK_Scalar1, 0, 0);
- fV.set(0, -SK_Scalar1, 0);
+ fOrigin = {0, 0, 0};
+ fU = {SK_Scalar1, 0, 0};
+ fV = {0, -SK_Scalar1, 0};
}
-void SkPatch3D::transform(const SkMatrix3D& m, SkPatch3D* dst) const {
+void SkPatch3D::transform(const SkM44& m, SkPatch3D* dst) const {
if (dst == nullptr) {
dst = (SkPatch3D*)this;
}
- m.mapVector(fU, &dst->fU);
- m.mapVector(fV, &dst->fV);
- m.mapPoint(fOrigin, &dst->fOrigin);
+ dst->fU = m * fU;
+ dst->fV = m * fV;
+ auto [x,y,z,_] = m.map(fOrigin.x, fOrigin.y, fOrigin.z, 1);
+ dst->fOrigin = {x, y, z};
}
SkScalar SkPatch3D::dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const {
- SkScalar cx = fU.fY * fV.fZ - fU.fZ * fV.fY;
- SkScalar cy = fU.fZ * fV.fX - fU.fX * fV.fY;
- SkScalar cz = fU.fX * fV.fY - fU.fY * fV.fX;
+ SkScalar cx = fU.y * fV.z - fU.z * fV.y;
+ SkScalar cy = fU.z * fV.x - fU.x * fV.y;
+ SkScalar cz = fU.x * fV.y - fU.y * fV.x;
return cx * dx + cy * dy + cz * dz;
}
///////////////////////////////////////////////////////////////////////////////
-void SkMatrix3D::reset() {
- memset(fMat, 0, sizeof(fMat));
- fMat[0][0] = fMat[1][1] = fMat[2][2] = SK_Scalar1;
-}
-
-void SkMatrix3D::setTranslate(SkScalar x, SkScalar y, SkScalar z) {
- memset(fMat, 0, sizeof(fMat));
- fMat[0][0] = x;
- fMat[1][1] = y;
- fMat[2][2] = z;
-}
-
-void SkMatrix3D::setRotateX(SkScalar degX) {
- SkScalar r = SkDegreesToRadians(degX),
- s = SkScalarSin(r),
- c = SkScalarCos(r);
- this->setRow(0, SK_Scalar1, 0, 0);
- this->setRow(1, 0, c, -s);
- this->setRow(2, 0, s, c);
-}
-
-void SkMatrix3D::setRotateY(SkScalar degY) {
- SkScalar r = SkDegreesToRadians(degY),
- s = SkScalarSin(r),
- c = SkScalarCos(r);
- this->setRow(0, c, 0, -s);
- this->setRow(1, 0, SK_Scalar1, 0);
- this->setRow(2, s, 0, c);
-}
-
-void SkMatrix3D::setRotateZ(SkScalar degZ) {
- SkScalar r = SkDegreesToRadians(degZ),
- s = SkScalarSin(r),
- c = SkScalarCos(r);
- this->setRow(0, c, -s, 0);
- this->setRow(1, s, c, 0);
- this->setRow(2, 0, 0, SK_Scalar1);
-}
-
-void SkMatrix3D::preTranslate(SkScalar x, SkScalar y, SkScalar z) {
- SkScalar col[3] = { x, y, z};
-
- for (int i = 0; i < 3; i++) {
- fMat[i][3] += SkScalarDot(3, &fMat[i][0], 1, col, 1);
- }
-}
-
-void SkMatrix3D::preRotateX(SkScalar degX) {
- SkMatrix3D m;
- m.setRotateX(degX);
- this->setConcat(*this, m);
-}
-
-void SkMatrix3D::preRotateY(SkScalar degY) {
- SkMatrix3D m;
- m.setRotateY(degY);
- this->setConcat(*this, m);
-}
-
-void SkMatrix3D::preRotateZ(SkScalar degZ) {
- SkMatrix3D m;
- m.setRotateZ(degZ);
- this->setConcat(*this, m);
-}
-
-void SkMatrix3D::setConcat(const SkMatrix3D& a, const SkMatrix3D& b) {
- SkMatrix3D tmp;
- SkMatrix3D* c = this;
-
- if (this == &a || this == &b) {
- c = &tmp;
- }
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- c->fMat[i][j] = SkScalarDot(3, &a.fMat[i][0], 1, &b.fMat[0][j], 4);
- }
- c->fMat[i][3] = SkScalarDot(3, &a.fMat[i][0], 1,
- &b.fMat[0][3], 4) + a.fMat[i][3];
- }
-
- if (c == &tmp) {
- *this = tmp;
- }
-}
-
-void SkMatrix3D::mapPoint(const SkPoint3D& src, SkPoint3D* dst) const {
- SkScalar x = SkScalarDot(3, &fMat[0][0], 1, &src.fX, 1) + fMat[0][3];
- SkScalar y = SkScalarDot(3, &fMat[1][0], 1, &src.fX, 1) + fMat[1][3];
- SkScalar z = SkScalarDot(3, &fMat[2][0], 1, &src.fX, 1) + fMat[2][3];
- dst->set(x, y, z);
-}
-
-void SkMatrix3D::mapVector(const SkVector3D& src, SkVector3D* dst) const {
- SkScalar x = SkScalarDot(3, &fMat[0][0], 1, &src.fX, 1);
- SkScalar y = SkScalarDot(3, &fMat[1][0], 1, &src.fX, 1);
- SkScalar z = SkScalarDot(3, &fMat[2][0], 1, &src.fX, 1);
- dst->set(x, y, z);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
SkCamera3D::SkCamera3D() {
this->reset();
}
void SkCamera3D::reset() {
- fLocation.set(0, 0, -SkIntToScalar(576)); // 8 inches backward
- fAxis.set(0, 0, SK_Scalar1); // forward
- fZenith.set(0, -SK_Scalar1, 0); // up
+ fLocation = {0, 0, -SkIntToScalar(576)}; // 8 inches backward
+ fAxis = {0, 0, SK_Scalar1}; // forward
+ fZenith = {0, -SK_Scalar1, 0}; // up
- fObserver.set(0, 0, fLocation.fZ);
+ fObserver = {0, 0, fLocation.z};
fNeedToUpdate = true;
}
@@ -212,28 +70,19 @@ void SkCamera3D::update() {
}
void SkCamera3D::doUpdate() const {
- SkUnit3D axis, zenith, cross;
+ SkV3 axis, zenith, cross;
// construct a orthonormal basis of cross (x), zenith (y), and axis (z)
- fAxis.normalize(&axis);
+ axis = fAxis.normalize();
- {
- SkScalar dot = SkUnit3D::Dot(SkUnit3D{fZenith.fX, fZenith.fY, fZenith.fZ}, axis);
+ zenith = fZenith - (axis * fZenith) * axis;
+ zenith = zenith.normalize();
- zenith.fX = fZenith.fX - dot * axis.fX;
- zenith.fY = fZenith.fY - dot * axis.fY;
- zenith.fZ = fZenith.fZ - dot * axis.fZ;
-
- SkPoint3D{zenith.fX, zenith.fY, zenith.fZ}.normalize(&zenith);
- }
-
- SkUnit3D::Cross(axis, zenith, &cross);
+ cross = axis.cross(zenith);
{
SkMatrix* orien = &fOrientation;
- SkScalar x = fObserver.fX;
- SkScalar y = fObserver.fY;
- SkScalar z = fObserver.fZ;
+ auto [x, y, z] = fObserver;
// Looking along the view axis we have:
//
@@ -249,15 +98,15 @@ void SkCamera3D::doUpdate() const {
// and scales in x and y relative to the negative of the observer's z value
// (the observer is in the negative z direction).
- orien->set(SkMatrix::kMScaleX, x * axis.fX - z * cross.fX);
- orien->set(SkMatrix::kMSkewX, x * axis.fY - z * cross.fY);
- orien->set(SkMatrix::kMTransX, x * axis.fZ - z * cross.fZ);
- orien->set(SkMatrix::kMSkewY, y * axis.fX - z * zenith.fX);
- orien->set(SkMatrix::kMScaleY, y * axis.fY - z * zenith.fY);
- orien->set(SkMatrix::kMTransY, y * axis.fZ - z * zenith.fZ);
- orien->set(SkMatrix::kMPersp0, axis.fX);
- orien->set(SkMatrix::kMPersp1, axis.fY);
- orien->set(SkMatrix::kMPersp2, axis.fZ);
+ orien->set(SkMatrix::kMScaleX, x * axis.x - z * cross.x);
+ orien->set(SkMatrix::kMSkewX, x * axis.y - z * cross.y);
+ orien->set(SkMatrix::kMTransX, x * axis.z - z * cross.z);
+ orien->set(SkMatrix::kMSkewY, y * axis.x - z * zenith.x);
+ orien->set(SkMatrix::kMScaleY, y * axis.y - z * zenith.y);
+ orien->set(SkMatrix::kMTransY, y * axis.z - z * zenith.z);
+ orien->set(SkMatrix::kMPersp0, axis.x);
+ orien->set(SkMatrix::kMPersp1, axis.y);
+ orien->set(SkMatrix::kMPersp2, axis.z);
}
}
@@ -269,15 +118,9 @@ void SkCamera3D::patchToMatrix(const SkPatch3D& quilt, SkMatrix* matrix) const {
const SkScalar* mapPtr = (const SkScalar*)(const void*)&fOrientation;
const SkScalar* patchPtr;
- SkPoint3D diff;
- SkScalar dot;
-
- diff.fX = quilt.fOrigin.fX - fLocation.fX;
- diff.fY = quilt.fOrigin.fY - fLocation.fY;
- diff.fZ = quilt.fOrigin.fZ - fLocation.fZ;
- dot = SkUnit3D::Dot(SkUnit3D{diff.fX, diff.fY, diff.fZ},
- SkUnit3D{mapPtr[6], mapPtr[7], mapPtr[8]});
+ SkV3 diff = quilt.fOrigin - fLocation;
+ SkScalar dot = diff.dot({mapPtr[6], mapPtr[7], mapPtr[8]});
// This multiplies fOrientation by the matrix [quilt.fU quilt.fV diff] -- U, V, and diff are
// column vectors in the matrix -- then divides by the length of the projection of diff onto
@@ -307,7 +150,6 @@ void SkCamera3D::patchToMatrix(const SkPatch3D& quilt, SkMatrix* matrix) const {
///////////////////////////////////////////////////////////////////////////////
Sk3DView::Sk3DView() {
- fInitialRec.fMatrix.reset();
fRec = &fInitialRec;
}
@@ -338,22 +180,22 @@ void Sk3DView::restore() {
void Sk3DView::setCameraLocation(SkScalar x, SkScalar y, SkScalar z) {
// the camera location is passed in inches, set in pt
SkScalar lz = z * 72.0f;
- fCamera.fLocation.set(x * 72.0f, y * 72.0f, lz);
- fCamera.fObserver.set(0, 0, lz);
+ fCamera.fLocation = {x * 72.0f, y * 72.0f, lz};
+ fCamera.fObserver = {0, 0, lz};
fCamera.update();
}
SkScalar Sk3DView::getCameraLocationX() const {
- return fCamera.fLocation.fX / 72.0f;
+ return fCamera.fLocation.x / 72.0f;
}
SkScalar Sk3DView::getCameraLocationY() const {
- return fCamera.fLocation.fY / 72.0f;
+ return fCamera.fLocation.y / 72.0f;
}
SkScalar Sk3DView::getCameraLocationZ() const {
- return fCamera.fLocation.fZ / 72.0f;
+ return fCamera.fLocation.z / 72.0f;
}
#endif
@@ -362,15 +204,15 @@ void Sk3DView::translate(SkScalar x, SkScalar y, SkScalar z) {
}
void Sk3DView::rotateX(SkScalar deg) {
- fRec->fMatrix.preRotateX(deg);
+ fRec->fMatrix.preConcat(SkM44::Rotate({1, 0, 0}, deg * SK_ScalarPI / 180));
}
void Sk3DView::rotateY(SkScalar deg) {
- fRec->fMatrix.preRotateY(deg);
+ fRec->fMatrix.preConcat(SkM44::Rotate({0,-1, 0}, deg * SK_ScalarPI / 180));
}
void Sk3DView::rotateZ(SkScalar deg) {
- fRec->fMatrix.preRotateZ(deg);
+ fRec->fMatrix.preConcat(SkM44::Rotate({0, 0, 1}, deg * SK_ScalarPI / 180));
}
SkScalar Sk3DView::dotWithNormal(SkScalar x, SkScalar y, SkScalar z) const {
diff --git a/chromium/third_party/skia/src/utils/SkClipStackUtils.cpp b/chromium/third_party/skia/src/utils/SkClipStackUtils.cpp
index 00b933630e4..fade198d6d9 100644
--- a/chromium/third_party/skia/src/utils/SkClipStackUtils.cpp
+++ b/chromium/third_party/skia/src/utils/SkClipStackUtils.cpp
@@ -14,6 +14,11 @@ void SkClipStack_AsPath(const SkClipStack& cs, SkPath* path) {
SkClipStack::Iter iter(cs, SkClipStack::Iter::kBottom_IterStart);
while (const SkClipStack::Element* element = iter.next()) {
+ if (element->getDeviceSpaceType() == SkClipStack::Element::DeviceSpaceType::kShader) {
+ // TODO: Handle DeviceSpaceType::kShader somehow; it can't be turned into an SkPath
+ // but perhaps the pdf backend can apply shaders in another way.
+ continue;
+ }
SkPath operand;
if (element->getDeviceSpaceType() != SkClipStack::Element::DeviceSpaceType::kEmpty) {
element->asDeviceSpacePath(&operand);
diff --git a/chromium/third_party/skia/src/utils/SkCustomTypeface.cpp b/chromium/third_party/skia/src/utils/SkCustomTypeface.cpp
index 61664aff9c1..2fbdd7542b9 100644
--- a/chromium/third_party/skia/src/utils/SkCustomTypeface.cpp
+++ b/chromium/third_party/skia/src/utils/SkCustomTypeface.cpp
@@ -11,21 +11,46 @@
#include "include/utils/SkCustomTypeface.h"
#include "src/core/SkAdvancedTypefaceMetrics.h"
-class SkUserTypeface : public SkTypeface {
+static SkFontMetrics scale_fontmetrics(const SkFontMetrics& src, float sx, float sy) {
+ SkFontMetrics dst = src;
+
+ #define SCALE_X(field) dst.field *= sx
+ #define SCALE_Y(field) dst.field *= sy
+
+ SCALE_X(fAvgCharWidth);
+ SCALE_X(fMaxCharWidth);
+ SCALE_X(fXMin);
+ SCALE_X(fXMax);
+
+ SCALE_Y(fTop);
+ SCALE_Y(fAscent);
+ SCALE_Y(fDescent);
+ SCALE_Y(fBottom);
+ SCALE_Y(fLeading);
+ SCALE_Y(fXHeight);
+ SCALE_Y(fCapHeight);
+ SCALE_Y(fUnderlineThickness);
+ SCALE_Y(fUnderlinePosition);
+ SCALE_Y(fStrikeoutThickness);
+ SCALE_Y(fStrikeoutPosition);
+
+ #undef SCALE_X
+ #undef SCALE_Y
+
+ return dst;
+}
+
+class SkUserTypeface final : public SkTypeface {
+private:
friend class SkCustomTypefaceBuilder;
friend class SkUserScalerContext;
- SkUserTypeface(int count)
- : SkTypeface(SkFontStyle())
- , fGlyphCount(count)
- {}
+ SkUserTypeface() : SkTypeface(SkFontStyle()) {}
- const int fGlyphCount;
std::vector<SkPath> fPaths;
std::vector<float> fAdvances;
- SkRect fBounds;
+ SkFontMetrics fMetrics;
-protected:
SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
const SkDescriptor* desc) const override;
void onFilterRec(SkScalerContextRec* rec) const override;
@@ -46,9 +71,12 @@ protected:
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
return sk_ref_sp(this);
}
- int onCountGlyphs() const override { return fGlyphCount; }
+ int onCountGlyphs() const override { return this->glyphCount(); }
int onGetUPEM() const override { return 2048; /* ?? */ }
- bool onComputeBounds(SkRect* bounds) const override { *bounds = fBounds; return true; }
+ bool onComputeBounds(SkRect* bounds) const override {
+ bounds->setLTRB(fMetrics.fXMin, fMetrics.fTop, fMetrics.fXMax, fMetrics.fBottom);
+ return true;
+ }
// noops
@@ -59,27 +87,39 @@ protected:
int) const override { return 0; }
int onGetTableTags(SkFontTableTag tags[]) const override { return 0; }
size_t onGetTableData(SkFontTableTag, size_t, size_t, void*) const override { return 0; }
+
+ int glyphCount() const {
+ SkASSERT(fPaths.size() == fAdvances.size());
+ return SkToInt(fPaths.size());
+ }
};
-SkCustomTypefaceBuilder::SkCustomTypefaceBuilder(int numGlyphs) : fGlyphCount(numGlyphs) {
- fAdvances.resize(numGlyphs);
- fPaths.resize(numGlyphs);
+SkCustomTypefaceBuilder::SkCustomTypefaceBuilder() {
+ sk_bzero(&fMetrics, sizeof(fMetrics));
+}
+
+void SkCustomTypefaceBuilder::setMetrics(const SkFontMetrics& fm, float scale) {
+ fMetrics = scale_fontmetrics(fm, scale, scale);
}
void SkCustomTypefaceBuilder::setGlyph(SkGlyphID index, float advance, const SkPath& path) {
- if (index >= (unsigned)fGlyphCount) {
- return;
+ SkASSERT(fPaths.size() == fAdvances.size());
+ if (index >= fPaths.size()) {
+ fPaths.resize(SkToSizeT(index) + 1);
+ fAdvances.resize(SkToSizeT(index) + 1);
}
fAdvances[index] = advance;
fPaths[index] = path;
}
sk_sp<SkTypeface> SkCustomTypefaceBuilder::detach() {
- if (fGlyphCount <= 0) return nullptr;
+ SkASSERT(fPaths.size() == fAdvances.size());
+ if (fPaths.empty()) return nullptr;
- SkUserTypeface* tf = new SkUserTypeface(fGlyphCount);
+ sk_sp<SkUserTypeface> tf(new SkUserTypeface());
tf->fAdvances = std::move(fAdvances);
tf->fPaths = std::move(fPaths);
+ tf->fMetrics = fMetrics;
// initially inverted, so that any "union" will overwrite the first time
SkRect bounds = {SK_ScalarMax, SK_ScalarMax, -SK_ScalarMax, -SK_ScalarMax};
@@ -89,9 +129,12 @@ sk_sp<SkTypeface> SkCustomTypefaceBuilder::detach() {
bounds.join(path.getBounds());
}
}
- tf->fBounds = bounds;
+ tf->fMetrics.fTop = bounds.top();
+ tf->fMetrics.fBottom = bounds.bottom();
+ tf->fMetrics.fXMin = bounds.left();
+ tf->fMetrics.fXMax = bounds.right();
- return sk_sp<SkTypeface>(tf);
+ return std::move(tf);
}
/////////////
@@ -103,8 +146,8 @@ void SkUserTypeface::onFilterRec(SkScalerContextRec* rec) const {
}
void SkUserTypeface::getGlyphToUnicodeMap(SkUnichar* glyphToUnicode) const {
- for (int gid = 0; gid < fGlyphCount; ++gid) {
- glyphToUnicode[gid] = 0;
+ for (int gid = 0; gid < this->glyphCount(); ++gid) {
+ glyphToUnicode[gid] = SkTo<SkUnichar>(gid);
}
}
@@ -118,7 +161,7 @@ void SkUserTypeface::onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal)
void SkUserTypeface::onCharsToGlyphs(const SkUnichar uni[], int count, SkGlyphID glyphs[]) const {
for (int i = 0; i < count; ++i) {
- glyphs[i] = 0;
+ glyphs[i] = uni[i] < this->glyphCount() ? SkTo<SkGlyphID>(uni[i]) : 0;
}
}
@@ -150,7 +193,7 @@ public:
protected:
unsigned generateGlyphCount() override {
- return this->userTF()->fGlyphCount;
+ return this->userTF()->glyphCount();
}
bool generateAdvance(SkGlyph* glyph) override {
@@ -176,15 +219,8 @@ protected:
}
void generateFontMetrics(SkFontMetrics* metrics) override {
- auto [_, sy] = fMatrix.mapXY(0, 1);
-
- sk_bzero(metrics, sizeof(*metrics));
- metrics->fTop = this->userTF()->fBounds.fTop * sy;
- metrics->fBottom = this->userTF()->fBounds.fBottom * sy;
-
- // todo: get these from the creator of the typeface?
- metrics->fAscent = metrics->fTop;
- metrics->fDescent = metrics->fBottom;
+ auto [sx, sy] = fMatrix.mapXY(1, 1);
+ *metrics = scale_fontmetrics(this->userTF()->fMetrics, sx, sy);
}
private:
@@ -268,7 +304,7 @@ static void compress_write(SkWStream* stream, const SkPath& path, int upem) {
static constexpr int kMaxGlyphCount = 65536;
static constexpr size_t kHeaderSize = 16;
-static const char gHeaderString[] = "SkUserTypeface00";
+static const char gHeaderString[] = "SkUserTypeface01";
static_assert(sizeof(gHeaderString) == 1 + kHeaderSize, "need header to be 16 bytes");
std::unique_ptr<SkStreamAsset> SkUserTypeface::onOpenStream(int* ttcIndex) const {
@@ -276,20 +312,19 @@ std::unique_ptr<SkStreamAsset> SkUserTypeface::onOpenStream(int* ttcIndex) const
wstream.write(gHeaderString, kHeaderSize);
- SkASSERT(fAdvances.size() == (unsigned)fGlyphCount);
- SkASSERT(fPaths.size() == (unsigned)fGlyphCount);
+ wstream.write(&fMetrics, sizeof(fMetrics));
// just hacking around -- this makes the serialized font 1/2 size
const bool use_compression = false;
- wstream.write32(fGlyphCount);
+ wstream.write32(this->glyphCount());
if (use_compression) {
for (float a : fAdvances) {
write_scaled_float_to_16(&wstream, a, 2048);
}
} else {
- wstream.write(fAdvances.data(), fGlyphCount * sizeof(float));
+ wstream.write(fAdvances.data(), this->glyphCount() * sizeof(float));
}
for (const auto& p : fPaths) {
@@ -334,12 +369,19 @@ sk_sp<SkTypeface> SkCustomTypefaceBuilder::Deserialize(SkStream* stream) {
return nullptr;
}
+ SkFontMetrics metrics;
+ if (stream->read(&metrics, sizeof(metrics)) != sizeof(metrics)) {
+ return nullptr;
+ }
+
int glyphCount;
if (!stream->readS32(&glyphCount) || glyphCount < 0 || glyphCount > kMaxGlyphCount) {
return nullptr;
}
- SkCustomTypefaceBuilder builder(glyphCount);
+ SkCustomTypefaceBuilder builder;
+
+ builder.setMetrics(metrics);
std::vector<float> advances(glyphCount);
if (stream->read(advances.data(), glyphCount * sizeof(float)) != glyphCount * sizeof(float)) {
diff --git a/chromium/third_party/skia/src/utils/SkJSON.cpp b/chromium/third_party/skia/src/utils/SkJSON.cpp
index 181ca752e5a..c53fc1bfc0a 100644
--- a/chromium/third_party/skia/src/utils/SkJSON.cpp
+++ b/chromium/third_party/skia/src/utils/SkJSON.cpp
@@ -28,23 +28,22 @@ static constexpr size_t kRecAlign = alignof(Value);
void Value::init_tagged(Tag t) {
memset(fData8, 0, sizeof(fData8));
- fData8[Value::kTagOffset] = SkTo<uint8_t>(t);
+ fData8[0] = SkTo<uint8_t>(t);
SkASSERT(this->getTag() == t);
}
-// Pointer values store a type (in the upper kTagBits bits) and a pointer.
+// Pointer values store a type (in the lower kTagBits bits) and a pointer.
void Value::init_tagged_pointer(Tag t, void* p) {
- *this->cast<uintptr_t>() = reinterpret_cast<uintptr_t>(p);
-
if (sizeof(Value) == sizeof(uintptr_t)) {
- // For 64-bit, we rely on the pointer upper bits being unused/zero.
- SkASSERT(!(fData8[kTagOffset] & kTagMask));
- fData8[kTagOffset] |= SkTo<uint8_t>(t);
+ *this->cast<uintptr_t>() = reinterpret_cast<uintptr_t>(p);
+ // For 64-bit, we rely on the pointer lower bits being zero.
+ SkASSERT(!(fData8[0] & kTagMask));
+ fData8[0] |= SkTo<uint8_t>(t);
} else {
- // For 32-bit, we need to zero-initialize the upper 32 bits
+ // For 32-bit, we store the pointer in the upper word
SkASSERT(sizeof(Value) == sizeof(uintptr_t) * 2);
- this->cast<uintptr_t>()[kTagOffset >> 2] = 0;
- fData8[kTagOffset] = SkTo<uint8_t>(t);
+ this->init_tagged(t);
+ *this->cast<uintptr_t>() = reinterpret_cast<uintptr_t>(p);
}
SkASSERT(this->getTag() == t);
@@ -126,11 +125,8 @@ public:
return;
}
- static_assert(static_cast<uint8_t>(Tag::kShortString) == 0, "please don't break this");
- static_assert(sizeof(Value) == 8, "");
-
- // TODO: LIKELY
- if (src && src + 7 <= eos) {
+ // initFastShortString is faster (doh), but requires access to 6 chars past src.
+ if (src && src + 6 <= eos) {
this->initFastShortString(src, size);
} else {
this->initShortString(src, size);
@@ -140,7 +136,8 @@ public:
}
private:
- static constexpr size_t kMaxInlineStringSize = sizeof(Value) - 1;
+ // first byte reserved for tagging, \0 terminator => 6 usable chars
+ static constexpr size_t kMaxInlineStringSize = sizeof(Value) - 2;
void initLongString(const char* src, size_t size, SkArenaAlloc& alloc) {
SkASSERT(size > kMaxInlineStringSize);
@@ -162,12 +159,23 @@ private:
void initFastShortString(const char* src, size_t size) {
SkASSERT(size <= kMaxInlineStringSize);
- // Load 8 chars and mask out the tag and \0 terminator.
uint64_t* s64 = this->cast<uint64_t>();
- memcpy(s64, src, 8);
+
+ // Load 8 chars and mask out the tag and \0 terminator.
+ // Note: we picked kShortString == 0 to avoid setting explicitly below.
+ static_assert(SkToU8(Tag::kShortString) == 0, "please don't break this");
+
+ // Since the first byte is occupied by the tag, we want the string chars [0..5] to land
+ // on bytes [1..6] => the fastest way is to read8 @(src - 1) (always safe, because the
+ // string requires a " prefix at the very least).
+ memcpy(s64, src - 1, 8);
#if defined(SK_CPU_LENDIAN)
- *s64 &= 0x00ffffffffffffffULL >> ((kMaxInlineStringSize - size) * 8);
+ // The mask for a max-length string (6), with a leading tag and trailing \0 is
+ // 0x00ffffffffffff00. Accounting for the final left-shift, this becomes
+ // 0x0000ffffffffffff.
+ *s64 &= (0x0000ffffffffffffULL >> ((kMaxInlineStringSize - size) * 8)) // trailing \0s
+ << 8; // tag byte
#else
static_assert(false, "Big-endian builds are not supported at this time.");
#endif
diff --git a/chromium/third_party/skia/src/utils/SkJSON.h b/chromium/third_party/skia/src/utils/SkJSON.h
index 931b30f0a4e..d3f0b1d48f0 100644
--- a/chromium/third_party/skia/src/utils/SkJSON.h
+++ b/chromium/third_party/skia/src/utils/SkJSON.h
@@ -117,58 +117,69 @@ protected:
char[8] (short string storage)
external payload (tagged) pointer
- -- highest 3 bits reserved for type storage
+ -- lowest 3 bits reserved for tag storage
*/
enum class Tag : uint8_t {
- // We picked kShortString == 0 so that tag 0x00 and stored max_size-size (7-7=0)
- // conveniently overlap the '\0' terminator, allowing us to store a 7 character
- // C string inline.
+ // n.b.: we picked kShortString == 0 on purpose,
+ // to enable certain short-string optimizations.
kShortString = 0b00000000, // inline payload
- kNull = 0b00100000, // no payload
- kBool = 0b01000000, // inline payload
- kInt = 0b01100000, // inline payload
- kFloat = 0b10000000, // inline payload
- kString = 0b10100000, // ptr to external storage
- kArray = 0b11000000, // ptr to external storage
- kObject = 0b11100000, // ptr to external storage
+ kNull = 0b00000001, // no payload
+ kBool = 0b00000010, // inline payload
+ kInt = 0b00000011, // inline payload
+ kFloat = 0b00000100, // inline payload
+ kString = 0b00000101, // ptr to external storage
+ kArray = 0b00000110, // ptr to external storage
+ kObject = 0b00000111, // ptr to external storage
};
- static constexpr uint8_t kTagMask = 0b11100000;
+ static constexpr uint8_t kTagMask = 0b00000111;
void init_tagged(Tag);
void init_tagged_pointer(Tag, void*);
Tag getTag() const {
- return static_cast<Tag>(fData8[kTagOffset] & kTagMask);
+ return static_cast<Tag>(fData8[0] & kTagMask);
}
- // Access the record data as T.
+ // Access the record payload as T.
//
- // This is also used to access the payload for inline records. Since the record type lives in
- // the high bits, sizeof(T) must be less than sizeof(Value) when accessing inline payloads.
+ // Since the tag is stored in the lower bits, we skip the first word whenever feasible.
//
- // E.g.
+ // E.g. (U == unused)
//
// uint8_t
// -----------------------------------------------------------------------
- // | val8 | val8 | val8 | val8 | val8 | val8 | val8 | TYPE|
+ // |TAG| U | val8 | U | U | U | U | U | U |
+ // -----------------------------------------------------------------------
+ //
+ // uint16_t
+ // -----------------------------------------------------------------------
+ // |TAG| U | val16 | U | U |
// -----------------------------------------------------------------------
//
// uint32_t
// -----------------------------------------------------------------------
- // | val32 | unused | TYPE|
+ // |TAG| U | val32 |
+ // -----------------------------------------------------------------------
+ //
+ // T* (32b)
+ // -----------------------------------------------------------------------
+ // |TAG| U | T* (32bits) |
// -----------------------------------------------------------------------
//
// T* (64b)
// -----------------------------------------------------------------------
- // | T* (kTypeShift bits) |TYPE|
+ // |TAG| T* (61bits) |
// -----------------------------------------------------------------------
//
template <typename T>
const T* cast() const {
static_assert(sizeof (T) <= sizeof(Value), "");
static_assert(alignof(T) <= alignof(Value), "");
- return reinterpret_cast<const T*>(this);
+
+ return (sizeof(T) > sizeof(*this) / 2)
+ ? reinterpret_cast<const T*>(this) + 0 // need all the bits
+ : reinterpret_cast<const T*>(this) + 1; // skip the first word (where the tag lives)
}
template <typename T>
@@ -183,8 +194,8 @@ protected:
return (sizeof(uintptr_t) < sizeof(Value))
// For 32-bit, pointers are stored unmodified.
? *this->cast<const T*>()
- // For 64-bit, we use the high bits of the pointer as tag storage.
- : reinterpret_cast<T*>(*this->cast<uintptr_t>() & kTagPointerMask);
+ // For 64-bit, we use the lower bits of the pointer as tag storage.
+ : reinterpret_cast<T*>(*this->cast<uintptr_t>() & ~static_cast<uintptr_t>(kTagMask));
}
private:
@@ -192,12 +203,7 @@ private:
uint8_t fData8[kValueSize];
-#if defined(SK_CPU_LENDIAN)
- static constexpr size_t kTagOffset = kValueSize - 1;
-
- static constexpr uintptr_t kTagPointerMask =
- ~(static_cast<uintptr_t>(kTagMask) << ((sizeof(uintptr_t) - 1) * 8));
-#else
+#if !defined(SK_CPU_LENDIAN)
// The current value layout assumes LE and will take some tweaking for BE.
static_assert(false, "Big-endian builds are not supported at this time.");
#endif
@@ -319,11 +325,11 @@ class ObjectValue final : public VectorValue<Member, Value::Type::kObject> {
public:
ObjectValue(const Member* src, size_t size, SkArenaAlloc& alloc);
- const Value& operator[](const char*) const;
+ const Value& operator[](const char*) const;
-private:
- // Not particularly interesting - hiding for disambiguation.
- const Member& operator[](size_t i) const = delete;
+ const Member& operator[](size_t i) const {
+ return this->VectorValue::operator[](i);
+ }
};
class DOM final : public SkNoncopyable {
diff --git a/chromium/third_party/skia/src/utils/SkLuaCanvas.cpp b/chromium/third_party/skia/src/utils/SkLuaCanvas.cpp
index 7bdeb482da4..3a094c3f5f6 100644
--- a/chromium/third_party/skia/src/utils/SkLuaCanvas.cpp
+++ b/chromium/third_party/skia/src/utils/SkLuaCanvas.cpp
@@ -114,10 +114,10 @@ void SkLuaCanvas::didConcat44(const SkM44&) {
// TODO
}
void SkLuaCanvas::didScale(SkScalar x, SkScalar y) {
- this->didConcat(SkMatrix::MakeScale(x, y));
+ this->didConcat(SkMatrix::Scale(x, y));
}
void SkLuaCanvas::didTranslate(SkScalar x, SkScalar y) {
- this->didConcat(SkMatrix::MakeTrans(x, y));
+ this->didConcat(SkMatrix::Translate(x, y));
}
void SkLuaCanvas::didConcat(const SkMatrix& matrix) {
switch (matrix.getType()) {
diff --git a/chromium/third_party/skia/src/utils/SkParseColor.cpp b/chromium/third_party/skia/src/utils/SkParseColor.cpp
index ba7c51048f1..9846a8ff5ee 100644
--- a/chromium/third_party/skia/src/utils/SkParseColor.cpp
+++ b/chromium/third_party/skia/src/utils/SkParseColor.cpp
@@ -8,211 +8,172 @@
#include "include/utils/SkParse.h"
-static const unsigned int gColorNames[] = {
-0x85891945, 0x32a50000, 0x00f0f8ff, // aliceblue
-0x85d44c6b, 0x16e84d0a, 0x00faebd7, // antiquewhite
-0x86350800, 0x0000ffff, // aqua
-0x86350b43, 0x492e2800, 0x007fffd4, // aquamarine
-0x87559140, 0x00f0ffff, // azure
-0x88a93940, 0x00f5f5dc, // beige
-0x89338d4a, 0x00ffe4c4, // bisque
-0x89811ac0, 0x00000000, // black
-0x898170d1, 0x1481635f, 0x38800000, 0x00ffebcd, // blanchedalmond
-0x89952800, 0x000000ff, // blue
-0x89952d93, 0x3d85a000, 0x008a2be2, // blueviolet
-0x8a4fbb80, 0x00a52a2a, // brown
-0x8ab2666f, 0x3de40000, 0x00deb887, // burlywood
-0x8c242d05, 0x32a50000, 0x005f9ea0, // cadetblue
-0x8d019525, 0x16b32800, 0x007fff00, // chartreuse
-0x8d0f1bd9, 0x06850000, 0x00d2691e, // chocolate
-0x8df20b00, 0x00ff7f50, // coral
-0x8df27199, 0x3ee59099, 0x54a00000, 0x006495ed, // cornflowerblue
-0x8df274d3, 0x31600000, 0x00fff8dc, // cornsilk
-0x8e496cdf, 0x38000000, 0x00dc143c, // crimson
-0x8f217000, 0x0000ffff, // cyan
-0x90325899, 0x54a00000, 0x0000008b, // darkblue
-0x903258f3, 0x05c00000, 0x00008b8b, // darkcyan
-0x903259df, 0x3085749f, 0x10000000, 0x00b8860b, // darkgoldenrod
-0x903259e5, 0x07200000, 0x00a9a9a9, // darkgray
-0x903259e5, 0x14ae0000, 0x00006400, // darkgreen
-0x90325ad1, 0x05690000, 0x00bdb76b, // darkkhaki
-0x90325b43, 0x1caea040, 0x008b008b, // darkmagenta
-0x90325bd9, 0x26c53c8b, 0x15c00000, 0x00556b2f, // darkolivegreen
-0x90325be5, 0x05c72800, 0x00ff8c00, // darkorange
-0x90325be5, 0x0d092000, 0x009932cc, // darkorchid
-0x90325c8b, 0x10000000, 0x008b0000, // darkred
-0x90325cc3, 0x31af7000, 0x00e9967a, // darksalmon
-0x90325ccb, 0x04f2295c, 0x008fbc8f, // darkseagreen
-0x90325cd9, 0x0685132b, 0x14000000, 0x00483d8b, // darkslateblue
-0x90325cd9, 0x06853c83, 0x64000000, 0x002f4f4f, // darkslategray
-0x90325d2b, 0x4a357a67, 0x14000000, 0x0000ced1, // darkturquoise
-0x90325d93, 0x3d85a000, 0x009400d3, // darkviolet
-0x90a58413, 0x39600000, 0x00ff1493, // deeppink
-0x90a584d7, 0x644ca940, 0x0000bfff, // deepskyblue
-0x912d3c83, 0x64000000, 0x00696969, // dimgray
-0x91e43965, 0x09952800, 0x001e90ff, // dodgerblue
-0x993228a5, 0x246b0000, 0x00b22222, // firebrick
-0x998f9059, 0x5d09a140, 0x00fffaf0, // floralwhite
-0x99f22ce9, 0x1e452b80, 0x00228b22, // forestgreen
-0x9aa344d3, 0x04000000, 0x00ff00ff, // fuchsia
-0x9c2974c5, 0x3e4f0000, 0x00dcdcdc, // gainsboro
-0x9d0f9d2f, 0x21342800, 0x00f8f8ff, // ghostwhite
-0x9dec2000, 0x00ffd700, // gold
-0x9dec215d, 0x49e40000, 0x00daa520, // goldenrod
-0x9e41c800, 0x00808080, // gray
-0x9e452b80, 0x00008000, // green
-0x9e452bb3, 0x158c7dc0, 0x00adff2f, // greenyellow
-0xa1ee2e49, 0x16e00000, 0x00f0fff0, // honeydew
-0xa1f4825d, 0x2c000000, 0x00ff69b4, // hotpink
-0xa5c4485d, 0x48a40000, 0x00cd5c5c, // indianred
-0xa5c449de, 0x004b0082, // indigo
-0xa6cf9640, 0x00fffff0, // ivory
-0xad015a40, 0x00f0e68c, // khaki
-0xb0362b89, 0x16400000, 0x00e6e6fa, // lavender
-0xb0362b89, 0x16426567, 0x20000000, 0x00fff0f5, // lavenderblush
-0xb03771e5, 0x14ae0000, 0x007cfc00, // lawngreen
-0xb0ad7b87, 0x212633dc, 0x00fffacd, // lemonchiffon
-0xb1274505, 0x32a50000, 0x00add8e6, // lightblue
-0xb1274507, 0x3e416000, 0x00f08080, // lightcoral
-0xb1274507, 0x642e0000, 0x00e0ffff, // lightcyan
-0xb127450f, 0x3d842ba5, 0x3c992b19, 0x3ee00000, 0x00fafad2, // lightgoldenrodyellow
-0xb127450f, 0x48a57000, 0x0090ee90, // lightgreen
-0xb127450f, 0x48b90000, 0x00d3d3d3, // lightgrey
-0xb1274521, 0x25cb0000, 0x00ffb6c1, // lightpink
-0xb1274527, 0x058d7b80, 0x00ffa07a, // lightsalmon
-0xb1274527, 0x1427914b, 0x38000000, 0x0020b2aa, // lightseagreen
-0xb1274527, 0x2f22654a, 0x0087cefa, // lightskyblue
-0xb1274527, 0x303429e5, 0x07200000, 0x00778899, // lightslategray
-0xb1274527, 0x50a56099, 0x54a00000, 0x00b0c4de, // lightsteelblue
-0xb1274533, 0x158c7dc0, 0x00ffffe0, // lightyellow
-0xb12d2800, 0x0000ff00, // lime
-0xb12d29e5, 0x14ae0000, 0x0032cd32, // limegreen
-0xb12e2b80, 0x00faf0e6, // linen
-0xb4272ba9, 0x04000000, 0x00ff00ff, // magenta
-0xb4327bdc, 0x00800000, // maroon
-0xb4a44d5b, 0x06350b43, 0x492e2800, 0x0066cdaa, // mediumaquamarine
-0xb4a44d5b, 0x09952800, 0x000000cd, // mediumblue
-0xb4a44d5b, 0x3e434248, 0x00ba55d3, // mediumorchid
-0xb4a44d5b, 0x42b2830a, 0x009370db, // mediumpurple
-0xb4a44d5b, 0x4ca13c8b, 0x15c00000, 0x003cb371, // mediumseagreen
-0xb4a44d5b, 0x4d81a145, 0x32a50000, 0x007b68ee, // mediumslateblue
-0xb4a44d5b, 0x4e124b8f, 0x1e452b80, 0x0000fa9a, // mediumspringgreen
-0xb4a44d5b, 0x52b28d5f, 0x26650000, 0x0048d1cc, // mediumturquoise
-0xb4a44d5b, 0x592f6169, 0x48a40000, 0x00c71585, // mediumvioletred
-0xb524724f, 0x2282654a, 0x00191970, // midnightblue
-0xb52ea0e5, 0x142d0000, 0x00f5fffa, // mintcream
-0xb533a665, 0x3e650000, 0x00ffe4e1, // mistyrose
-0xb5e31867, 0x25c00000, 0x00ffe4b5, // moccasin
-0xb8360a9f, 0x5d09a140, 0x00ffdead, // navajowhite
-0xb836c800, 0x00000080, // navy
-0xbd846047, 0x14000000, 0x00fdf5e6, // oldlace
-0xbd89b140, 0x00808000, // olive
-0xbd89b149, 0x48220000, 0x006b8e23, // olivedrab
-0xbe4171ca, 0x00ffa500, // orange
-0xbe4171cb, 0x48a40000, 0x00ff4500, // orangered
-0xbe434248, 0x00da70d6, // orchid
-0xc02c29df, 0x3085749f, 0x10000000, 0x00eee8aa, // palegoldenrod
-0xc02c29e5, 0x14ae0000, 0x0098fb98, // palegreen
-0xc02c2d2b, 0x4a357a67, 0x14000000, 0x00afeeee, // paleturquoise
-0xc02c2d93, 0x3d85a48b, 0x10000000, 0x00db7093, // palevioletred
-0xc0300e43, 0x5d098000, 0x00ffefd5, // papayawhip
-0xc0a11a21, 0x54c60000, 0x00ffdab9, // peachpuff
-0xc0b2a800, 0x00cd853f, // peru
-0xc12e5800, 0x00ffc0cb, // pink
-0xc1956800, 0x00dda0dd, // plum
-0xc1f72165, 0x09952800, 0x00b0e0e6, // powderblue
-0xc2b2830a, 0x00800080, // purple
-0xc8a40000, 0x00ff0000, // red
-0xc9f3c8a5, 0x3eee0000, 0x00bc8f8f, // rosybrown
-0xc9f90b05, 0x32a50000, 0x004169e1, // royalblue
-0xcc24230b, 0x0a4fbb80, 0x008b4513, // saddlebrown
-0xcc2c6bdc, 0x00fa8072, // salmon
-0xcc2e2645, 0x49f77000, 0x00f4a460, // sandybrown
-0xcca13c8b, 0x15c00000, 0x002e8b57, // seagreen
-0xcca19a0b, 0x31800000, 0x00fff5ee, // seashell
-0xcd257382, 0x00a0522d, // sienna
-0xcd2cb164, 0x00c0c0c0, // silver
-0xcd79132b, 0x14000000, 0x0087ceeb, // skyblue
-0xcd81a145, 0x32a50000, 0x006a5acd, // slateblue
-0xcd81a14f, 0x48390000, 0x00708090, // slategray
-0xcdcfb800, 0x00fffafa, // snow
-0xce124b8f, 0x1e452b80, 0x0000ff7f, // springgreen
-0xce852b05, 0x32a50000, 0x004682b4, // steelblue
-0xd02e0000, 0x00d2b48c, // tan
-0xd0a16000, 0x00008080, // teal
-0xd1099d19, 0x14000000, 0x00d8bfd8, // thistle
-0xd1ed0d1e, 0x00ff6347, // tomato
-0xd2b28d5f, 0x26650000, 0x0040e0d0, // turquoise
-0xd92f6168, 0x00ee82ee, // violet
-0xdd050d00, 0x00f5deb3, // wheat
-0xdd09a140, 0x00ffffff, // white
-0xdd09a167, 0x35eb2800, 0x00f5f5f5, // whitesmoke
-0xe4ac63ee, 0x00ffff00, // yellow
-0xe4ac63ef, 0x1e452b80, 0x009acd32 // yellowgreen
-}; // original = 2505 : replacement = 1616
+#pragma pack(push,1)
+static constexpr struct ColorRec {
+ const char* name;
+ uint8_t r, g, b;
+} gNamedColors[] = {
+ { "aliceblue", 0xf0,0xf8,0xff },
+ { "antiquewhite", 0xfa,0xeb,0xd7 },
+ { "aqua", 0x00,0xff,0xff },
+ { "aquamarine", 0x7f,0xff,0xd4 },
+ { "azure", 0xf0,0xff,0xff },
+ { "beige", 0xf5,0xf5,0xdc },
+ { "bisque", 0xff,0xe4,0xc4 },
+ { "black", 0x00,0x00,0x00 },
+ { "blanchedalmond", 0xff,0xeb,0xcd },
+ { "blue", 0x00,0x00,0xff },
+ { "blueviolet", 0x8a,0x2b,0xe2 },
+ { "brown", 0xa5,0x2a,0x2a },
+ { "burlywood", 0xde,0xb8,0x87 },
+ { "cadetblue", 0x5f,0x9e,0xa0 },
+ { "chartreuse", 0x7f,0xff,0x00 },
+ { "chocolate", 0xd2,0x69,0x1e },
+ { "coral", 0xff,0x7f,0x50 },
+ { "cornflowerblue", 0x64,0x95,0xed },
+ { "cornsilk", 0xff,0xf8,0xdc },
+ { "crimson", 0xdc,0x14,0x3c },
+ { "cyan", 0x00,0xff,0xff },
+ { "darkblue", 0x00,0x00,0x8b },
+ { "darkcyan", 0x00,0x8b,0x8b },
+ { "darkgoldenrod", 0xb8,0x86,0x0b },
+ { "darkgray", 0xa9,0xa9,0xa9 },
+ { "darkgreen", 0x00,0x64,0x00 },
+ { "darkkhaki", 0xbd,0xb7,0x6b },
+ { "darkmagenta", 0x8b,0x00,0x8b },
+ { "darkolivegreen", 0x55,0x6b,0x2f },
+ { "darkorange", 0xff,0x8c,0x00 },
+ { "darkorchid", 0x99,0x32,0xcc },
+ { "darkred", 0x8b,0x00,0x00 },
+ { "darksalmon", 0xe9,0x96,0x7a },
+ { "darkseagreen", 0x8f,0xbc,0x8f },
+ { "darkslateblue", 0x48,0x3d,0x8b },
+ { "darkslategray", 0x2f,0x4f,0x4f },
+ { "darkturquoise", 0x00,0xce,0xd1 },
+ { "darkviolet", 0x94,0x00,0xd3 },
+ { "deeppink", 0xff,0x14,0x93 },
+ { "deepskyblue", 0x00,0xbf,0xff },
+ { "dimgray", 0x69,0x69,0x69 },
+ { "dodgerblue", 0x1e,0x90,0xff },
+ { "firebrick", 0xb2,0x22,0x22 },
+ { "floralwhite", 0xff,0xfa,0xf0 },
+ { "forestgreen", 0x22,0x8b,0x22 },
+ { "fuchsia", 0xff,0x00,0xff },
+ { "gainsboro", 0xdc,0xdc,0xdc },
+ { "ghostwhite", 0xf8,0xf8,0xff },
+ { "gold", 0xff,0xd7,0x00 },
+ { "goldenrod", 0xda,0xa5,0x20 },
+ { "gray", 0x80,0x80,0x80 },
+ { "green", 0x00,0x80,0x00 },
+ { "greenyellow", 0xad,0xff,0x2f },
+ { "honeydew", 0xf0,0xff,0xf0 },
+ { "hotpink", 0xff,0x69,0xb4 },
+ { "indianred", 0xcd,0x5c,0x5c },
+ { "indigo", 0x4b,0x00,0x82 },
+ { "ivory", 0xff,0xff,0xf0 },
+ { "khaki", 0xf0,0xe6,0x8c },
+ { "lavender", 0xe6,0xe6,0xfa },
+ { "lavenderblush", 0xff,0xf0,0xf5 },
+ { "lawngreen", 0x7c,0xfc,0x00 },
+ { "lemonchiffon", 0xff,0xfa,0xcd },
+ { "lightblue", 0xad,0xd8,0xe6 },
+ { "lightcoral", 0xf0,0x80,0x80 },
+ { "lightcyan", 0xe0,0xff,0xff },
+ { "lightgoldenrodyellow", 0xfa,0xfa,0xd2 },
+ { "lightgreen", 0x90,0xee,0x90 },
+ { "lightgrey", 0xd3,0xd3,0xd3 },
+ { "lightpink", 0xff,0xb6,0xc1 },
+ { "lightsalmon", 0xff,0xa0,0x7a },
+ { "lightseagreen", 0x20,0xb2,0xaa },
+ { "lightskyblue", 0x87,0xce,0xfa },
+ { "lightslategray", 0x77,0x88,0x99 },
+ { "lightsteelblue", 0xb0,0xc4,0xde },
+ { "lightyellow", 0xff,0xff,0xe0 },
+ { "lime", 0x00,0xff,0x00 },
+ { "limegreen", 0x32,0xcd,0x32 },
+ { "linen", 0xfa,0xf0,0xe6 },
+ { "magenta", 0xff,0x00,0xff },
+ { "maroon", 0x80,0x00,0x00 },
+ { "mediumaquamarine", 0x66,0xcd,0xaa },
+ { "mediumblue", 0x00,0x00,0xcd },
+ { "mediumorchid", 0xba,0x55,0xd3 },
+ { "mediumpurple", 0x93,0x70,0xdb },
+ { "mediumseagreen", 0x3c,0xb3,0x71 },
+ { "mediumslateblue", 0x7b,0x68,0xee },
+ { "mediumspringgreen", 0x00,0xfa,0x9a },
+ { "mediumturquoise", 0x48,0xd1,0xcc },
+ { "mediumvioletred", 0xc7,0x15,0x85 },
+ { "midnightblue", 0x19,0x19,0x70 },
+ { "mintcream", 0xf5,0xff,0xfa },
+ { "mistyrose", 0xff,0xe4,0xe1 },
+ { "moccasin", 0xff,0xe4,0xb5 },
+ { "navajowhite", 0xff,0xde,0xad },
+ { "navy", 0x00,0x00,0x80 },
+ { "oldlace", 0xfd,0xf5,0xe6 },
+ { "olive", 0x80,0x80,0x00 },
+ { "olivedrab", 0x6b,0x8e,0x23 },
+ { "orange", 0xff,0xa5,0x00 },
+ { "orangered", 0xff,0x45,0x00 },
+ { "orchid", 0xda,0x70,0xd6 },
+ { "palegoldenrod", 0xee,0xe8,0xaa },
+ { "palegreen", 0x98,0xfb,0x98 },
+ { "paleturquoise", 0xaf,0xee,0xee },
+ { "palevioletred", 0xdb,0x70,0x93 },
+ { "papayawhip", 0xff,0xef,0xd5 },
+ { "peachpuff", 0xff,0xda,0xb9 },
+ { "peru", 0xcd,0x85,0x3f },
+ { "pink", 0xff,0xc0,0xcb },
+ { "plum", 0xdd,0xa0,0xdd },
+ { "powderblue", 0xb0,0xe0,0xe6 },
+ { "purple", 0x80,0x00,0x80 },
+ { "red", 0xff,0x00,0x00 },
+ { "rosybrown", 0xbc,0x8f,0x8f },
+ { "royalblue", 0x41,0x69,0xe1 },
+ { "saddlebrown", 0x8b,0x45,0x13 },
+ { "salmon", 0xfa,0x80,0x72 },
+ { "sandybrown", 0xf4,0xa4,0x60 },
+ { "seagreen", 0x2e,0x8b,0x57 },
+ { "seashell", 0xff,0xf5,0xee },
+ { "sienna", 0xa0,0x52,0x2d },
+ { "silver", 0xc0,0xc0,0xc0 },
+ { "skyblue", 0x87,0xce,0xeb },
+ { "slateblue", 0x6a,0x5a,0xcd },
+ { "slategray", 0x70,0x80,0x90 },
+ { "snow", 0xff,0xfa,0xfa },
+ { "springgreen", 0x00,0xff,0x7f },
+ { "steelblue", 0x46,0x82,0xb4 },
+ { "tan", 0xd2,0xb4,0x8c },
+ { "teal", 0x00,0x80,0x80 },
+ { "thistle", 0xd8,0xbf,0xd8 },
+ { "tomato", 0xff,0x63,0x47 },
+ { "turquoise", 0x40,0xe0,0xd0 },
+ { "violet", 0xee,0x82,0xee },
+ { "wheat", 0xf5,0xde,0xb3 },
+ { "white", 0xff,0xff,0xff },
+ { "whitesmoke", 0xf5,0xf5,0xf5 },
+ { "yellow", 0xff,0xff,0x00 },
+ { "yellowgreen", 0x9a,0xcd,0x32 },
+};
+#pragma pack(pop)
const char* SkParse::FindNamedColor(const char* name, size_t len, SkColor* color) {
- const char* namePtr = name;
- unsigned int sixMatches[4];
- unsigned int* sixMatchPtr = sixMatches;
- bool first = true;
- bool last = false;
- char ch;
- do {
- unsigned int sixMatch = 0;
- for (int chIndex = 0; chIndex < 6; chIndex++) {
- sixMatch <<= 5;
- ch = *namePtr | 0x20;
- if (ch < 'a' || ch > 'z')
- ch = 0;
- else {
- ch = ch - 'a' + 1;
- namePtr++;
- }
- sixMatch |= ch ; // turn 'A' (0x41) into 'a' (0x61);
- }
- sixMatch <<= 1;
- sixMatch |= 1;
- if (first) {
- sixMatch |= 0x80000000;
- first = false;
- }
- ch = *namePtr | 0x20;
- last = ch < 'a' || ch > 'z';
- if (last)
- sixMatch &= ~1;
- len -= 6;
- *sixMatchPtr++ = sixMatch;
- } while (last == false && len > 0);
- const int colorNameSize = sizeof(gColorNames) / sizeof(unsigned int);
- int lo = 0;
- int hi = colorNameSize - 3; // back off to beginning of yellowgreen
- while (lo <= hi) {
- int mid = (hi + lo) >> 1;
- while ((int) gColorNames[mid] >= 0)
- --mid;
- sixMatchPtr = sixMatches;
- while (gColorNames[mid] == *sixMatchPtr) {
- ++mid;
- if ((*sixMatchPtr & 1) == 0) { // last
- *color = gColorNames[mid] | 0xFF000000;
- return namePtr;
- }
- ++sixMatchPtr;
- }
- int sixMask = *sixMatchPtr & ~0x80000000;
- int midMask = gColorNames[mid] & ~0x80000000;
- if (sixMask > midMask) {
- lo = mid + 2; // skip color
- while ((int) gColorNames[lo] >= 0)
- ++lo;
- } else if (hi == mid)
- return nullptr;
- else
- hi = mid;
+ const auto* rec = std::lower_bound(std::begin(gNamedColors),
+ std::end (gNamedColors),
+ ColorRec{name, 0,0,0}, // key
+ [](const ColorRec& rec, const ColorRec& key) {
+ return strcmp(rec.name, key.name) < 0;
+ });
+
+ if (rec == std::end(gNamedColors) || strcmp(name, rec->name)) {
+ return nullptr;
+ }
+
+ if (color) {
+ *color = SkColorSetRGB(rec->r, rec->g, rec->b);
}
- return nullptr;
+
+ return name + strlen(rec->name);
}
// !!! move to char utilities
diff --git a/chromium/third_party/skia/src/utils/SkParsePath.cpp b/chromium/third_party/skia/src/utils/SkParsePath.cpp
index 688daae33b1..31a912ca476 100644
--- a/chromium/third_party/skia/src/utils/SkParsePath.cpp
+++ b/chromium/third_party/skia/src/utils/SkParsePath.cpp
@@ -92,7 +92,7 @@ bool SkParsePath::FromSVGString(const char data[], SkPath* result) {
}
char ch = data[0];
if (is_digit(ch) || ch == '-' || ch == '+' || ch == '.') {
- if (op == '\0') {
+ if (op == '\0' || op == 'Z') {
return false;
}
} else if (is_sep(ch)) {
diff --git a/chromium/third_party/skia/src/utils/SkShadowUtils.cpp b/chromium/third_party/skia/src/utils/SkShadowUtils.cpp
index 869997f7b34..4691b3fef26 100644
--- a/chromium/third_party/skia/src/utils/SkShadowUtils.cpp
+++ b/chromium/third_party/skia/src/utils/SkShadowUtils.cpp
@@ -17,6 +17,7 @@
#include "include/private/SkIDChangeListener.h"
#include "include/utils/SkRandom.h"
#include "src/core/SkBlurMask.h"
+#include "src/core/SkColorFilterBase.h"
#include "src/core/SkColorFilterPriv.h"
#include "src/core/SkDevice.h"
#include "src/core/SkDrawShadowInfo.h"
@@ -40,7 +41,7 @@
* Final result is black with alpha of Gaussian(B)*G.
* The assumption is that the original color's alpha is 1.
*/
-class SkGaussianColorFilter : public SkColorFilter {
+class SkGaussianColorFilter : public SkColorFilterBase {
public:
SkGaussianColorFilter() : INHERITED() {}
@@ -73,7 +74,7 @@ protected:
private:
SK_FLATTENABLE_HOOKS(SkGaussianColorFilter)
- typedef SkColorFilter INHERITED;
+ typedef SkColorFilterBase INHERITED;
};
sk_sp<SkFlattenable> SkGaussianColorFilter::CreateProc(SkReadBuffer&) {
@@ -84,7 +85,8 @@ sk_sp<SkFlattenable> SkGaussianColorFilter::CreateProc(SkReadBuffer&) {
std::unique_ptr<GrFragmentProcessor> SkGaussianColorFilter::asFragmentProcessor(
GrRecordingContext*, const GrColorInfo&) const {
- return GrBlurredEdgeFragmentProcessor::Make(GrBlurredEdgeFragmentProcessor::Mode::kGaussian);
+ return GrBlurredEdgeFragmentProcessor::Make(
+ /*inputFP=*/nullptr, GrBlurredEdgeFragmentProcessor::Mode::kGaussian);
}
#endif
@@ -594,8 +596,7 @@ void SkBaseDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
SkAutoDeviceTransformRestore adr(
this,
hasPerspective ? SkMatrix::I()
- : SkMatrix::Concat(this->localToDevice(),
- SkMatrix::MakeTrans(tx, ty)));
+ : this->localToDevice() * SkMatrix::Translate(tx, ty));
this->drawVertices(vertices, mode, paint);
}
};
diff --git a/chromium/third_party/skia/src/utils/mac/SkCGBase.h b/chromium/third_party/skia/src/utils/mac/SkCGBase.h
new file mode 100644
index 00000000000..a7b0ed06d05
--- /dev/null
+++ b/chromium/third_party/skia/src/utils/mac/SkCGBase.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkCGBase_DEFINED
+#define SkCGBase_DEFINED
+
+#include "include/core/SkTypes.h"
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+
+#ifdef SK_BUILD_FOR_MAC
+#import <ApplicationServices/ApplicationServices.h>
+#endif
+
+#ifdef SK_BUILD_FOR_IOS
+#include <CoreGraphics/CoreGraphics.h>
+#endif
+
+// Skia extensions for types in CGBase.h
+
+static inline CGFloat SkScalarToCGFloat(SkScalar scalar) {
+ return CGFLOAT_IS_DOUBLE ? SkScalarToDouble(scalar) : SkScalarToFloat(scalar);
+}
+
+static inline SkScalar SkScalarFromCGFloat(CGFloat cgFloat) {
+ return CGFLOAT_IS_DOUBLE ? SkDoubleToScalar(cgFloat) : SkFloatToScalar(cgFloat);
+}
+
+static inline float SkFloatFromCGFloat(CGFloat cgFloat) {
+ return CGFLOAT_IS_DOUBLE ? static_cast<float>(cgFloat) : cgFloat;
+}
+
+#endif
+#endif //SkCGBase_DEFINED
diff --git a/chromium/third_party/skia/src/utils/mac/SkCGGeometry.h b/chromium/third_party/skia/src/utils/mac/SkCGGeometry.h
new file mode 100644
index 00000000000..04b1263bcd5
--- /dev/null
+++ b/chromium/third_party/skia/src/utils/mac/SkCGGeometry.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkCGGeometry_DEFINED
+#define SkCGGeometry_DEFINED
+
+#include "include/core/SkTypes.h"
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+
+#ifdef SK_BUILD_FOR_MAC
+#import <ApplicationServices/ApplicationServices.h>
+#endif
+
+#ifdef SK_BUILD_FOR_IOS
+#include <CoreGraphics/CoreGraphics.h>
+#endif
+
+// Skia extensions for types in CGGeometry.h
+
+// Inline versions of these CGRect helpers.
+// The CG versions require making a call and a copy of the CGRect on the stack.
+
+static inline bool SkCGRectIsEmpty(const CGRect& rect) {
+ return rect.size.width <= 0 || rect.size.height <= 0;
+}
+
+static inline CGFloat SkCGRectGetMinX(const CGRect& rect) {
+ return rect.origin.x;
+}
+
+static inline CGFloat SkCGRectGetMaxX(const CGRect& rect) {
+ return rect.origin.x + rect.size.width;
+}
+
+static inline CGFloat SkCGRectGetMinY(const CGRect& rect) {
+ return rect.origin.y;
+}
+
+static inline CGFloat SkCGRectGetMaxY(const CGRect& rect) {
+ return rect.origin.y + rect.size.height;
+}
+
+static inline CGFloat SkCGRectGetWidth(const CGRect& rect) {
+ return rect.size.width;
+}
+
+#endif
+#endif //SkCGGeometry_DEFINED
diff --git a/chromium/third_party/skia/src/utils/mac/SkCTFontSmoothBehavior.cpp b/chromium/third_party/skia/src/utils/mac/SkCTFontSmoothBehavior.cpp
new file mode 100644
index 00000000000..da516874596
--- /dev/null
+++ b/chromium/third_party/skia/src/utils/mac/SkCTFontSmoothBehavior.cpp
@@ -0,0 +1,271 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "include/core/SkTypes.h"
+
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+
+#include "src/utils/mac/SkCTFontSmoothBehavior.h"
+#include "src/utils/mac/SkUniqueCFRef.h"
+
+#ifdef SK_BUILD_FOR_MAC
+#import <ApplicationServices/ApplicationServices.h>
+#endif
+
+#ifdef SK_BUILD_FOR_IOS
+#include <CoreText/CoreText.h>
+#include <CoreText/CTFontManager.h>
+#include <CoreGraphics/CoreGraphics.h>
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
+static constexpr CGBitmapInfo kBitmapInfoRGB = ((CGBitmapInfo)kCGImageAlphaNoneSkipFirst |
+ kCGBitmapByteOrder32Host);
+
+/** Drawn in FontForge, reduced with fonttools ttx, converted by xxd -i,
+ * this TrueType font contains a glyph of the spider.
+ *
+ * To re-forge the original bytes of the TrueType font file,
+ * remove all ',|( +0x)' from this definition,
+ * copy the data to the clipboard,
+ * run 'pbpaste | xxd -p -r - spider.ttf'.
+ */
+static constexpr const uint8_t kSpiderSymbol_ttf[] = {
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x80, 0x00, 0x03, 0x00, 0x40,
+ 0x47, 0x44, 0x45, 0x46, 0x00, 0x14, 0x00, 0x14, 0x00, 0x00, 0x07, 0xa8,
+ 0x00, 0x00, 0x00, 0x18, 0x4f, 0x53, 0x2f, 0x32, 0x8a, 0xf4, 0xfb, 0xdb,
+ 0x00, 0x00, 0x01, 0x48, 0x00, 0x00, 0x00, 0x60, 0x63, 0x6d, 0x61, 0x70,
+ 0xe0, 0x7f, 0x10, 0x7e, 0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, 0x54,
+ 0x67, 0x61, 0x73, 0x70, 0xff, 0xff, 0x00, 0x03, 0x00, 0x00, 0x07, 0xa0,
+ 0x00, 0x00, 0x00, 0x08, 0x67, 0x6c, 0x79, 0x66, 0x97, 0x0b, 0x6a, 0xf6,
+ 0x00, 0x00, 0x02, 0x18, 0x00, 0x00, 0x03, 0x40, 0x68, 0x65, 0x61, 0x64,
+ 0x0f, 0xa2, 0x24, 0x1a, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x36,
+ 0x68, 0x68, 0x65, 0x61, 0x0e, 0xd3, 0x07, 0x3f, 0x00, 0x00, 0x01, 0x04,
+ 0x00, 0x00, 0x00, 0x24, 0x68, 0x6d, 0x74, 0x78, 0x10, 0x03, 0x00, 0x44,
+ 0x00, 0x00, 0x01, 0xa8, 0x00, 0x00, 0x00, 0x0e, 0x6c, 0x6f, 0x63, 0x61,
+ 0x01, 0xb4, 0x00, 0x28, 0x00, 0x00, 0x02, 0x0c, 0x00, 0x00, 0x00, 0x0a,
+ 0x6d, 0x61, 0x78, 0x70, 0x00, 0x4a, 0x01, 0x4d, 0x00, 0x00, 0x01, 0x28,
+ 0x00, 0x00, 0x00, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0xc3, 0xe5, 0x39, 0xd4,
+ 0x00, 0x00, 0x05, 0x58, 0x00, 0x00, 0x02, 0x28, 0x70, 0x6f, 0x73, 0x74,
+ 0xff, 0x03, 0x00, 0x67, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x0b, 0x0f, 0x08, 0x1d,
+ 0x5f, 0x0f, 0x3c, 0xf5, 0x00, 0x0b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xd1, 0x97, 0xa8, 0x5a, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xe8, 0x32, 0x33,
+ 0x00, 0x03, 0xff, 0x3b, 0x08, 0x00, 0x05, 0x55, 0x00, 0x00, 0x00, 0x08,
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x05, 0x55, 0xff, 0x3b, 0x01, 0x79, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x04, 0x01, 0x1c, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x2e,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x00, 0x01, 0x90, 0x00, 0x05,
+ 0x00, 0x00, 0x05, 0x33, 0x05, 0x99, 0x00, 0x00, 0x01, 0x1e, 0x05, 0x33,
+ 0x05, 0x99, 0x00, 0x00, 0x03, 0xd7, 0x00, 0x66, 0x02, 0x12, 0x00, 0x00,
+ 0x05, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x73, 0x6b, 0x69, 0x61, 0x00, 0xc0, 0x00, 0x00, 0xf0, 0x21,
+ 0x06, 0x66, 0xfe, 0x66, 0x01, 0x79, 0x05, 0x55, 0x00, 0xc5, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x20, 0x00, 0x01, 0x08, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x48,
+ 0x00, 0x00, 0x00, 0x0e, 0x00, 0x08, 0x00, 0x02, 0x00, 0x06, 0x00, 0x00,
+ 0x00, 0x09, 0x00, 0x0d, 0x00, 0x1d, 0x00, 0x21, 0xf0, 0x21, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0d, 0x00, 0x1d, 0x00, 0x21,
+ 0xf0, 0x21, 0xff, 0xff, 0x00, 0x01, 0xff, 0xf9, 0xff, 0xf5, 0xff, 0xe4,
+ 0xff, 0xe2, 0x0f, 0xe2, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14,
+ 0x00, 0x14, 0x00, 0x14, 0x01, 0xa0, 0x00, 0x00, 0x00, 0x02, 0x00, 0x44,
+ 0x00, 0x00, 0x02, 0x64, 0x05, 0x55, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00,
+ 0x33, 0x11, 0x21, 0x11, 0x25, 0x21, 0x11, 0x21, 0x44, 0x02, 0x20, 0xfe,
+ 0x24, 0x01, 0x98, 0xfe, 0x68, 0x05, 0x55, 0xfa, 0xab, 0x44, 0x04, 0xcd,
+ 0x00, 0x04, 0x00, 0x03, 0xff, 0x3b, 0x08, 0x00, 0x05, 0x4c, 0x00, 0x15,
+ 0x00, 0x1d, 0x00, 0x25, 0x01, 0x1b, 0x00, 0x00, 0x01, 0x36, 0x37, 0x36,
+ 0x27, 0x26, 0x07, 0x06, 0x06, 0x23, 0x22, 0x27, 0x26, 0x27, 0x26, 0x07,
+ 0x06, 0x17, 0x16, 0x17, 0x16, 0x32, 0x37, 0x32, 0x35, 0x34, 0x23, 0x22,
+ 0x15, 0x14, 0x27, 0x32, 0x35, 0x34, 0x23, 0x22, 0x15, 0x14, 0x03, 0x32,
+ 0x17, 0x30, 0x17, 0x31, 0x36, 0x37, 0x36, 0x37, 0x36, 0x37, 0x36, 0x33,
+ 0x32, 0x33, 0x16, 0x33, 0x32, 0x17, 0x16, 0x07, 0x06, 0x23, 0x22, 0x27,
+ 0x26, 0x27, 0x26, 0x23, 0x22, 0x07, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06,
+ 0x1f, 0x02, 0x37, 0x36, 0x37, 0x36, 0x33, 0x32, 0x17, 0x17, 0x16, 0x33,
+ 0x16, 0x17, 0x16, 0x07, 0x06, 0x23, 0x22, 0x27, 0x27, 0x26, 0x23, 0x22,
+ 0x07, 0x06, 0x07, 0x06, 0x17, 0x16, 0x17, 0x16, 0x33, 0x32, 0x33, 0x32,
+ 0x37, 0x36, 0x37, 0x36, 0x17, 0x16, 0x1f, 0x02, 0x16, 0x17, 0x16, 0x15,
+ 0x14, 0x23, 0x22, 0x27, 0x27, 0x26, 0x27, 0x27, 0x26, 0x27, 0x26, 0x07,
+ 0x06, 0x07, 0x06, 0x17, 0x16, 0x17, 0x16, 0x15, 0x14, 0x07, 0x06, 0x07,
+ 0x06, 0x23, 0x22, 0x27, 0x26, 0x07, 0x06, 0x07, 0x06, 0x15, 0x14, 0x17,
+ 0x16, 0x17, 0x16, 0x15, 0x14, 0x07, 0x06, 0x23, 0x22, 0x27, 0x26, 0x27,
+ 0x26, 0x35, 0x34, 0x37, 0x36, 0x37, 0x36, 0x37, 0x34, 0x27, 0x26, 0x07,
+ 0x06, 0x07, 0x06, 0x0f, 0x02, 0x06, 0x23, 0x22, 0x27, 0x26, 0x35, 0x34,
+ 0x37, 0x37, 0x36, 0x37, 0x36, 0x37, 0x36, 0x37, 0x36, 0x27, 0x26, 0x27,
+ 0x26, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x07, 0x06, 0x23, 0x22,
+ 0x27, 0x26, 0x35, 0x34, 0x37, 0x36, 0x37, 0x37, 0x36, 0x37, 0x37, 0x36,
+ 0x37, 0x36, 0x37, 0x36, 0x35, 0x34, 0x27, 0x26, 0x27, 0x26, 0x27, 0x26,
+ 0x23, 0x22, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x27, 0x26, 0x27, 0x26,
+ 0x27, 0x26, 0x35, 0x34, 0x37, 0x36, 0x37, 0x36, 0x37, 0x36, 0x33, 0x32,
+ 0x17, 0x16, 0x33, 0x32, 0x37, 0x36, 0x35, 0x34, 0x37, 0x36, 0x37, 0x36,
+ 0x33, 0x04, 0xf5, 0x23, 0x13, 0x11, 0x14, 0x16, 0x1d, 0x1b, 0x4c, 0x1f,
+ 0x0e, 0x2d, 0x23, 0x14, 0x2c, 0x13, 0x18, 0x25, 0x2c, 0x10, 0x3c, 0x71,
+ 0x1d, 0x5c, 0x5c, 0x3f, 0xae, 0x5c, 0x5c, 0x3f, 0x6a, 0x27, 0x31, 0x5b,
+ 0x09, 0x27, 0x36, 0x03, 0x0a, 0x26, 0x35, 0x2e, 0x09, 0x08, 0xc6, 0x13,
+ 0x81, 0x17, 0x20, 0x18, 0x21, 0x1e, 0x04, 0x04, 0x15, 0x5c, 0x22, 0x26,
+ 0x48, 0x56, 0x3b, 0x10, 0x21, 0x01, 0x0c, 0x06, 0x06, 0x0f, 0x31, 0x44,
+ 0x3c, 0x52, 0x4a, 0x1d, 0x11, 0x3f, 0xb4, 0x71, 0x01, 0x26, 0x06, 0x0d,
+ 0x15, 0x1a, 0x2a, 0x13, 0x53, 0xaa, 0x42, 0x1d, 0x0a, 0x33, 0x20, 0x21,
+ 0x2b, 0x01, 0x02, 0x3e, 0x21, 0x09, 0x02, 0x02, 0x0f, 0x2d, 0x4b, 0x0a,
+ 0x22, 0x15, 0x20, 0x1f, 0x72, 0x8b, 0x2d, 0x2f, 0x1d, 0x1f, 0x0e, 0x25,
+ 0x3f, 0x4d, 0x1b, 0x63, 0x2a, 0x2c, 0x14, 0x22, 0x18, 0x1c, 0x0f, 0x08,
+ 0x2a, 0x08, 0x08, 0x0d, 0x3b, 0x4c, 0x52, 0x74, 0x27, 0x71, 0x2e, 0x01,
+ 0x0c, 0x10, 0x15, 0x0d, 0x06, 0x0d, 0x05, 0x01, 0x06, 0x2c, 0x28, 0x14,
+ 0x1b, 0x05, 0x04, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x16, 0x27, 0x03, 0x0d,
+ 0x30, 0x4c, 0x4c, 0x4b, 0x1f, 0x0b, 0x22, 0x26, 0x0d, 0x15, 0x0d, 0x2d,
+ 0x68, 0x34, 0x14, 0x3c, 0x25, 0x12, 0x04, 0x10, 0x18, 0x0b, 0x09, 0x30,
+ 0x2b, 0x44, 0x66, 0x14, 0x47, 0x47, 0x59, 0x73, 0x25, 0x05, 0x03, 0x1f,
+ 0x01, 0x08, 0x3f, 0x48, 0x4b, 0x4b, 0x76, 0x2f, 0x49, 0x2d, 0x22, 0x24,
+ 0x0c, 0x15, 0x08, 0x0e, 0x33, 0x03, 0x44, 0x4c, 0x10, 0x46, 0x13, 0x1f,
+ 0x27, 0x1b, 0x1d, 0x13, 0x02, 0x24, 0x08, 0x02, 0x42, 0x0e, 0x4d, 0x3c,
+ 0x19, 0x1b, 0x40, 0x2b, 0x2b, 0x1e, 0x16, 0x11, 0x04, 0x1f, 0x11, 0x04,
+ 0x18, 0x11, 0x35, 0x01, 0xa3, 0x13, 0x24, 0x1f, 0x0b, 0x0c, 0x19, 0x19,
+ 0x18, 0x13, 0x0f, 0x0c, 0x1a, 0x18, 0x1f, 0x19, 0x1e, 0x07, 0x1a, 0xc3,
+ 0x54, 0x51, 0x54, 0x51, 0x04, 0x53, 0x51, 0x54, 0x50, 0x02, 0x48, 0x1a,
+ 0x31, 0x18, 0x55, 0x74, 0x04, 0x0e, 0x09, 0x0d, 0x06, 0x10, 0x16, 0x1b,
+ 0x24, 0x01, 0x04, 0x0b, 0x04, 0x10, 0x3f, 0x0a, 0x41, 0x02, 0x41, 0x20,
+ 0x06, 0x12, 0x16, 0x21, 0x17, 0x2a, 0x1e, 0x15, 0x40, 0x27, 0x11, 0x0e,
+ 0x1e, 0x11, 0x15, 0x1f, 0x43, 0x13, 0x1a, 0x10, 0x15, 0x1b, 0x04, 0x09,
+ 0x4d, 0x2a, 0x0f, 0x19, 0x0a, 0x0a, 0x03, 0x05, 0x15, 0x3c, 0x64, 0x21,
+ 0x4b, 0x2e, 0x21, 0x28, 0x13, 0x47, 0x44, 0x19, 0x3f, 0x11, 0x18, 0x0b,
+ 0x0a, 0x07, 0x18, 0x0d, 0x07, 0x24, 0x2c, 0x2b, 0x21, 0x32, 0x10, 0x48,
+ 0x2a, 0x2d, 0x1e, 0x1a, 0x01, 0x0c, 0x43, 0x59, 0x28, 0x4e, 0x1c, 0x0d,
+ 0x5d, 0x24, 0x14, 0x0a, 0x05, 0x1f, 0x24, 0x32, 0x46, 0x3e, 0x5f, 0x3e,
+ 0x44, 0x1a, 0x30, 0x15, 0x0d, 0x07, 0x18, 0x2b, 0x03, 0x0d, 0x1a, 0x28,
+ 0x28, 0x57, 0xb2, 0x29, 0x27, 0x40, 0x2c, 0x23, 0x16, 0x63, 0x58, 0x1a,
+ 0x0a, 0x18, 0x11, 0x23, 0x08, 0x1b, 0x29, 0x05, 0x04, 0x0b, 0x15, 0x0d,
+ 0x14, 0x0b, 0x2a, 0x29, 0x5a, 0x62, 0x01, 0x19, 0x1e, 0x05, 0x05, 0x26,
+ 0x42, 0x42, 0x2a, 0x2a, 0x3f, 0x0d, 0x0f, 0x09, 0x05, 0x07, 0x01, 0x0b,
+ 0x25, 0x3e, 0x0d, 0x17, 0x11, 0x01, 0x03, 0x0d, 0x13, 0x20, 0x19, 0x11,
+ 0x03, 0x02, 0x01, 0x04, 0x11, 0x04, 0x05, 0x1b, 0x3d, 0x10, 0x29, 0x20,
+ 0x04, 0x04, 0x0a, 0x07, 0x04, 0x1f, 0x15, 0x20, 0x3e, 0x0f, 0x2a, 0x1e,
+ 0x00, 0x00, 0x00, 0x1b, 0x01, 0x4a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x00, 0x0c, 0x00, 0x1b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x07, 0x00, 0x27, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x03, 0x00, 0x0c, 0x00, 0x1b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0x00, 0x0c, 0x00, 0x1b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x05, 0x00, 0x02, 0x00, 0x2e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x06, 0x00, 0x0c, 0x00, 0x1b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0d, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0e, 0x00, 0x1a, 0x00, 0x30, 0x00, 0x03, 0x00, 0x00, 0x04, 0x09,
+ 0x00, 0x00, 0x00, 0x36, 0x00, 0x4a, 0x00, 0x03, 0x00, 0x00, 0x04, 0x09,
+ 0x00, 0x01, 0x00, 0x18, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x04, 0x09,
+ 0x00, 0x02, 0x00, 0x0e, 0x00, 0x98, 0x00, 0x03, 0x00, 0x00, 0x04, 0x09,
+ 0x00, 0x03, 0x00, 0x18, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x04, 0x09,
+ 0x00, 0x04, 0x00, 0x18, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x04, 0x09,
+ 0x00, 0x05, 0x00, 0x04, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x00, 0x04, 0x09,
+ 0x00, 0x06, 0x00, 0x18, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x04, 0x09,
+ 0x00, 0x0d, 0x00, 0x36, 0x00, 0x4a, 0x00, 0x03, 0x00, 0x00, 0x04, 0x09,
+ 0x00, 0x0e, 0x00, 0x34, 0x00, 0xaa, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
+ 0x00, 0x00, 0x00, 0x36, 0x00, 0x4a, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
+ 0x00, 0x01, 0x00, 0x18, 0x00, 0x80, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
+ 0x00, 0x02, 0x00, 0x0e, 0x00, 0x98, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
+ 0x00, 0x03, 0x00, 0x18, 0x00, 0x80, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
+ 0x00, 0x04, 0x00, 0x18, 0x00, 0x80, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
+ 0x00, 0x05, 0x00, 0x04, 0x00, 0xa6, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
+ 0x00, 0x06, 0x00, 0x18, 0x00, 0x80, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
+ 0x00, 0x0d, 0x00, 0x36, 0x00, 0x4a, 0x00, 0x03, 0x00, 0x01, 0x04, 0x09,
+ 0x00, 0x0e, 0x00, 0x34, 0x00, 0xaa, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69,
+ 0x67, 0x68, 0x74, 0x20, 0x28, 0x63, 0x29, 0x20, 0x32, 0x30, 0x31, 0x35,
+ 0x2c, 0x20, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x53, 0x70, 0x69,
+ 0x64, 0x65, 0x72, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x52, 0x65, 0x67,
+ 0x75, 0x6c, 0x61, 0x72, 0x56, 0x31, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
+ 0x2f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x2e, 0x73, 0x69, 0x6c,
+ 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x4f, 0x46, 0x4c, 0x00, 0x43, 0x00, 0x6f,
+ 0x00, 0x70, 0x00, 0x79, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68,
+ 0x00, 0x74, 0x00, 0x20, 0x00, 0x28, 0x00, 0x63, 0x00, 0x29, 0x00, 0x20,
+ 0x00, 0x32, 0x00, 0x30, 0x00, 0x31, 0x00, 0x35, 0x00, 0x2c, 0x00, 0x20,
+ 0x00, 0x47, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x67, 0x00, 0x6c, 0x00, 0x65,
+ 0x00, 0x2e, 0x00, 0x53, 0x00, 0x70, 0x00, 0x69, 0x00, 0x64, 0x00, 0x65,
+ 0x00, 0x72, 0x00, 0x53, 0x00, 0x79, 0x00, 0x6d, 0x00, 0x62, 0x00, 0x6f,
+ 0x00, 0x6c, 0x00, 0x52, 0x00, 0x65, 0x00, 0x67, 0x00, 0x75, 0x00, 0x6c,
+ 0x00, 0x61, 0x00, 0x72, 0x00, 0x56, 0x00, 0x31, 0x00, 0x68, 0x00, 0x74,
+ 0x00, 0x74, 0x00, 0x70, 0x00, 0x3a, 0x00, 0x2f, 0x00, 0x2f, 0x00, 0x73,
+ 0x00, 0x63, 0x00, 0x72, 0x00, 0x69, 0x00, 0x70, 0x00, 0x74, 0x00, 0x73,
+ 0x00, 0x2e, 0x00, 0x73, 0x00, 0x69, 0x00, 0x6c, 0x00, 0x2e, 0x00, 0x6f,
+ 0x00, 0x72, 0x00, 0x67, 0x00, 0x2f, 0x00, 0x4f, 0x00, 0x46, 0x00, 0x4c,
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x66,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0xff, 0xff, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0c, 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x00
+};
+
+/**
+ * There does not appear to be a publicly accessible API for determining if lcd
+ * font smoothing will be applied if we request it. The main issue is that if
+ * smoothing is applied a gamma of 2.0 will be used, if not a gamma of 1.0.
+ */
+SkCTFontSmoothBehavior SkCTFontGetSmoothBehavior() {
+ static SkCTFontSmoothBehavior gSmoothBehavior = []{
+ uint32_t noSmoothBitmap[16][16] = {};
+ uint32_t smoothBitmap[16][16] = {};
+
+ SkUniqueCFRef<CGColorSpaceRef> colorspace(CGColorSpaceCreateDeviceRGB());
+ SkUniqueCFRef<CGContextRef> noSmoothContext(
+ CGBitmapContextCreate(&noSmoothBitmap, 16, 16, 8, 16*4,
+ colorspace.get(), kBitmapInfoRGB));
+ SkUniqueCFRef<CGContextRef> smoothContext(
+ CGBitmapContextCreate(&smoothBitmap, 16, 16, 8, 16*4,
+ colorspace.get(), kBitmapInfoRGB));
+
+ SkUniqueCFRef<CFDataRef> data(CFDataCreateWithBytesNoCopy(
+ kCFAllocatorDefault, kSpiderSymbol_ttf, SK_ARRAY_COUNT(kSpiderSymbol_ttf),
+ kCFAllocatorNull));
+ SkUniqueCFRef<CTFontDescriptorRef> desc(
+ CTFontManagerCreateFontDescriptorFromData(data.get()));
+ SkUniqueCFRef<CTFontRef> ctFont(CTFontCreateWithFontDescriptor(desc.get(), 16, nullptr));
+ SkASSERT(ctFont);
+
+ CGContextSetShouldSmoothFonts(noSmoothContext.get(), false);
+ CGContextSetShouldAntialias(noSmoothContext.get(), true);
+ CGContextSetTextDrawingMode(noSmoothContext.get(), kCGTextFill);
+ CGContextSetGrayFillColor(noSmoothContext.get(), 1, 1);
+
+ CGContextSetShouldSmoothFonts(smoothContext.get(), true);
+ CGContextSetShouldAntialias(smoothContext.get(), true);
+ CGContextSetTextDrawingMode(smoothContext.get(), kCGTextFill);
+ CGContextSetGrayFillColor(smoothContext.get(), 1, 1);
+
+ CGPoint point = CGPointMake(0, 3);
+ CGGlyph spiderGlyph = 3;
+ CTFontDrawGlyphs(ctFont.get(), &spiderGlyph, &point, 1, noSmoothContext.get());
+ CTFontDrawGlyphs(ctFont.get(), &spiderGlyph, &point, 1, smoothContext.get());
+
+ // For debugging.
+ //SkUniqueCFRef<CGImageRef> image(CGBitmapContextCreateImage(noSmoothContext()));
+ //SkUniqueCFRef<CGImageRef> image(CGBitmapContextCreateImage(smoothContext()));
+
+ SkCTFontSmoothBehavior smoothBehavior = SkCTFontSmoothBehavior::none;
+ for (int x = 0; x < 16; ++x) {
+ for (int y = 0; y < 16; ++y) {
+ uint32_t smoothPixel = smoothBitmap[x][y];
+ uint32_t r = (smoothPixel >> 16) & 0xFF;
+ uint32_t g = (smoothPixel >> 8) & 0xFF;
+ uint32_t b = (smoothPixel >> 0) & 0xFF;
+ if (r != g || r != b) {
+ return SkCTFontSmoothBehavior::subpixel;
+ }
+ if (noSmoothBitmap[x][y] != smoothPixel) {
+ smoothBehavior = SkCTFontSmoothBehavior::some;
+ }
+ }
+ }
+ return smoothBehavior;
+ }();
+ return gSmoothBehavior;
+}
+
+#endif
diff --git a/chromium/third_party/skia/src/utils/mac/SkCTFontSmoothBehavior.h b/chromium/third_party/skia/src/utils/mac/SkCTFontSmoothBehavior.h
new file mode 100644
index 00000000000..126cdb3ab2d
--- /dev/null
+++ b/chromium/third_party/skia/src/utils/mac/SkCTFontSmoothBehavior.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkCTFontSmoothBehavior_DEFINED
+#define SkCTFontSmoothBehavior_DEFINED
+
+#include "include/core/SkTypes.h"
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+
+enum class SkCTFontSmoothBehavior {
+ none, // SmoothFonts produces no effect.
+ some, // SmoothFonts produces some effect, but not subpixel coverage.
+ subpixel, // SmoothFonts produces some effect and provides subpixel coverage.
+};
+
+SkCTFontSmoothBehavior SkCTFontGetSmoothBehavior();
+
+#endif
+#endif // SkCTFontSmoothBehavior_DEFINED
diff --git a/chromium/third_party/skia/src/utils/mac/SkStream_mac.cpp b/chromium/third_party/skia/src/utils/mac/SkStream_mac.cpp
deleted file mode 100644
index b299fced492..00000000000
--- a/chromium/third_party/skia/src/utils/mac/SkStream_mac.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-// Remove file after it is removed from downstream builds.