Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(729)

Unified Diff: experimental/SkiaExamples/Presentation.cpp

Issue 16337012: Smallest possible desktop application that uses Skia to render stuff. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Initial support for OSX (not working yet). Code review fixes. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: experimental/SkiaExamples/Presentation.cpp
diff --git a/experimental/SkiaExamples/Presentation.cpp b/experimental/SkiaExamples/Presentation.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7a38077636bdedef5831955665418a4c47cc1c2a
--- /dev/null
+++ b/experimental/SkiaExamples/Presentation.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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 "SkApplication.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);
+// return new SampleWindow(hwnd, argc, argv, NULL);
+}
+
+SkPresentation::SkPresentation(void* hWnd, int argc, char** argv)
+ : INHERITED(hWnd, argc, argv)
+ , slideIndex(0)
+{
+// setupBackend(kRaster_DeviceType);
+ setupBackend(kGPU_DeviceType);
+}
+
+void SkPresentation::draw(SkCanvas* canvas) {
+ gSlides[slideIndex](this, canvas);
+ canvas->flush();
+
+ INHERITED::draw(canvas);
+}
+
+bool SkPresentation::onEvent(const SkEvent& evt) {
+ return INHERITED::onEvent(evt);
+}
+

Powered by Google App Engine
This is Rietveld 408576698