gfx/skia/trunk/src/effects/SkPixelXorXfermode.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/effects/SkPixelXorXfermode.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,39 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2011 Google Inc.
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#include "SkPixelXorXfermode.h"
    1.14 +#include "SkColorPriv.h"
    1.15 +#include "SkReadBuffer.h"
    1.16 +#include "SkWriteBuffer.h"
    1.17 +#include "SkString.h"
    1.18 +
    1.19 +// we always return an opaque color, 'cause I don't know what to do with
    1.20 +// the alpha-component and still return a valid premultiplied color.
    1.21 +SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) const {
    1.22 +    SkPMColor res = src ^ dst ^ fOpColor;
    1.23 +    res |= (SK_A32_MASK << SK_A32_SHIFT);   // force it to be opaque
    1.24 +    return res;
    1.25 +}
    1.26 +
    1.27 +void SkPixelXorXfermode::flatten(SkWriteBuffer& wb) const {
    1.28 +    this->INHERITED::flatten(wb);
    1.29 +    wb.writeColor(fOpColor);
    1.30 +}
    1.31 +
    1.32 +SkPixelXorXfermode::SkPixelXorXfermode(SkReadBuffer& rb)
    1.33 +        : INHERITED(rb) {
    1.34 +    fOpColor = rb.readColor();
    1.35 +}
    1.36 +
    1.37 +#ifndef SK_IGNORE_TO_STRING
    1.38 +void SkPixelXorXfermode::toString(SkString* str) const {
    1.39 +    str->append("SkPixelXorXfermode: ");
    1.40 +    str->appendHex(fOpColor);
    1.41 +}
    1.42 +#endif

mercurial