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 |
11 #include "GrTexture.h" | 11 #include "GrTexture.h" |
12 #include "SkImageFilterUtils.h" | 12 #include "SkImageFilterUtils.h" |
13 #include "SkBitmap.h" | 13 #include "SkBitmap.h" |
14 #include "SkGrPixelRef.h" | 14 #include "SkGrPixelRef.h" |
15 #include "SkGr.h" | 15 #include "SkGr.h" |
16 | 16 |
17 bool SkImageFilterUtils::WrapTexture(GrTexture* texture, int width, int height,
SkBitmap* result) { | 17 bool SkImageFilterUtils::WrapTexture(GrTexture* texture, int width, int height,
SkBitmap* result) { |
18 result->setConfig(SkBitmap::kARGB_8888_Config, width, height); | 18 result->setConfig(SkBitmap::kARGB_8888_Config, width, height); |
19 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (texture)))->unref(); | 19 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (texture)))->unref(); |
20 return true; | 20 return true; |
21 } | 21 } |
22 | 22 |
23 bool SkImageFilterUtils::GetInputResultGPU(SkImageFilter* filter, SkImageFilter:
:Proxy* proxy, const SkBitmap& src, SkBitmap* result) { | 23 bool SkImageFilterUtils::GetInputResultGPU(SkImageFilter* filter, SkImageFilter:
:Proxy* proxy, |
| 24 const SkBitmap& src, SkBitmap* result
, |
| 25 SkIPoint* offset) { |
24 if (!filter) { | 26 if (!filter) { |
25 *result = src; | 27 *result = src; |
26 return true; | 28 return true; |
27 } else if (filter->canFilterImageGPU()) { | 29 } else if (filter->canFilterImageGPU()) { |
28 return filter->filterImageGPU(proxy, src, result); | 30 return filter->filterImageGPU(proxy, src, result, offset); |
29 } else { | 31 } else { |
30 SkIPoint offset; | 32 if (filter->filterImage(proxy, src, SkMatrix(), result, offset)) { |
31 if (filter->filterImage(proxy, src, SkMatrix(), result, &offset)) { | |
32 if (!result->getTexture()) { | 33 if (!result->getTexture()) { |
33 GrContext* context = ((GrTexture *) src.getTexture())->getContex
t(); | 34 GrContext* context = ((GrTexture *) src.getTexture())->getContex
t(); |
34 GrTexture* resultTex = GrLockAndRefCachedBitmapTexture(context, | 35 GrTexture* resultTex = GrLockAndRefCachedBitmapTexture(context, |
35 *result, NULL); | 36 *result, NULL); |
36 result->setPixelRef(new SkGrPixelRef(resultTex))->unref(); | 37 result->setPixelRef(new SkGrPixelRef(resultTex))->unref(); |
37 GrUnlockAndUnrefCachedBitmapTexture(resultTex); | 38 GrUnlockAndUnrefCachedBitmapTexture(resultTex); |
38 } | 39 } |
39 return true; | 40 return true; |
40 } else { | 41 } else { |
41 return false; | 42 return false; |
42 } | 43 } |
43 } | 44 } |
44 } | 45 } |
45 #endif | 46 #endif |
OLD | NEW |