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

Side by Side Diff: gm/xfermodeimagefilter.cpp

Issue 1842243002: Update SkImageSource to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT 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
« no previous file with comments | « gm/tileimagefilter.cpp ('k') | include/effects/SkImageSource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "gm.h" 8 #include "gm.h"
9 #include "sk_tool_utils.h" 9 #include "sk_tool_utils.h"
10 #include "SkArithmeticMode.h" 10 #include "SkArithmeticMode.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 { SkXfermode::kDifference_Mode, "Difference" }, 78 { SkXfermode::kDifference_Mode, "Difference" },
79 { SkXfermode::kExclusion_Mode, "Exclusion" }, 79 { SkXfermode::kExclusion_Mode, "Exclusion" },
80 { SkXfermode::kMultiply_Mode, "Multiply" }, 80 { SkXfermode::kMultiply_Mode, "Multiply" },
81 { SkXfermode::kHue_Mode, "Hue" }, 81 { SkXfermode::kHue_Mode, "Hue" },
82 { SkXfermode::kSaturation_Mode, "Saturation" }, 82 { SkXfermode::kSaturation_Mode, "Saturation" },
83 { SkXfermode::kColor_Mode, "Color" }, 83 { SkXfermode::kColor_Mode, "Color" },
84 { SkXfermode::kLuminosity_Mode, "Luminosity" }, 84 { SkXfermode::kLuminosity_Mode, "Luminosity" },
85 }; 85 };
86 86
87 int x = 0, y = 0; 87 int x = 0, y = 0;
88 sk_sp<SkImageFilter> background(SkImageSource::Create(fCheckerboard.get( ))); 88 sk_sp<SkImageFilter> background(SkImageSource::Make(fCheckerboard));
89 for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) { 89 for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) {
90 paint.setImageFilter(SkXfermodeImageFilter::Make(SkXfermode::Make(gM odes[i].fMode), 90 paint.setImageFilter(SkXfermodeImageFilter::Make(SkXfermode::Make(gM odes[i].fMode),
91 background.get())); 91 background.get()));
92 DrawClippedBitmap(canvas, fBitmap, paint, x, y); 92 DrawClippedBitmap(canvas, fBitmap, paint, x, y);
93 x += fBitmap.width() + MARGIN; 93 x += fBitmap.width() + MARGIN;
94 if (x + fBitmap.width() > WIDTH) { 94 if (x + fBitmap.width() > WIDTH) {
95 x = 0; 95 x = 0;
96 y += fBitmap.height() + MARGIN; 96 y += fBitmap.height() + MARGIN;
97 } 97 }
98 } 98 }
99 // Test arithmetic mode as image filter 99 // Test arithmetic mode as image filter
100 paint.setImageFilter(SkXfermodeImageFilter::Make( 100 paint.setImageFilter(SkXfermodeImageFilter::Make(
101 SkArithmeticMode::Make(0, SK_Scalar1, SK_Scalar1, 0), 101 SkArithmeticMode::Make(0, SK_Scalar1, SK_Scalar1, 0), b ackground.get()));
102 background.get()));
103 DrawClippedBitmap(canvas, fBitmap, paint, x, y); 102 DrawClippedBitmap(canvas, fBitmap, paint, x, y);
104 x += fBitmap.width() + MARGIN; 103 x += fBitmap.width() + MARGIN;
105 if (x + fBitmap.width() > WIDTH) { 104 if (x + fBitmap.width() > WIDTH) {
106 x = 0; 105 x = 0;
107 y += fBitmap.height() + MARGIN; 106 y += fBitmap.height() + MARGIN;
108 } 107 }
109 // Test nullptr mode 108 // Test nullptr mode
110 paint.setImageFilter(SkXfermodeImageFilter::Make(nullptr, background.get ())); 109 paint.setImageFilter(SkXfermodeImageFilter::Make(nullptr, background.get ()));
111 DrawClippedBitmap(canvas, fBitmap, paint, x, y); 110 DrawClippedBitmap(canvas, fBitmap, paint, x, y);
112 x += fBitmap.width() + MARGIN; 111 x += fBitmap.width() + MARGIN;
113 if (x + fBitmap.width() > WIDTH) { 112 if (x + fBitmap.width() > WIDTH) {
114 x = 0; 113 x = 0;
115 y += fBitmap.height() + MARGIN; 114 y += fBitmap.height() + MARGIN;
116 } 115 }
117 SkRect clipRect = SkRect::MakeWH(SkIntToScalar(fBitmap.width() + 4), 116 SkRect clipRect = SkRect::MakeWH(SkIntToScalar(fBitmap.width() + 4),
118 SkIntToScalar(fBitmap.height() + 4)); 117 SkIntToScalar(fBitmap.height() + 4));
119 // Test offsets on SrcMode (uses fixed-function blend) 118 // Test offsets on SrcMode (uses fixed-function blend)
120 sk_sp<SkImage> bitmapImage(SkImage::MakeFromBitmap(fBitmap)); 119 sk_sp<SkImage> bitmapImage(SkImage::MakeFromBitmap(fBitmap));
121 sk_sp<SkImageFilter> foreground(SkImageSource::Create(bitmapImage.get()) ); 120 sk_sp<SkImageFilter> foreground(SkImageSource::Make(std::move(bitmapImag e)));
122 sk_sp<SkImageFilter> offsetForeground(SkOffsetImageFilter::Make(SkIntToS calar(4), 121 sk_sp<SkImageFilter> offsetForeground(SkOffsetImageFilter::Make(SkIntToS calar(4),
123 SkIntToS calar(-4), 122 SkIntToS calar(-4),
124 foregrou nd)); 123 foregrou nd));
125 sk_sp<SkImageFilter> offsetBackground(SkOffsetImageFilter::Make(SkIntToS calar(4), 124 sk_sp<SkImageFilter> offsetBackground(SkOffsetImageFilter::Make(SkIntToS calar(4),
126 SkIntToS calar(4), 125 SkIntToS calar(4),
127 backgrou nd)); 126 backgrou nd));
128 paint.setImageFilter(SkXfermodeImageFilter::Make( 127 paint.setImageFilter(SkXfermodeImageFilter::Make(
129 SkXfermode::Make(SkXfermode ::kSrcOver_Mode), 128 SkXfermode::Make(SkXfermode ::kSrcOver_Mode),
130 offsetBackground.get(), 129 offsetBackground.get(),
131 offsetForeground.get(), 130 offsetForeground.get(),
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 sk_sp<SkImage> fCheckerboard; 231 sk_sp<SkImage> fCheckerboard;
233 232
234 typedef GM INHERITED; 233 typedef GM INHERITED;
235 }; 234 };
236 235
237 ////////////////////////////////////////////////////////////////////////////// 236 //////////////////////////////////////////////////////////////////////////////
238 237
239 DEF_GM( return new XfermodeImageFilterGM; ); 238 DEF_GM( return new XfermodeImageFilterGM; );
240 239
241 } 240 }
OLDNEW
« no previous file with comments | « gm/tileimagefilter.cpp ('k') | include/effects/SkImageSource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698