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 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2160 const SkPaint& skPaint, | 2160 const SkPaint& skPaint, |
2161 const GrPaint& grPaint, | 2161 const GrPaint& grPaint, |
2162 SkDrawFilter* drawFilter, | 2162 SkDrawFilter* drawFilter, |
2163 const GrClip& clip, | 2163 const GrClip& clip, |
2164 const SkMatrix& viewMatrix, | 2164 const SkMatrix& viewMatrix, |
2165 const SkIRect& clipBounds, | 2165 const SkIRect& clipBounds, |
2166 SkScalar x, SkScalar y, | 2166 SkScalar x, SkScalar y, |
2167 SkScalar transX, SkScalar transY) { | 2167 SkScalar transX, SkScalar transY) { |
2168 // We loop through the runs of the blob, flushing each. If any run is too l
arge, then we flush | 2168 // We loop through the runs of the blob, flushing each. If any run is too l
arge, then we flush |
2169 // it as paths | 2169 // it as paths |
2170 GrPipelineBuilder pipelineBuilder; | 2170 GrPipelineBuilder pipelineBuilder(grPaint, rt, clip); |
2171 pipelineBuilder.setFromPaint(grPaint, rt, clip); | |
2172 | 2171 |
2173 GrColor color = grPaint.getColor(); | 2172 GrColor color = grPaint.getColor(); |
2174 | 2173 |
2175 SkTextBlob::RunIterator it(blob); | 2174 SkTextBlob::RunIterator it(blob); |
2176 for (int run = 0; !it.done(); it.next(), run++) { | 2175 for (int run = 0; !it.done(); it.next(), run++) { |
2177 if (cacheBlob->fRuns[run].fDrawAsPaths) { | 2176 if (cacheBlob->fRuns[run].fDrawAsPaths) { |
2178 this->flushRunAsPaths(rt, it, clip, skPaint, | 2177 this->flushRunAsPaths(rt, it, clip, skPaint, |
2179 drawFilter, viewMatrix, clipBounds, x, y); | 2178 drawFilter, viewMatrix, clipBounds, x, y); |
2180 continue; | 2179 continue; |
2181 } | 2180 } |
2182 cacheBlob->fRuns[run].fVertexBounds.offset(transX, transY); | 2181 cacheBlob->fRuns[run].fVertexBounds.offset(transX, transY); |
2183 this->flushRun(&pipelineBuilder, cacheBlob, run, color, | 2182 this->flushRun(&pipelineBuilder, cacheBlob, run, color, |
2184 transX, transY, skPaint); | 2183 transX, transY, skPaint); |
2185 } | 2184 } |
2186 | 2185 |
2187 // Now flush big glyphs | 2186 // Now flush big glyphs |
2188 this->flushBigGlyphs(cacheBlob, rt, clip, skPaint, transX, transY, clipBound
s); | 2187 this->flushBigGlyphs(cacheBlob, rt, clip, skPaint, transX, transY, clipBound
s); |
2189 } | 2188 } |
2190 | 2189 |
2191 void GrAtlasTextContext::flush(BitmapTextBlob* cacheBlob, | 2190 void GrAtlasTextContext::flush(BitmapTextBlob* cacheBlob, |
2192 GrRenderTarget* rt, | 2191 GrRenderTarget* rt, |
2193 const SkPaint& skPaint, | 2192 const SkPaint& skPaint, |
2194 const GrPaint& grPaint, | 2193 const GrPaint& grPaint, |
2195 const GrClip& clip, | 2194 const GrClip& clip, |
2196 const SkIRect& clipBounds) { | 2195 const SkIRect& clipBounds) { |
2197 GrPipelineBuilder pipelineBuilder; | 2196 GrPipelineBuilder pipelineBuilder(grPaint, rt, clip); |
2198 pipelineBuilder.setFromPaint(grPaint, rt, clip); | |
2199 | 2197 |
2200 GrColor color = grPaint.getColor(); | 2198 GrColor color = grPaint.getColor(); |
2201 for (int run = 0; run < cacheBlob->fRunCount; run++) { | 2199 for (int run = 0; run < cacheBlob->fRunCount; run++) { |
2202 this->flushRun(&pipelineBuilder, cacheBlob, run, color, 0, 0, skPaint); | 2200 this->flushRun(&pipelineBuilder, cacheBlob, run, color, 0, 0, skPaint); |
2203 } | 2201 } |
2204 | 2202 |
2205 // Now flush big glyphs | 2203 // Now flush big glyphs |
2206 this->flushBigGlyphs(cacheBlob, rt, clip, skPaint, 0, 0, clipBounds); | 2204 this->flushBigGlyphs(cacheBlob, rt, clip, skPaint, 0, 0, clipBounds); |
2207 } | 2205 } |
2208 | 2206 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2266 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, | 2264 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, |
2267 static_cast<size_t>(textLen), 0, 0,
noClip)); | 2265 static_cast<size_t>(textLen), 0, 0,
noClip)); |
2268 | 2266 |
2269 SkScalar transX = static_cast<SkScalar>(random->nextU()); | 2267 SkScalar transX = static_cast<SkScalar>(random->nextU()); |
2270 SkScalar transY = static_cast<SkScalar>(random->nextU()); | 2268 SkScalar transY = static_cast<SkScalar>(random->nextU()); |
2271 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
s[0].fSubRunInfo[0]; | 2269 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
s[0].fSubRunInfo[0]; |
2272 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); | 2270 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); |
2273 } | 2271 } |
2274 | 2272 |
2275 #endif | 2273 #endif |
OLD | NEW |