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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) { | 90 static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) { |
91 unsigned r = SkColorGetR(c); | 91 unsigned r = SkColorGetR(c); |
92 unsigned g = SkColorGetG(c); | 92 unsigned g = SkColorGetG(c); |
93 unsigned b = SkColorGetB(c); | 93 unsigned b = SkColorGetB(c); |
94 return GrColorPackRGBA(r, g, b, 0xff); | 94 return GrColorPackRGBA(r, g, b, 0xff); |
95 } | 95 } |
96 | 96 |
97 }; | 97 }; |
98 | 98 |
99 // TODO | |
100 // Distance field text in textblobs | |
101 | |
102 GrAtlasTextContext::GrAtlasTextContext(GrContext* context, | 99 GrAtlasTextContext::GrAtlasTextContext(GrContext* context, |
103 GrDrawContext* drawContext, | 100 GrDrawContext* drawContext, |
104 const SkSurfaceProps& surfaceProps) | 101 const SkSurfaceProps& surfaceProps) |
105 : INHERITED(context, drawContext, surfaceProps) | 102 : INHERITED(context, drawContext, surfaceProps) |
106 , fDistanceAdjustTable(SkNEW(DistanceAdjustTable)) { | 103 , fDistanceAdjustTable(SkNEW(DistanceAdjustTable)) { |
107 // We overallocate vertices in our textblobs based on the assumption that A8
has the greatest | 104 // We overallocate vertices in our textblobs based on the assumption that A8
has the greatest |
108 // vertexStride | 105 // vertexStride |
109 SK_COMPILE_ASSERT(kGrayTextVASize >= kColorTextVASize && kGrayTextVASize >=
kLCDTextVASize, | 106 SK_COMPILE_ASSERT(kGrayTextVASize >= kColorTextVASize && kGrayTextVASize >=
kLCDTextVASize, |
110 vertex_attribute_changed); | 107 vertex_attribute_changed); |
111 fCurrStrike = NULL; | 108 fCurrStrike = NULL; |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 // 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 |
1932 // kMinGeometryAllocated). | 1929 // kMinGeometryAllocated). |
1933 int newAllocSize = GrNextPow2(newGeoCount); | 1930 int newAllocSize = GrNextPow2(newGeoCount); |
1934 int currAllocSize = SkTMax<int>(kMinGeometryAllocated, GrNextPow2(fGeoCo
unt)); | 1931 int currAllocSize = SkTMax<int>(kMinGeometryAllocated, GrNextPow2(fGeoCo
unt)); |
1935 | 1932 |
1936 if (newAllocSize > currAllocSize) { | 1933 if (newAllocSize > currAllocSize) { |
1937 fGeoData.realloc(newAllocSize); | 1934 fGeoData.realloc(newAllocSize); |
1938 } | 1935 } |
1939 | 1936 |
1940 memcpy(&fGeoData[fGeoCount], that->fGeoData.get(), that->fGeoCount * siz
eof(Geometry)); | 1937 memcpy(&fGeoData[fGeoCount], that->fGeoData.get(), that->fGeoCount * siz
eof(Geometry)); |
1941 for (int i = fGeoCount; i < newGeoCount; ++i) { | 1938 // We steal the ref on the blobs from the other TextBatch and set its co
unt to 0 so that |
1942 fGeoData[i].fBlob->ref(); | 1939 // it doesn't try to unref them. |
| 1940 #ifdef SK_DEBUG |
| 1941 for (int i = 0; i < that->fGeoCount; ++i) { |
| 1942 that->fGeoData.get()[i].fBlob = (Blob*)0x1; |
1943 } | 1943 } |
| 1944 #endif |
| 1945 that->fGeoCount = 0; |
1944 fGeoCount = newGeoCount; | 1946 fGeoCount = newGeoCount; |
1945 | 1947 |
1946 this->joinBounds(that->bounds()); | 1948 this->joinBounds(that->bounds()); |
1947 return true; | 1949 return true; |
1948 } | 1950 } |
1949 | 1951 |
1950 // TODO just use class params | 1952 // TODO just use class params |
1951 // TODO trying to figure out why lcd is so whack | 1953 // TODO trying to figure out why lcd is so whack |
1952 GrGeometryProcessor* setupDfProcessor(const SkMatrix& viewMatrix, SkColor fi
lteredColor, | 1954 GrGeometryProcessor* setupDfProcessor(const SkMatrix& viewMatrix, SkColor fi
lteredColor, |
1953 GrColor color, GrTexture* texture) { | 1955 GrColor color, GrTexture* texture) { |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2270 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, | 2272 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, |
2271 static_cast<size_t>(textLen), 0, 0,
noClip)); | 2273 static_cast<size_t>(textLen), 0, 0,
noClip)); |
2272 | 2274 |
2273 SkScalar transX = static_cast<SkScalar>(random->nextU()); | 2275 SkScalar transX = static_cast<SkScalar>(random->nextU()); |
2274 SkScalar transY = static_cast<SkScalar>(random->nextU()); | 2276 SkScalar transY = static_cast<SkScalar>(random->nextU()); |
2275 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0]
; | 2277 const GrAtlasTextBlob::Run::SubRunInfo& info = blob->fRuns[0].fSubRunInfo[0]
; |
2276 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); |
2277 } | 2279 } |
2278 | 2280 |
2279 #endif | 2281 #endif |
OLD | NEW |