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

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: Presentation example 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 "SkCanvas.h"
13 #include "SkGraphics.h"
14
15 // Define a type for presentation functions.
16 typedef void (*DrawSlide)(SkView* parent, SkCanvas* canvas);
17
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 }
41
42 void application_init() {
43 SkGraphics::Init();
44 SkEvent::Init();
45 }
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
46
47 void application_term() {
48 SkEvent::Term();
49 SkGraphics::Term();
50 }
51
52 SkPresentation::SkPresentation(void* hWnd, int argc, char** argv)
53 : INHERITED(hWnd, argc, argv)
54 , slideIndex(0)
55 {
56 setupBackend(kGPU_DeviceType);
57 }
58
59 void SkPresentation::draw(SkCanvas* canvas) {
60 gSlides[slideIndex](this, canvas);
61 canvas->flush();
62 if(this->getDeviceType() == kGPU_DeviceType) {
63 present();
64 }
65 }
66
67 void SkPresentation::onEvent(SkEvent* evt) SK_OVERRIDE {
68 }
69
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698