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

Unified Diff: gm/lightingshader.cpp

Issue 1304673002: Revert "Update SkLightingShader to support rotation" (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/SampleApp.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/lightingshader.cpp
diff --git a/gm/lightingshader.cpp b/gm/lightingshader.cpp
index c73ad5b4c8b9fed79b438857f5b3a4649af804e7..7e33504477fef81e0c5740caf505e1bdb89dc91c 100644
--- a/gm/lightingshader.cpp
+++ b/gm/lightingshader.cpp
@@ -19,7 +19,7 @@ static SkBitmap make_checkerboard(int texSize) {
sk_tool_utils::draw_checkerboard(&canvas,
sk_tool_utils::color_to_565(0x0),
sk_tool_utils::color_to_565(0xFF804020),
- 8);
+ 2);
return bitmap;
}
@@ -58,13 +58,10 @@ public:
LightingShaderGM() {
this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC));
- SkLightingShader::Lights::Builder builder;
+ fLight.fColor = SkColor3f::Make(1.0f, 1.0f, 1.0f);
+ fLight.fDirection = SkVector3::Make(0.0f, 0.0f, 1.0f);
- builder.add(SkLight(SkColor3f::Make(1.0f, 1.0f, 1.0f),
- SkVector3::Make(1.0f, 0.0f, 0.0f)));
- builder.add(SkLight(SkColor3f::Make(0.2f, 0.2f, 0.2f)));
-
- fLights.reset(builder.finish());
+ fAmbient = SkColor3f::Make(0.1f, 0.1f, 0.1f);
}
protected:
@@ -101,16 +98,11 @@ protected:
SkMatrix matrix;
matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit);
- const SkMatrix& ctm = canvas->getTotalMatrix();
-
- // TODO: correctly pull out the pure rotation
- SkVector invNormRotation = { ctm[SkMatrix::kMScaleX], ctm[SkMatrix::kMSkewY] };
-
SkAutoTUnref<SkShader> fShader(SkLightingShader::Create(
fDiffuse,
fNormalMaps[mapType],
- fLights,
- invNormRotation, &matrix, &matrix));
+ fLight, fAmbient,
+ &matrix));
SkPaint paint;
paint.setShader(fShader);
@@ -119,56 +111,17 @@ protected:
}
void onDraw(SkCanvas* canvas) override {
- SkMatrix m;
- SkRect r;
-
- {
- r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSize));
- this->drawRect(canvas, r, kHemi_NormalMap);
-
- canvas->save();
- m.setRotate(45.0f, r.centerX(), r.centerY());
- m.postTranslate(kGMSize/2.0f - kTexSize/2.0f, 0.0f);
- canvas->setMatrix(m);
- this->drawRect(canvas, r, kHemi_NormalMap);
- canvas->restore();
- }
-
- {
- r.offset(kGMSize - kTexSize, 0);
- this->drawRect(canvas, r, kFrustum_NormalMap);
-
- canvas->save();
- m.setRotate(45.0f, r.centerX(), r.centerY());
- m.postTranslate(0.0f, kGMSize/2.0f - kTexSize/2.0f);
- canvas->setMatrix(m);
- this->drawRect(canvas, r, kFrustum_NormalMap);
- canvas->restore();
- }
-
- {
- r.offset(0, kGMSize - kTexSize);
- this->drawRect(canvas, r, kTetra_NormalMap);
-
- canvas->save();
- m.setRotate(45.0f, r.centerX(), r.centerY());
- m.postTranslate(-kGMSize/2.0f + kTexSize/2.0f, 0.0f);
- canvas->setMatrix(m);
- this->drawRect(canvas, r, kTetra_NormalMap);
- canvas->restore();
- }
-
- {
- r.offset(kTexSize - kGMSize, 0);
- this->drawRect(canvas, r, kHemi_NormalMap);
-
- canvas->save();
- m.setRotate(45.0f, r.centerX(), r.centerY());
- m.postTranslate(0.0f, -kGMSize/2.0f + kTexSize/2.0f);
- canvas->setMatrix(m);
- this->drawRect(canvas, r, kHemi_NormalMap);
- canvas->restore();
- }
+ SkRect r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSize));
+ this->drawRect(canvas, r, kHemi_NormalMap);
+
+ r.offset(kGMSize - kTexSize, 0);
+ this->drawRect(canvas, r, kFrustum_NormalMap);
+
+ r.offset(0, kGMSize - kTexSize);
+ this->drawRect(canvas, r, kTetra_NormalMap);
+
+ r.offset(kTexSize - kGMSize, 0);
+ this->drawRect(canvas, r, kHemi_NormalMap);
}
private:
@@ -178,7 +131,8 @@ private:
SkBitmap fDiffuse;
SkBitmap fNormalMaps[kNormalMapCount];
- SkAutoTUnref<const SkLightingShader::Lights> fLights;
+ SkLightingShader::Light fLight;
+ SkColor3f fAmbient;
typedef GM INHERITED;
};
« no previous file with comments | « no previous file | gyp/SampleApp.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698