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

Side by Side Diff: gm/imagefiltersclipped.cpp

Issue 1245983002: Run noise shader separately in imagefiltersclipped (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | no next file » | 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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkBlurImageFilter.h" 10 #include "SkBlurImageFilter.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), 84 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode),
85 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS electorType, 85 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS electorType,
86 SkDisplacementMapEffect::kR_ChannelS electorType, 86 SkDisplacementMapEffect::kR_ChannelS electorType,
87 SkIntToScalar(12), 87 SkIntToScalar(12),
88 gradient.get(), 88 gradient.get(),
89 checkerboard.get()), 89 checkerboard.get()),
90 SkDilateImageFilter::Create(2, 2, checkerboard.get()), 90 SkDilateImageFilter::Create(2, 2, checkerboard.get()),
91 SkErodeImageFilter::Create(2, 2, checkerboard.get()), 91 SkErodeImageFilter::Create(2, 2, checkerboard.get()),
92 SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)), 92 SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)),
93 SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQualit y), 93 SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQualit y),
94 SkRectShaderImageFilter::Create(noise),
95 }; 94 };
96 95
97 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); 96 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
98 SkScalar margin = SkIntToScalar(16); 97 SkScalar margin = SkIntToScalar(16);
99 SkRect bounds = r; 98 SkRect bounds = r;
100 bounds.outset(margin, margin); 99 bounds.outset(margin, margin);
101 100
101 canvas->save();
102 for (int xOffset = 0; xOffset < 80; xOffset += 16) { 102 for (int xOffset = 0; xOffset < 80; xOffset += 16) {
103 canvas->save(); 103 canvas->save();
104 bounds.fLeft = SkIntToScalar(xOffset); 104 bounds.fLeft = SkIntToScalar(xOffset);
105 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { 105 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
106 SkPaint paint; 106 SkPaint paint;
107 paint.setColor(SK_ColorWHITE); 107 paint.setColor(SK_ColorWHITE);
108 paint.setImageFilter(filters[i]); 108 paint.setImageFilter(filters[i]);
109 paint.setAntiAlias(true); 109 paint.setAntiAlias(true);
110 canvas->save(); 110 canvas->save();
111 canvas->clipRect(bounds); 111 canvas->clipRect(bounds);
112 if (5 == i) { 112 if (5 == i) {
113 canvas->translate(SkIntToScalar(16), SkIntToScalar(-32)); 113 canvas->translate(SkIntToScalar(16), SkIntToScalar(-32));
114 } else if (6 == i) { 114 } else if (6 == i) {
115 canvas->scale(SkScalarInvert(RESIZE_FACTOR_X), 115 canvas->scale(SkScalarInvert(RESIZE_FACTOR_X),
116 SkScalarInvert(RESIZE_FACTOR_Y)); 116 SkScalarInvert(RESIZE_FACTOR_Y));
117 } 117 }
118 canvas->drawCircle(r.centerX(), r.centerY(), r.width() * 2 / 5, paint); 118 canvas->drawCircle(r.centerX(), r.centerY(), r.width() * 2 / 5, paint);
119 canvas->restore(); 119 canvas->restore();
120 canvas->translate(r.width() + margin, 0); 120 canvas->translate(r.width() + margin, 0);
121 } 121 }
122 canvas->restore(); 122 canvas->restore();
123 canvas->translate(0, r.height() + margin); 123 canvas->translate(0, r.height() + margin);
124 } 124 }
125 canvas->restore();
125 126
126 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { 127 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
127 SkSafeUnref(filters[i]); 128 SkSafeUnref(filters[i]);
128 } 129 }
130
robertphillips 2015/07/21 14:38:41 leak? Mv 'noise' down here too?
jvanverth1 2015/07/21 15:30:45 Done.
131 SkImageFilter* rectFilter = SkRectShaderImageFilter::Create(noise);
132 canvas->translate(SK_ARRAY_COUNT(filters)*(r.width() + margin), 0);
133 for (int xOffset = 0; xOffset < 80; xOffset += 16) {
robertphillips 2015/07/21 14:38:42 Would it be clearer if this were a subroutine: dr
jvanverth1 2015/07/21 15:30:45 Done.
134 canvas->save();
135 bounds.fLeft = SkIntToScalar(xOffset);
136 SkPaint paint;
137 paint.setColor(SK_ColorWHITE);
138 paint.setImageFilter(rectFilter);
139 paint.setAntiAlias(true);
140 canvas->clipRect(bounds);
141 canvas->drawCircle(r.centerX(), r.centerY(), r.width() * 2 / 5, pain t);
142 canvas->restore();
143 canvas->translate(0, r.height() + margin);
144 }
129 } 145 }
130 146
131 private: 147 private:
132 bool fInitialized; 148 bool fInitialized;
133 SkBitmap fCheckerboard; 149 SkBitmap fCheckerboard;
134 SkBitmap fGradientCircle; 150 SkBitmap fGradientCircle;
135 typedef GM INHERITED; 151 typedef GM INHERITED;
136 }; 152 };
137 153
138 ////////////////////////////////////////////////////////////////////////////// 154 //////////////////////////////////////////////////////////////////////////////
139 155
140 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } 156 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; }
141 static GMRegistry reg(MyFactory); 157 static GMRegistry reg(MyFactory);
142 158
143 } 159 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698