aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/Nima.h
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2018-06-19 16:05:09 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-19 20:30:28 +0000
commitc069a57301a468dbc45f3f3775b623e5532f9398 (patch)
tree4c067efbba58df8f6333f80b73924ae0f6e24843 /samplecode/Nima.h
parent644341af03d22dfe10e8e6c47e0aa21f5346031b (diff)
added NIMA sample to showcase animations
improved third_party template to include headers as system headers for non-Windows machines Bug: skia: Change-Id: Id2fa74fc31b49f9b07cc83e7f60477c7ab4f8d83 Reviewed-on: https://skia-review.googlesource.com/135450 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'samplecode/Nima.h')
-rw-r--r--samplecode/Nima.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/samplecode/Nima.h b/samplecode/Nima.h
new file mode 100644
index 0000000000..0017fcf59c
--- /dev/null
+++ b/samplecode/Nima.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef Nima_DEFINED
+#define Nima_DEFINED
+
+#include <nima/Actor.hpp>
+#include <nima/ActorImage.hpp>
+#include <nima/Vec2D.hpp>
+
+#include "SkCanvas.h"
+#include "SkImage.h"
+
+class SampleActor;
+class SampleActorImage;
+
+class SampleActor : public nima::Actor {
+public:
+ SampleActor(std::string baseName);
+ ~SampleActor();
+
+ void render(SkCanvas* canvas) const;
+
+private:
+ sk_sp<SkImage> fTexture;
+ std::vector<SampleActorImage> fActorImages;
+ std::unique_ptr<SkPaint> fPaint;
+
+ typedef nima::Actor INHERITED;
+};
+
+class SampleActorImage {
+public:
+ SampleActorImage(nima::ActorImage* actorImage, sk_sp<SkImage> texture, SkPaint* paint);
+ ~SampleActorImage();
+
+ void render(const SampleActor* actor, SkCanvas* canvas) const;
+
+ int drawOrder() const { return fActorImage->drawOrder(); }
+
+private:
+ nima::Vec2D deform(const nima::Vec2D& position, float* boneIdx, float* boneWgt) const;
+
+private:
+ nima::ActorImage* fActorImage;
+ sk_sp<SkImage> fTexture;
+ SkPaint* fPaint;
+};
+
+#endif