| 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 "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 maskRect.roundOut(&finalIRect); | 510 maskRect.roundOut(&finalIRect); |
| 511 if (draw.fClip->quickReject(finalIRect)) { | 511 if (draw.fClip->quickReject(finalIRect)) { |
| 512 // clipped out | 512 // clipped out |
| 513 return; | 513 return; |
| 514 } | 514 } |
| 515 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext
, | 515 if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext
, |
| 516 fRenderT
arget, | 516 fRenderT
arget, |
| 517 &grPaint
, | 517 &grPaint
, |
| 518 fClip, | 518 fClip, |
| 519 *draw.fM
atrix, | 519 *draw.fM
atrix, |
| 520 strokeIn
fo.getStrokeRec(), | 520 strokeIn
fo, |
| 521 devRRect
)) { | 521 devRRect
)) { |
| 522 return; | 522 return; |
| 523 } | 523 } |
| 524 } | 524 } |
| 525 | 525 |
| 526 } | 526 } |
| 527 } | 527 } |
| 528 | 528 |
| 529 } | 529 } |
| 530 | 530 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 SkTLazy<SkPath> tmpPath; | 781 SkTLazy<SkPath> tmpPath; |
| 782 SkTLazy<SkPath> effectPath; | 782 SkTLazy<SkPath> effectPath; |
| 783 SkPathEffect* pathEffect = paint.getPathEffect(); | 783 SkPathEffect* pathEffect = paint.getPathEffect(); |
| 784 | 784 |
| 785 SkMatrix viewMatrix = origViewMatrix; | 785 SkMatrix viewMatrix = origViewMatrix; |
| 786 | 786 |
| 787 if (prePathMatrix) { | 787 if (prePathMatrix) { |
| 788 // stroking, path effects, and blurs are supposed to be applied *after*
the prePathMatrix. | 788 // stroking, path effects, and blurs are supposed to be applied *after*
the prePathMatrix. |
| 789 // The pre-path-matrix also should not affect shading. | 789 // The pre-path-matrix also should not affect shading. |
| 790 if (NULL == paint.getMaskFilter() && NULL == pathEffect && NULL == paint
.getShader() && | 790 if (NULL == paint.getMaskFilter() && NULL == pathEffect && NULL == paint
.getShader() && |
| 791 (strokeInfo.getStrokeRec().isFillStyle() || | 791 (strokeInfo.isFillStyle() || strokeInfo.isHairlineStyle())) { |
| 792 strokeInfo.getStrokeRec().isHairlineStyle())) { | |
| 793 viewMatrix.preConcat(*prePathMatrix); | 792 viewMatrix.preConcat(*prePathMatrix); |
| 794 } else { | 793 } else { |
| 795 SkPath* result = pathPtr; | 794 SkPath* result = pathPtr; |
| 796 | 795 |
| 797 if (!pathIsMutable) { | 796 if (!pathIsMutable) { |
| 798 result = tmpPath.init(); | 797 result = tmpPath.init(); |
| 799 result->setIsVolatile(true); | 798 result->setIsVolatile(true); |
| 800 pathIsMutable = true; | 799 pathIsMutable = true; |
| 801 } | 800 } |
| 802 // should I push prePathMatrix on our MV stack temporarily, instead | 801 // should I push prePathMatrix on our MV stack temporarily, instead |
| 803 // of applying it here? See SkDraw.cpp | 802 // of applying it here? See SkDraw.cpp |
| 804 pathPtr->transform(*prePathMatrix, result); | 803 pathPtr->transform(*prePathMatrix, result); |
| 805 pathPtr = result; | 804 pathPtr = result; |
| 806 } | 805 } |
| 807 } | 806 } |
| 808 // at this point we're done with prePathMatrix | 807 // at this point we're done with prePathMatrix |
| 809 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) | 808 SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;) |
| 810 | 809 |
| 811 GrPaint grPaint; | 810 GrPaint grPaint; |
| 812 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, viewMatrix, true
, &grPaint)) { | 811 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, viewMatrix, true
, &grPaint)) { |
| 813 return; | 812 return; |
| 814 } | 813 } |
| 815 | 814 |
| 816 const SkRect* cullRect = NULL; // TODO: what is our bounds? | 815 const SkRect* cullRect = NULL; // TODO: what is our bounds? |
| 817 SkStrokeRec* strokePtr = strokeInfo.getStrokeRecPtr(); | |
| 818 if (!strokeInfo.isDashed() && pathEffect && pathEffect->filterPath(effectPat
h.init(), *pathPtr, | 816 if (!strokeInfo.isDashed() && pathEffect && pathEffect->filterPath(effectPat
h.init(), *pathPtr, |
| 819 strokePtr
, cullRect)) { | 817 &strokeIn
fo, cullRect)) { |
| 820 pathPtr = effectPath.get(); | 818 pathPtr = effectPath.get(); |
| 821 pathIsMutable = true; | 819 pathIsMutable = true; |
| 822 } | 820 } |
| 823 | 821 |
| 824 const SkStrokeRec& stroke = strokeInfo.getStrokeRec(); | |
| 825 if (paint.getMaskFilter()) { | 822 if (paint.getMaskFilter()) { |
| 826 if (!stroke.isHairlineStyle()) { | 823 if (!strokeInfo.isHairlineStyle()) { |
| 827 SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init(); | 824 SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init(); |
| 828 if (strokeInfo.isDashed()) { | 825 if (strokeInfo.isDashed()) { |
| 829 if (pathEffect->filterPath(strokedPath, *pathPtr, strokePtr, cul
lRect)) { | 826 if (pathEffect->filterPath(strokedPath, *pathPtr, &strokeInfo, c
ullRect)) { |
| 830 pathPtr = strokedPath; | 827 pathPtr = strokedPath; |
| 831 pathIsMutable = true; | 828 pathIsMutable = true; |
| 832 } | 829 } |
| 833 strokeInfo.removeDash(); | 830 strokeInfo.removeDash(); |
| 834 } | 831 } |
| 835 if (stroke.applyToPath(strokedPath, *pathPtr)) { | 832 if (strokeInfo.applyToPath(strokedPath, *pathPtr)) { |
| 836 pathPtr = strokedPath; | 833 pathPtr = strokedPath; |
| 837 pathIsMutable = true; | 834 pathIsMutable = true; |
| 838 strokeInfo.setFillStyle(); | 835 strokeInfo.setFillStyle(); |
| 839 } | 836 } |
| 840 } | 837 } |
| 841 | 838 |
| 842 // avoid possibly allocating a new path in transform if we can | 839 // avoid possibly allocating a new path in transform if we can |
| 843 SkPath* devPathPtr = pathIsMutable ? pathPtr : tmpPath.init(); | 840 SkPath* devPathPtr = pathIsMutable ? pathPtr : tmpPath.init(); |
| 844 if (!pathIsMutable) { | 841 if (!pathIsMutable) { |
| 845 devPathPtr->setIsVolatile(true); | 842 devPathPtr->setIsVolatile(true); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 858 if (clip_bounds_quick_reject(clipBounds, finalIRect)) { | 855 if (clip_bounds_quick_reject(clipBounds, finalIRect)) { |
| 859 // clipped out | 856 // clipped out |
| 860 return; | 857 return; |
| 861 } | 858 } |
| 862 | 859 |
| 863 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, | 860 if (paint.getMaskFilter()->directFilterMaskGPU(fContext, |
| 864 fRenderTarget, | 861 fRenderTarget, |
| 865 &grPaint, | 862 &grPaint, |
| 866 fClip, | 863 fClip, |
| 867 viewMatrix, | 864 viewMatrix, |
| 868 stroke, | 865 strokeInfo, |
| 869 *devPathPtr)) { | 866 *devPathPtr)) { |
| 870 // the mask filter was able to draw itself directly, so there's
nothing | 867 // the mask filter was able to draw itself directly, so there's
nothing |
| 871 // left to do. | 868 // left to do. |
| 872 return; | 869 return; |
| 873 } | 870 } |
| 874 | 871 |
| 875 | 872 |
| 876 SkAutoTUnref<GrTexture> mask(create_mask_GPU(fContext, | 873 SkAutoTUnref<GrTexture> mask(create_mask_GPU(fContext, |
| 877 fRenderTarget, | 874 fRenderTarget, |
| 878 maskRect, | 875 maskRect, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 895 filtered)) { | 892 filtered)) { |
| 896 // This path is completely drawn | 893 // This path is completely drawn |
| 897 return; | 894 return; |
| 898 } | 895 } |
| 899 } | 896 } |
| 900 } | 897 } |
| 901 } | 898 } |
| 902 | 899 |
| 903 // draw the mask on the CPU - this is a fallthrough path in case the | 900 // draw the mask on the CPU - this is a fallthrough path in case the |
| 904 // GPU path fails | 901 // GPU path fails |
| 905 SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style
: | 902 SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_S
tyle : |
| 906 SkPaint::kFill_Style; | 903 SkPaint::kFill_Sty
le; |
| 907 draw_with_mask_filter(fContext, fRenderTarget, fClip, viewMatrix, *devPa
thPtr, | 904 draw_with_mask_filter(fContext, fRenderTarget, fClip, viewMatrix, *devPa
thPtr, |
| 908 paint.getMaskFilter(), clipBounds, &grPaint, style
); | 905 paint.getMaskFilter(), clipBounds, &grPaint, style
); |
| 909 return; | 906 return; |
| 910 } | 907 } |
| 911 | 908 |
| 912 fContext->drawPath(fRenderTarget, fClip, grPaint, viewMatrix, *pathPtr, stro
keInfo); | 909 fContext->drawPath(fRenderTarget, fClip, grPaint, viewMatrix, *pathPtr, stro
keInfo); |
| 913 } | 910 } |
| 914 | 911 |
| 915 static const int kBmpSmallTileSize = 1 << 10; | 912 static const int kBmpSmallTileSize = 1 << 10; |
| 916 | 913 |
| (...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2057 #endif | 2054 #endif |
| 2058 } | 2055 } |
| 2059 | 2056 |
| 2060 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 2057 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
| 2061 // We always return a transient cache, so it is freed after each | 2058 // We always return a transient cache, so it is freed after each |
| 2062 // filter traversal. | 2059 // filter traversal. |
| 2063 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 2060 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
| 2064 } | 2061 } |
| 2065 | 2062 |
| 2066 #endif | 2063 #endif |
| OLD | NEW |