Brian Osman | c069a57 | 2018-06-19 16:05:09 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 | |
Ruiqi Mao | c5c3df6 | 2018-06-21 14:40:28 -0400 | [diff] [blame] | 8 | #ifndef SampleNimaActor_DEFINED |
| 9 | #define SampleNimaActor_DEFINED |
Brian Osman | c069a57 | 2018-06-19 16:05:09 -0400 | [diff] [blame] | 10 | |
| 11 | #include <nima/Actor.hpp> |
| 12 | #include <nima/ActorImage.hpp> |
| 13 | #include <nima/Vec2D.hpp> |
| 14 | |
| 15 | #include "SkCanvas.h" |
| 16 | #include "SkImage.h" |
| 17 | |
| 18 | class SampleActor; |
| 19 | class SampleActorImage; |
| 20 | |
| 21 | class SampleActor : public nima::Actor { |
| 22 | public: |
| 23 | SampleActor(std::string baseName); |
| 24 | ~SampleActor(); |
| 25 | |
| 26 | void render(SkCanvas* canvas) const; |
| 27 | |
| 28 | private: |
| 29 | sk_sp<SkImage> fTexture; |
| 30 | std::vector<SampleActorImage> fActorImages; |
| 31 | std::unique_ptr<SkPaint> fPaint; |
| 32 | |
| 33 | typedef nima::Actor INHERITED; |
| 34 | }; |
| 35 | |
| 36 | class SampleActorImage { |
| 37 | public: |
| 38 | SampleActorImage(nima::ActorImage* actorImage, sk_sp<SkImage> texture, SkPaint* paint); |
| 39 | ~SampleActorImage(); |
| 40 | |
| 41 | void render(const SampleActor* actor, SkCanvas* canvas) const; |
| 42 | |
| 43 | int drawOrder() const { return fActorImage->drawOrder(); } |
| 44 | |
| 45 | private: |
| 46 | nima::Vec2D deform(const nima::Vec2D& position, float* boneIdx, float* boneWgt) const; |
| 47 | |
| 48 | private: |
| 49 | nima::ActorImage* fActorImage; |
| 50 | sk_sp<SkImage> fTexture; |
| 51 | SkPaint* fPaint; |
| 52 | }; |
| 53 | |
| 54 | #endif |