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 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | 18 SkImageInfo info = { |
19 result->installPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); | 19 width, |
| 20 height, |
| 21 kPMColor_SkColorType, |
| 22 kPremul_SkAlphaType, |
| 23 }; |
| 24 result->setConfig(info); |
| 25 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); |
20 return true; | 26 return true; |
21 } | 27 } |
22 | 28 |
23 bool SkImageFilterUtils::GetInputResultGPU(SkImageFilter* filter, SkImageFilter:
:Proxy* proxy, | 29 bool SkImageFilterUtils::GetInputResultGPU(SkImageFilter* filter, SkImageFilter:
:Proxy* proxy, |
24 const SkBitmap& src, const SkMatrix&
ctm, | 30 const SkBitmap& src, const SkMatrix&
ctm, |
25 SkBitmap* result, SkIPoint* offset) { | 31 SkBitmap* result, SkIPoint* offset) { |
26 // 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 |
27 // 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 |
28 // called are restored before we return to the caller. | 34 // called are restored before we return to the caller. |
29 GrContext* context = src.getTexture()->getContext(); | 35 GrContext* context = src.getTexture()->getContext(); |
(...skipping 15 matching lines...) Expand all Loading... |
45 result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref(); | 51 result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref(); |
46 GrUnlockAndUnrefCachedBitmapTexture(resultTex); | 52 GrUnlockAndUnrefCachedBitmapTexture(resultTex); |
47 } | 53 } |
48 return true; | 54 return true; |
49 } else { | 55 } else { |
50 return false; | 56 return false; |
51 } | 57 } |
52 } | 58 } |
53 } | 59 } |
54 #endif | 60 #endif |
OLD | NEW |