michael@0: michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #include "SkPixelXorXfermode.h" michael@0: #include "SkColorPriv.h" michael@0: #include "SkReadBuffer.h" michael@0: #include "SkWriteBuffer.h" michael@0: #include "SkString.h" michael@0: michael@0: // we always return an opaque color, 'cause I don't know what to do with michael@0: // the alpha-component and still return a valid premultiplied color. michael@0: SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) const { michael@0: SkPMColor res = src ^ dst ^ fOpColor; michael@0: res |= (SK_A32_MASK << SK_A32_SHIFT); // force it to be opaque michael@0: return res; michael@0: } michael@0: michael@0: void SkPixelXorXfermode::flatten(SkWriteBuffer& wb) const { michael@0: this->INHERITED::flatten(wb); michael@0: wb.writeColor(fOpColor); michael@0: } michael@0: michael@0: SkPixelXorXfermode::SkPixelXorXfermode(SkReadBuffer& rb) michael@0: : INHERITED(rb) { michael@0: fOpColor = rb.readColor(); michael@0: } michael@0: michael@0: #ifndef SK_IGNORE_TO_STRING michael@0: void SkPixelXorXfermode::toString(SkString* str) const { michael@0: str->append("SkPixelXorXfermode: "); michael@0: str->appendHex(fOpColor); michael@0: } michael@0: #endif