| 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 "SkDropShadowImageFilter.h" | 8 #include "SkDropShadowImageFilter.h" |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 buffer.writeColor(fColor); | 43 buffer.writeColor(fColor); |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source
, const SkMatrix& matrix, SkBitmap* result, SkIPoint* loc) | 46 bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source
, const SkMatrix& matrix, SkBitmap* result, SkIPoint* loc) |
| 47 { | 47 { |
| 48 SkBitmap src = source; | 48 SkBitmap src = source; |
| 49 if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, lo
c)) | 49 if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, lo
c)) |
| 50 return false; | 50 return false; |
| 51 | 51 |
| 52 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(src.width(), src.heigh
t())); | 52 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(src.width(), src.heigh
t())); |
| 53 if (NULL == device.get()) { |
| 54 return false; |
| 55 } |
| 53 SkCanvas canvas(device.get()); | 56 SkCanvas canvas(device.get()); |
| 54 | 57 |
| 55 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(fSigma, fSigma)
); | 58 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(fSigma, fSigma)
); |
| 56 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol
or, SkXfermode::kSrcIn_Mode)); | 59 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol
or, SkXfermode::kSrcIn_Mode)); |
| 57 SkPaint paint; | 60 SkPaint paint; |
| 58 paint.setImageFilter(blurFilter.get()); | 61 paint.setImageFilter(blurFilter.get()); |
| 59 paint.setColorFilter(colorFilter.get()); | 62 paint.setColorFilter(colorFilter.get()); |
| 60 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 63 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 61 canvas.drawBitmap(src, fDx, fDy, &paint); | 64 canvas.drawBitmap(src, fDx, fDy, &paint); |
| 62 canvas.drawBitmap(src, 0, 0); | 65 canvas.drawBitmap(src, 0, 0); |
| 63 *result = device->accessBitmap(false); | 66 *result = device->accessBitmap(false); |
| 64 return true; | 67 return true; |
| 65 } | 68 } |
| OLD | NEW |