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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 *
8 */
9
10 #include "Presentation.h"
11
12 #include "SkApplication.h"
13 #include "SkCanvas.h"
14 #include "SkGraphics.h"
15
16 // Define a type for presentation functions.
17 typedef void (*DrawSlide)(SkView* parent, SkCanvas* canvas);
18
19 ////////////////////////////////////////////////////////////////////////////////
20 // Slides
21
22 static void sample_slide(SkView* parent, SkCanvas* canvas) {
23 canvas->drawColor(SK_ColorGREEN);
24 const char text[] = "Skia Presentation Slide";
25 SkPaint paint;
26 paint.setFlags(SkPaint::kAntiAlias_Flag | SkPaint::kUnderlineText_Flag);
27 canvas->drawText(text, strlen(text),
28 100, parent->height() / SkIntToScalar(2), paint);
29 }
30
31 // Register the slides here:
32 const uint32_t kNumSlides = 1;
33 DrawSlide gSlides[kNumSlides] = {
34 &sample_slide
35 };
36 ////////////////////////////////////////////////////////////////////////////////
37
38 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
39 return new SkPresentation(hwnd, argc, argv);
40 // return new SampleWindow(hwnd, argc, argv, NULL);
41 }
42
43 SkPresentation::SkPresentation(void* hWnd, int argc, char** argv)
44 : INHERITED(hWnd, argc, argv)
45 , slideIndex(0)
46 {
47 // setupBackend(kRaster_DeviceType);
48 setupBackend(kGPU_DeviceType);
49 }
50
51 void SkPresentation::draw(SkCanvas* canvas) {
52 gSlides[slideIndex](this, canvas);
53 canvas->flush();
54
55 INHERITED::draw(canvas);
56 }
57
58 bool SkPresentation::onEvent(const SkEvent& evt) {
59 return INHERITED::onEvent(evt);
60 }
61
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698