| 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 | 8 |
| 9 #include "gm.h" | 9 #include "gm.h" |
| 10 #include "SkPathEffect.h" | 10 #include "SkPathEffect.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // - reddish directional light pointing more down than right | 69 // - reddish directional light pointing more down than right |
| 70 // - soft white ambient light | 70 // - soft white ambient light |
| 71 | 71 |
| 72 SkLights::Builder builder; | 72 SkLights::Builder builder; |
| 73 builder.add(SkLights::Light::MakeDirectional(SkColor3f::Make(0.2f, 0.3f,
0.4f), | 73 builder.add(SkLights::Light::MakeDirectional(SkColor3f::Make(0.2f, 0.3f,
0.4f), |
| 74 SkVector3::Make(0.2f, 0.1f,
1.0f))); | 74 SkVector3::Make(0.2f, 0.1f,
1.0f))); |
| 75 builder.add(SkLights::Light::MakeDirectional(SkColor3f::Make(0.4f, 0.3f,
0.2f), | 75 builder.add(SkLights::Light::MakeDirectional(SkColor3f::Make(0.4f, 0.3f,
0.2f), |
| 76 SkVector3::Make(0.1f, 0.2f,
1.0f))); | 76 SkVector3::Make(0.1f, 0.2f,
1.0f))); |
| 77 builder.add(SkLights::Light::MakeAmbient(SkColor3f::Make(0.4f, 0.4f, 0.4
f))); | 77 builder.add(SkLights::Light::MakeAmbient(SkColor3f::Make(0.4f, 0.4f, 0.4
f))); |
| 78 fLights = builder.finish(); | 78 fLights = builder.finish(); |
| 79 |
| 80 fShadowParams.fShadowRadius = 4.0f; |
| 81 fShadowParams.fBiasingConstant = 0.3f; |
| 82 fShadowParams.fMinVariance = 1024; |
| 83 fShadowParams.fType = SkShadowParams::kVariance_ShadowType; |
| 79 } | 84 } |
| 80 | 85 |
| 81 protected: | 86 protected: |
| 82 static const int kWidth = 400; | 87 static const int kWidth = 400; |
| 83 static const int kHeight = 400; | 88 static const int kHeight = 400; |
| 84 | 89 |
| 85 SkString onShortName() override { | 90 SkString onShortName() override { |
| 86 return SkString("shadowmaps"); | 91 return SkString("shadowmaps"); |
| 87 } | 92 } |
| 88 | 93 |
| 89 SkISize onISize() override { | 94 SkISize onISize() override { |
| 90 return SkISize::Make(kWidth, kHeight); | 95 return SkISize::Make(kWidth, kHeight); |
| 91 } | 96 } |
| 92 | 97 |
| 93 void onDraw(SkCanvas* canvas) override { | 98 void onDraw(SkCanvas* canvas) override { |
| 94 // This picture stores the picture of the scene. | 99 // This picture stores the picture of the scene. |
| 95 // It's used to generate the depth maps. | 100 // It's used to generate the depth maps. |
| 96 sk_sp<SkPicture> pic(make_test_picture(kWidth, kHeight)); | 101 sk_sp<SkPicture> pic(make_test_picture(kWidth, kHeight)); |
| 97 canvas->setLights(fLights); | 102 canvas->setLights(fLights); |
| 98 canvas->drawShadowedPicture(pic, nullptr, nullptr); | 103 canvas->drawShadowedPicture(pic, nullptr, nullptr, fShadowParams); |
| 99 } | 104 } |
| 100 | 105 |
| 101 private: | 106 private: |
| 102 sk_sp<SkLights> fLights; | 107 sk_sp<SkLights> fLights; |
| 108 SkShadowParams fShadowParams; |
| 103 typedef GM INHERITED; | 109 typedef GM INHERITED; |
| 104 }; | 110 }; |
| 105 | 111 |
| 106 ////////////////////////////////////////////////////////////////////////////// | 112 ////////////////////////////////////////////////////////////////////////////// |
| 107 | 113 |
| 108 DEF_GM(return new ShadowMapsGM;) | 114 DEF_GM(return new ShadowMapsGM;) |
| 109 } | 115 } |
| 110 | 116 |
| 111 #endif | 117 #endif |
| OLD | NEW |