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

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

Issue 1259103004: Fix silly mistake in allocating geoms in TextBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 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 "GrBatch.h" 9 #include "GrBatch.h"
10 #include "GrBatchFontCache.h" 10 #include "GrBatchFontCache.h"
(...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 } 1921 }
1922 1922
1923 fBatch.fNumGlyphs += that->numGlyphs(); 1923 fBatch.fNumGlyphs += that->numGlyphs();
1924 1924
1925 // Reallocate space for geo data if necessary and then import that's geo data. 1925 // Reallocate space for geo data if necessary and then import that's geo data.
1926 int newGeoCount = that->fGeoCount + fGeoCount; 1926 int newGeoCount = that->fGeoCount + fGeoCount;
1927 // We assume (and here enforce) that the allocation size is the smallest power of two that 1927 // We assume (and here enforce) that the allocation size is the smallest power of two that
1928 // is greater than or equal to the number of geometries (and at least 1928 // is greater than or equal to the number of geometries (and at least
1929 // kMinGeometryAllocated). 1929 // kMinGeometryAllocated).
1930 int newAllocSize = GrNextPow2(newGeoCount); 1930 int newAllocSize = GrNextPow2(newGeoCount);
1931 int currAllocSize = SkTMax<int>(kMinGeometryAllocated, GrNextPow2(fGeoCo unt)); 1931 int currAllocSize = SkTMax<int>(kMinGeometryAllocated, GrNextPow2(fGeoCo unt));
joshualitt 2015/07/29 13:45:10 Actually, I'm not sure I like the use of 'size' he
1932 1932
1933 if (newAllocSize > currAllocSize) { 1933 if (newGeoCount > currAllocSize) {
1934 fGeoData.realloc(newAllocSize); 1934 fGeoData.realloc(newAllocSize);
1935 } 1935 }
1936 1936
1937 memcpy(&fGeoData[fGeoCount], that->fGeoData.get(), that->fGeoCount * siz eof(Geometry)); 1937 memcpy(&fGeoData[fGeoCount], that->fGeoData.get(), that->fGeoCount * siz eof(Geometry));
1938 // We steal the ref on the blobs from the other TextBatch and set its co unt to 0 so that 1938 // We steal the ref on the blobs from the other TextBatch and set its co unt to 0 so that
1939 // it doesn't try to unref them. 1939 // it doesn't try to unref them.
1940 #ifdef SK_DEBUG 1940 #ifdef SK_DEBUG
1941 for (int i = 0; i < that->fGeoCount; ++i) { 1941 for (int i = 0; i < that->fGeoCount; ++i) {
1942 that->fGeoData.get()[i].fBlob = (Blob*)0x1; 1942 that->fGeoData.get()[i].fBlob = (Blob*)0x1;
1943 } 1943 }
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text, 2272 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat rix, text,
2273 static_cast<size_t>(textLen), 0, 0, noClip)); 2273 static_cast<size_t>(textLen), 0, 0, noClip));
2274 2274
2275 SkScalar transX = static_cast<SkScalar>(random->nextU()); 2275 SkScalar transX = static_cast<SkScalar>(random->nextU());
2276 SkScalar transY = static_cast<SkScalar>(random->nextU()); 2276 SkScalar transY = static_cast<SkScalar>(random->nextU());
2277 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ; 2277 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0] ;
2278 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint); 2278 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t ransY, skPaint);
2279 } 2279 }
2280 2280
2281 #endif 2281 #endif
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