9fa60daad4
Refactoring pattern: 1. guard the existing constructor(readbuffer) with the legacy build-flag 2. If you are a instancable subclass, implement CreateProc(readbuffer) to create a new instances from the buffer params (or return NULL). If you're a shader subclass 1. You must read/write the local matrix if your class accepts that in its factory/constructor, else ignore it. R=robertphillips@google.com, mtklein@google.com, senorblanco@google.com, senorblanco@chromium.org, sugoi@chromium.org Author: reed@google.com Review URL: https://codereview.chromium.org/395603002
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
/*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkLerpXfermode_DEFINED
|
|
#define SkLerpXfermode_DEFINED
|
|
|
|
#include "SkXfermode.h"
|
|
|
|
class SK_API SkLerpXfermode : public SkXfermode {
|
|
public:
|
|
/**
|
|
* result = scale * src + (1 - scale) * dst
|
|
*
|
|
* When scale == 1, this is the same as kSrc_Mode
|
|
* When scale == 0, this is the same as kDst_Mode
|
|
*/
|
|
static SkXfermode* Create(SkScalar scale);
|
|
|
|
// overrides from SkXfermode
|
|
virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
|
|
const SkAlpha aa[]) const SK_OVERRIDE;
|
|
virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
|
|
const SkAlpha aa[]) const SK_OVERRIDE;
|
|
virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count,
|
|
const SkAlpha aa[]) const SK_OVERRIDE;
|
|
|
|
SK_TO_STRING_OVERRIDE()
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLerpXfermode)
|
|
|
|
protected:
|
|
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
|
|
SkLerpXfermode(SkReadBuffer&);
|
|
#endif
|
|
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
|
|
|
private:
|
|
SkLerpXfermode(unsigned scale256);
|
|
|
|
unsigned fScale256; // 0..256
|
|
|
|
typedef SkXfermode INHERITED;
|
|
};
|
|
|
|
#endif
|