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 "SkBicubicImageFilter.h" | 8 #include "SkBicubicImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 SkScalar g = SkScalarMul(cc[0], SkGetPackedG32(c0)) + SkScalarMul(cc[1], SkG
etPackedG32(c1)) + SkScalarMul(cc[2], SkGetPackedG32(c2)) + SkScalarMul(cc[3], S
kGetPackedG32(c3)); | 75 SkScalar g = SkScalarMul(cc[0], SkGetPackedG32(c0)) + SkScalarMul(cc[1], SkG
etPackedG32(c1)) + SkScalarMul(cc[2], SkGetPackedG32(c2)) + SkScalarMul(cc[3], S
kGetPackedG32(c3)); |
76 SkScalar b = SkScalarMul(cc[0], SkGetPackedB32(c0)) + SkScalarMul(cc[1], SkG
etPackedB32(c1)) + SkScalarMul(cc[2], SkGetPackedB32(c2)) + SkScalarMul(cc[3], S
kGetPackedB32(c3)); | 76 SkScalar b = SkScalarMul(cc[0], SkGetPackedB32(c0)) + SkScalarMul(cc[1], SkG
etPackedB32(c1)) + SkScalarMul(cc[2], SkGetPackedB32(c2)) + SkScalarMul(cc[3], S
kGetPackedB32(c3)); |
77 return SkPackARGB32(SkScalarRoundToInt(a), | 77 return SkPackARGB32(SkScalarRoundToInt(a), |
78 SkScalarRoundToInt(SkScalarClampMax(r, a)), | 78 SkScalarRoundToInt(SkScalarClampMax(r, a)), |
79 SkScalarRoundToInt(SkScalarClampMax(g, a)), | 79 SkScalarRoundToInt(SkScalarClampMax(g, a)), |
80 SkScalarRoundToInt(SkScalarClampMax(b, a))); | 80 SkScalarRoundToInt(SkScalarClampMax(b, a))); |
81 } | 81 } |
82 | 82 |
83 bool SkBicubicImageFilter::onFilterImage(Proxy* proxy, | 83 bool SkBicubicImageFilter::onFilterImage(Proxy* proxy, |
84 const SkBitmap& source, | 84 const SkBitmap& source, |
85 const SkMatrix& matrix, | 85 const Context& ctx, |
86 SkBitmap* result, | 86 SkBitmap* result, |
87 SkIPoint* offset) const { | 87 SkIPoint* offset) const { |
88 SkBitmap src = source; | 88 SkBitmap src = source; |
89 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 89 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
90 if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, &s
rcOffset)) { | 90 if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcO
ffset)) { |
91 return false; | 91 return false; |
92 } | 92 } |
93 | 93 |
94 if (src.colorType() != kPMColor_SkColorType) { | 94 if (src.colorType() != kPMColor_SkColorType) { |
95 return false; | 95 return false; |
96 } | 96 } |
97 | 97 |
98 SkAutoLockPixels alp(src); | 98 SkAutoLockPixels alp(src); |
99 if (!src.getPixels()) { | 99 if (!src.getPixels()) { |
100 return false; | 100 return false; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 offset->fX = dstIRect.fLeft; | 162 offset->fX = dstIRect.fLeft; |
163 offset->fY = dstIRect.fTop; | 163 offset->fY = dstIRect.fTop; |
164 return true; | 164 return true; |
165 } | 165 } |
166 | 166 |
167 /////////////////////////////////////////////////////////////////////////////// | 167 /////////////////////////////////////////////////////////////////////////////// |
168 | 168 |
169 #if SK_SUPPORT_GPU | 169 #if SK_SUPPORT_GPU |
170 | 170 |
171 bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, con
st SkMatrix& ctm, | 171 bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, con
st Context& ctx, |
172 SkBitmap* result, SkIPoint* offset) co
nst { | 172 SkBitmap* result, SkIPoint* offset) co
nst { |
173 SkBitmap srcBM = src; | 173 SkBitmap srcBM = src; |
174 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctm, &srcBM,
offset)) { | 174 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &srcBM,
offset)) { |
175 return false; | 175 return false; |
176 } | 176 } |
177 GrTexture* srcTexture = srcBM.getTexture(); | 177 GrTexture* srcTexture = srcBM.getTexture(); |
178 GrContext* context = srcTexture->getContext(); | 178 GrContext* context = srcTexture->getContext(); |
179 | 179 |
180 SkRect dstRect = SkRect::MakeWH(srcBM.width() * fScale.fWidth, | 180 SkRect dstRect = SkRect::MakeWH(srcBM.width() * fScale.fWidth, |
181 srcBM.height() * fScale.fHeight); | 181 srcBM.height() * fScale.fHeight); |
182 | 182 |
183 GrTextureDesc desc; | 183 GrTextureDesc desc; |
184 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; | 184 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; |
(...skipping 11 matching lines...) Expand all Loading... |
196 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un
ref(); | 196 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un
ref(); |
197 SkRect srcRect; | 197 SkRect srcRect; |
198 srcBM.getBounds(&srcRect); | 198 srcBM.getBounds(&srcRect); |
199 context->drawRectToRect(paint, dstRect, srcRect); | 199 context->drawRectToRect(paint, dstRect, srcRect); |
200 WrapTexture(dst, desc.fWidth, desc.fHeight, result); | 200 WrapTexture(dst, desc.fWidth, desc.fHeight, result); |
201 return true; | 201 return true; |
202 } | 202 } |
203 #endif | 203 #endif |
204 | 204 |
205 /////////////////////////////////////////////////////////////////////////////// | 205 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |