OLD | NEW |
---|---|
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 #include "DecodeFile.h" | 7 #include "DecodeFile.h" |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "Resources.h" | 9 #include "Resources.h" |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 | 57 |
58 void onDrawContent(SkCanvas* canvas) override { | 58 void onDrawContent(SkCanvas* canvas) override { |
59 fLightAngle += 0.015f; | 59 fLightAngle += 0.015f; |
60 fColorFactor += 0.01f; | 60 fColorFactor += 0.01f; |
61 if (fColorFactor > 1.0f) { | 61 if (fColorFactor > 1.0f) { |
62 fColorFactor = 0.0f; | 62 fColorFactor = 0.0f; |
63 } | 63 } |
64 | 64 |
65 sk_sp<SkLights> lights(create_lights(fLightAngle, fColorFactor)); | 65 sk_sp<SkLights> lights(create_lights(fLightAngle, fColorFactor)); |
66 SkPaint paint; | 66 SkPaint paint; |
67 paint.setShader(SkLightingShader::Make(fDiffuseBitmap, fNormalBitmap, | 67 auto normalSource = SkLightingShader::NormalMapSource::Make(fNormalBitma p, |
68 std::move(lights), SkVector::Make (1.0f, 0.0f), | 68 SkVector::Ma ke(1.0f, 0.0f), |
69 nullptr, nullptr)); | 69 nullptr); |
70 paint.setShader(SkLightingShader::Make(fDiffuseBitmap, std::move(lights) , nullptr, | |
71 normalSource)); | |
egdaniel
2016/06/16 13:15:08
move?
dvonbeck
2016/06/16 23:21:56
Done.
| |
70 paint.setColor(SK_ColorBLACK); | 72 paint.setColor(SK_ColorBLACK); |
71 | 73 |
72 SkRect r = SkRect::MakeWH((SkScalar)fDiffuseBitmap.width(), | 74 SkRect r = SkRect::MakeWH((SkScalar)fDiffuseBitmap.width(), |
73 (SkScalar)fDiffuseBitmap.height()); | 75 (SkScalar)fDiffuseBitmap.height()); |
74 canvas->drawRect(r, paint); | 76 canvas->drawRect(r, paint); |
75 | 77 |
76 // so we're constantly updating | 78 // so we're constantly updating |
77 this->inval(nullptr); | 79 this->inval(nullptr); |
78 } | 80 } |
79 | 81 |
80 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride { | 82 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride { |
81 this->inval(nullptr); | 83 this->inval(nullptr); |
82 return this->INHERITED::onFindClickHandler(x, y, modi); | 84 return this->INHERITED::onFindClickHandler(x, y, modi); |
83 } | 85 } |
84 | 86 |
85 private: | 87 private: |
86 typedef SampleView INHERITED; | 88 typedef SampleView INHERITED; |
87 }; | 89 }; |
88 | 90 |
89 ////////////////////////////////////////////////////////////////////////////// | 91 ////////////////////////////////////////////////////////////////////////////// |
90 | 92 |
91 static SkView* MyFactory() { return new LightingView; } | 93 static SkView* MyFactory() { return new LightingView; } |
92 static SkViewRegister reg(MyFactory); | 94 static SkViewRegister reg(MyFactory); |
OLD | NEW |