aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/fonts/SkGScalerContext.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-04-12 06:47:05 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-12 06:47:05 -0700
commita9322c2d86aaef1085c267dfc43cf0747f170a86 (patch)
tree6af9e63ea49c092cb76bd0dfa482a03b82444911 /src/fonts/SkGScalerContext.cpp
parentac8681b0a1f0a5b55df059d75c4112bf411ba8b5 (diff)
Revert "Revert of Pass effects directly to fontcache (patchset #8 id:140001 of https://codereview.chromium.org/1863013003/ )"
add SK_SUPPORT_NEW_ONCREATESCALERCONTEXT for chrome this has now landed https://codereview.chromium.org/1878913002/ TBR= BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1880873002 Review URL: https://codereview.chromium.org/1880873002
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 {