SkColorMatrixFilter.h revision ba28d03e94dc221d6a803bf2a84a420b9159255c
1 2/* 3 * Copyright 2007 The Android Open Source Project 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 10#ifndef SkColorMatrixFilter_DEFINED 11#define SkColorMatrixFilter_DEFINED 12 13#include "SkColorFilter.h" 14#include "SkColorMatrix.h" 15 16class SK_API SkColorMatrixFilter : public SkColorFilter { 17public: 18 SkColorMatrixFilter(); 19 explicit SkColorMatrixFilter(const SkColorMatrix&); 20 SkColorMatrixFilter(const SkScalar array[20]); 21 22 void setMatrix(const SkColorMatrix&); 23 void setArray(const SkScalar array[20]); 24 25 // overrides from SkColorFilter 26 virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]) SK_OVERRIDE; 27 virtual void filterSpan16(const uint16_t src[], int count, uint16_t[]) SK_OVERRIDE; 28 virtual uint32_t getFlags() SK_OVERRIDE; 29 virtual bool asColorMatrix(SkScalar matrix[20]) SK_OVERRIDE; 30 31 // overrides for SkFlattenable 32 virtual void flatten(SkFlattenableWriteBuffer& buffer) SK_OVERRIDE; 33 34 struct State { 35 int32_t fArray[20]; 36 int fShift; 37 int32_t fResult[4]; 38 }; 39 40 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter) 41 42protected: 43 SkColorMatrixFilter(SkFlattenableReadBuffer& buffer); 44 45private: 46 47 typedef void (*Proc)(State*, unsigned r, unsigned g, unsigned b, 48 unsigned a); 49 50 Proc fProc; 51 State fState; 52 uint32_t fFlags; 53 54 void setup(const SkScalar array[20]); 55 56 typedef SkColorFilter INHERITED; 57}; 58 59#endif 60