Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Side by Side Diff: include/effects/SkLumaXfermode.h

Issue 23710053: [External patch] Source-over support for SkLumaXfermode. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gm/lumamode.cpp ('k') | src/effects/SkLumaXfermode.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkLumaXfermode_DEFINED 8 #ifndef SkLumaXfermode_DEFINED
9 #define SkLumaXfermode_DEFINED 9 #define SkLumaXfermode_DEFINED
10 10
11 #include "SkXfermode.h" 11 #include "SkXfermode.h"
12 12
13 /** 13 /**
14 * Luminance mask transfer, as defined in 14 * Luminance mask transfer, as defined in
15 * http://www.w3.org/TR/SVG/masking.html#Masking 15 * http://www.w3.org/TR/SVG/masking.html#Masking
16 * http://www.w3.org/TR/css-masking/#MaskValues 16 * http://www.w3.org/TR/css-masking/#MaskValues
17 * 17 *
18 * The luminance-to-alpha function is applied before performing a standard 18 * The luminance-to-alpha function is applied before performing a standard
19 * SrcIn/DstIn xfer: 19 * SrcIn/DstIn/SrcOver xfer:
20 * 20 *
21 * luma(C) = (0.2125 * C.r + 0.7154 * C.g + 0.0721 * C.b) * C.a 21 * luma(C) = (0.2125 * C.r + 0.7154 * C.g + 0.0721 * C.b) * C.a
22 * 22 *
23 * (where C is un-premultiplied) 23 * (where C is un-premultiplied)
24 */ 24 */
25 class SK_API SkLumaMaskXfermode : public SkXfermode { 25 class SK_API SkLumaMaskXfermode : public SkXfermode {
26 public: 26 public:
27 /** Return an SkLumaMaskXfermode object for the specified submode. 27 /** Return an SkLumaMaskXfermode object for the specified submode.
28 * 28 *
29 * Only kSrcIn_Mode and kDstIn_Mode are supported - for everything else, 29 * Only kSrcIn_Mode, kDstIn_Mode kSrcOver_Mode are supported - for everythi ng else,
30 * the factory returns NULL. 30 * the factory returns NULL.
31 */ 31 */
32 static SkXfermode* Create(SkXfermode::Mode); 32 static SkXfermode* Create(SkXfermode::Mode);
33 33
34 virtual SkPMColor xferColor(SkPMColor, SkPMColor) const SK_OVERRIDE; 34 virtual SkPMColor xferColor(SkPMColor, SkPMColor) const SK_OVERRIDE;
35 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, 35 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
36 const SkAlpha aa[]) const SK_OVERRIDE; 36 const SkAlpha aa[]) const SK_OVERRIDE;
37 37
38 SK_DEVELOPER_TO_STRING() 38 SK_DEVELOPER_TO_STRING()
39 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaMaskXfermode) 39 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaMaskXfermode)
40 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
40 41
41 #if SK_SUPPORT_GPU 42 #if SK_SUPPORT_GPU
42 virtual bool asNewEffectOrCoeff(GrContext*, GrEffectRef**, Coeff*, Coeff*, 43 virtual bool asNewEffectOrCoeff(GrContext*, GrEffectRef**, Coeff*, Coeff*,
43 GrTexture*) const SK_OVERRIDE; 44 GrTexture*) const SK_OVERRIDE;
44 #endif 45 #endif
45 46
46 protected: 47 protected:
47 SkLumaMaskXfermode(SkFlattenableReadBuffer&); 48 SkLumaMaskXfermode(SkFlattenableReadBuffer&);
48 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; 49 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
49 50
50 private:
51 SkLumaMaskXfermode(SkXfermode::Mode); 51 SkLumaMaskXfermode(SkXfermode::Mode);
52 52
53 private:
53 const SkXfermode::Mode fMode; 54 const SkXfermode::Mode fMode;
54 55
55 typedef SkXfermode INHERITED; 56 typedef SkXfermode INHERITED;
57
58 virtual SkPMColor lumaProc(const SkPMColor a, const SkPMColor b) const;
56 }; 59 };
57 60
58 #endif 61 #endif
OLDNEW
« no previous file with comments | « gm/lumamode.cpp ('k') | src/effects/SkLumaXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698