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

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

Issue 605533002: Fix SkTextBlob offset semantics. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: default run positioning fix Created 6 years, 2 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 | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrDistanceFieldTextContext.h » ('j') | 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 "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 262
263 fx += glyph.fAdvanceX; 263 fx += glyph.fAdvanceX;
264 fy += glyph.fAdvanceY; 264 fy += glyph.fAdvanceY;
265 } 265 }
266 266
267 this->finish(); 267 this->finish();
268 } 268 }
269 269
270 void GrBitmapTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPai nt, 270 void GrBitmapTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPai nt,
271 const char text[], size_t byteLength, 271 const char text[], size_t byteLength,
272 const SkScalar pos[], SkScalar constY, 272 const SkScalar pos[], int scalarsPerPositi on,
273 int scalarsPerPosition) { 273 const SkPoint& offset) {
274 SkASSERT(byteLength == 0 || text != NULL); 274 SkASSERT(byteLength == 0 || text != NULL);
275 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 275 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
276 276
277 // nothing to draw 277 // nothing to draw
278 if (text == NULL || byteLength == 0/* || fRC->isEmpty()*/) { 278 if (text == NULL || byteLength == 0/* || fRC->isEmpty()*/) {
279 return; 279 return;
280 } 280 }
281 281
282 this->init(paint, skPaint); 282 this->init(paint, skPaint);
283 283
284 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); 284 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
285 285
286 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &fContext->getMa trix()); 286 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &fContext->getMa trix());
287 SkGlyphCache* cache = autoCache.getCache(); 287 SkGlyphCache* cache = autoCache.getCache();
288 GrFontScaler* fontScaler = GetGrFontScaler(cache); 288 GrFontScaler* fontScaler = GetGrFontScaler(cache);
289 289
290 // store original matrix before we reset, so we can use it to transform posi tions 290 // store original matrix before we reset, so we can use it to transform posi tions
291 SkMatrix ctm = fContext->getMatrix(); 291 SkMatrix ctm = fContext->getMatrix();
292 GrContext::AutoMatrix autoMatrix; 292 GrContext::AutoMatrix autoMatrix;
293 autoMatrix.setIdentity(fContext, &fPaint); 293 autoMatrix.setIdentity(fContext, &fPaint);
294 294
295 const char* stop = text + byteLength; 295 const char* stop = text + byteLength;
296 SkTextAlignProc alignProc(fSkPaint.getTextAlign()); 296 SkTextAlignProc alignProc(fSkPaint.getTextAlign());
297 SkTextMapStateProc tmsProc(ctm, constY, scalarsPerPosition); 297 SkTextMapStateProc tmsProc(ctm, offset, scalarsPerPosition);
298 SkFixed halfSampleX = 0, halfSampleY = 0; 298 SkFixed halfSampleX = 0, halfSampleY = 0;
299 299
300 if (cache->isSubpixel()) { 300 if (cache->isSubpixel()) {
301 // maybe we should skip the rounding if linearText is set 301 // maybe we should skip the rounding if linearText is set
302 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(ctm); 302 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(ctm);
303 303
304 SkFixed fxMask = ~0; 304 SkFixed fxMask = ~0;
305 SkFixed fyMask = ~0; 305 SkFixed fyMask = ~0;
306 if (kX_SkAxisAlignment == baseline) { 306 if (kX_SkAxisAlignment == baseline) {
307 fyMask = 0; 307 fyMask = 0;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 598 }
599 // color comes after position. 599 // color comes after position.
600 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); 600 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1);
601 for (int i = 0; i < 4; ++i) { 601 for (int i = 0; i < 4; ++i) {
602 *colors = fPaint.getColor(); 602 *colors = fPaint.getColor();
603 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors ) + vertSize); 603 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors ) + vertSize);
604 } 604 }
605 } 605 }
606 fCurrVertex += 4; 606 fCurrVertex += 4;
607 } 607 }
OLDNEW
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrDistanceFieldTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698