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

Side by Side Diff: experimental/SkiaExamples/SkExample.h

Issue 18574002: SkiaExamples improvements. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Make diffs usable Created 7 years, 5 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
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 * 7 *
8 */ 8 */
9 9
10 #ifndef BaseExample_DEFINED 10 #ifndef SkExample_DEFINED
11 #define BaseExample_DEFINED 11 #define SkExample_DEFINED
12 12
13 #include "SkWindow.h" 13 #include "SkWindow.h"
14 14
15 class GrContext; 15 class GrContext;
16 struct GrGLInterface; 16 struct GrGLInterface;
17 class GrRenderTarget; 17 class GrRenderTarget;
18 class SkCanvas; 18 class SkCanvas;
19 19
20 class BaseExample : public SkOSWindow { 20 class HelloSkia;
caryclark 2013/07/08 12:42:35 remove this if it isn't required for this header
21
22 class SkExample : public SkOSWindow {
21 public: 23 public:
24 /**
25 * Member function that creates the SkExample. By default it will create a s ample
26 * defined in SkExample.cpp
27 * The user of this framework can register a new (and only one) example by r unning:
28 *
29 * SkExample::SetExample<DerivedClass> reg("My derived class");
30 *
31 * ... where DerivedClass is a child of SkExample and 'reg' can be any name.
32 *
33 */
34 static SkOSWindow* (*create_user_example) (void* hwnd, int argc, char** argv );
caryclark 2013/07/08 12:42:35 use gCreateUserExample to hint to reader that this
35
36 template<typename T>
37 class SetExample {
38 public:
caryclark 2013/07/08 12:42:35 unindent
39 static SkOSWindow* create(void* hwnd, int argc, char** argv) {
40 return new T(hwnd, argc, argv);
41 }
caryclark 2013/07/08 12:42:35 add a blank line here
42 SetExample(const char* name) {
43 if (SkExample::userExampleExists) {
44 SkDebugf("Rejecting the following Skia Example: %s\n", name) ;
45 return;
46 }
47 SkDebugf("Using skia example: %s\n", name);
48 SkExample::create_user_example = &create;
49 SkExample::userExampleExists = true;
50 }
51 };
52
22 enum DeviceType { 53 enum DeviceType {
23 kRaster_DeviceType, 54 kRaster_DeviceType,
24 kGPU_DeviceType, 55 kGPU_DeviceType,
25 }; 56 };
26 BaseExample(void* hWnd, int argc, char** argv); 57 SkExample(void* hWnd, int argc, char** argv);
27 58
28 // Changes the device type of the object. 59 // Changes the device type of the object.
29 bool setupBackend(DeviceType type); 60 bool setupBackend(DeviceType type);
30 void tearDownBackend(); 61 void tearDownBackend();
31 62
32 DeviceType getDeviceType() const { return fType; } 63 DeviceType getDeviceType() const { return fType; }
33 64
34 protected: 65 protected:
35 // Your class should override this method to do its thing. 66 // Your class should override this method to do its thing.
36 virtual void draw(SkCanvas* canvas) SK_OVERRIDE; 67 virtual void draw(SkCanvas* canvas) SK_OVERRIDE;
37 68
38 virtual void onSizeChange() SK_OVERRIDE; 69 virtual void onSizeChange() SK_OVERRIDE;
39 70
40 #ifdef SK_BUILD_FOR_WIN 71 #ifdef SK_BUILD_FOR_WIN
41 virtual void onHandleInval(const SkIRect&) SK_OVERRIDE; 72 virtual void onHandleInval(const SkIRect&) SK_OVERRIDE;
42 #endif 73 #endif
43 74
44 SkCanvas* createCanvas() SK_OVERRIDE; 75 SkCanvas* createCanvas() SK_OVERRIDE;
45 76
46 private: 77 private:
78 static bool userExampleExists;
caryclark 2013/07/08 12:42:35 use 'gUserExampleExists' to hint to reader that th
79
47 void setupRenderTarget(); 80 void setupRenderTarget();
48 81
49 DeviceType fType; 82 DeviceType fType;
50 83
51 GrContext* fContext; 84 GrContext* fContext;
52 GrRenderTarget* fRenderTarget; 85 GrRenderTarget* fRenderTarget;
53 AttachmentInfo fAttachmentInfo; 86 AttachmentInfo fAttachmentInfo;
54 const GrGLInterface* fInterface; 87 const GrGLInterface* fInterface;
88
55 typedef SkOSWindow INHERITED; 89 typedef SkOSWindow INHERITED;
56 }; 90 };
91
57 #endif 92 #endif
93
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698