Index: experimental/SkiaExamples/Presentation.cpp |
diff --git a/experimental/SkiaExamples/Presentation.cpp b/experimental/SkiaExamples/Presentation.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4978c7c9e811657b7bf92588adb598891a493039 |
--- /dev/null |
+++ b/experimental/SkiaExamples/Presentation.cpp |
@@ -0,0 +1,69 @@ |
+/* |
+ * Copyright 2013 Google Inc. |
+ * |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ * |
+ */ |
+ |
+#include "Presentation.h" |
+ |
+#include "SkCanvas.h" |
+#include "SkGraphics.h" |
+ |
+// Define a type for presentation functions. |
+typedef void (*DrawSlide)(SkView* parent, SkCanvas* canvas); |
+ |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
+// Slides |
+ |
+static void sample_slide(SkView* parent, SkCanvas* canvas) { |
+ canvas->drawColor(SK_ColorGREEN); |
+ const char text[] = "Skia Presentation Slide"; |
+ SkPaint paint; |
+ paint.setFlags(SkPaint::kAntiAlias_Flag | SkPaint::kUnderlineText_Flag); |
+ canvas->drawText(text, strlen(text), |
+ 100, parent->height() / SkIntToScalar(2), paint); |
+} |
+ |
+// Register the slides here: |
+const uint32_t kNumSlides = 1; |
+DrawSlide gSlides[kNumSlides] = { |
+ &sample_slide |
+}; |
+//////////////////////////////////////////////////////////////////////////////// |
+ |
+SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { |
+ return new SkPresentation(hwnd, argc, argv); |
+} |
+ |
+void application_init() { |
+ SkGraphics::Init(); |
+ SkEvent::Init(); |
+} |
caryclark
2013/06/10 15:48:40
can this go into base so it isn't repeated in chil
sglez
2013/06/11 04:24:38
Done. (But just for the record, defining these fun
|
+ |
+void application_term() { |
+ SkEvent::Term(); |
+ SkGraphics::Term(); |
+} |
+ |
+SkPresentation::SkPresentation(void* hWnd, int argc, char** argv) |
+ : INHERITED(hWnd, argc, argv) |
+ , slideIndex(0) |
+{ |
+ setupBackend(kGPU_DeviceType); |
+} |
+ |
+void SkPresentation::draw(SkCanvas* canvas) { |
+ gSlides[slideIndex](this, canvas); |
+ canvas->flush(); |
+ if(this->getDeviceType() == kGPU_DeviceType) { |
+ present(); |
+ } |
+} |
+ |
+void SkPresentation::onEvent(SkEvent* evt) SK_OVERRIDE { |
+} |
+ |