aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-01-11 12:34:04 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-11 12:34:04 -0800
commit0daf5dd7fc682c939325e16cac6f8aa2e1295060 (patch)
tree9ce9e7832ff5b651bde6a762d4553cd12de13373
parent639475e375b7e62277ac5e5b96eadeaaa1afcddc (diff)
move declaration of CreateLightingFilter into SkColorMatrixFilter
-rw-r--r--gm/colorfilters.cpp4
-rw-r--r--gm/textbloblooper.cpp4
-rw-r--r--include/core/SkColorFilter.h6
-rw-r--r--include/effects/SkColorMatrixFilter.h8
-rw-r--r--samplecode/SampleAll.cpp6
-rw-r--r--samplecode/SampleFilterFuzz.cpp2
-rw-r--r--src/effects/SkColorFilters.cpp26
-rw-r--r--src/effects/SkColorMatrixFilter.cpp29
8 files changed, 46 insertions, 39 deletions
diff --git a/gm/colorfilters.cpp b/gm/colorfilters.cpp
index 2d220d2c1d..dcd24d9ce4 100644
--- a/gm/colorfilters.cpp
+++ b/gm/colorfilters.cpp
@@ -7,7 +7,7 @@
#include "gm.h"
#include "SkCanvas.h"
-#include "SkColorFilter.h"
+#include "SkColorMatrixFilter.h"
#include "SkGradientShader.h"
static SkShader* make_shader(const SkRect& bounds) {
@@ -31,7 +31,7 @@ static void install_nothing(SkPaint* paint, uint32_t, uint32_t) {
}
static void install_lighting(SkPaint* paint, uint32_t mul, uint32_t add) {
- paint->setColorFilter(SkColorFilter::CreateLightingFilter(mul, add))->unref();
+ paint->setColorFilter(SkColorMatrixFilter::CreateLightingFilter(mul, add))->unref();
}
class ColorFiltersGM : public skiagm::GM {
diff --git a/gm/textbloblooper.cpp b/gm/textbloblooper.cpp
index c40a4eb2c6..fef3e248f4 100644
--- a/gm/textbloblooper.cpp
+++ b/gm/textbloblooper.cpp
@@ -10,7 +10,7 @@
#include "Sk2DPathEffect.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
-#include "SkColorFilter.h"
+#include "SkColorMatrixFilter.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
@@ -98,7 +98,7 @@ static void color_filter(SkPaint* paint) {
SkRect r;
r.setWH(SkIntToScalar(kWidth), 50);
paint->setShader(make_shader(r))->unref();
- paint->setColorFilter(SkColorFilter::CreateLightingFilter(0xF0F0F0, 0))->unref();
+ paint->setColorFilter(SkColorMatrixFilter::CreateLightingFilter(0xF0F0F0, 0))->unref();
}
static void kitchen_sink(SkPaint* paint) {
diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h
index 57650fbd98..e89b2b1e4f 100644
--- a/include/core/SkColorFilter.h
+++ b/include/core/SkColorFilter.h
@@ -106,11 +106,7 @@ public:
*/
static SkColorFilter* CreateModeFilter(SkColor c, SkXfermode::Mode mode);
- /** Create a colorfilter that multiplies the RGB channels by one color, and
- then adds a second color, pinning the result for each component to
- [0..255]. The alpha components of the mul and add arguments
- are ignored.
- */
+ // DEPRECATED -- call this from SkColorMatrixFilter instead -- see skbug.com/4791
static SkColorFilter* CreateLightingFilter(SkColor mul, SkColor add);
/** Construct a colorfilter whose effect is to first apply the inner filter and then apply
diff --git a/include/effects/SkColorMatrixFilter.h b/include/effects/SkColorMatrixFilter.h
index 851a6e9002..7ffbf117cb 100644
--- a/include/effects/SkColorMatrixFilter.h
+++ b/include/effects/SkColorMatrixFilter.h
@@ -20,6 +20,14 @@ public:
return new SkColorMatrixFilter(array);
}
+ /**
+ * Create a colorfilter that multiplies the RGB channels by one color, and
+ * then adds a second color, pinning the result for each component to
+ * [0..255]. The alpha components of the mul and add arguments
+ * are ignored.
+ */
+ static SkColorFilter* CreateLightingFilter(SkColor mul, SkColor add);
+
void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override;
uint32_t getFlags() const override;
bool asColorMatrix(SkScalar matrix[20]) const override;
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp
index 21d93bd8ae..ad3181f7cd 100644
--- a/samplecode/SampleAll.cpp
+++ b/samplecode/SampleAll.cpp
@@ -12,7 +12,7 @@
#include "Sk1DPathEffect.h"
#include "Sk2DPathEffect.h"
#include "SkBlurMaskFilter.h"
-#include "SkColorFilter.h"
+#include "SkColorMatrixFilter.h"
#include "SkColorPriv.h"
#include "SkCornerPathEffect.h"
#include "SkDashPathEffect.h"
@@ -385,7 +385,7 @@ protected:
SkMaskFilter* embossFilter = SkEmbossMaskFilter::Create(sigma, light);
SkXfermode* xfermode = SkXfermode::Create(SkXfermode::kXor_Mode);
- SkColorFilter* lightingFilter = SkColorFilter::CreateLightingFilter(
+ SkColorFilter* lightingFilter = SkColorMatrixFilter::CreateLightingFilter(
0xff89bc45, 0xff112233);
canvas->save();
@@ -551,7 +551,7 @@ protected:
#if 01
int index = i % SK_ARRAY_COUNT(gLightingColors);
- paint.setColorFilter(SkColorFilter::CreateLightingFilter(
+ paint.setColorFilter(SkColorMatrixFilter::CreateLightingFilter(
gLightingColors[index].fMul,
gLightingColors[index].fAdd))->unref();
#endif
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index 9d45fa6e07..f8ceed452c 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -381,7 +381,7 @@ static SkColorFilter* make_color_filter() {
colorFilter = SkColorFilter::CreateModeFilter(make_color(), make_xfermode());
break;
case 4:
- colorFilter = SkColorFilter::CreateLightingFilter(make_color(), make_color());
+ colorFilter = SkColorMatrixFilter::CreateLightingFilter(make_color(), make_color());
break;
case 5:
default:
diff --git a/src/effects/SkColorFilters.cpp b/src/effects/SkColorFilters.cpp
index 4515c0d3fe..fe39dd9800 100644
--- a/src/effects/SkColorFilters.cpp
+++ b/src/effects/SkColorFilters.cpp
@@ -14,7 +14,6 @@
#include "SkUtils.h"
#include "SkString.h"
#include "SkValidationUtils.h"
-#include "SkColorMatrixFilter.h"
bool SkModeColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) const {
if (color) {
@@ -169,28 +168,3 @@ SkColorFilter* SkColorFilter::CreateModeFilter(SkColor color, SkXfermode::Mode m
return SkModeColorFilter::Create(color, mode);
}
}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static SkScalar byte_to_scale(U8CPU byte) {
- if (0xFF == byte) {
- // want to get this exact
- return 1;
- } else {
- return byte * 0.00392156862745f;
- }
-}
-
-SkColorFilter* SkColorFilter::CreateLightingFilter(SkColor mul, SkColor add) {
- SkColorMatrix matrix;
- matrix.setScale(byte_to_scale(SkColorGetR(mul)),
- byte_to_scale(SkColorGetG(mul)),
- byte_to_scale(SkColorGetB(mul)),
- 1);
- matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
- SkIntToScalar(SkColorGetG(add)),
- SkIntToScalar(SkColorGetB(add)),
- 0);
- return SkColorMatrixFilter::Create(matrix);
-}
-
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index 3cc6e2c0c0..f24670e4bc 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -338,3 +338,32 @@ void SkColorMatrixFilter::toString(SkString* str) const {
str->append(")");
}
#endif
+
+///////////////////////////////////////////////////////////////////////////////
+
+static SkScalar byte_to_scale(U8CPU byte) {
+ if (0xFF == byte) {
+ // want to get this exact
+ return 1;
+ } else {
+ return byte * 0.00392156862745f;
+ }
+}
+
+SkColorFilter* SkColorMatrixFilter::CreateLightingFilter(SkColor mul, SkColor add) {
+ SkColorMatrix matrix;
+ matrix.setScale(byte_to_scale(SkColorGetR(mul)),
+ byte_to_scale(SkColorGetG(mul)),
+ byte_to_scale(SkColorGetB(mul)),
+ 1);
+ matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
+ SkIntToScalar(SkColorGetG(add)),
+ SkIntToScalar(SkColorGetB(add)),
+ 0);
+ return SkColorMatrixFilter::Create(matrix);
+}
+
+// DEPRECTED -- remove this when chrome/android stop calling it
+SkColorFilter* SkColorFilter::CreateLightingFilter(SkColor mul, SkColor add) {
+ return SkColorMatrixFilter::CreateLightingFilter(mul, add);
+}