| 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 = SkImageInfo::MakeN32Premul(width, height); |
| 19 result->setConfig(info); | 19 result->setConfig(info); |
| 20 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); | 20 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); |
| 21 return true; | 21 return true; |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool SkImageFilterUtils::GetInputResultGPU(SkImageFilter* filter, SkImageFilter:
:Proxy* proxy, | 24 bool SkImageFilterUtils::GetInputResultGPU(const SkImageFilter* filter, SkImageF
ilter::Proxy* proxy, |
| 25 const SkBitmap& src, const SkMatrix&
ctm, | 25 const SkBitmap& src, const SkMatrix&
ctm, |
| 26 SkBitmap* result, SkIPoint* offset) { | 26 SkBitmap* result, SkIPoint* offset) { |
| 27 // Ensure that GrContext calls under filterImage and filterImageGPU below wi
ll see an identity | 27 // Ensure that GrContext calls under filterImage and filterImageGPU below wi
ll see an identity |
| 28 // matrix with no clip and that the matrix, clip, and render target set befo
re this function was | 28 // matrix with no clip and that the matrix, clip, and render target set befo
re this function was |
| 29 // called are restored before we return to the caller. | 29 // called are restored before we return to the caller. |
| 30 GrContext* context = src.getTexture()->getContext(); | 30 GrContext* context = src.getTexture()->getContext(); |
| 31 GrContext::AutoWideOpenIdentityDraw awoid(context, NULL); | 31 GrContext::AutoWideOpenIdentityDraw awoid(context, NULL); |
| 32 if (!filter) { | 32 if (!filter) { |
| 33 offset->fX = offset->fY = 0; | 33 offset->fX = offset->fY = 0; |
| 34 *result = src; | 34 *result = src; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 46 result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref(); | 46 result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref(); |
| 47 GrUnlockAndUnrefCachedBitmapTexture(resultTex); | 47 GrUnlockAndUnrefCachedBitmapTexture(resultTex); |
| 48 } | 48 } |
| 49 return true; | 49 return true; |
| 50 } else { | 50 } else { |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 #endif | 55 #endif |
| OLD | NEW |