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

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

Issue 1103243002: fix a bug in scrolling BitmapText gpu cached textblobs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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/GrAtlasTextContext.h ('k') | src/gpu/GrTextBlobCache.cpp » ('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 2015 Google Inc. 2 * Copyright 2015 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 #include "GrAtlasTextContext.h" 7 #include "GrAtlasTextContext.h"
8 8
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // This cool bit of math will determine the necessary translation to app ly to the already 300 // This cool bit of math will determine the necessary translation to app ly to the already
301 // generated vertex coordinates to move them to the correct position 301 // generated vertex coordinates to move them to the correct position
302 SkScalar transX = viewMatrix.getTranslateX() + 302 SkScalar transX = viewMatrix.getTranslateX() +
303 viewMatrix.getScaleX() * (x - blob.fX) + 303 viewMatrix.getScaleX() * (x - blob.fX) +
304 viewMatrix.getSkewX() * (y - blob.fY) - 304 viewMatrix.getSkewX() * (y - blob.fY) -
305 blob.fViewMatrix.getTranslateX(); 305 blob.fViewMatrix.getTranslateX();
306 SkScalar transY = viewMatrix.getTranslateY() + 306 SkScalar transY = viewMatrix.getTranslateY() +
307 viewMatrix.getSkewY() * (x - blob.fX) + 307 viewMatrix.getSkewY() * (x - blob.fX) +
308 viewMatrix.getScaleY() * (y - blob.fY) - 308 viewMatrix.getScaleY() * (y - blob.fY) -
309 blob.fViewMatrix.getTranslateY(); 309 blob.fViewMatrix.getTranslateY();
310 if (SkScalarFraction(transX) > SK_ScalarNearlyZero || 310 if (!SkScalarIsInt(transX) || !SkScalarIsInt(transY) ) {
311 SkScalarFraction(transY) > SK_ScalarNearlyZero) {
312 return true; 311 return true;
313 } 312 }
314 313
315 #ifdef SK_DEBUG
316 static const SkScalar kMinDiscernableTranslation = 0.0625;
317 // As a safeguard when debugging, we store the total error across all tr anslations and print
318 // if the error becomes discernable. This is pretty unlikely to occur g iven the tight
319 // bounds above on translation
320 blob.fTotalXError += SkScalarAbs(SkScalarFraction(transX));
321 blob.fTotalYError += SkScalarAbs(SkScalarFraction(transY));
322 if (blob.fTotalXError > kMinDiscernableTranslation ||
323 blob.fTotalYError > kMinDiscernableTranslation) {
324 SkDebugf("Exceeding error threshold for bitmap text translation");
325 }
326 #endif
327 (*outTransX) = transX; 314 (*outTransX) = transX;
328 (*outTransY) = transY; 315 (*outTransY) = transY;
329 } else if (blob.hasDistanceField()) { 316 } else if (blob.hasDistanceField()) {
330 // A scale outside of [blob.fMaxMinScale, blob.fMinMaxScale] would resul t in a different 317 // A scale outside of [blob.fMaxMinScale, blob.fMinMaxScale] would resul t in a different
331 // distance field being generated, so we have to regenerate in those cas es 318 // distance field being generated, so we have to regenerate in those cas es
332 SkScalar newMaxScale = viewMatrix.getMaxScale(); 319 SkScalar newMaxScale = viewMatrix.getMaxScale();
333 SkScalar oldMaxScale = blob.fViewMatrix.getMaxScale(); 320 SkScalar oldMaxScale = blob.fViewMatrix.getMaxScale();
334 SkScalar scaleAdjust = newMaxScale / oldMaxScale; 321 SkScalar scaleAdjust = newMaxScale / oldMaxScale;
335 if (scaleAdjust < blob.fMaxMinScale || scaleAdjust > blob.fMinMaxScale) { 322 if (scaleAdjust < blob.fMaxMinScale || scaleAdjust > blob.fMinMaxScale) {
336 return true; 323 return true;
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 pipelineBuilder.setFromPaint(grPaint, rt, clip); 2156 pipelineBuilder.setFromPaint(grPaint, rt, clip);
2170 2157
2171 GrColor color = grPaint.getColor(); 2158 GrColor color = grPaint.getColor();
2172 for (int run = 0; run < cacheBlob->fRunCount; run++) { 2159 for (int run = 0; run < cacheBlob->fRunCount; run++) {
2173 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, 0, 0, sk Paint); 2160 this->flushRun(target, &pipelineBuilder, cacheBlob, run, color, 0, 0, sk Paint);
2174 } 2161 }
2175 2162
2176 // Now flush big glyphs 2163 // Now flush big glyphs
2177 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip, 0, 0); 2164 this->flushBigGlyphs(cacheBlob, rt, grPaint, clip, 0, 0);
2178 } 2165 }
OLDNEW
« no previous file with comments | « src/gpu/GrAtlasTextContext.h ('k') | src/gpu/GrTextBlobCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698