Home | History | Annotate | Download | only in core
      1 /*
      2  * Copyright 2016 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #ifndef SkColorMatrixFilter_DEFINED
      9 #define SkColorMatrixFilter_DEFINED
     10 
     11 #include "SkColorFilter.h"
     12 
     13 class SK_API SkColorMatrixFilterRowMajor255 : public SkColorFilter {
     14 public:
     15     SkColorMatrixFilterRowMajor255() {}
     16     explicit SkColorMatrixFilterRowMajor255(const SkScalar array[20]);
     17 
     18     /** Creates a color matrix filter that returns the same value in all four channels. */
     19     static sk_sp<SkColorFilter> MakeSingleChannelOutput(const SkScalar row[5]);
     20 
     21     uint32_t getFlags() const override;
     22     bool asColorMatrix(SkScalar matrix[20]) const override;
     23     sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter>) const override;
     24 
     25 #if SK_SUPPORT_GPU
     26     sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, SkColorSpace*) const override;
     27 #endif
     28 
     29     SK_TO_STRING_OVERRIDE()
     30 
     31     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter)
     32 
     33 protected:
     34     void flatten(SkWriteBuffer&) const override;
     35 
     36 private:
     37     void onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*,
     38                         bool shaderIsOpaque) const override;
     39 
     40     SkScalar        fMatrix[20];
     41     float           fTranspose[20]; // for Sk4s
     42     uint32_t        fFlags;
     43 
     44     void initState();
     45 
     46     typedef SkColorFilter INHERITED;
     47 };
     48 
     49 #endif
     50