OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/demos/app_framework/application.h" | 5 #include "gpu/demos/app_framework/application.h" |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 #include "gpu/command_buffer/client/gles2_lib.h" | 8 #include "gpu/command_buffer/client/gles2_lib.h" |
9 #include "gpu/command_buffer/service/command_buffer_service.h" | 9 #include "gpu/command_buffer/service/command_buffer_service.h" |
10 #include "gpu/command_buffer/service/gpu_processor.h" | 10 #include "gpu/command_buffer/service/gpu_processor.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 if (msg.message == WM_QUIT) done = true; | 67 if (msg.message == WM_QUIT) done = true; |
68 TranslateMessage(&msg); | 68 TranslateMessage(&msg); |
69 DispatchMessage(&msg); | 69 DispatchMessage(&msg); |
70 } | 70 } |
71 // Message queue is empty and application has not quit yet - keep painting. | 71 // Message queue is empty and application has not quit yet - keep painting. |
72 if (!done) SendMessage(window_handle_, WM_PAINT, 0, 0); | 72 if (!done) SendMessage(window_handle_, WM_PAINT, 0, 0); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 void Application::OnPaint() { | 76 void Application::OnPaint() { |
77 Draw(); | 77 float elapsed_sec = 0.0f; |
| 78 const base::Time current_time = base::Time::Now(); |
| 79 if (!last_draw_time_.is_null()) { |
| 80 base::TimeDelta time_delta = current_time - last_draw_time_; |
| 81 elapsed_sec = static_cast<float>(time_delta.InSecondsF()); |
| 82 } |
| 83 last_draw_time_ = current_time; |
| 84 |
| 85 Draw(elapsed_sec); |
78 gles2::GetGLContext()->SwapBuffers(); | 86 gles2::GetGLContext()->SwapBuffers(); |
79 } | 87 } |
80 | 88 |
81 bool Application::InitRenderContext() { | 89 bool Application::InitRenderContext() { |
82 window_handle_ = CreateNativeWindow(); | 90 window_handle_ = CreateNativeWindow(); |
83 if (window_handle_ == NULL) { | 91 if (window_handle_ == NULL) { |
84 return false; | 92 return false; |
85 } | 93 } |
86 | 94 |
87 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); | 95 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 160 |
153 ShowWindow(hwnd, SW_SHOWNORMAL); | 161 ShowWindow(hwnd, SW_SHOWNORMAL); |
154 // Set this to the GWL_USERDATA so that it is available to WindowProc. | 162 // Set this to the GWL_USERDATA so that it is available to WindowProc. |
155 SetWindowLongPtr(hwnd, GWL_USERDATA, (LONG_PTR)this); | 163 SetWindowLongPtr(hwnd, GWL_USERDATA, (LONG_PTR)this); |
156 | 164 |
157 return hwnd; | 165 return hwnd; |
158 } | 166 } |
159 | 167 |
160 } // namespace gpu_demos | 168 } // namespace gpu_demos |
161 #endif // defined(OS_WIN) | 169 #endif // defined(OS_WIN) |
OLD | NEW |