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 "effects/GrTextureDomainEffect.h" | 10 #include "effects/GrTextureDomainEffect.h" |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 return; | 944 return; |
945 } | 945 } |
946 | 946 |
947 GrAutoScratchTexture mask; | 947 GrAutoScratchTexture mask; |
948 | 948 |
949 if (create_mask_GPU(fContext, maskRect, *devPathPtr, stroke, | 949 if (create_mask_GPU(fContext, maskRect, *devPathPtr, stroke, |
950 grPaint.isAntiAlias(), &mask)) { | 950 grPaint.isAntiAlias(), &mask)) { |
951 GrTexture* filtered; | 951 GrTexture* filtered; |
952 | 952 |
953 if (paint.getMaskFilter()->filterMaskGPU(mask.texture(), maskRec
t, &filtered, true)) { | 953 if (paint.getMaskFilter()->filterMaskGPU(mask.texture(), maskRec
t, &filtered, true)) { |
| 954 // filterMaskGPU gives us ownership of a ref to the result |
954 SkAutoTUnref<GrTexture> atu(filtered); | 955 SkAutoTUnref<GrTexture> atu(filtered); |
955 | 956 |
| 957 // If the scratch texture that we used as the filter src als
o holds the filter |
| 958 // result then we must detach so that this texture isn't rec
ycled for a later |
| 959 // draw. |
| 960 if (filtered == mask.texture()) { |
| 961 mask.detach(); |
| 962 filtered->unref(); // detach transfers GrAutoScratchText
ure's ref to us. |
| 963 } |
| 964 |
956 if (draw_mask(fContext, maskRect, &grPaint, filtered)) { | 965 if (draw_mask(fContext, maskRect, &grPaint, filtered)) { |
957 // This path is completely drawn | 966 // This path is completely drawn |
958 return; | 967 return; |
959 } | 968 } |
960 } | 969 } |
961 } | 970 } |
962 } | 971 } |
963 | 972 |
964 // draw the mask on the CPU - this is a fallthrough path in case the | 973 // draw the mask on the CPU - this is a fallthrough path in case the |
965 // GPU path fails | 974 // GPU path fails |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1842 GrTexture* texture, | 1851 GrTexture* texture, |
1843 bool needClear) | 1852 bool needClear) |
1844 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1853 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
1845 | 1854 |
1846 SkASSERT(texture && texture->asRenderTarget()); | 1855 SkASSERT(texture && texture->asRenderTarget()); |
1847 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1856 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
1848 // cache. We pass true for the third argument so that it will get unlocked. | 1857 // cache. We pass true for the third argument so that it will get unlocked. |
1849 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1858 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
1850 fNeedClear = needClear; | 1859 fNeedClear = needClear; |
1851 } | 1860 } |
OLD | NEW |