blob: 1957c9e70612722cd4fa9b5a8976d6fb6787eeba [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
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*/
27class SkPixelXorXfermode : public SkXfermode {
28public:
29 SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
30
31 // override from SkFlattenable
32 virtual Factory getFactory();
33 virtual void flatten(SkFlattenableWriteBuffer&);
34
tomhudson@google.com1447c6f2011-04-27 14:09:52 +000035 static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
36 return SkNEW_ARGS(SkPixelXorXfermode, (buffer));
37 }
38
reed@android.com8a1c16f2008-12-17 15:59:43 +000039protected:
40 // override from SkXfermode
41 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst);
42
43private:
44 SkColor fOpColor;
45
46 SkPixelXorXfermode(SkFlattenableReadBuffer& rb);
47 // our private factory
48 static SkFlattenable* Create(SkFlattenableReadBuffer&);
49
50 typedef SkXfermode INHERITED;
51};
52
53#endif