blob: 2a6ac47aac4fb8e34a948ed2c8debeefd9cf9947 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
mike@reedtribe.org3334c3a2011-04-20 11:39:28 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * 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.
mike@reedtribe.org3334c3a2011-04-20 11:39:28 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com8a1c16f2008-12-17 15:59:43 +000010#include "SkPixelXorXfermode.h"
11#include "SkColorPriv.h"
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000012#include "SkReadBuffer.h"
13#include "SkWriteBuffer.h"
robertphillips@google.comb83b6b42013-01-22 14:32:09 +000014#include "SkString.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000015
16// we always return an opaque color, 'cause I don't know what to do with
17// the alpha-component and still return a valid premultiplied color.
mike@reedtribe.org61490fa2012-12-24 14:38:46 +000018SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) const {
reed@android.com8a1c16f2008-12-17 15:59:43 +000019 SkPMColor res = src ^ dst ^ fOpColor;
20 res |= (SK_A32_MASK << SK_A32_SHIFT); // force it to be opaque
21 return res;
22}
23
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000024void SkPixelXorXfermode::flatten(SkWriteBuffer& wb) const {
djsollen@google.comc73dd5c2012-08-07 15:54:32 +000025 wb.writeColor(fOpColor);
reed@android.com8a1c16f2008-12-17 15:59:43 +000026}
27
reed9fa60da2014-08-21 07:59:51 -070028SkFlattenable* SkPixelXorXfermode::CreateProc(SkReadBuffer& buffer) {
29 return Create(buffer.readColor());
30}
robertphillips@google.comb83b6b42013-01-22 14:32:09 +000031
commit-bot@chromium.org0f10f7b2014-03-13 18:02:17 +000032#ifndef SK_IGNORE_TO_STRING
robertphillips@google.comb83b6b42013-01-22 14:32:09 +000033void SkPixelXorXfermode::toString(SkString* str) const {
34 str->append("SkPixelXorXfermode: ");
35 str->appendHex(fOpColor);
36}
37#endif