Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 SkPaint paint; | 152 SkPaint paint; |
| 153 paint.setColor(SK_ColorBLACK); | 153 paint.setColor(SK_ColorBLACK); |
| 154 canvas->drawRect(fSliders[i].fGeometry, paint); | 154 canvas->drawRect(fSliders[i].fGeometry, paint); |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| 158 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride { | 158 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride { |
| 159 return new SkView::Click(this); | 159 return new SkView::Click(this); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void updateLights(int x, int y) { | 162 void updateLights(int x, int y) { |
|
robertphillips
2016/08/26 19:45:00
I'm okay with this change but don't you want to ke
vjiaoblack
2016/08/28 20:11:56
Mmmm..... I was going to do another pass and fix i
| |
| 163 float recipX = 1.0f / kWidth; | |
| 164 float recipY = 1.0f / kHeight; | |
| 165 | |
| 163 SkLights::Builder builder; | 166 SkLights::Builder builder; |
| 164 builder.add(SkLights::Light::MakePoint(SkColor3f::Make(0.2f, 0.4f, 0.6f) , | 167 builder.add(SkLights::Light::MakeDirectional( |
| 165 SkVector3::Make(x - 50, | 168 SkColor3f::Make(0.2f, 0.3f, 0.4f), |
| 166 350 - y, | 169 SkVector3::Make(0.2f + (200.0f - x) * recipX, |
| 167 fLightDepth), | 170 0.05f + (200.0f - y) * recipY, |
| 168 1024)); | 171 1.0f))); |
| 169 builder.add(SkLights::Light::MakePoint(SkColor3f::Make(0.6f, 0.4f, 0.2f) , | 172 builder.add(SkLights::Light::MakeDirectional( |
| 170 SkVector3::Make(x + 50, | 173 SkColor3f::Make(0.4f, 0.3f, 0.2f), |
| 171 450 - y, | 174 SkVector3::Make(0.05f + (200.0f - x) * recipX, |
| 172 fLightDepth), | 175 0.2f + (200.0f - y) * recipY, |
| 173 1024)); | 176 1.0f))); |
| 174 builder.add(SkLights::Light::MakeDirectional(SkColor3f::Make(0.2f, 0.2f, 0.2f), | 177 builder.setAmbientLightColor(SkColor3f::Make(0.4f, 0.4f, 0.4f)); |
| 175 SkVector3::Make(0.2f, 0.2f, 1.0f))); | |
| 176 fLights = builder.finish(); | 178 fLights = builder.finish(); |
| 177 } | 179 } |
| 178 | 180 |
| 179 void updateFromSelectedSlider() { | 181 void updateFromSelectedSlider() { |
| 180 SkScalar newValue = fSliders[fSelectedSliderID].fGeometry.fLeft * | 182 SkScalar newValue = fSliders[fSelectedSliderID].fGeometry.fLeft * |
| 181 fSliders[fSelectedSliderID].fScale + | 183 fSliders[fSelectedSliderID].fScale + |
| 182 fSliders[fSelectedSliderID].fOffset; | 184 fSliders[fSelectedSliderID].fOffset; |
| 183 | 185 |
| 184 switch (fSelectedSliderID) { | 186 switch (fSelectedSliderID) { |
| 185 case 0: | 187 case 0: |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 sk_sp<SkLights> fLights; | 300 sk_sp<SkLights> fLights; |
| 299 | 301 |
| 300 typedef SampleView INHERITED; | 302 typedef SampleView INHERITED; |
| 301 }; | 303 }; |
| 302 | 304 |
| 303 ////////////////////////////////////////////////////////////////////////////// | 305 ////////////////////////////////////////////////////////////////////////////// |
| 304 static SkView* MyFactory() { return new ShadowingView; } | 306 static SkView* MyFactory() { return new ShadowingView; } |
| 305 static SkViewRegister reg(MyFactory); | 307 static SkViewRegister reg(MyFactory); |
| 306 | 308 |
| 307 #endif | 309 #endif |
| OLD | NEW |