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 | 7 |
8 #include "GrAtlasTextBlob.h" | 8 #include "GrAtlasTextBlob.h" |
9 | 9 |
10 #include "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return false; | 250 return false; |
251 } | 251 } |
252 | 252 |
253 inline GrDrawBatch* GrAtlasTextBlob::createBatch( | 253 inline GrDrawBatch* GrAtlasTextBlob::createBatch( |
254 const Run::SubRunInfo& info, | 254 const Run::SubRunInfo& info, |
255 int glyphCount, int run, int subRu
n, | 255 int glyphCount, int run, int subRu
n, |
256 const SkMatrix& viewMatrix, SkScal
ar x, SkScalar y, | 256 const SkMatrix& viewMatrix, SkScal
ar x, SkScalar y, |
257 GrColor color, | 257 GrColor color, |
258 const SkPaint& skPaint, const SkSu
rfaceProps& props, | 258 const SkPaint& skPaint, const SkSu
rfaceProps& props, |
259 const GrDistanceFieldAdjustTable*
distanceAdjustTable, | 259 const GrDistanceFieldAdjustTable*
distanceAdjustTable, |
260 bool useSRGBDistanceTable, | 260 bool useGammaCorrectDistanceTable, |
261 GrBatchFontCache* cache) { | 261 GrBatchFontCache* cache) { |
262 GrMaskFormat format = info.maskFormat(); | 262 GrMaskFormat format = info.maskFormat(); |
263 GrColor subRunColor; | 263 GrColor subRunColor; |
264 if (kARGB_GrMaskFormat == format) { | 264 if (kARGB_GrMaskFormat == format) { |
265 uint8_t paintAlpha = skPaint.getAlpha(); | 265 uint8_t paintAlpha = skPaint.getAlpha(); |
266 subRunColor = SkColorSetARGB(paintAlpha, paintAlpha, paintAlpha, paintAl
pha); | 266 subRunColor = SkColorSetARGB(paintAlpha, paintAlpha, paintAlpha, paintAl
pha); |
267 } else { | 267 } else { |
268 subRunColor = color; | 268 subRunColor = color; |
269 } | 269 } |
270 | 270 |
271 GrAtlasTextBatch* batch; | 271 GrAtlasTextBatch* batch; |
272 if (info.drawAsDistanceFields()) { | 272 if (info.drawAsDistanceFields()) { |
273 SkColor filteredColor; | 273 SkColor filteredColor; |
274 SkColorFilter* colorFilter = skPaint.getColorFilter(); | 274 SkColorFilter* colorFilter = skPaint.getColorFilter(); |
275 if (colorFilter) { | 275 if (colorFilter) { |
276 filteredColor = colorFilter->filterColor(skPaint.getColor()); | 276 filteredColor = colorFilter->filterColor(skPaint.getColor()); |
277 } else { | 277 } else { |
278 filteredColor = skPaint.getColor(); | 278 filteredColor = skPaint.getColor(); |
279 } | 279 } |
280 bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry()); | 280 bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry()); |
281 batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, cache, | 281 batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, cache, |
282 distanceAdjustTable, useSR
GBDistanceTable, | 282 distanceAdjustTable, |
| 283 useGammaCorrectDistanceTab
le, |
283 filteredColor, info.hasUse
LCDText(), useBGR); | 284 filteredColor, info.hasUse
LCDText(), useBGR); |
284 } else { | 285 } else { |
285 batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, cache); | 286 batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, cache); |
286 } | 287 } |
287 GrAtlasTextBatch::Geometry& geometry = batch->geometry(); | 288 GrAtlasTextBatch::Geometry& geometry = batch->geometry(); |
288 geometry.fViewMatrix = viewMatrix; | 289 geometry.fViewMatrix = viewMatrix; |
289 geometry.fBlob = SkRef(this); | 290 geometry.fBlob = SkRef(this); |
290 geometry.fRun = run; | 291 geometry.fRun = run; |
291 geometry.fSubRun = subRun; | 292 geometry.fSubRun = subRun; |
292 geometry.fColor = subRunColor; | 293 geometry.fColor = subRunColor; |
(...skipping 11 matching lines...) Expand all Loading... |
304 const SkPaint& skPaint, const SkSurfaceProps& pro
ps, | 305 const SkPaint& skPaint, const SkSurfaceProps& pro
ps, |
305 const GrDistanceFieldAdjustTable* distanceAdjustT
able, | 306 const GrDistanceFieldAdjustTable* distanceAdjustT
able, |
306 GrBatchFontCache* cache) { | 307 GrBatchFontCache* cache) { |
307 for (int subRun = 0; subRun < fRuns[run].fSubRunInfo.count(); subRun++) { | 308 for (int subRun = 0; subRun < fRuns[run].fSubRunInfo.count(); subRun++) { |
308 const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; | 309 const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; |
309 int glyphCount = info.glyphCount(); | 310 int glyphCount = info.glyphCount(); |
310 if (0 == glyphCount) { | 311 if (0 == glyphCount) { |
311 continue; | 312 continue; |
312 } | 313 } |
313 | 314 |
314 bool useSRGBDistanceTable = GrPixelConfigIsSRGB(dc->accessRenderTarget()
->config()) && | 315 bool useGammaCorrectTable = GrPixelConfigIsSRGB(dc->accessRenderTarget()
->config()) && |
315 !pipelineBuilder->getDisableOutputConversion
ToSRGB(); | 316 !pipelineBuilder->getDisableOutputConversion
ToSRGB(); |
316 | 317 |
317 SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run, | 318 SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run, |
318 subRun, viewMatrix, x,
y, color, | 319 subRun, viewMatrix, x,
y, color, |
319 skPaint, props, | 320 skPaint, props, |
320 distanceAdjustTable, u
seSRGBDistanceTable, | 321 distanceAdjustTable, u
seGammaCorrectTable, |
321 cache)); | 322 cache)); |
322 dc->drawBatch(pipelineBuilder, batch); | 323 dc->drawBatch(pipelineBuilder, batch); |
323 } | 324 } |
324 } | 325 } |
325 | 326 |
326 static void calculate_translation(bool applyVM, | 327 static void calculate_translation(bool applyVM, |
327 const SkMatrix& newViewMatrix, SkScalar newX,
SkScalar newY, | 328 const SkMatrix& newViewMatrix, SkScalar newX,
SkScalar newY, |
328 const SkMatrix& currentViewMatrix, SkScalar cu
rrentX, | 329 const SkMatrix& currentViewMatrix, SkScalar cu
rrentX, |
329 SkScalar currentY, SkScalar* transX, SkScalar*
transY) { | 330 SkScalar currentY, SkScalar* transX, SkScalar*
transY) { |
330 if (applyVM) { | 331 if (applyVM) { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 | 560 |
560 void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMa
trix, | 561 void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMa
trix, |
561 SkScalar x, SkScalar y
, SkScalar* transX, | 562 SkScalar x, SkScalar y
, SkScalar* transX, |
562 SkScalar* transY) { | 563 SkScalar* transY) { |
563 calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y, | 564 calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y, |
564 fCurrentViewMatrix, fX, fY, transX, transY); | 565 fCurrentViewMatrix, fX, fY, transX, transY); |
565 fCurrentViewMatrix = viewMatrix; | 566 fCurrentViewMatrix = viewMatrix; |
566 fX = x; | 567 fX = x; |
567 fY = y; | 568 fY = y; |
568 } | 569 } |
OLD | NEW |