OLD | NEW |
(Empty) | |
| 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 SkNormalMapSource_DEFINED |
| 9 #define SkNormalMapSource_DEFINED |
| 10 |
| 11 #include "SkNormalSource.h" |
| 12 |
| 13 class SkNormalMapSourceImpl : public SkNormalSource { |
| 14 public: |
| 15 SkNormalMapSourceImpl(sk_sp<SkShader> mapShader, const SkMatrix& invCTM) |
| 16 : fMapShader(std::move(mapShader)) |
| 17 , fInvCTM(invCTM) {} |
| 18 |
| 19 #if SK_SUPPORT_GPU |
| 20 sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, |
| 21 const SkMatrix& viewM, |
| 22 const SkMatrix* localMatrix, |
| 23 SkFilterQuality, |
| 24 SkSourceGammaTreatment) const
override; |
| 25 #endif |
| 26 |
| 27 SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec, |
| 28 void* storage) const override; |
| 29 size_t providerSize(const SkShader::ContextRec& rec) const override; |
| 30 |
| 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkNormalMapSourceImpl) |
| 32 |
| 33 protected: |
| 34 void flatten(SkWriteBuffer& buf) const override; |
| 35 |
| 36 bool computeNormTotalInverse(const SkShader::ContextRec& rec, SkMatrix* norm
TotalInverse) const; |
| 37 |
| 38 private: |
| 39 class Provider : public SkNormalSource::Provider { |
| 40 public: |
| 41 Provider(const SkNormalMapSourceImpl& source, SkShader::Context* mapCont
ext, |
| 42 SkPaint* overridePaint); |
| 43 |
| 44 virtual ~Provider() override; |
| 45 |
| 46 void fillScanLine(int x, int y, SkPoint3 output[], int count) const over
ride; |
| 47 |
| 48 private: |
| 49 const SkNormalMapSourceImpl& fSource; |
| 50 SkShader::Context* fMapContext; |
| 51 |
| 52 SkPaint* fOverridePaint; |
| 53 |
| 54 typedef SkNormalSource::Provider INHERITED; |
| 55 }; |
| 56 |
| 57 sk_sp<SkShader> fMapShader; |
| 58 SkMatrix fInvCTM; // Inverse of the canvas total matrix, used for rot
ating normals. |
| 59 |
| 60 friend class SkNormalSource; |
| 61 |
| 62 typedef SkNormalSource INHERITED; |
| 63 }; |
| 64 |
| 65 #endif |
| 66 |
OLD | NEW |