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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 result->setConfig(src.config(), dstIRect.width(), dstIRect.height()); | 108 result->setConfig(src.config(), dstIRect.width(), dstIRect.height()); |
109 result->allocPixels(); | 109 result->allocPixels(); |
110 if (!result->getPixels()) { | 110 if (!result->getPixels()) { |
111 return false; | 111 return false; |
112 } | 112 } |
113 | 113 |
114 SkRect srcRect; | 114 SkRect srcRect; |
115 src.getBounds(&srcRect); | 115 src.getBounds(&srcRect); |
116 SkMatrix inverse; | 116 SkMatrix inverse; |
117 inverse.setRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit); | 117 inverse.setRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit); |
118 inverse.postTranslate(SkFloatToScalar(-0.5f), SkFloatToScalar(-0.5f)); | 118 inverse.postTranslate(-0.5f, -0.5f); |
119 | 119 |
120 for (int y = dstIRect.fTop; y < dstIRect.fBottom; ++y) { | 120 for (int y = dstIRect.fTop; y < dstIRect.fBottom; ++y) { |
121 SkPMColor* dptr = result->getAddr32(dstIRect.fLeft, y); | 121 SkPMColor* dptr = result->getAddr32(dstIRect.fLeft, y); |
122 for (int x = dstIRect.fLeft; x < dstIRect.fRight; ++x) { | 122 for (int x = dstIRect.fLeft; x < dstIRect.fRight; ++x) { |
123 SkPoint srcPt, dstPt = SkPoint::Make(SkIntToScalar(x), SkIntToScalar
(y)); | 123 SkPoint srcPt, dstPt = SkPoint::Make(SkIntToScalar(x), SkIntToScalar
(y)); |
124 inverse.mapPoints(&srcPt, &dstPt, 1); | 124 inverse.mapPoints(&srcPt, &dstPt, 1); |
125 SkScalar fractx = srcPt.fX - SkScalarFloorToScalar(srcPt.fX); | 125 SkScalar fractx = srcPt.fX - SkScalarFloorToScalar(srcPt.fX); |
126 SkScalar fracty = srcPt.fY - SkScalarFloorToScalar(srcPt.fY); | 126 SkScalar fracty = srcPt.fY - SkScalarFloorToScalar(srcPt.fY); |
127 int sx = SkScalarFloorToInt(srcPt.fX); | 127 int sx = SkScalarFloorToInt(srcPt.fX); |
128 int sy = SkScalarFloorToInt(srcPt.fY); | 128 int sy = SkScalarFloorToInt(srcPt.fY); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 GrPaint paint; | 191 GrPaint paint; |
192 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un
ref(); | 192 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un
ref(); |
193 SkRect srcRect; | 193 SkRect srcRect; |
194 srcBM.getBounds(&srcRect); | 194 srcBM.getBounds(&srcRect); |
195 context->drawRectToRect(paint, dstRect, srcRect); | 195 context->drawRectToRect(paint, dstRect, srcRect); |
196 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul
t); | 196 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul
t); |
197 } | 197 } |
198 #endif | 198 #endif |
199 | 199 |
200 /////////////////////////////////////////////////////////////////////////////// | 200 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |