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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (fColorFactor > 1.0f) { | 63 if (fColorFactor > 1.0f) { |
64 fColorFactor = 0.0f; | 64 fColorFactor = 0.0f; |
65 } | 65 } |
66 | 66 |
67 sk_sp<SkLights> lights(create_lights(fLightAngle, fColorFactor)); | 67 sk_sp<SkLights> lights(create_lights(fLightAngle, fColorFactor)); |
68 SkPaint paint; | 68 SkPaint paint; |
69 sk_sp<SkShader> normalMap = SkMakeBitmapShader(fNormalBitmap, | 69 sk_sp<SkShader> normalMap = SkMakeBitmapShader(fNormalBitmap, |
70 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr, nullp
tr); | 70 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr, nullp
tr); |
71 sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalMap( | 71 sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalMap( |
72 std::move(normalMap), SkMatrix::I()); | 72 std::move(normalMap), SkMatrix::I()); |
73 sk_sp<SkShader> diffuseShader = SkBitmapProcShader::MakeBitmapShader(fDi
ffuseBitmap, | 73 sk_sp<SkShader> diffuseShader = SkShader::MakeBitmapShader(fDiffuseBitma
p, |
74 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr); | 74 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr); |
75 paint.setShader(SkLightingShader::Make(std::move(diffuseShader), std::mo
ve(normalSource), | 75 paint.setShader(SkLightingShader::Make(std::move(diffuseShader), std::mo
ve(normalSource), |
76 std::move(lights))); | 76 std::move(lights))); |
77 paint.setColor(SK_ColorBLACK); | 77 paint.setColor(SK_ColorBLACK); |
78 | 78 |
79 SkRect r = SkRect::MakeWH((SkScalar)fDiffuseBitmap.width(), | 79 SkRect r = SkRect::MakeWH((SkScalar)fDiffuseBitmap.width(), |
80 (SkScalar)fDiffuseBitmap.height()); | 80 (SkScalar)fDiffuseBitmap.height()); |
81 canvas->drawRect(r, paint); | 81 canvas->drawRect(r, paint); |
82 | 82 |
83 // so we're constantly updating | 83 // so we're constantly updating |
84 this->inval(nullptr); | 84 this->inval(nullptr); |
85 } | 85 } |
86 | 86 |
87 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove
rride { | 87 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove
rride { |
88 this->inval(nullptr); | 88 this->inval(nullptr); |
89 return this->INHERITED::onFindClickHandler(x, y, modi); | 89 return this->INHERITED::onFindClickHandler(x, y, modi); |
90 } | 90 } |
91 | 91 |
92 private: | 92 private: |
93 typedef SampleView INHERITED; | 93 typedef SampleView INHERITED; |
94 }; | 94 }; |
95 | 95 |
96 ////////////////////////////////////////////////////////////////////////////// | 96 ////////////////////////////////////////////////////////////////////////////// |
97 | 97 |
98 static SkView* MyFactory() { return new LightingView; } | 98 static SkView* MyFactory() { return new LightingView; } |
99 static SkViewRegister reg(MyFactory); | 99 static SkViewRegister reg(MyFactory); |
OLD | NEW |