aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/fonts/SkGScalerContext.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-04-11 07:51:07 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-11 07:51:07 -0700
commitc79172857c3f69cc46837e1beeae0c1ead377bb2 (patch)
tree4e6eebf5b3b09e91c58287875d24f75d62850818 /src/fonts/SkGScalerContext.cpp
parent6dc14aab5ea6be87b5b10f17a19737f586708768 (diff)
Pass effects directly to fontcache
Diffstat (limited to 'src/fonts/SkGScalerContext.cpp')
-rw-r--r--src/fonts/SkGScalerContext.cpp76
1 files changed, 36 insertions, 40 deletions
diff --git a/src/fonts/SkGScalerContext.cpp b/src/fonts/SkGScalerContext.cpp
index 9766e34ff0..0a9601bd7e 100644
--- a/src/fonts/SkGScalerContext.cpp
+++ b/src/fonts/SkGScalerContext.cpp
@@ -5,15 +5,46 @@
* found in the LICENSE file.
*/
+#include "SkDescriptor.h"
#include "SkGScalerContext.h"
#include "SkGlyph.h"
#include "SkPath.h"
#include "SkCanvas.h"
+#define STD_SIZE 1
+
class SkGScalerContext : public SkScalerContext {
public:
- SkGScalerContext(SkGTypeface*, const SkDescriptor*);
- virtual ~SkGScalerContext();
+ SkGScalerContext(SkGTypeface* face, const SkScalerContextEffects& effects,
+ const SkDescriptor* desc)
+ : SkScalerContext(face, effects, desc)
+ , fFace(face)
+ {
+
+ size_t descSize = SkDescriptor::ComputeOverhead(1) + sizeof(SkScalerContext::Rec);
+ SkAutoDescriptor ad(descSize);
+ SkDescriptor* newDesc = ad.getDesc();
+
+ newDesc->init();
+ void* entry = newDesc->addEntry(kRec_SkDescriptorTag,
+ sizeof(SkScalerContext::Rec), &fRec);
+ {
+ SkScalerContext::Rec* rec = (SkScalerContext::Rec*)entry;
+ rec->fTextSize = STD_SIZE;
+ rec->fPreScaleX = SK_Scalar1;
+ rec->fPreSkewX = 0;
+ rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
+ rec->fPost2x2[1][0] = rec->fPost2x2[0][1] = 0;
+ }
+ SkASSERT(descSize == newDesc->getLength());
+ newDesc->computeChecksum();
+
+ fProxy = face->proxy()->createScalerContext(effects, newDesc);
+
+ fRec.getSingleMatrix(&fMatrix);
+ fMatrix.preScale(SK_Scalar1 / STD_SIZE, SK_Scalar1 / STD_SIZE);
+ }
+ virtual ~SkGScalerContext() { delete fProxy; }
protected:
unsigned generateGlyphCount() override;
@@ -30,41 +61,6 @@ private:
SkMatrix fMatrix;
};
-#define STD_SIZE 1
-
-#include "SkDescriptor.h"
-
-SkGScalerContext::SkGScalerContext(SkGTypeface* face, const SkDescriptor* desc)
- : SkScalerContext(face, desc)
- , fFace(face)
-{
-
- size_t descSize = SkDescriptor::ComputeOverhead(1) + sizeof(SkScalerContext::Rec);
- SkAutoDescriptor ad(descSize);
- SkDescriptor* newDesc = ad.getDesc();
-
- newDesc->init();
- void* entry = newDesc->addEntry(kRec_SkDescriptorTag,
- sizeof(SkScalerContext::Rec), &fRec);
- {
- SkScalerContext::Rec* rec = (SkScalerContext::Rec*)entry;
- rec->fTextSize = STD_SIZE;
- rec->fPreScaleX = SK_Scalar1;
- rec->fPreSkewX = 0;
- rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
- rec->fPost2x2[1][0] = rec->fPost2x2[0][1] = 0;
- }
- SkASSERT(descSize == newDesc->getLength());
- newDesc->computeChecksum();
-
- fProxy = face->proxy()->createScalerContext(newDesc);
-
- fRec.getSingleMatrix(&fMatrix);
- fMatrix.preScale(SK_Scalar1 / STD_SIZE, SK_Scalar1 / STD_SIZE);
-}
-
-SkGScalerContext::~SkGScalerContext() { delete fProxy; }
-
unsigned SkGScalerContext::generateGlyphCount() {
return fProxy->getGlyphCount();
}
@@ -164,9 +160,9 @@ SkGTypeface::~SkGTypeface() {
fProxy->unref();
}
-SkScalerContext* SkGTypeface::onCreateScalerContext(
- const SkDescriptor* desc) const {
- return new SkGScalerContext(const_cast<SkGTypeface*>(this), desc);
+SkScalerContext* SkGTypeface::onCreateScalerContext(const SkScalerContextEffects& effects,
+ const SkDescriptor* desc) const {
+ return new SkGScalerContext(const_cast<SkGTypeface*>(this), effects, desc);
}
void SkGTypeface::onFilterRec(SkScalerContextRec* rec) const {