1589708bf7c706348b763e8277004cb160b202bdbrileya@google.com 2589708bf7c706348b763e8277004cb160b202bdbrileya@google.com/* 3589708bf7c706348b763e8277004cb160b202bdbrileya@google.com * Copyright 2012 Google Inc. 4589708bf7c706348b763e8277004cb160b202bdbrileya@google.com * 5589708bf7c706348b763e8277004cb160b202bdbrileya@google.com * Use of this source code is governed by a BSD-style license that can be 6589708bf7c706348b763e8277004cb160b202bdbrileya@google.com * found in the LICENSE file. 7589708bf7c706348b763e8277004cb160b202bdbrileya@google.com */ 8589708bf7c706348b763e8277004cb160b202bdbrileya@google.com 9589708bf7c706348b763e8277004cb160b202bdbrileya@google.com #ifndef SkTwoPointRadialGradient_DEFINED 10589708bf7c706348b763e8277004cb160b202bdbrileya@google.com #define SkTwoPointRadialGradient_DEFINED 11589708bf7c706348b763e8277004cb160b202bdbrileya@google.com 12589708bf7c706348b763e8277004cb160b202bdbrileya@google.com #include "SkGradientShaderPriv.h" 13589708bf7c706348b763e8277004cb160b202bdbrileya@google.com 14589708bf7c706348b763e8277004cb160b202bdbrileya@google.comclass SkTwoPointRadialGradient : public SkGradientShaderBase { 15589708bf7c706348b763e8277004cb160b202bdbrileya@google.compublic: 16589708bf7c706348b763e8277004cb160b202bdbrileya@google.com SkTwoPointRadialGradient(const SkPoint& start, SkScalar startRadius, 17b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt const SkPoint& end, SkScalar endRadius, 18b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt const Descriptor&); 19589708bf7c706348b763e8277004cb160b202bdbrileya@google.com 20589708bf7c706348b763e8277004cb160b202bdbrileya@google.com virtual BitmapType asABitmap(SkBitmap* bitmap, 21589708bf7c706348b763e8277004cb160b202bdbrileya@google.com SkMatrix* matrix, 22589708bf7c706348b763e8277004cb160b202bdbrileya@google.com TileMode* xy) const SK_OVERRIDE; 23589708bf7c706348b763e8277004cb160b202bdbrileya@google.com virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; 24b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt virtual bool asFragmentProcessor(GrContext* context, const SkPaint&, const SkMatrix*, GrColor*, 25b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt GrFragmentProcessor**) const SK_OVERRIDE; 26589708bf7c706348b763e8277004cb160b202bdbrileya@google.com 2787fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org virtual size_t contextSize() const SK_OVERRIDE; 2887fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org 2987fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org class TwoPointRadialGradientContext : public SkGradientShaderBase::GradientShaderBaseContext { 3087fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org public: 31e901b6de3ef8dea842008a08fc81e92fb1478d61commit-bot@chromium.org TwoPointRadialGradientContext(const SkTwoPointRadialGradient&, const ContextRec&); 3287fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org 3387fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE; 3487fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org 3587fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org private: 3687fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED; 3787fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org }; 38589708bf7c706348b763e8277004cb160b202bdbrileya@google.com 391c6d64b78b24083ee9fd7411dac8a4a7e2d03a3crileya@google.com SkScalar getCenterX1() const { return fDiff.length(); } 401c6d64b78b24083ee9fd7411dac8a4a7e2d03a3crileya@google.com SkScalar getStartRadius() const { return fStartRadius; } 411c6d64b78b24083ee9fd7411dac8a4a7e2d03a3crileya@google.com SkScalar getDiffRadius() const { return fDiffRadius; } 421c6d64b78b24083ee9fd7411dac8a4a7e2d03a3crileya@google.com 430f10f7bf1fb43ca6346dc220a076773b1f19a367commit-bot@chromium.org SK_TO_STRING_OVERRIDE() 44589708bf7c706348b763e8277004cb160b202bdbrileya@google.com SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointRadialGradient) 45589708bf7c706348b763e8277004cb160b202bdbrileya@google.com 46589708bf7c706348b763e8277004cb160b202bdbrileya@google.comprotected: 478b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkTwoPointRadialGradient(SkReadBuffer& buffer); 488b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; 49ce56d965069c1649afe14319cb239e6ad670682acommit-bot@chromium.org virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE; 50589708bf7c706348b763e8277004cb160b202bdbrileya@google.com 51589708bf7c706348b763e8277004cb160b202bdbrileya@google.comprivate: 52589708bf7c706348b763e8277004cb160b202bdbrileya@google.com const SkPoint fCenter1; 53589708bf7c706348b763e8277004cb160b202bdbrileya@google.com const SkPoint fCenter2; 54589708bf7c706348b763e8277004cb160b202bdbrileya@google.com const SkScalar fRadius1; 55589708bf7c706348b763e8277004cb160b202bdbrileya@google.com const SkScalar fRadius2; 56589708bf7c706348b763e8277004cb160b202bdbrileya@google.com SkPoint fDiff; 57589708bf7c706348b763e8277004cb160b202bdbrileya@google.com SkScalar fStartRadius, fDiffRadius, fSr2D2, fA, fOneOverTwoA; 58589708bf7c706348b763e8277004cb160b202bdbrileya@google.com 59589708bf7c706348b763e8277004cb160b202bdbrileya@google.com void init(); 6087fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org 619fa60daad4d5f54c0dbe3dbcc7608a8f6d721187reed friend class SkGradientShader; 6287fcd950198a16211b3988610beebb5ca5bcf323commit-bot@chromium.org typedef SkGradientShaderBase INHERITED; 63589708bf7c706348b763e8277004cb160b202bdbrileya@google.com}; 64589708bf7c706348b763e8277004cb160b202bdbrileya@google.com 65589708bf7c706348b763e8277004cb160b202bdbrileya@google.com#endif 66