aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-12-20 20:58:18 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-12-20 20:58:18 +0000
commite5ff3cefe007d092daf9d0bc2b03f9ff87b2c34e (patch)
tree9442d032a8b676b7a8070d544c605f769303b19e /src
parent9d0c6ecb8440e8e546881a4ff850eb6333f24541 (diff)
Implement SkColorFilter::asColorMatrix() virtual, and override in
SkColorMatrixFilter. Implement missing SkColorMatrixFilter::setMatrix() and setArray() functions (were in .h, just not implemented). Add a gm for color matrix filters. Review URL: http://codereview.appspot.com/5500044/ git-svn-id: http://skia.googlecode.com/svn/trunk@2909 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkColorFilter.cpp4
-rw-r--r--src/effects/SkColorMatrixFilter.cpp24
2 files changed, 28 insertions, 0 deletions
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index d3f5faa955..e91488b18c 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -15,6 +15,10 @@ bool SkColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) {
return false;
}
+bool SkColorFilter::asColorMatrix(SkScalar matrix[20]) {
+ return false;
+}
+
void SkColorFilter::filterSpan16(const uint16_t s[], int count, uint16_t d[]) {
SkASSERT(this->getFlags() & SkColorFilter::kHasFilter16_Flag);
SkASSERT(!"missing implementation of SkColorFilter::filterSpan16");
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index a58e06da78..5ed86981a2 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -333,8 +333,32 @@ SkColorMatrixFilter::SkColorMatrixFilter(SkFlattenableReadBuffer& buffer)
fFlags = buffer.readU32();
}
+bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) {
+ int32_t* SK_RESTRICT array = fState.fArray;
+ for (int i = 0; i < 20; i++) {
+ matrix[i] = SkFixedToScalar(array[i]);
+ }
+ if (NULL != fProc) {
+ // Undo the offset applied to the constant column in setup().
+ SkScalar offset = SkFixedToScalar(1 << (fState.fShift - 1));
+ matrix[4] -= offset;
+ matrix[9] -= offset;
+ matrix[14] -= offset;
+ matrix[19] -= offset;
+ }
+ return true;
+}
+
SkFlattenable* SkColorMatrixFilter::CreateProc(SkFlattenableReadBuffer& buf) {
return SkNEW_ARGS(SkColorMatrixFilter, (buf));
}
+void SkColorMatrixFilter::setMatrix(const SkColorMatrix& matrix) {
+ setup(matrix.fMat);
+}
+
+void SkColorMatrixFilter::setArray(const SkScalar array[20]) {
+ setup(array);
+}
+
SK_DEFINE_FLATTENABLE_REGISTRAR(SkColorMatrixFilter)