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

Unified Diff: src/effects/SkLightingShader.cpp

Issue 1253223003: Update SkLightingShader to take a localMatrix (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix serialization bug Created 5 years, 5 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 | « src/effects/SkLightingShader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkLightingShader.cpp
diff --git a/src/effects/SkLightingShader.cpp b/src/effects/SkLightingShader.cpp
index be92ccf36129a5054fe838f42f630cdddd709396..7dcba959416751a22327e4a2186e3125dc23b30c 100644
--- a/src/effects/SkLightingShader.cpp
+++ b/src/effects/SkLightingShader.cpp
@@ -51,8 +51,9 @@ public:
*/
SkLightingShaderImpl(const SkBitmap& diffuse, const SkBitmap& normal,
const SkLightingShader::Light& light,
- const SkColor ambient)
- : fDiffuseMap(diffuse)
+ const SkColor ambient, const SkMatrix* localMatrix)
+ : INHERITED(localMatrix)
+ , fDiffuseMap(diffuse)
, fNormalMap(normal)
, fLight(light)
, fAmbientColor(ambient) {
@@ -480,6 +481,9 @@ void SkLightingShaderImpl::toString(SkString* str) const {
#endif
SkFlattenable* SkLightingShaderImpl::CreateProc(SkReadBuffer& buf) {
+ SkMatrix localMatrix;
+ buf.readMatrix(&localMatrix);
+
SkBitmap diffuse;
if (!buf.readBitmap(&diffuse)) {
return NULL;
@@ -500,12 +504,12 @@ SkFlattenable* SkLightingShaderImpl::CreateProc(SkReadBuffer& buf) {
SkColor ambient = buf.readColor();
- // TODO: this would be nice to enable
- // return SkCreateLightingShader(diffuse, normal, light, ambient, NULL);
- return SkNEW_ARGS(SkLightingShaderImpl, (diffuse, normal, light, ambient));
+ return SkNEW_ARGS(SkLightingShaderImpl, (diffuse, normal, light, ambient, &localMatrix));
}
void SkLightingShaderImpl::flatten(SkWriteBuffer& buf) const {
+ buf.writeMatrix(this->getLocalMatrix());
+
buf.writeBitmap(fDiffuseMap);
buf.writeBitmap(fNormalMap);
buf.writeScalarArray(&fLight.fDirection.fX, 3);
@@ -565,7 +569,8 @@ static bool bitmap_is_too_big(const SkBitmap& bm) {
SkShader* SkLightingShader::Create(const SkBitmap& diffuse, const SkBitmap& normal,
const SkLightingShader::Light& light,
- const SkColor ambient) {
+ const SkColor ambient,
+ const SkMatrix* localMatrix) {
if (diffuse.isNull() || bitmap_is_too_big(diffuse) ||
normal.isNull() || bitmap_is_too_big(normal) ||
diffuse.width() != normal.width() ||
@@ -573,7 +578,7 @@ SkShader* SkLightingShader::Create(const SkBitmap& diffuse, const SkBitmap& norm
return nullptr;
}
- return SkNEW_ARGS(SkLightingShaderImpl, (diffuse, normal, light, ambient));
+ return SkNEW_ARGS(SkLightingShaderImpl, (diffuse, normal, light, ambient, localMatrix));
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/effects/SkLightingShader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698