@@ -65,10 +65,7 @@ struct RasterTarget {
65
65
static void SpanFunc (int y, int , const FT_Span* spans, void * user) {
66
66
auto * target = reinterpret_cast <RasterTarget*>(user);
67
67
auto * q = target->origin - target->pitch * y + spans->x ;
68
- auto c = spans->coverage ;
69
- if (target->gammaTable ) {
70
- c = target->gammaTable [c];
71
- }
68
+ auto c = target->gammaTable [spans->coverage ];
72
69
auto aCount = spans->len ;
73
70
/* *
74
71
* For small-spans it is faster to do it by ourselves than calling memset.
@@ -118,21 +115,36 @@ void FTMask::onFillPath(const Path& path, const Matrix& matrix, bool needsGammaC
118
115
ftPath.setFillType (path.getFillType ());
119
116
auto outlines = ftPath.getOutlines ();
120
117
auto ftLibrary = GetLibrary ().library ();
118
+ if (!needsGammaCorrection) {
119
+ FT_Bitmap bitmap;
120
+ bitmap.width = static_cast <unsigned >(info.width ());
121
+ bitmap.rows = static_cast <unsigned >(info.height ());
122
+ bitmap.pitch = static_cast <int >(info.rowBytes ());
123
+ bitmap.buffer = static_cast <unsigned char *>(pixels);
124
+ bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
125
+ bitmap.num_grays = 256 ;
126
+ for (auto & outline : outlines) {
127
+ FT_Outline_Get_Bitmap (ftLibrary, &(outline ->outline ), &bitmap);
128
+ }
129
+ pixelRef->unlockPixels ();
130
+ return ;
131
+ }
121
132
auto buffer = static_cast <unsigned char *>(pixels);
122
133
int rows = info.height ();
123
134
int pitch = static_cast <int >(info.rowBytes ());
124
- RasterTarget target{};
135
+ RasterTarget target = {};
125
136
target.origin = buffer + (rows - 1 ) * pitch;
126
137
target.pitch = pitch;
127
- if (needsGammaCorrection) {
128
- target.gammaTable = PixelRefMask::GammaTable ().data ();
129
- } else {
130
- target.gammaTable = nullptr ;
131
- }
138
+ target.gammaTable = PixelRefMask::GammaTable ().data ();
132
139
FT_Raster_Params params;
133
- params.flags = FT_RASTER_FLAG_AA | FT_RASTER_FLAG_DIRECT;
140
+ params.flags = FT_RASTER_FLAG_AA | FT_RASTER_FLAG_DIRECT | FT_RASTER_FLAG_CLIP ;
134
141
params.gray_spans = SpanFunc;
135
142
params.user = ⌖
143
+ auto & clip = params.clip_box ;
144
+ clip.xMin = 0 ;
145
+ clip.yMin = 0 ;
146
+ clip.xMax = (FT_Pos)info.width ();
147
+ clip.yMax = (FT_Pos)info.height ();
136
148
for (auto & outline : outlines) {
137
149
FT_Outline_Render (ftLibrary, &(outline ->outline ), ¶ms);
138
150
}
0 commit comments