| 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 paint.setShader(SkLightingShader::Make(fDiffuseBitmap, std::move(lights)
, nullptr, | 73 sk_sp<SkShader> diffuseShader = SkBitmapProcShader::MakeBitmapShader(fDi
ffuseBitmap, |
| 74 std::move(normalSource))); | 74 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr); |
| 75 paint.setShader(SkLightingShader::Make(std::move(diffuseShader), std::mo
ve(normalSource), |
| 76 std::move(lights))); |
| 75 paint.setColor(SK_ColorBLACK); | 77 paint.setColor(SK_ColorBLACK); |
| 76 | 78 |
| 77 SkRect r = SkRect::MakeWH((SkScalar)fDiffuseBitmap.width(), | 79 SkRect r = SkRect::MakeWH((SkScalar)fDiffuseBitmap.width(), |
| 78 (SkScalar)fDiffuseBitmap.height()); | 80 (SkScalar)fDiffuseBitmap.height()); |
| 79 canvas->drawRect(r, paint); | 81 canvas->drawRect(r, paint); |
| 80 | 82 |
| 81 // so we're constantly updating | 83 // so we're constantly updating |
| 82 this->inval(nullptr); | 84 this->inval(nullptr); |
| 83 } | 85 } |
| 84 | 86 |
| 85 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove
rride { | 87 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove
rride { |
| 86 this->inval(nullptr); | 88 this->inval(nullptr); |
| 87 return this->INHERITED::onFindClickHandler(x, y, modi); | 89 return this->INHERITED::onFindClickHandler(x, y, modi); |
| 88 } | 90 } |
| 89 | 91 |
| 90 private: | 92 private: |
| 91 typedef SampleView INHERITED; | 93 typedef SampleView INHERITED; |
| 92 }; | 94 }; |
| 93 | 95 |
| 94 ////////////////////////////////////////////////////////////////////////////// | 96 ////////////////////////////////////////////////////////////////////////////// |
| 95 | 97 |
| 96 static SkView* MyFactory() { return new LightingView; } | 98 static SkView* MyFactory() { return new LightingView; } |
| 97 static SkViewRegister reg(MyFactory); | 99 static SkViewRegister reg(MyFactory); |
| OLD | NEW |