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

Side by Side Diff: samplecode/SampleShadowing.cpp

Issue 2224163005: Made shadows blurry (thru implementing variance mapping) (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: removed extra comments Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkPictureRecorder.h" 9 #include "SkPictureRecorder.h"
10 #include "SkShadowPaintFilterCanvas.h" 10 #include "SkShadowPaintFilterCanvas.h"
(...skipping 27 matching lines...) Expand all
38 fTestRects[2].fDepth = 240; 38 fTestRects[2].fDepth = 240;
39 fTestRects[2].fGeometry = SkRect::MakeLTRB(100,100,250,250); 39 fTestRects[2].fGeometry = SkRect::MakeLTRB(100,100,250,250);
40 40
41 fSceneChanged = true; 41 fSceneChanged = true;
42 fLightsChanged = true; 42 fLightsChanged = true;
43 43
44 fSelectedRect = -1; 44 fSelectedRect = -1;
45 fMoveLight = false; 45 fMoveLight = false;
46 46
47 fClearShadowMaps = false; 47 fClearShadowMaps = false;
48
49 fShadowType.fShadowRadius = 2.0f;
50 fShadowType.fBiasingConstant = 0.3f;
51 fShadowType.fMinVariance = 1024;
52 fShadowType.fBlurAlgorithm = SkShadowType::kVariance_BlurAlgorithm;
48 } 53 }
49 54
50 protected: 55 protected:
51 bool onQuery(SkEvent *evt) override { 56 bool onQuery(SkEvent *evt) override {
52 if (SampleCode::TitleQ(*evt)) { 57 if (SampleCode::TitleQ(*evt)) {
53 SampleCode::TitleR(evt, "shadowing"); 58 SampleCode::TitleR(evt, "shadowing");
54 return true; 59 return true;
55 } 60 }
56 61
57 SkUnichar uni; 62 SkUnichar uni;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 111
107 void onDrawContent(SkCanvas *canvas) override { 112 void onDrawContent(SkCanvas *canvas) override {
108 if (fSceneChanged) { 113 if (fSceneChanged) {
109 fPicture = this->makeTestPicture(kWidth, kHeight); 114 fPicture = this->makeTestPicture(kWidth, kHeight);
110 } 115 }
111 116
112 if (fSceneChanged || fLightsChanged || fClearShadowMaps) { 117 if (fSceneChanged || fLightsChanged || fClearShadowMaps) {
113 for (int i = 0; i < fLights->numLights(); i++) { 118 for (int i = 0; i < fLights->numLights(); i++) {
114 fLights->light(i).setShadowMap(nullptr); 119 fLights->light(i).setShadowMap(nullptr);
115 } 120 }
121
116 fSceneChanged = false; 122 fSceneChanged = false;
117 fLightsChanged = false; 123 fLightsChanged = false;
118 fClearShadowMaps = false; 124 fClearShadowMaps = false;
125 }
119 126
120 canvas->setLights(fLights); 127 canvas->setLights(fLights);
121 canvas->drawShadowedPicture(fPicture, nullptr, nullptr); 128
122 } 129 canvas->drawShadowedPicture(fPicture, nullptr, nullptr, fShadowType);
123 } 130 }
124 131
125 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride { 132 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride {
126 return new SkView::Click(this); 133 return new SkView::Click(this);
127 } 134 }
128 135
129 bool onClick(Click *click) override { 136 bool onClick(Click *click) override {
130 SkScalar x = click->fCurr.fX; 137 SkScalar x = click->fCurr.fX;
131 SkScalar y = click->fCurr.fY; 138 SkScalar y = click->fCurr.fY;
132 139
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } fTestRects[kNumTestRects]; 205 } fTestRects[kNumTestRects];
199 206
200 int fSelectedRect; 207 int fSelectedRect;
201 bool fMoveLight; 208 bool fMoveLight;
202 209
203 sk_sp<SkPicture> fPicture; 210 sk_sp<SkPicture> fPicture;
204 211
205 bool fSceneChanged; 212 bool fSceneChanged;
206 bool fLightsChanged; 213 bool fLightsChanged;
207 214
215 SkShadowType fShadowType;
216
208 sk_sp<SkLights> fLights; 217 sk_sp<SkLights> fLights;
209 218
210 typedef SampleView INHERITED; 219 typedef SampleView INHERITED;
211 }; 220 };
212 221
213 ////////////////////////////////////////////////////////////////////////////// 222 //////////////////////////////////////////////////////////////////////////////
214 static SkView* MyFactory() { return new ShadowingView; } 223 static SkView* MyFactory() { return new ShadowingView; }
215 static SkViewRegister reg(MyFactory); 224 static SkViewRegister reg(MyFactory);
216 225
217 #endif 226 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698