Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkGammaColorFilter.h
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 SkGammaColorFilter_DEFINED
9 #define SkGammaColorFilter_DEFINED
10 
11 #include "SkColorFilter.h"
12 #include "SkRefCnt.h"
13 
14 // This colorfilter can be used to perform pixel-by-pixel conversion between linear and
15 // power-law color spaces. A gamma of 2.2 is interpreted to mean convert from sRGB to linear
16 // while a gamma of 1/2.2 is interpreted to mean convert from linear to sRGB. Any other
17 // values are just directly applied (i.e., out = in^gamma)
18 //
19 // More complicated color space mapping (i.e., ICC profiles) should be handled via the
20 // SkColorSpace object.
21 class SK_API SkGammaColorFilter : public SkColorFilter {
22 public:
23  static sk_sp<SkColorFilter> Make(SkScalar gamma);
24 
25 #ifdef SK_SUPPORT_LEGACY_COLORFILTER_PTR
26  static SkColorFilter* Create(SkScalar gamma) { return Make(gamma).release(); }
27 #endif
28 
29  void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override;
30 
31 #if SK_SUPPORT_GPU
33 #endif
34 
35  SK_TO_STRING_OVERRIDE()
36  SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter)
37 
38 protected:
39  void flatten(SkWriteBuffer&) const override;
40 
41 private:
42  SkGammaColorFilter(SkScalar gamma);
43 
44  SkScalar fGamma;
45  typedef SkColorFilter INHERITED;
46 };
47 
48 #endif
T *SK_WARN_UNUSED_RESULT release()
Return the bare pointer, and set the internal object pointer to nullptr.
Definition: SkRefCnt.h:363
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:29
virtual void filterSpan(const SkPMColor src[], int count, SkPMColor result[]) const =0
Called with a scanline of colors, as if there was a shader installed.
Definition: SkGammaColorFilter.h:21
SkFlattenable is the base class for objects that need to be flattened into a data stream for either t...
Definition: SkFlattenable.h:70
Definition: GrContext.h:48
uint32_t SkPMColor
32 bit ARGB color value, premultiplied.
Definition: SkColor.h:147
Luminance-to-alpha color filter, as defined in http://www.w3.org/TR/SVG/masking.html#Masking http://w...
Definition: SkLumaColorFilter.h:25
Definition: SkWriteBuffer.h:26
virtual void flatten(SkWriteBuffer &) const
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
Definition: SkFlattenable.h:117
virtual sk_sp< GrFragmentProcessor > asFragmentProcessor(GrContext *) const
A subclass may implement this factory function to work with the GPU backend.