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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, lo
c)) | 63 if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, lo
c)) |
64 return false; | 64 return false; |
65 | 65 |
66 SkIRect bounds; | 66 SkIRect bounds; |
67 src.getBounds(&bounds); | 67 src.getBounds(&bounds); |
68 if (!this->applyCropRect(&bounds, matrix)) { | 68 if (!this->applyCropRect(&bounds, matrix)) { |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); | 72 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
| 73 if (NULL == device.get()) { |
| 74 return false; |
| 75 } |
73 SkCanvas canvas(device.get()); | 76 SkCanvas canvas(device.get()); |
74 | 77 |
75 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(fSigmaX, fSigma
Y)); | 78 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(fSigmaX, fSigma
Y)); |
76 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol
or, SkXfermode::kSrcIn_Mode)); | 79 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol
or, SkXfermode::kSrcIn_Mode)); |
77 SkPaint paint; | 80 SkPaint paint; |
78 paint.setImageFilter(blurFilter.get()); | 81 paint.setImageFilter(blurFilter.get()); |
79 paint.setColorFilter(colorFilter.get()); | 82 paint.setColorFilter(colorFilter.get()); |
80 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 83 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
81 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); | 84 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); |
82 canvas.drawBitmap(src, fDx, fDy, &paint); | 85 canvas.drawBitmap(src, fDx, fDy, &paint); |
83 canvas.drawBitmap(src, 0, 0); | 86 canvas.drawBitmap(src, 0, 0); |
84 *result = device->accessBitmap(false); | 87 *result = device->accessBitmap(false); |
85 loc->fX += bounds.fLeft; | 88 loc->fX += bounds.fLeft; |
86 loc->fY += bounds.fTop; | 89 loc->fY += bounds.fTop; |
87 return true; | 90 return true; |
88 } | 91 } |
OLD | NEW |