OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
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 "SkGpuBlurUtils.h" | 8 #include "SkGpuBlurUtils.h" |
9 | 9 |
10 #include "SkRect.h" | 10 #include "SkRect.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 dstRect.offset(-dstRect.fLeft, -dstRect.fTop); | 125 dstRect.offset(-dstRect.fLeft, -dstRect.fTop); |
126 SkRect domain; | 126 SkRect domain; |
127 matrix.mapRect(&domain, rect); | 127 matrix.mapRect(&domain, rect); |
128 domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width()
: 0.0f, | 128 domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width()
: 0.0f, |
129 i < scaleFactorY ? SK_ScalarHalf / srcTexture->height()
: 0.0f); | 129 i < scaleFactorY ? SK_ScalarHalf / srcTexture->height()
: 0.0f); |
130 SkAutoTUnref<GrEffectRef> effect(GrTextureDomainEffect::Create( | 130 SkAutoTUnref<GrEffectRef> effect(GrTextureDomainEffect::Create( |
131 srcTexture, | 131 srcTexture, |
132 matrix, | 132 matrix, |
133 domain, | 133 domain, |
134 GrTextureDomainEffect::kDecal_WrapMode, | 134 GrTextureDomainEffect::kDecal_WrapMode, |
135 true)); | 135 GrTextureParams::kBilerp_FilterMode)); |
136 paint.addColorEffect(effect); | 136 paint.addColorEffect(effect); |
137 } else { | 137 } else { |
138 GrTextureParams params(SkShader::kClamp_TileMode, true); | 138 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k
Bilerp_FilterMode); |
139 paint.addColorTextureEffect(srcTexture, matrix, params); | 139 paint.addColorTextureEffect(srcTexture, matrix, params); |
140 } | 140 } |
141 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, | 141 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, |
142 i < scaleFactorY ? 0.5f : 1.0f); | 142 i < scaleFactorY ? 0.5f : 1.0f); |
143 context->drawRectToRect(paint, dstRect, srcRect); | 143 context->drawRectToRect(paint, dstRect, srcRect); |
144 srcRect = dstRect; | 144 srcRect = dstRect; |
145 srcTexture = dstTexture; | 145 srcTexture = dstTexture; |
146 SkTSwap(dstTexture, tempTexture); | 146 SkTSwap(dstTexture, tempTexture); |
147 } | 147 } |
148 | 148 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 context->clear(&clearRect, 0x0); | 192 context->clear(&clearRect, 0x0); |
193 clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop, | 193 clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop, |
194 1, srcIRect.height()); | 194 1, srcIRect.height()); |
195 context->clear(&clearRect, 0x0); | 195 context->clear(&clearRect, 0x0); |
196 SkMatrix matrix; | 196 SkMatrix matrix; |
197 matrix.setIDiv(srcTexture->width(), srcTexture->height()); | 197 matrix.setIDiv(srcTexture->width(), srcTexture->height()); |
198 context->setRenderTarget(dstTexture->asRenderTarget()); | 198 context->setRenderTarget(dstTexture->asRenderTarget()); |
199 | 199 |
200 GrPaint paint; | 200 GrPaint paint; |
201 // FIXME: this should be mitchell, not bilinear. | 201 // FIXME: this should be mitchell, not bilinear. |
202 GrTextureParams params(SkShader::kClamp_TileMode, true); | 202 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBile
rp_FilterMode); |
203 paint.addColorTextureEffect(srcTexture, matrix, params); | 203 paint.addColorTextureEffect(srcTexture, matrix, params); |
204 | 204 |
205 SkRect dstRect(srcRect); | 205 SkRect dstRect(srcRect); |
206 scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY); | 206 scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY); |
207 context->drawRectToRect(paint, dstRect, srcRect); | 207 context->drawRectToRect(paint, dstRect, srcRect); |
208 srcRect = dstRect; | 208 srcRect = dstRect; |
209 srcTexture = dstTexture; | 209 srcTexture = dstTexture; |
210 SkTSwap(dstTexture, tempTexture); | 210 SkTSwap(dstTexture, tempTexture); |
211 } | 211 } |
212 if (srcTexture == temp1.texture()) { | 212 if (srcTexture == temp1.texture()) { |
213 return temp1.detach(); | 213 return temp1.detach(); |
214 } else if (srcTexture == temp2.texture()) { | 214 } else if (srcTexture == temp2.texture()) { |
215 return temp2.detach(); | 215 return temp2.detach(); |
216 } else { | 216 } else { |
217 srcTexture->ref(); | 217 srcTexture->ref(); |
218 return srcTexture; | 218 return srcTexture; |
219 } | 219 } |
220 } | 220 } |
221 #endif | 221 #endif |
222 | 222 |
223 } | 223 } |
OLD | NEW |