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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 101 } |
102 | 102 |
103 SkRect dstRect = SkRect::MakeWH(SkScalarMul(SkIntToScalar(src.width()), fSca
le.fWidth), | 103 SkRect dstRect = SkRect::MakeWH(SkScalarMul(SkIntToScalar(src.width()), fSca
le.fWidth), |
104 SkScalarMul(SkIntToScalar(src.height()), fSc
ale.fHeight)); | 104 SkScalarMul(SkIntToScalar(src.height()), fSc
ale.fHeight)); |
105 SkIRect dstIRect; | 105 SkIRect dstIRect; |
106 dstRect.roundOut(&dstIRect); | 106 dstRect.roundOut(&dstIRect); |
107 if (dstIRect.isEmpty()) { | 107 if (dstIRect.isEmpty()) { |
108 return false; | 108 return false; |
109 } | 109 } |
110 result->setConfig(src.config(), dstIRect.width(), dstIRect.height()); | 110 result->setConfig(src.config(), dstIRect.width(), dstIRect.height()); |
111 result->allocPixels(); | 111 if (!result->allocPixels()) { |
112 if (!result->getPixels()) { | |
113 return false; | 112 return false; |
114 } | 113 } |
115 | 114 |
116 SkRect srcRect; | 115 SkRect srcRect; |
117 src.getBounds(&srcRect); | 116 src.getBounds(&srcRect); |
118 srcRect.offset(SkPoint::Make(SkIntToScalar(srcOffset.fX), SkIntToScalar(srcO
ffset.fY))); | 117 srcRect.offset(SkPoint::Make(SkIntToScalar(srcOffset.fX), SkIntToScalar(srcO
ffset.fY))); |
119 SkMatrix inverse; | 118 SkMatrix inverse; |
120 inverse.setRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit); | 119 inverse.setRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit); |
121 inverse.postTranslate(-0.5f, -0.5f); | 120 inverse.postTranslate(-0.5f, -0.5f); |
122 | 121 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 GrPaint paint; | 195 GrPaint paint; |
197 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un
ref(); | 196 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un
ref(); |
198 SkRect srcRect; | 197 SkRect srcRect; |
199 srcBM.getBounds(&srcRect); | 198 srcBM.getBounds(&srcRect); |
200 context->drawRectToRect(paint, dstRect, srcRect); | 199 context->drawRectToRect(paint, dstRect, srcRect); |
201 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul
t); | 200 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul
t); |
202 } | 201 } |
203 #endif | 202 #endif |
204 | 203 |
205 /////////////////////////////////////////////////////////////////////////////// | 204 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |