180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2012 Google Inc. 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #ifndef SkTwoPointConicalGradient_DEFINED 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru #define SkTwoPointConicalGradient_DEFINED 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkGradientShaderPriv.h" 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustruct TwoPtRadial { 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru enum { 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kDontDrawT = 0x80000000 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru }; 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru float fCenterX, fCenterY; 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru float fDCenterX, fDCenterY; 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru float fRadius; 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru float fDRadius; 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru float fA; 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru float fRadius2; 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru float fRDR; 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void init(const SkPoint& center0, SkScalar rad0, 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkPoint& center1, SkScalar rad1); 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // used by setup and nextT 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru float fRelX, fRelY, fIncX, fIncY; 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru float fB, fDB; 3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void setup(SkScalar fx, SkScalar fy, SkScalar dfx, SkScalar dfy); 3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkFixed nextT(); 3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static bool DontDrawT(SkFixed t) { 3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return kDontDrawT == (uint32_t)t; 3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkTwoPointConicalGradient : public SkGradientShaderBase { 4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru TwoPtRadial fRec; 4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void init(); 4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkTwoPointConicalGradient(const SkPoint& start, SkScalar startRadius, 4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkPoint& end, SkScalar endRadius, 5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkColor colors[], const SkScalar pos[], 5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int colorCount, SkShader::TileMode mode, 5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkUnitMapper* mapper); 5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void shadeSpan(int x, int y, SkPMColor* dstCParam, 5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int count) SK_OVERRIDE; 5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual bool setContext(const SkBitmap& device, 5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkPaint& paint, 5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkMatrix& matrix) SK_OVERRIDE; 5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual BitmapType asABitmap(SkBitmap* bitmap, 6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkMatrix* matrix, 6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru TileMode* xy) const; 6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; 64d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) const SK_OVERRIDE; 6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); } 6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkScalar getStartRadius() const { return fRadius1; } 6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkScalar getDiffRadius() const { return fRadius2 - fRadius1; } 6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 70d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger SK_DEVELOPER_TO_STRING() 7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointConicalGradient) 7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected: 7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkTwoPointConicalGradient(SkFlattenableReadBuffer& buffer); 7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; 7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru typedef SkGradientShaderBase INHERITED; 7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkPoint fCenter1; 8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkPoint fCenter2; 8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkScalar fRadius1; 8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkScalar fRadius2; 8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 86