| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 srcTexture = nullptr; // we don't use this from here on out | 348 srcTexture = nullptr; // we don't use this from here on out |
| 349 | 349 |
| 350 if (scaleFactorX > 1 || scaleFactorY > 1) { | 350 if (scaleFactorX > 1 || scaleFactorY > 1) { |
| 351 // Clear one pixel to the right and below, to accommodate bilinear upsam
pling. | 351 // Clear one pixel to the right and below, to accommodate bilinear upsam
pling. |
| 352 clearRect = SkIRect::MakeXYWH(srcRect.fLeft, srcRect.fBottom, srcRect.wi
dth() + 1, 1); | 352 clearRect = SkIRect::MakeXYWH(srcRect.fLeft, srcRect.fBottom, srcRect.wi
dth() + 1, 1); |
| 353 srcDrawContext->clear(&clearRect, 0x0, false); | 353 srcDrawContext->clear(&clearRect, 0x0, false); |
| 354 clearRect = SkIRect::MakeXYWH(srcRect.fRight, srcRect.fTop, 1, srcRect.h
eight()); | 354 clearRect = SkIRect::MakeXYWH(srcRect.fRight, srcRect.fTop, 1, srcRect.h
eight()); |
| 355 srcDrawContext->clear(&clearRect, 0x0, false); | 355 srcDrawContext->clear(&clearRect, 0x0, false); |
| 356 | 356 |
| 357 SkMatrix matrix; | 357 SkMatrix matrix; |
| 358 matrix.setIDiv(srcDrawContext->width(), srcDrawContext->height()); | 358 matrix.setIDiv(srcDrawContext->accessRenderTarget()->width(), |
| 359 srcDrawContext->accessRenderTarget()->height()); |
| 359 | 360 |
| 360 GrPaint paint; | 361 GrPaint paint; |
| 361 paint.setGammaCorrect(gammaCorrect); | 362 paint.setGammaCorrect(gammaCorrect); |
| 362 // FIXME: this should be mitchell, not bilinear. | 363 // FIXME: this should be mitchell, not bilinear. |
| 363 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBile
rp_FilterMode); | 364 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBile
rp_FilterMode); |
| 364 sk_sp<GrTexture> tex(srcDrawContext->asTexture()); | 365 sk_sp<GrTexture> tex(srcDrawContext->asTexture()); |
| 365 paint.addColorTextureProcessor(tex.get(), nullptr, matrix, params); | 366 paint.addColorTextureProcessor(tex.get(), nullptr, matrix, params); |
| 366 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 367 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 367 | 368 |
| 368 SkIRect dstRect(srcRect); | 369 SkIRect dstRect(srcRect); |
| 369 scale_irect(&dstRect, scaleFactorX, scaleFactorY); | 370 scale_irect(&dstRect, scaleFactorX, scaleFactorY); |
| 370 | 371 |
| 371 dstDrawContext->fillRectToRect(clip, paint, SkMatrix::I(), | 372 dstDrawContext->fillRectToRect(clip, paint, SkMatrix::I(), |
| 372 SkRect::Make(dstRect), SkRect::Make(srcRe
ct)); | 373 SkRect::Make(dstRect), SkRect::Make(srcRe
ct)); |
| 373 | 374 |
| 374 srcDrawContext = dstDrawContext; | 375 srcDrawContext = dstDrawContext; |
| 375 srcRect = dstRect; | 376 srcRect = dstRect; |
| 376 dstDrawContext.swap(tmpDrawContext); | 377 dstDrawContext.swap(tmpDrawContext); |
| 377 } | 378 } |
| 378 | 379 |
| 379 return srcDrawContext; | 380 return srcDrawContext; |
| 380 } | 381 } |
| 381 | 382 |
| 382 } | 383 } |
| 383 | 384 |
| 384 #endif | 385 #endif |
| 385 | 386 |
| OLD | NEW |