dvonbeck | bba4cfe | 2016-07-28 08:58:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkNormalBevelSource_DEFINED |
| 9 | #define SkNormalBevelSource_DEFINED |
| 10 | |
| 11 | #include "SkNormalSource.h" |
| 12 | |
| 13 | class SK_API SkNormalBevelSourceImpl : public SkNormalSource { |
| 14 | public: |
| 15 | SkNormalBevelSourceImpl(BevelType type, SkScalar width, SkScalar height) |
| 16 | : fType(type) |
| 17 | , fWidth(width) |
| 18 | , fHeight(height) {} |
| 19 | |
| 20 | #if SK_SUPPORT_GPU |
| 21 | sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShader::AsFPArgs&) const override; |
| 22 | #endif |
| 23 | |
| 24 | SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec, |
Herb Derby | 83e939b | 2017-02-07 14:25:11 -0500 | [diff] [blame] | 25 | SkArenaAlloc*) const override; |
dvonbeck | bba4cfe | 2016-07-28 08:58:19 -0700 | [diff] [blame] | 26 | |
| 27 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkNormalBevelSourceImpl) |
| 28 | |
| 29 | protected: |
| 30 | void flatten(SkWriteBuffer& buf) const override; |
| 31 | |
| 32 | private: |
| 33 | class Provider : public SkNormalSource::Provider { |
| 34 | public: |
| 35 | Provider(); |
| 36 | |
| 37 | virtual ~Provider(); |
| 38 | |
| 39 | void fillScanLine(int x, int y, SkPoint3 output[], int count) const override; |
| 40 | |
| 41 | private: |
| 42 | typedef SkNormalSource::Provider INHERITED; |
| 43 | |
| 44 | }; |
| 45 | |
| 46 | SkNormalSource::BevelType fType; |
| 47 | SkScalar fWidth; |
| 48 | SkScalar fHeight; |
| 49 | |
| 50 | friend class SkNormalSource; |
| 51 | |
| 52 | typedef SkNormalSource INHERITED; |
| 53 | }; |
| 54 | |
| 55 | |
| 56 | #endif |