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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 return false; | 100 return false; |
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 if (!result->allocPixels(src.info().makeWH(dstIRect.width(), dstIRect.height
()))) { |
111 if (!result->allocPixels()) { | |
112 return false; | 111 return false; |
113 } | 112 } |
114 | 113 |
115 SkRect srcRect; | 114 SkRect srcRect; |
116 src.getBounds(&srcRect); | 115 src.getBounds(&srcRect); |
117 srcRect.offset(SkPoint::Make(SkIntToScalar(srcOffset.fX), SkIntToScalar(srcO
ffset.fY))); | 116 srcRect.offset(SkPoint::Make(SkIntToScalar(srcOffset.fX), SkIntToScalar(srcO
ffset.fY))); |
118 SkMatrix inverse; | 117 SkMatrix inverse; |
119 inverse.setRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit); | 118 inverse.setRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit); |
120 inverse.postTranslate(-0.5f, -0.5f); | 119 inverse.postTranslate(-0.5f, -0.5f); |
121 | 120 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un
ref(); | 195 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un
ref(); |
197 SkRect srcRect; | 196 SkRect srcRect; |
198 srcBM.getBounds(&srcRect); | 197 srcBM.getBounds(&srcRect); |
199 context->drawRectToRect(paint, dstRect, srcRect); | 198 context->drawRectToRect(paint, dstRect, srcRect); |
200 WrapTexture(dst, desc.fWidth, desc.fHeight, result); | 199 WrapTexture(dst, desc.fWidth, desc.fHeight, result); |
201 return true; | 200 return true; |
202 } | 201 } |
203 #endif | 202 #endif |
204 | 203 |
205 /////////////////////////////////////////////////////////////////////////////// | 204 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |