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

Side by Side Diff: gm/imagefiltersstroked.cpp

Issue 1858353002: Update SkMatrixImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix fuzz 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/imagefiltersscaled.cpp ('k') | gm/imageresizetiled.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 2015 Google Inc. 2 * Copyright 2015 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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 void onDraw(SkCanvas* canvas) override { 50 void onDraw(SkCanvas* canvas) override {
51 void (*drawProc[])(SkCanvas*, const SkRect&, const SkPaint&) = { 51 void (*drawProc[])(SkCanvas*, const SkRect&, const SkPaint&) = {
52 draw_line, draw_rect, draw_circle, 52 draw_line, draw_rect, draw_circle,
53 }; 53 };
54 54
55 canvas->clear(SK_ColorBLACK); 55 canvas->clear(SK_ColorBLACK);
56 56
57 SkMatrix resizeMatrix; 57 SkMatrix resizeMatrix;
58 resizeMatrix.setScale(RESIZE_FACTOR_X, RESIZE_FACTOR_Y); 58 resizeMatrix.setScale(RESIZE_FACTOR_X, RESIZE_FACTOR_Y);
59 59
60 SkImageFilter* filters[] = { 60 sk_sp<SkImageFilter> filters[] = {
61 SkBlurImageFilter::Make(5, 5, nullptr).release(), 61 SkBlurImageFilter::Make(5, 5, nullptr),
62 SkDropShadowImageFilter::Create(10, 10, 3, 3, SK_ColorGREEN, 62 sk_sp<SkImageFilter>(SkDropShadowImageFilter::Create(10, 10, 3, 3, S K_ColorGREEN,
63 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), 63 SkDropShadowImageFilter::kDrawShadowAndForeground_Sh adowMode)),
64 SkOffsetImageFilter::Make(-16, 32, nullptr).release(), 64 SkOffsetImageFilter::Make(-16, 32, nullptr),
65 SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQualit y), 65 SkImageFilter::MakeMatrixFilter(resizeMatrix, kNone_SkFilterQuality, nullptr),
66 }; 66 };
67 67
68 SkRect r = SkRect::MakeWH(64, 64); 68 SkRect r = SkRect::MakeWH(64, 64);
69 SkScalar margin = 32; 69 SkScalar margin = 32;
70 SkPaint paint; 70 SkPaint paint;
71 paint.setColor(SK_ColorWHITE); 71 paint.setColor(SK_ColorWHITE);
72 paint.setAntiAlias(true); 72 paint.setAntiAlias(true);
73 paint.setStrokeWidth(10); 73 paint.setStrokeWidth(10);
74 paint.setStyle(SkPaint::kStroke_Style); 74 paint.setStyle(SkPaint::kStroke_Style);
75 paint.setTextSize(48); 75 paint.setTextSize(48);
(...skipping 12 matching lines...) Expand all
88 SkScalarInvert(RESIZE_FACTOR_Y)); 88 SkScalarInvert(RESIZE_FACTOR_Y));
89 } 89 }
90 paint.setImageFilter(filters[j]); 90 paint.setImageFilter(filters[j]);
91 drawProc[i](canvas, r, paint); 91 drawProc[i](canvas, r, paint);
92 canvas->restore(); 92 canvas->restore();
93 canvas->translate(r.width() + margin, 0); 93 canvas->translate(r.width() + margin, 0);
94 } 94 }
95 canvas->restore(); 95 canvas->restore();
96 canvas->translate(0, r.height()); 96 canvas->translate(0, r.height());
97 } 97 }
98
99 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
100 SkSafeUnref(filters[i]);
101 }
102 } 98 }
103 99
104 private: 100 private:
105 typedef GM INHERITED; 101 typedef GM INHERITED;
106 }; 102 };
107 103
108 ////////////////////////////////////////////////////////////////////////////// 104 //////////////////////////////////////////////////////////////////////////////
109 105
110 DEF_GM(return new ImageFiltersStrokedGM;) 106 DEF_GM(return new ImageFiltersStrokedGM;)
111 107
112 } 108 }
OLDNEW
« no previous file with comments | « gm/imagefiltersscaled.cpp ('k') | gm/imageresizetiled.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698