Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/gpu/GrBitmapTextContext.cpp

Issue 1047803004: skia: Fix text subpixel half sample default for GPU rasterization (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: move declaration of halfSampleX, Y Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrBitmapTextContext.h" 8 #include "GrBitmapTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 SkDebugf("Cannot invert viewmatrix\n"); 220 SkDebugf("Cannot invert viewmatrix\n");
221 return; 221 return;
222 } 222 }
223 223
224 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); 224 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL);
225 fTotalVertexCount = kVerticesPerGlyph*numGlyphs; 225 fTotalVertexCount = kVerticesPerGlyph*numGlyphs;
226 226
227 const char* stop = text + byteLength; 227 const char* stop = text + byteLength;
228 SkTextAlignProc alignProc(fSkPaint.getTextAlign()); 228 SkTextAlignProc alignProc(fSkPaint.getTextAlign());
229 SkTextMapStateProc tmsProc(viewMatrix, offset, scalarsPerPosition); 229 SkTextMapStateProc tmsProc(viewMatrix, offset, scalarsPerPosition);
230 SkScalar halfSampleX = 0, halfSampleY = 0;
231 230
232 if (cache->isSubpixel()) { 231 if (cache->isSubpixel()) {
233 // maybe we should skip the rounding if linearText is set 232 // maybe we should skip the rounding if linearText is set
234 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(viewMatrix); 233 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(viewMatrix);
235 234
236 SkFixed fxMask = ~0; 235 SkFixed fxMask = ~0;
237 SkFixed fyMask = ~0; 236 SkFixed fyMask = ~0;
237 SkScalar halfSampleX = SkFixedToScalar(SkGlyph::kSubpixelRound);
238 SkScalar halfSampleY = SkFixedToScalar(SkGlyph::kSubpixelRound);
238 if (kX_SkAxisAlignment == baseline) { 239 if (kX_SkAxisAlignment == baseline) {
239 fyMask = 0; 240 fyMask = 0;
240 halfSampleY = SK_ScalarHalf; 241 halfSampleY = SK_ScalarHalf;
241 } else if (kY_SkAxisAlignment == baseline) { 242 } else if (kY_SkAxisAlignment == baseline) {
242 fxMask = 0; 243 fxMask = 0;
243 halfSampleX = SK_ScalarHalf; 244 halfSampleX = SK_ScalarHalf;
244 } 245 }
245 246
246 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { 247 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) {
247 while (text < stop) { 248 while (text < stop) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 304
304 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { 305 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) {
305 while (text < stop) { 306 while (text < stop) {
306 // the last 2 parameters are ignored 307 // the last 2 parameters are ignored
307 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); 308 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
308 309
309 if (glyph.fWidth) { 310 if (glyph.fWidth) {
310 SkPoint tmsLoc; 311 SkPoint tmsLoc;
311 tmsProc(pos, &tmsLoc); 312 tmsProc(pos, &tmsLoc);
312 313
313 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + SK_ScalarHalf); //halfSampleX; 314 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + SK_ScalarHalf);
314 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + SK_ScalarHalf); //halfSampleY; 315 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + SK_ScalarHalf);
315 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 316 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
316 glyph.getSubXFixed(), 317 glyph.getSubXFixed(),
317 glyph.getSubYFixed(), 318 glyph.getSubYFixed(),
318 GrGlyph::kCoverage_MaskStyle ), 319 GrGlyph::kCoverage_MaskStyle ),
319 Sk48Dot16FloorToInt(fx), 320 Sk48Dot16FloorToInt(fx),
320 Sk48Dot16FloorToInt(fy), 321 Sk48Dot16FloorToInt(fy),
321 fontScaler); 322 fontScaler);
322 } 323 }
323 pos += scalarsPerPosition; 324 pos += scalarsPerPosition;
324 } 325 }
325 } else { 326 } else {
326 while (text < stop) { 327 while (text < stop) {
327 // the last 2 parameters are ignored 328 // the last 2 parameters are ignored
328 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); 329 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
329 330
330 if (glyph.fWidth) { 331 if (glyph.fWidth) {
331 SkPoint tmsLoc; 332 SkPoint tmsLoc;
332 tmsProc(pos, &tmsLoc); 333 tmsProc(pos, &tmsLoc);
333 334
334 SkPoint alignLoc; 335 SkPoint alignLoc;
335 alignProc(tmsLoc, glyph, &alignLoc); 336 alignProc(tmsLoc, glyph, &alignLoc);
336 337
337 Sk48Dot16 fx = SkScalarTo48Dot16(alignLoc.fX + SK_ScalarHalf ); //halfSampleX; 338 Sk48Dot16 fx = SkScalarTo48Dot16(alignLoc.fX + SK_ScalarHalf );
338 Sk48Dot16 fy = SkScalarTo48Dot16(alignLoc.fY + SK_ScalarHalf ); //halfSampleY; 339 Sk48Dot16 fy = SkScalarTo48Dot16(alignLoc.fY + SK_ScalarHalf );
339 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 340 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
340 glyph.getSubXFixed(), 341 glyph.getSubXFixed(),
341 glyph.getSubYFixed(), 342 glyph.getSubYFixed(),
342 GrGlyph::kCoverage_MaskStyle ), 343 GrGlyph::kCoverage_MaskStyle ),
343 Sk48Dot16FloorToInt(fx), 344 Sk48Dot16FloorToInt(fx),
344 Sk48Dot16FloorToInt(fy), 345 Sk48Dot16FloorToInt(fy),
345 fontScaler); 346 fontScaler);
346 } 347 }
347 pos += scalarsPerPosition; 348 pos += scalarsPerPosition;
348 } 349 }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 } 633 }
633 } 634 }
634 635
635 inline void GrBitmapTextContext::finish() { 636 inline void GrBitmapTextContext::finish() {
636 this->flush(); 637 this->flush();
637 fTotalVertexCount = 0; 638 fTotalVertexCount = 0;
638 639
639 GrTextContext::finish(); 640 GrTextContext::finish();
640 } 641 }
641 642
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698