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