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(const SkShader::AsFPArgs&) co
nst override; |
| 21 #endif |
| 22 |
| 23 SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec, |
| 24 void* storage) const override; |
| 25 size_t providerSize(const SkShader::ContextRec& rec) const override; |
| 26 |
| 27 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkNormalMapSourceImpl) |
| 28 |
| 29 protected: |
| 30 void flatten(SkWriteBuffer& buf) const override; |
| 31 |
| 32 bool computeNormTotalInverse(const SkShader::ContextRec& rec, SkMatrix* norm
TotalInverse) const; |
| 33 |
| 34 private: |
| 35 class Provider : public SkNormalSource::Provider { |
| 36 public: |
| 37 Provider(const SkNormalMapSourceImpl& source, SkShader::Context* mapCont
ext, |
| 38 SkPaint* overridePaint); |
| 39 |
| 40 virtual ~Provider() override; |
| 41 |
| 42 void fillScanLine(int x, int y, SkPoint3 output[], int count) const over
ride; |
| 43 |
| 44 private: |
| 45 const SkNormalMapSourceImpl& fSource; |
| 46 SkShader::Context* fMapContext; |
| 47 |
| 48 SkPaint* fOverridePaint; |
| 49 |
| 50 typedef SkNormalSource::Provider INHERITED; |
| 51 }; |
| 52 |
| 53 sk_sp<SkShader> fMapShader; |
| 54 SkMatrix fInvCTM; // Inverse of the canvas total matrix, used for rot
ating normals. |
| 55 |
| 56 friend class SkNormalSource; |
| 57 |
| 58 typedef SkNormalSource INHERITED; |
| 59 }; |
| 60 |
| 61 #endif |
| 62 |
OLD | NEW |