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

Side by Side Diff: gm/imagefilterscropexpand.cpp

Issue 1821103004: Revert of Revert[2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/imagefiltersbase.cpp ('k') | gm/imagefilterscropped.cpp » ('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 2014 Google Inc. 2 * Copyright 2014 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 22 matching lines...) Expand all
33 33
34 protected: 34 protected:
35 35
36 SkString onShortName() override { 36 SkString onShortName() override {
37 return SkString("imagefilterscropexpand"); 37 return SkString("imagefilterscropexpand");
38 } 38 }
39 39
40 SkISize onISize() override { return SkISize::Make(730, 650); } 40 SkISize onISize() override { return SkISize::Make(730, 650); }
41 41
42 void onDraw(SkCanvas* canvas) override { 42 void onDraw(SkCanvas* canvas) override {
43 SkAutoTUnref<SkColorFilter> cf(
44 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod e));
43 SkImageFilter::CropRect cropRect( 45 SkImageFilter::CropRect cropRect(
44 SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)), 46 SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)),
45 SkImageFilter::CropRect::kHasAll_CropEdge); 47 SkImageFilter::CropRect::kHasAll_CropEdge);
46 48
47 sk_sp<SkImage> gradientCircle(MakeGradientCircle(64, 64)); 49 sk_sp<SkImage> gradientCircle(MakeGradientCircle(64, 64));
48 SkBitmap checkerboard; 50 SkBitmap checkerboard;
49 MakeCheckerboard(&checkerboard); 51 MakeCheckerboard(&checkerboard);
50 52
51 SkAutoTUnref<SkImageFilter> gradientCircleSource( 53 SkAutoTUnref<SkImageFilter> gradientCircleSource(
52 SkImageSource::Create(gradientCircle.get())); 54 SkImageSource::Create(gradientCircle.get()));
53 SkAutoTUnref<SkImageFilter> noopCropped( 55 SkAutoTUnref<SkImageFilter> noopCropped(
54 SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect)); 56 SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect));
55 SkScalar sk255 = SkIntToScalar(255); 57 SkScalar sk255 = SkIntToScalar(255);
56 SkScalar matrix[20] = { 1, 0, 0, 0, 0, 58 SkScalar matrix[20] = { 1, 0, 0, 0, 0,
57 0, 1, 0, 0, sk255, 59 0, 1, 0, 0, sk255,
58 0, 0, 1, 0, 0, 60 0, 0, 1, 0, 0,
59 0, 0, 0, 0, sk255 }; 61 0, 0, 0, 0, sk255 };
60 auto cfAlphaTrans(SkColorFilter::MakeMatrixFilterRowMajor255(matrix)); 62 SkAutoTUnref<SkColorFilter> cfAlphaTrans(SkColorMatrixFilter::Create(mat rix));
61 63
62 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); 64 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
63 SkScalar MARGIN = SkIntToScalar(12); 65 SkScalar MARGIN = SkIntToScalar(12);
64 66
65 SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10)); 67 SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10));
66 SkScalar kd = SkIntToScalar(2); 68 SkScalar kd = SkIntToScalar(2);
67 SkScalar surfaceScale = SkIntToScalar(1); 69 SkScalar surfaceScale = SkIntToScalar(1);
68 SkIRect bounds; 70 SkIRect bounds;
69 r.roundOut(&bounds); 71 r.roundOut(&bounds);
70 72
71 SkPaint paint; 73 SkPaint paint;
72 canvas->translate(MARGIN, MARGIN); 74 canvas->translate(MARGIN, MARGIN);
73 for (int outset = -15; outset <= 20; outset += 5) { 75 for (int outset = -15; outset <= 20; outset += 5) {
74 canvas->save(); 76 canvas->save();
75 SkRect rect = cropRect.rect(); 77 SkRect rect = cropRect.rect();
76 rect.outset(SkIntToScalar(outset), 78 rect.outset(SkIntToScalar(outset),
77 SkIntToScalar(outset)); 79 SkIntToScalar(outset));
78 SkImageFilter::CropRect bigRect(rect, SkImageFilter::CropRect::kHasA ll_CropEdge); 80 SkImageFilter::CropRect bigRect(rect, SkImageFilter::CropRect::kHasA ll_CropEdge);
79 81
80 Draw(canvas, checkerboard, rect, SkColorFilterImageFilter::Create( 82 Draw(canvas, checkerboard, rect, SkColorFilterImageFilter::Create(
81 cfAlphaTrans.get(), noopCropped.get(), &bigRect)); 83 cfAlphaTrans, noopCropped.get(), &bigRect));
82 84
83 Draw(canvas, checkerboard, rect, SkBlurImageFilter::Create( 85 Draw(canvas, checkerboard, rect, SkBlurImageFilter::Create(
84 0.3f, 0.3f, noopCropped.get(), &bigRect)); 86 0.3f, 0.3f, noopCropped.get(), &bigRect));
85 87
86 Draw(canvas, checkerboard, rect, SkBlurImageFilter::Create( 88 Draw(canvas, checkerboard, rect, SkBlurImageFilter::Create(
87 8.0f, 8.0f, noopCropped.get(), &bigRect)); 89 8.0f, 8.0f, noopCropped.get(), &bigRect));
88 90
89 Draw(canvas, checkerboard, rect, SkDilateImageFilter::Create( 91 Draw(canvas, checkerboard, rect, SkDilateImageFilter::Create(
90 2, 2, noopCropped.get(), &bigRect)); 92 2, 2, noopCropped.get(), &bigRect));
91 93
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 173
172 canvas->translate(SkIntToScalar(80), 0); 174 canvas->translate(SkIntToScalar(80), 0);
173 } 175 }
174 176
175 typedef GM INHERITED; 177 typedef GM INHERITED;
176 }; 178 };
177 179
178 /////////////////////////////////////////////////////////////////////////////// 180 ///////////////////////////////////////////////////////////////////////////////
179 181
180 DEF_GM( return new ImageFiltersCropExpandGM; ) 182 DEF_GM( return new ImageFiltersCropExpandGM; )
OLDNEW
« no previous file with comments | « gm/imagefiltersbase.cpp ('k') | gm/imagefilterscropped.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698