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

Side by Side Diff: gm/imagefilterscropexpand.cpp

Issue 1825073002: 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: remove flag 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));
45 SkImageFilter::CropRect cropRect( 43 SkImageFilter::CropRect cropRect(
46 SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)), 44 SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)),
47 SkImageFilter::CropRect::kHasAll_CropEdge); 45 SkImageFilter::CropRect::kHasAll_CropEdge);
48 46
49 sk_sp<SkImage> gradientCircle(MakeGradientCircle(64, 64)); 47 sk_sp<SkImage> gradientCircle(MakeGradientCircle(64, 64));
50 SkBitmap checkerboard; 48 SkBitmap checkerboard;
51 MakeCheckerboard(&checkerboard); 49 MakeCheckerboard(&checkerboard);
52 50
53 SkAutoTUnref<SkImageFilter> gradientCircleSource( 51 SkAutoTUnref<SkImageFilter> gradientCircleSource(
54 SkImageSource::Create(gradientCircle.get())); 52 SkImageSource::Create(gradientCircle.get()));
55 SkAutoTUnref<SkImageFilter> noopCropped( 53 SkAutoTUnref<SkImageFilter> noopCropped(
56 SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect)); 54 SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect));
57 SkScalar sk255 = SkIntToScalar(255); 55 SkScalar sk255 = SkIntToScalar(255);
58 SkScalar matrix[20] = { 1, 0, 0, 0, 0, 56 SkScalar matrix[20] = { 1, 0, 0, 0, 0,
59 0, 1, 0, 0, sk255, 57 0, 1, 0, 0, sk255,
60 0, 0, 1, 0, 0, 58 0, 0, 1, 0, 0,
61 0, 0, 0, 0, sk255 }; 59 0, 0, 0, 0, sk255 };
62 SkAutoTUnref<SkColorFilter> cfAlphaTrans(SkColorMatrixFilter::Create(mat rix)); 60 auto cfAlphaTrans(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
63 61
64 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); 62 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
65 SkScalar MARGIN = SkIntToScalar(12); 63 SkScalar MARGIN = SkIntToScalar(12);
66 64
67 SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10)); 65 SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10));
68 SkScalar kd = SkIntToScalar(2); 66 SkScalar kd = SkIntToScalar(2);
69 SkScalar surfaceScale = SkIntToScalar(1); 67 SkScalar surfaceScale = SkIntToScalar(1);
70 SkIRect bounds; 68 SkIRect bounds;
71 r.roundOut(&bounds); 69 r.roundOut(&bounds);
72 70
73 SkPaint paint; 71 SkPaint paint;
74 canvas->translate(MARGIN, MARGIN); 72 canvas->translate(MARGIN, MARGIN);
75 for (int outset = -15; outset <= 20; outset += 5) { 73 for (int outset = -15; outset <= 20; outset += 5) {
76 canvas->save(); 74 canvas->save();
77 SkRect rect = cropRect.rect(); 75 SkRect rect = cropRect.rect();
78 rect.outset(SkIntToScalar(outset), 76 rect.outset(SkIntToScalar(outset),
79 SkIntToScalar(outset)); 77 SkIntToScalar(outset));
80 SkImageFilter::CropRect bigRect(rect, SkImageFilter::CropRect::kHasA ll_CropEdge); 78 SkImageFilter::CropRect bigRect(rect, SkImageFilter::CropRect::kHasA ll_CropEdge);
81 79
82 Draw(canvas, checkerboard, rect, SkColorFilterImageFilter::Create( 80 Draw(canvas, checkerboard, rect, SkColorFilterImageFilter::Create(
83 cfAlphaTrans, noopCropped.get(), &bigRect)); 81 cfAlphaTrans.get(), noopCropped.get(), &bigRect));
84 82
85 Draw(canvas, checkerboard, rect, SkBlurImageFilter::Create( 83 Draw(canvas, checkerboard, rect, SkBlurImageFilter::Create(
86 0.3f, 0.3f, noopCropped.get(), &bigRect)); 84 0.3f, 0.3f, noopCropped.get(), &bigRect));
87 85
88 Draw(canvas, checkerboard, rect, SkBlurImageFilter::Create( 86 Draw(canvas, checkerboard, rect, SkBlurImageFilter::Create(
89 8.0f, 8.0f, noopCropped.get(), &bigRect)); 87 8.0f, 8.0f, noopCropped.get(), &bigRect));
90 88
91 Draw(canvas, checkerboard, rect, SkDilateImageFilter::Create( 89 Draw(canvas, checkerboard, rect, SkDilateImageFilter::Create(
92 2, 2, noopCropped.get(), &bigRect)); 90 2, 2, noopCropped.get(), &bigRect));
93 91
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 171
174 canvas->translate(SkIntToScalar(80), 0); 172 canvas->translate(SkIntToScalar(80), 0);
175 } 173 }
176 174
177 typedef GM INHERITED; 175 typedef GM INHERITED;
178 }; 176 };
179 177
180 /////////////////////////////////////////////////////////////////////////////// 178 ///////////////////////////////////////////////////////////////////////////////
181 179
182 DEF_GM( return new ImageFiltersCropExpandGM; ) 180 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