OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2013 The Android Open Source Project |
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 "SkXfermodeImageFilter.h" | 8 #include "SkXfermodeImageFilter.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
14 #include "SkXfermode.h" | 14 #include "SkXfermode.h" |
15 #if SK_SUPPORT_GPU | 15 #if SK_SUPPORT_GPU |
16 #include "GrContext.h" | 16 #include "GrContext.h" |
17 #include "GrDrawContext.h" | 17 #include "GrDrawContext.h" |
18 #include "effects/GrConstColorProcessor.h" | 18 #include "effects/GrConstColorProcessor.h" |
19 #include "effects/GrTextureDomain.h" | 19 #include "effects/GrTextureDomain.h" |
20 #include "effects/GrSimpleTextureEffect.h" | 20 #include "effects/GrSimpleTextureEffect.h" |
21 #include "SkGr.h" | 21 #include "SkGr.h" |
22 #endif | 22 #endif |
23 | 23 |
24 /////////////////////////////////////////////////////////////////////////////// | 24 /////////////////////////////////////////////////////////////////////////////// |
25 | 25 |
26 SkXfermodeImageFilter::SkXfermodeImageFilter(SkXfermode* mode, | 26 sk_sp<SkImageFilter> SkXfermodeImageFilter::Make(sk_sp<SkXfermode> mode, SkImage Filter* background, |
27 SkImageFilter* foreground, | |
28 const CropRect* cropRect) { | |
29 SkImageFilter* inputs[2] = { background, foreground }; | |
30 return sk_sp<SkImageFilter>(new SkXfermodeImageFilter(mode, inputs, cropRect )); | |
31 } | |
32 | |
33 SkXfermodeImageFilter::SkXfermodeImageFilter(sk_sp<SkXfermode> mode, | |
27 SkImageFilter* inputs[2], | 34 SkImageFilter* inputs[2], |
28 const CropRect* cropRect) | 35 const CropRect* cropRect) |
29 : INHERITED(2, inputs, cropRect) | 36 : INHERITED(2, inputs, cropRect) |
30 , fMode(SkSafeRef(mode)) { | 37 , fMode(std::move(mode)) |
31 } | 38 {} |
32 | 39 |
33 SkFlattenable* SkXfermodeImageFilter::CreateProc(SkReadBuffer& buffer) { | 40 SkFlattenable* SkXfermodeImageFilter::CreateProc(SkReadBuffer& buffer) { |
34 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); | 41 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); |
35 SkAutoTUnref<SkXfermode> mode(buffer.readXfermode()); | 42 sk_sp<SkXfermode> mode(buffer.readXfermode()); |
36 return Create(mode, common.getInput(0), common.getInput(1), &common.cropRect ()); | 43 return Make(mode, common.getInput(0), common.getInput(1), &common.cropRect() ).release(); |
f(malita)
2016/03/28 18:44:59
nit: std::move(mode), or inline?
reed1
2016/03/29 16:13:52
Done.
| |
37 } | 44 } |
38 | 45 |
39 void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const { | 46 void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const { |
40 this->INHERITED::flatten(buffer); | 47 this->INHERITED::flatten(buffer); |
41 buffer.writeFlattenable(fMode); | 48 buffer.writeFlattenable(fMode.get()); |
42 } | 49 } |
43 | 50 |
44 bool SkXfermodeImageFilter::onFilterImageDeprecated(Proxy* proxy, | 51 bool SkXfermodeImageFilter::onFilterImageDeprecated(Proxy* proxy, |
45 const SkBitmap& src, | 52 const SkBitmap& src, |
46 const Context& ctx, | 53 const Context& ctx, |
47 SkBitmap* dst, | 54 SkBitmap* dst, |
48 SkIPoint* offset) const { | 55 SkIPoint* offset) const { |
49 SkBitmap background = src, foreground = src; | 56 SkBitmap background = src, foreground = src; |
50 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); | 57 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); |
51 if (!this->filterInputDeprecated(0, proxy, src, ctx, &background, &backgroun dOffset)) { | 58 if (!this->filterInputDeprecated(0, proxy, src, ctx, &background, &backgroun dOffset)) { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds )); | 248 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds )); |
242 | 249 |
243 offset->fX = bounds.left(); | 250 offset->fX = bounds.left(); |
244 offset->fY = bounds.top(); | 251 offset->fY = bounds.top(); |
245 GrWrapTextureInBitmap(dst, bounds.width(), bounds.height(), false, result); | 252 GrWrapTextureInBitmap(dst, bounds.width(), bounds.height(), false, result); |
246 return true; | 253 return true; |
247 } | 254 } |
248 | 255 |
249 #endif | 256 #endif |
250 | 257 |
OLD | NEW |