Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: samplecode/SampleLighting.cpp

Issue 2195893002: Always return ImageShader, even from SkShader::MakeBitmapShader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update serialize-8888 ignore list: skbug.com/5595 Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698