• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SkPixelXorXfermode_DEFINED
18 #define SkPixelXorXfermode_DEFINED
19 
20 #include "SkXfermode.h"
21 
22 /** SkPixelXorXfermode implements a simple pixel xor (op ^ src ^ dst).
23     This transformation does not follow premultiplied conventions, therefore
24     this proc *always* returns an opaque color (alpha == 255). Thus it is
25     not really usefull for operating on blended colors.
26 */
27 class SkPixelXorXfermode : public SkXfermode {
28 public:
SkPixelXorXfermode(SkColor opColor)29     SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
30 
31     // override from SkFlattenable
32     virtual Factory getFactory();
33     virtual void flatten(SkFlattenableWriteBuffer&);
34 
35 protected:
36     // override from SkXfermode
37     virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst);
38 
39 private:
40     SkColor fOpColor;
41 
42     SkPixelXorXfermode(SkFlattenableReadBuffer& rb);
43     // our private factory
44     static SkFlattenable* Create(SkFlattenableReadBuffer&);
45 
46     typedef SkXfermode INHERITED;
47 };
48 
49 #endif
50 
51