| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 direction, radius, sigma, false, bounds); | 160 direction, radius, sigma, false, bounds); |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 | 163 |
| 164 GrTexture* GaussianBlur(GrContext* context, | 164 GrTexture* GaussianBlur(GrContext* context, |
| 165 GrTexture* srcTexture, | 165 GrTexture* srcTexture, |
| 166 bool canClobberSrc, | 166 bool canClobberSrc, |
| 167 const SkRect& dstBounds, | 167 const SkRect& dstBounds, |
| 168 const SkRect* srcBounds, | 168 const SkRect* srcBounds, |
| 169 float sigmaX, | 169 float sigmaX, |
| 170 float sigmaY, | 170 float sigmaY) { |
| 171 GrTextureProvider::SizeConstraint constraint) { | |
| 172 SkASSERT(context); | 171 SkASSERT(context); |
| 173 SkIRect clearRect; | 172 SkIRect clearRect; |
| 174 int scaleFactorX, radiusX; | 173 int scaleFactorX, radiusX; |
| 175 int scaleFactorY, radiusY; | 174 int scaleFactorY, radiusY; |
| 176 int maxTextureSize = context->caps()->maxTextureSize(); | 175 int maxTextureSize = context->caps()->maxTextureSize(); |
| 177 sigmaX = adjust_sigma(sigmaX, maxTextureSize, &scaleFactorX, &radiusX); | 176 sigmaX = adjust_sigma(sigmaX, maxTextureSize, &scaleFactorX, &radiusX); |
| 178 sigmaY = adjust_sigma(sigmaY, maxTextureSize, &scaleFactorY, &radiusY); | 177 sigmaY = adjust_sigma(sigmaY, maxTextureSize, &scaleFactorY, &radiusY); |
| 179 | 178 |
| 180 SkPoint srcOffset = SkPoint::Make(-dstBounds.x(), -dstBounds.y()); | 179 SkPoint srcOffset = SkPoint::Make(-dstBounds.x(), -dstBounds.y()); |
| 181 SkRect localDstBounds = SkRect::MakeWH(dstBounds.width(), dstBounds.height()
); | 180 SkRect localDstBounds = SkRect::MakeWH(dstBounds.width(), dstBounds.height()
); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 204 GrSurfaceDesc desc; | 203 GrSurfaceDesc desc; |
| 205 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 204 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 206 desc.fWidth = SkScalarFloorToInt(dstBounds.width()); | 205 desc.fWidth = SkScalarFloorToInt(dstBounds.width()); |
| 207 desc.fHeight = SkScalarFloorToInt(dstBounds.height()); | 206 desc.fHeight = SkScalarFloorToInt(dstBounds.height()); |
| 208 desc.fConfig = srcTexture->config(); | 207 desc.fConfig = srcTexture->config(); |
| 209 | 208 |
| 210 GrTexture* dstTexture; | 209 GrTexture* dstTexture; |
| 211 GrTexture* tempTexture; | 210 GrTexture* tempTexture; |
| 212 SkAutoTUnref<GrTexture> temp1, temp2; | 211 SkAutoTUnref<GrTexture> temp1, temp2; |
| 213 | 212 |
| 214 temp1.reset(context->textureProvider()->createTexture(desc, constraint)); | 213 temp1.reset(context->textureProvider()->createApproxTexture(desc)); |
| 215 dstTexture = temp1.get(); | 214 dstTexture = temp1.get(); |
| 216 if (canClobberSrc) { | 215 if (canClobberSrc) { |
| 217 tempTexture = srcTexture; | 216 tempTexture = srcTexture; |
| 218 } else { | 217 } else { |
| 219 temp2.reset(context->textureProvider()->createTexture(desc, constraint))
; | 218 temp2.reset(context->textureProvider()->createApproxTexture(desc)); |
| 220 tempTexture = temp2.get(); | 219 tempTexture = temp2.get(); |
| 221 } | 220 } |
| 222 | 221 |
| 223 if (nullptr == dstTexture || nullptr == tempTexture) { | 222 if (nullptr == dstTexture || nullptr == tempTexture) { |
| 224 return nullptr; | 223 return nullptr; |
| 225 } | 224 } |
| 226 | 225 |
| 227 SkAutoTUnref<GrDrawContext> srcDrawContext; | 226 SkAutoTUnref<GrDrawContext> srcDrawContext; |
| 228 | 227 |
| 229 for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) { | 228 for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 srcRect = dstRect; | 392 srcRect = dstRect; |
| 394 srcTexture = dstTexture; | 393 srcTexture = dstTexture; |
| 395 SkTSwap(dstTexture, tempTexture); | 394 SkTSwap(dstTexture, tempTexture); |
| 396 } | 395 } |
| 397 | 396 |
| 398 return SkRef(srcTexture); | 397 return SkRef(srcTexture); |
| 399 } | 398 } |
| 400 #endif | 399 #endif |
| 401 | 400 |
| 402 } | 401 } |
| OLD | NEW |