Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/effects/SkXfermodeImageFilter.cpp

Issue 1832223002: switch xfermodes over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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(std::move(mode), common.getInput(0),
44 common.getInput(1), &common.cropRect()).release();
37 } 45 }
38 46
39 void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const { 47 void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const {
40 this->INHERITED::flatten(buffer); 48 this->INHERITED::flatten(buffer);
41 buffer.writeFlattenable(fMode); 49 buffer.writeFlattenable(fMode.get());
42 } 50 }
43 51
44 bool SkXfermodeImageFilter::onFilterImageDeprecated(Proxy* proxy, 52 bool SkXfermodeImageFilter::onFilterImageDeprecated(Proxy* proxy,
45 const SkBitmap& src, 53 const SkBitmap& src,
46 const Context& ctx, 54 const Context& ctx,
47 SkBitmap* dst, 55 SkBitmap* dst,
48 SkIPoint* offset) const { 56 SkIPoint* offset) const {
49 SkBitmap background = src, foreground = src; 57 SkBitmap background = src, foreground = src;
50 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); 58 SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
51 if (!this->filterInputDeprecated(0, proxy, src, ctx, &background, &backgroun dOffset)) { 59 if (!this->filterInputDeprecated(0, proxy, src, ctx, &background, &backgroun dOffset)) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top ())); 248 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top ()));
241 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds )); 249 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds ));
242 250
243 offset->fX = bounds.left(); 251 offset->fX = bounds.left();
244 offset->fY = bounds.top(); 252 offset->fY = bounds.top();
245 GrWrapTextureInBitmap(dst, bounds.width(), bounds.height(), false, result); 253 GrWrapTextureInBitmap(dst, bounds.width(), bounds.height(), false, result);
246 return true; 254 return true;
247 } 255 }
248 256
249 #endif 257 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698