aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-07-30 10:11:42 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-30 10:11:42 -0700
commitc3eb50cd9e9a707b4198b81155ca13e552ec90c0 (patch)
treec515a29202531c244606812dd2d4e2aa2084411f /src
parentf684a78d9ea988883c9b2c7bcc4ea4d5e68bd998 (diff)
Minor cleanup of SkLightingShader
Fix: PM component swizzling on Macs Serialization Review URL: https://codereview.chromium.org/1270533003
Diffstat (limited to 'src')
-rw-r--r--src/effects/SkLightingShader.cpp18
-rw-r--r--src/ports/SkGlobalInitialization_chromium.cpp2
-rw-r--r--src/ports/SkGlobalInitialization_default.cpp2
3 files changed, 17 insertions, 5 deletions
diff --git a/src/effects/SkLightingShader.cpp b/src/effects/SkLightingShader.cpp
index 7dcba95941..7b55626f55 100644
--- a/src/effects/SkLightingShader.cpp
+++ b/src/effects/SkLightingShader.cpp
@@ -15,7 +15,7 @@
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
-///////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
/*
SkLightingShader TODOs:
@@ -93,7 +93,7 @@ public:
};
SK_TO_STRING_OVERRIDE()
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(LightingShader)
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLightingShaderImpl)
protected:
void flatten(SkWriteBuffer&) const override;
@@ -105,6 +105,8 @@ private:
SkLightingShader::Light fLight;
SkColor fAmbientColor; // linear (unpremul) color
+ friend class SkLightingShader;
+
typedef SkShader INHERITED;
};
@@ -447,9 +449,9 @@ void SkLightingShaderImpl::LightingShaderContext::shadeSpan(int x, int y,
for (int i = 0; i < n; ++i) {
SkASSERT(0xFF == SkColorGetA(tmpNormal2[i])); // opaque -> unpremul
- norm.set(SkIntToScalar(SkColorGetR(tmpNormal2[i]))-127.0f,
- SkIntToScalar(SkColorGetG(tmpNormal2[i]))-127.0f,
- SkIntToScalar(SkColorGetB(tmpNormal2[i]))-127.0f);
+ norm.set(SkIntToScalar(SkGetPackedR32(tmpNormal2[i]))-127.0f,
+ SkIntToScalar(SkGetPackedG32(tmpNormal2[i]))-127.0f,
+ SkIntToScalar(SkGetPackedB32(tmpNormal2[i]))-127.0f);
norm.normalize();
SkColor diffColor = SkUnPreMultiply::PMColorToColor(tmpColor2[i]);
@@ -582,3 +584,9 @@ SkShader* SkLightingShader::Create(const SkBitmap& diffuse, const SkBitmap& norm
}
///////////////////////////////////////////////////////////////////////////////
+
+SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader)
+ SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl)
+SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
+
+///////////////////////////////////////////////////////////////////////////////
diff --git a/src/ports/SkGlobalInitialization_chromium.cpp b/src/ports/SkGlobalInitialization_chromium.cpp
index b3eb3aa743..3aecbd5471 100644
--- a/src/ports/SkGlobalInitialization_chromium.cpp
+++ b/src/ports/SkGlobalInitialization_chromium.cpp
@@ -41,6 +41,7 @@
#include "SkLayerRasterizer.h"
#include "SkLerpXfermode.h"
#include "SkLightingImageFilter.h"
+#include "../effects/SkLightingShader.h"
#include "SkLocalMatrixShader.h"
#include "SkLumaColorFilter.h"
#include "SkMagnifierImageFilter.h"
@@ -132,6 +133,7 @@ public:
SkColorFilter::InitializeFlattenables();
SkGradientShader::InitializeFlattenables();
SkLightingImageFilter::InitializeFlattenables();
+ SkLightingShader::InitializeFlattenables();
SkTableColorFilter::InitializeFlattenables();
SkXfermode::InitializeFlattenables();
}
diff --git a/src/ports/SkGlobalInitialization_default.cpp b/src/ports/SkGlobalInitialization_default.cpp
index fb496f65cb..47b00b96f1 100644
--- a/src/ports/SkGlobalInitialization_default.cpp
+++ b/src/ports/SkGlobalInitialization_default.cpp
@@ -37,6 +37,7 @@
#include "SkLayerRasterizer.h"
#include "SkLerpXfermode.h"
#include "SkLightingImageFilter.h"
+#include "../effects/SkLightingShader.h"
#include "SkLocalMatrixShader.h"
#include "SkLumaColorFilter.h"
#include "SkMagnifierImageFilter.h"
@@ -111,6 +112,7 @@ public:
SkColorFilter::InitializeFlattenables();
SkGradientShader::InitializeFlattenables();
SkLightingImageFilter::InitializeFlattenables();
+ SkLightingShader::InitializeFlattenables();
SkTableColorFilter::InitializeFlattenables();
SkXfermode::InitializeFlattenables();
}