OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2013 The Android Open Source Project |
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 "SkMatrix.h" | 8 #include "SkMatrix.h" |
9 | 9 |
10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 bool SkImageFilterUtils::GetInputResultGPU(SkImageFilter* filter, SkImageFilter:
:Proxy* proxy, | 29 bool SkImageFilterUtils::GetInputResultGPU(SkImageFilter* filter, SkImageFilter:
:Proxy* proxy, |
30 const SkBitmap& src, const SkMatrix&
ctm, | 30 const SkBitmap& src, const SkMatrix&
ctm, |
31 SkBitmap* result, SkIPoint* offset) { | 31 SkBitmap* result, SkIPoint* offset) { |
32 // Ensure that GrContext calls under filterImage and filterImageGPU below wi
ll see an identity | 32 // Ensure that GrContext calls under filterImage and filterImageGPU below wi
ll see an identity |
33 // matrix with no clip and that the matrix, clip, and render target set befo
re this function was | 33 // matrix with no clip and that the matrix, clip, and render target set befo
re this function was |
34 // called are restored before we return to the caller. | 34 // called are restored before we return to the caller. |
35 GrContext* context = src.getTexture()->getContext(); | 35 GrContext* context = src.getTexture()->getContext(); |
36 GrContext::AutoWideOpenIdentityDraw awoid(context, NULL); | 36 GrContext::AutoWideOpenIdentityDraw awoid(context, NULL); |
37 if (!filter) { | 37 if (!filter) { |
| 38 offset->fX = offset->fY = 0; |
38 *result = src; | 39 *result = src; |
39 return true; | 40 return true; |
40 } else if (filter->canFilterImageGPU()) { | 41 } else if (filter->canFilterImageGPU()) { |
41 return filter->filterImageGPU(proxy, src, ctm, result, offset); | 42 return filter->filterImageGPU(proxy, src, ctm, result, offset); |
42 } else { | 43 } else { |
43 if (filter->filterImage(proxy, src, ctm, result, offset)) { | 44 if (filter->filterImage(proxy, src, ctm, result, offset)) { |
44 if (!result->getTexture()) { | 45 if (!result->getTexture()) { |
45 SkImageInfo info; | 46 SkImageInfo info; |
46 if (!result->asImageInfo(&info)) { | 47 if (!result->asImageInfo(&info)) { |
47 return false; | 48 return false; |
48 } | 49 } |
49 GrTexture* resultTex = GrLockAndRefCachedBitmapTexture(context,
*result, NULL); | 50 GrTexture* resultTex = GrLockAndRefCachedBitmapTexture(context,
*result, NULL); |
50 result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref(); | 51 result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref(); |
51 GrUnlockAndUnrefCachedBitmapTexture(resultTex); | 52 GrUnlockAndUnrefCachedBitmapTexture(resultTex); |
52 } | 53 } |
53 return true; | 54 return true; |
54 } else { | 55 } else { |
55 return false; | 56 return false; |
56 } | 57 } |
57 } | 58 } |
58 } | 59 } |
59 #endif | 60 #endif |
OLD | NEW |