OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Base class for gles2 applications using command buffer. | |
6 | |
7 #ifndef GPU_DEMOS_APP_FRAMEWORK_APPLICATION_H_ | |
8 #define GPU_DEMOS_APP_FRAMEWORK_APPLICATION_H_ | |
9 | |
10 #include "base/at_exit.h" | |
11 #include "base/message_loop.h" | |
12 #include "base/time.h" | |
13 | |
14 #include "gpu/demos/app_framework/platform.h" | |
15 | |
16 namespace gpu_demos { | |
17 | |
18 // Acts as a base class for GLES2 applications using command buffer. | |
19 // The derived calls needs to call InitRenderContext() to create a render | |
20 // surface and initialize a rendering context. Currently it only creates | |
21 // an on-screen window. It will be extended to support pepper/nacl plugin | |
22 // when pepper 3D api is in place. | |
23 class Application { | |
24 public: | |
25 Application(); | |
26 virtual ~Application(); | |
27 | |
28 // Enters the event processing loop. | |
29 void MainLoop(); | |
30 void OnPaint(); | |
31 | |
32 protected: | |
33 // Returns the width of rendering surface. | |
34 inline int width() const { return width_; } | |
35 // Returns the height of rendering surface. | |
36 inline int height() const { return height_; } | |
37 | |
38 bool InitRenderContext(); | |
39 | |
40 // The framework calls this function for the derived classes to do custom | |
41 // rendering. There is no default implementation. It must be defined by the | |
42 // derived classes. The elapsed_sec param represents the time elapsed | |
43 // (in seconds) after Draw was called the last time. It can be used to | |
44 // make the application frame-rate independent. It is 0.0f for the | |
45 // first draw call. | |
46 virtual void Draw(float elapsed_sec) = 0; | |
47 | |
48 private: | |
49 // Creates a native on-screen window. | |
50 NativeWindowHandle CreateNativeWindow(); | |
51 | |
52 int width_; | |
53 int height_; | |
54 NativeWindowHandle window_handle_; | |
55 | |
56 // Time at which draw was called last. | |
57 base::Time last_draw_time_; | |
58 | |
59 // The following two variables are just needed to satisfy | |
60 // the assumption that we are running inside a browser. | |
61 base::AtExitManager at_exit_manager_; | |
62 MessageLoopForUI message_loop_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(Application); | |
65 }; | |
66 | |
67 } // namespace gpu_demos | |
68 #endif // GPU_DEMOS_APP_FRAMEWORK_APPLICATION_H_ | |
OLD | NEW |