gfx/skia/trunk/src/effects/gradients/SkTwoPointConicalGradient.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2012 Google Inc.
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9 #ifndef SkTwoPointConicalGradient_DEFINED
michael@0 10 #define SkTwoPointConicalGradient_DEFINED
michael@0 11
michael@0 12 #include "SkGradientShaderPriv.h"
michael@0 13
michael@0 14 struct TwoPtRadial {
michael@0 15 enum {
michael@0 16 kDontDrawT = 0x80000000
michael@0 17 };
michael@0 18
michael@0 19 float fCenterX, fCenterY;
michael@0 20 float fDCenterX, fDCenterY;
michael@0 21 float fRadius;
michael@0 22 float fDRadius;
michael@0 23 float fA;
michael@0 24 float fRadius2;
michael@0 25 float fRDR;
michael@0 26
michael@0 27 void init(const SkPoint& center0, SkScalar rad0,
michael@0 28 const SkPoint& center1, SkScalar rad1);
michael@0 29
michael@0 30 // used by setup and nextT
michael@0 31 float fRelX, fRelY, fIncX, fIncY;
michael@0 32 float fB, fDB;
michael@0 33
michael@0 34 void setup(SkScalar fx, SkScalar fy, SkScalar dfx, SkScalar dfy);
michael@0 35 SkFixed nextT();
michael@0 36
michael@0 37 static bool DontDrawT(SkFixed t) {
michael@0 38 return kDontDrawT == (uint32_t)t;
michael@0 39 }
michael@0 40 };
michael@0 41
michael@0 42
michael@0 43 class SkTwoPointConicalGradient : public SkGradientShaderBase {
michael@0 44 TwoPtRadial fRec;
michael@0 45 void init();
michael@0 46
michael@0 47 public:
michael@0 48 SkTwoPointConicalGradient(const SkPoint& start, SkScalar startRadius,
michael@0 49 const SkPoint& end, SkScalar endRadius,
michael@0 50 const Descriptor&);
michael@0 51
michael@0 52 virtual void shadeSpan(int x, int y, SkPMColor* dstCParam,
michael@0 53 int count) SK_OVERRIDE;
michael@0 54 virtual bool setContext(const SkBitmap& device,
michael@0 55 const SkPaint& paint,
michael@0 56 const SkMatrix& matrix) SK_OVERRIDE;
michael@0 57
michael@0 58 virtual BitmapType asABitmap(SkBitmap* bitmap,
michael@0 59 SkMatrix* matrix,
michael@0 60 TileMode* xy) const;
michael@0 61 virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
michael@0 62 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) const SK_OVERRIDE;
michael@0 63 virtual bool isOpaque() const SK_OVERRIDE;
michael@0 64
michael@0 65 SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); }
michael@0 66 SkScalar getStartRadius() const { return fRadius1; }
michael@0 67 SkScalar getDiffRadius() const { return fRadius2 - fRadius1; }
michael@0 68
michael@0 69 SK_TO_STRING_OVERRIDE()
michael@0 70 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointConicalGradient)
michael@0 71
michael@0 72 protected:
michael@0 73 SkTwoPointConicalGradient(SkReadBuffer& buffer);
michael@0 74 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
michael@0 75
michael@0 76 private:
michael@0 77 typedef SkGradientShaderBase INHERITED;
michael@0 78 const SkPoint fCenter1;
michael@0 79 const SkPoint fCenter2;
michael@0 80 const SkScalar fRadius1;
michael@0 81 const SkScalar fRadius2;
michael@0 82 };
michael@0 83
michael@0 84 #endif

mercurial