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: 29 SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {} 30 31 // override from SkFlattenable 32 virtual Factory getFactory(); 33 virtual void flatten(SkFlattenableWriteBuffer&); 34 35 static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { 36 return SkNEW_ARGS(SkPixelXorXfermode, (buffer)); 37 } 38 39 protected: 40 // override from SkXfermode 41 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst); 42 43 private: 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 54