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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void SkDropShadowImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const | 50 void SkDropShadowImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const |
51 { | 51 { |
52 this->INHERITED::flatten(buffer); | 52 this->INHERITED::flatten(buffer); |
53 buffer.writeScalar(fDx); | 53 buffer.writeScalar(fDx); |
54 buffer.writeScalar(fDy); | 54 buffer.writeScalar(fDy); |
55 buffer.writeScalar(fSigmaX); | 55 buffer.writeScalar(fSigmaX); |
56 buffer.writeScalar(fSigmaY); | 56 buffer.writeScalar(fSigmaY); |
57 buffer.writeColor(fColor); | 57 buffer.writeColor(fColor); |
58 } | 58 } |
59 | 59 |
60 bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source
, const SkMatrix& matrix, SkBitmap* result, SkIPoint* loc) | 60 bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source
, const SkMatrix& matrix, SkBitmap* result, SkIPoint* offset) |
61 { | 61 { |
62 SkBitmap src = source; | 62 SkBitmap src = source; |
63 if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, lo
c)) | 63 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 64 if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, &s
rcOffset)) |
64 return false; | 65 return false; |
65 | 66 |
66 SkIRect bounds; | 67 SkIRect bounds; |
67 src.getBounds(&bounds); | 68 src.getBounds(&bounds); |
| 69 bounds.offset(srcOffset); |
68 if (!this->applyCropRect(&bounds, matrix)) { | 70 if (!this->applyCropRect(&bounds, matrix)) { |
69 return false; | 71 return false; |
70 } | 72 } |
71 | 73 |
72 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); | 74 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
73 if (NULL == device.get()) { | 75 if (NULL == device.get()) { |
74 return false; | 76 return false; |
75 } | 77 } |
76 SkCanvas canvas(device.get()); | 78 SkCanvas canvas(device.get()); |
77 | 79 |
78 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(fSigmaX, fSigma
Y)); | 80 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(fSigmaX, fSigma
Y)); |
79 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol
or, SkXfermode::kSrcIn_Mode)); | 81 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol
or, SkXfermode::kSrcIn_Mode)); |
80 SkPaint paint; | 82 SkPaint paint; |
81 paint.setImageFilter(blurFilter.get()); | 83 paint.setImageFilter(blurFilter.get()); |
82 paint.setColorFilter(colorFilter.get()); | 84 paint.setColorFilter(colorFilter.get()); |
83 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 85 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
84 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); | 86 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); |
85 canvas.drawBitmap(src, fDx, fDy, &paint); | 87 canvas.drawBitmap(src, fDx, fDy, &paint); |
86 canvas.drawBitmap(src, 0, 0); | 88 canvas.drawBitmap(src, 0, 0); |
87 *result = device->accessBitmap(false); | 89 *result = device->accessBitmap(false); |
88 loc->fX += bounds.fLeft; | 90 offset->fX = bounds.fLeft; |
89 loc->fY += bounds.fTop; | 91 offset->fY = bounds.fTop; |
90 return true; | 92 return true; |
91 } | 93 } |
OLD | NEW |