Home | History | Annotate | Download | only in effects
      1 
      2 /*
      3  * Copyright 2011 Google Inc.
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 
      9 
     10 #include "SkPixelXorXfermode.h"
     11 #include "SkColorPriv.h"
     12 
     13 // we always return an opaque color, 'cause I don't know what to do with
     14 // the alpha-component and still return a valid premultiplied color.
     15 SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) {
     16     SkPMColor res = src ^ dst ^ fOpColor;
     17     res |= (SK_A32_MASK << SK_A32_SHIFT);   // force it to be opaque
     18     return res;
     19 }
     20 
     21 void SkPixelXorXfermode::flatten(SkFlattenableWriteBuffer& wb) {
     22     this->INHERITED::flatten(wb);
     23     wb.write32(fOpColor);
     24 }
     25 
     26 SkPixelXorXfermode::SkPixelXorXfermode(SkFlattenableReadBuffer& rb)
     27         : SkXfermode(rb) {
     28     fOpColor = rb.readU32();
     29 }
     30 
     31 SkFlattenable::Factory SkPixelXorXfermode::getFactory() {
     32     return Create;
     33 }
     34 
     35 SkFlattenable* SkPixelXorXfermode::Create(SkFlattenableReadBuffer& rb) {
     36     return SkNEW_ARGS(SkPixelXorXfermode, (rb));
     37 }
     38 
     39 SK_DEFINE_FLATTENABLE_REGISTRAR(SkPixelXorXfermode)
     40