| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 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 "SkImageFilter.h" | 8 #include "SkImageFilter.h" |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 SkASSERT(dst); | 99 SkASSERT(dst); |
| 100 return this->onFilterBounds(src, ctm, dst); | 100 return this->onFilterBounds(src, ctm, dst); |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const SkMatrix&, | 103 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const SkMatrix&, |
| 104 SkBitmap*, SkIPoint*) { | 104 SkBitmap*, SkIPoint*) { |
| 105 return false; | 105 return false; |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool SkImageFilter::canFilterImageGPU() const { | 108 bool SkImageFilter::canFilterImageGPU() const { |
| 109 return this->asNewEffect(NULL, NULL, SkMatrix::I()); | 109 return this->asNewEffect(NULL, NULL, SkMatrix::I(), SkIRect()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMa
trix& ctm, | 112 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMa
trix& ctm, |
| 113 SkBitmap* result, SkIPoint* offset) { | 113 SkBitmap* result, SkIPoint* offset) { |
| 114 #if SK_SUPPORT_GPU | 114 #if SK_SUPPORT_GPU |
| 115 SkBitmap input; | 115 SkBitmap input; |
| 116 SkASSERT(fInputCount == 1); | 116 SkASSERT(fInputCount == 1); |
| 117 if (!SkImageFilterUtils::GetInputResultGPU(this->getInput(0), proxy, src, ct
m, &input, offset)) { | 117 if (!SkImageFilterUtils::GetInputResultGPU(this->getInput(0), proxy, src, ct
m, &input, offset)) { |
| 118 return false; | 118 return false; |
| 119 } | 119 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 134 desc.fConfig = kRGBA_8888_GrPixelConfig; | 134 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 135 | 135 |
| 136 GrAutoScratchTexture dst(context, desc); | 136 GrAutoScratchTexture dst(context, desc); |
| 137 GrContext::AutoMatrix am; | 137 GrContext::AutoMatrix am; |
| 138 am.setIdentity(context); | 138 am.setIdentity(context); |
| 139 GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget()); | 139 GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget()); |
| 140 GrContext::AutoClip acs(context, dstRect); | 140 GrContext::AutoClip acs(context, dstRect); |
| 141 GrEffectRef* effect; | 141 GrEffectRef* effect; |
| 142 SkMatrix matrix(ctm); | 142 SkMatrix matrix(ctm); |
| 143 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); | 143 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); |
| 144 this->asNewEffect(&effect, srcTexture, matrix); | 144 this->asNewEffect(&effect, srcTexture, matrix, bounds); |
| 145 SkASSERT(effect); | 145 SkASSERT(effect); |
| 146 SkAutoUnref effectRef(effect); | 146 SkAutoUnref effectRef(effect); |
| 147 GrPaint paint; | 147 GrPaint paint; |
| 148 paint.addColorEffect(effect); | 148 paint.addColorEffect(effect); |
| 149 context->drawRectToRect(paint, dstRect, srcRect); | 149 context->drawRectToRect(paint, dstRect, srcRect); |
| 150 | 150 |
| 151 SkAutoTUnref<GrTexture> resultTex(dst.detach()); | 151 SkAutoTUnref<GrTexture> resultTex(dst.detach()); |
| 152 SkImageFilterUtils::WrapTexture(resultTex, bounds.width(), bounds.height(),
result); | 152 SkImageFilterUtils::WrapTexture(resultTex, bounds.width(), bounds.height(),
result); |
| 153 offset->fX += bounds.left(); | 153 offset->fX += bounds.left(); |
| 154 offset->fY += bounds.top(); | 154 offset->fY += bounds.top(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 171 if (!(flags & CropRect::kHasBottom_CropEdge)) cropRectI.fBottom = SK_MaxS32; | 171 if (!(flags & CropRect::kHasBottom_CropEdge)) cropRectI.fBottom = SK_MaxS32; |
| 172 return rect->intersect(cropRectI); | 172 return rect->intersect(cropRectI); |
| 173 } | 173 } |
| 174 | 174 |
| 175 bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, | 175 bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, |
| 176 SkIRect* dst) { | 176 SkIRect* dst) { |
| 177 *dst = src; | 177 *dst = src; |
| 178 return true; | 178 return true; |
| 179 } | 179 } |
| 180 | 180 |
| 181 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&) cons
t { | 181 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&, cons
t SkIRect&) const { |
| 182 return false; | 182 return false; |
| 183 } | 183 } |
| 184 | 184 |
| 185 bool SkImageFilter::asColorFilter(SkColorFilter**) const { | 185 bool SkImageFilter::asColorFilter(SkColorFilter**) const { |
| 186 return false; | 186 return false; |
| 187 } | 187 } |
| OLD | NEW |