Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
| 9 | 9 |
| 10 #include "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 return; | 328 return; |
| 329 } | 329 } |
| 330 SkPath path; | 330 SkPath path; |
| 331 path.setIsVolatile(true); | 331 path.setIsVolatile(true); |
| 332 path.moveTo(pts[0]); | 332 path.moveTo(pts[0]); |
| 333 path.lineTo(pts[1]); | 333 path.lineTo(pts[1]); |
| 334 fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, style); | 334 fDrawContext->drawPath(fClip, grPaint, *draw.fMatrix, path, style); |
| 335 return; | 335 return; |
| 336 } | 336 } |
| 337 | 337 |
| 338 SkScalar scales[2]; | |
| 339 bool isHairline = (0 == width) || (1 == width && draw.fMatrix->getMinMaxScal es(scales) && | |
| 340 SkScalarNearlyEqual(scales[0], 1.f) && | |
| 341 SkScalarNearlyEqual(scales[1], 1.f)); | |
| 338 // we only handle non-antialiased hairlines and paints without path effects or mask filters, | 342 // we only handle non-antialiased hairlines and paints without path effects or mask filters, |
| 339 // else we let the SkDraw call our drawPath() | 343 // else we let the SkDraw call our drawPath() |
| 340 if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() || | 344 if (!isHairline || paint.getPathEffect() || paint.getMaskFilter() || |
| 341 (paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) { | 345 (paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) { |
| 342 draw.drawPoints(mode, count, pts, paint, true); | 346 draw.drawPoints(mode, count, pts, paint, true); |
| 343 return; | 347 return; |
| 344 } | 348 } |
| 345 | 349 |
|
robertphillips
2016/09/12 17:16:51
PrimtiveType - missing 'i' ?
bsalomon
2016/09/12 17:59:15
Done.
| |
| 350 GrPrimitiveType primitiveType = gPointMode2PrimtiveType[mode]; | |
| 351 | |
| 352 const SkMatrix* viewMatrix = draw.fMatrix; | |
| 353 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | |
| 354 // This offsetting in device space matches the expectations of the Android f ramework for non-AA | |
| 355 // points and lines. | |
| 356 SkMatrix tempMatrix; | |
| 357 if (GrIsPrimTypeLines(primitiveType) || kPoints_GrPrimitiveType == primitive Type) { | |
| 358 tempMatrix = *viewMatrix; | |
| 359 static const SkScalar kOffset = 0.063f; // Just greater than 1/16. | |
| 360 tempMatrix.postTranslate(kOffset, kOffset); | |
| 361 viewMatrix = &tempMatrix; | |
| 362 } | |
| 363 #endif | |
| 364 | |
| 346 GrPaint grPaint; | 365 GrPaint grPaint; |
| 347 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.fMat rix, &grPaint)) { | 366 if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *viewMatri x, &grPaint)) { |
| 348 return; | 367 return; |
| 349 } | 368 } |
| 350 | 369 |
| 351 fDrawContext->drawVertices(fClip, | 370 fDrawContext->drawVertices(fClip, |
| 352 grPaint, | 371 grPaint, |
| 353 *draw.fMatrix, | 372 *viewMatrix, |
| 354 gPointMode2PrimtiveType[mode], | 373 primitiveType, |
| 355 SkToS32(count), | 374 SkToS32(count), |
| 356 (SkPoint*)pts, | 375 (SkPoint*)pts, |
| 357 nullptr, | 376 nullptr, |
| 358 nullptr, | 377 nullptr, |
| 359 nullptr, | 378 nullptr, |
| 360 0); | 379 0); |
| 361 } | 380 } |
| 362 | 381 |
| 363 /////////////////////////////////////////////////////////////////////////////// | 382 /////////////////////////////////////////////////////////////////////////////// |
| 364 | 383 |
| (...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1798 } | 1817 } |
| 1799 | 1818 |
| 1800 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { | 1819 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { |
| 1801 ASSERT_SINGLE_OWNER | 1820 ASSERT_SINGLE_OWNER |
| 1802 // We always return a transient cache, so it is freed after each | 1821 // We always return a transient cache, so it is freed after each |
| 1803 // filter traversal. | 1822 // filter traversal. |
| 1804 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); | 1823 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); |
| 1805 } | 1824 } |
| 1806 | 1825 |
| 1807 #endif | 1826 #endif |
| OLD | NEW |