Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |