OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file implements a standalone executable demo of using GLES2 over | 5 // This file implements a standalone executable demo of using GLES2 over |
6 // command buffers. This code is temporary as the setup that happens | 6 // command buffers. This code is temporary as the setup that happens |
7 // here is in a state of flux. Eventually there will be several versions of | 7 // here is in a state of flux. Eventually there will be several versions of |
8 // setup, one for trusted code, one for pepper, one for NaCl, and maybe others. | 8 // setup, one for trusted code, one for pepper, one for NaCl, and maybe others. |
9 | 9 |
10 #include <windows.h> | 10 #include <windows.h> |
11 #include <windowsx.h> | 11 #include <windowsx.h> |
12 #include <shellapi.h> | 12 #include <shellapi.h> |
13 #include <stdlib.h> | 13 #include <stdlib.h> |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 #include "base/at_exit.h" | 15 #include "base/at_exit.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/callback.h" | 17 #include "base/callback.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
20 #include "base/message_loop.h" | 20 #include "base/message_loop.h" |
21 #include "base/shared_memory.h" | 21 #include "base/shared_memory.h" |
22 #include "gpu/command_buffer/service/context_group.h" | |
23 #include "gpu/command_buffer/service/gpu_scheduler.h" | 22 #include "gpu/command_buffer/service/gpu_scheduler.h" |
24 #include "gpu/command_buffer/service/command_buffer_service.h" | 23 #include "gpu/command_buffer/service/command_buffer_service.h" |
25 #include "gpu/command_buffer/client/gles2_implementation.h" | 24 #include "gpu/command_buffer/client/gles2_implementation.h" |
26 #include "gpu/command_buffer/client/gles2_lib.h" | 25 #include "gpu/command_buffer/client/gles2_lib.h" |
27 #include "gpu/command_buffer/client/gles2_demo_c.h" | 26 #include "gpu/command_buffer/client/gles2_demo_c.h" |
28 #include "gpu/command_buffer/client/gles2_demo_cc.h" | 27 #include "gpu/command_buffer/client/gles2_demo_cc.h" |
29 #include "ui/gfx/gl/gl_surface.h" | 28 #include "ui/gfx/gl/gl_surface.h" |
30 | 29 |
31 using base::SharedMemory; | 30 using base::SharedMemory; |
32 using gpu::Buffer; | 31 using gpu::Buffer; |
(...skipping 17 matching lines...) Expand all Loading... |
50 }; | 49 }; |
51 | 50 |
52 GLES2Demo::GLES2Demo() { | 51 GLES2Demo::GLES2Demo() { |
53 } | 52 } |
54 | 53 |
55 bool GLES2Demo::Setup(void* hwnd, int32 size) { | 54 bool GLES2Demo::Setup(void* hwnd, int32 size) { |
56 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); | 55 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); |
57 if (!command_buffer->Initialize(size)) | 56 if (!command_buffer->Initialize(size)) |
58 return NULL; | 57 return NULL; |
59 | 58 |
60 gpu::gles2::ContextGroup::Ref group(new gpu::gles2::ContextGroup(true)); | |
61 GpuScheduler* gpu_scheduler = GpuScheduler::Create(command_buffer.get(), | 59 GpuScheduler* gpu_scheduler = GpuScheduler::Create(command_buffer.get(), |
62 NULL, | 60 NULL, |
63 NULL); | 61 NULL); |
64 if (!gpu_scheduler->Initialize(reinterpret_cast<HWND>(hwnd), | 62 if (!gpu_scheduler->Initialize(reinterpret_cast<HWND>(hwnd), |
65 gfx::Size(), | 63 gfx::Size(), |
66 false, | 64 false, |
67 gpu::gles2::DisallowedExtensions(), | 65 gpu::gles2::DisallowedExtensions(), |
68 NULL, | 66 NULL, |
69 std::vector<int32>(), | 67 std::vector<int32>(), |
70 NULL)) { | 68 NULL)) { |
(...skipping 16 matching lines...) Expand all Loading... |
87 command_buffer->GetTransferBuffer(transfer_buffer_id); | 85 command_buffer->GetTransferBuffer(transfer_buffer_id); |
88 if (!transfer_buffer.ptr) | 86 if (!transfer_buffer.ptr) |
89 return false; | 87 return false; |
90 | 88 |
91 | 89 |
92 gles2::Initialize(); | 90 gles2::Initialize(); |
93 gles2::SetGLContext(new GLES2Implementation(helper, | 91 gles2::SetGLContext(new GLES2Implementation(helper, |
94 transfer_buffer.size, | 92 transfer_buffer.size, |
95 transfer_buffer.ptr, | 93 transfer_buffer.ptr, |
96 transfer_buffer_id, | 94 transfer_buffer_id, |
97 false, | 95 false)); |
98 true)); | |
99 | 96 |
100 GLFromCPPInit(); | 97 GLFromCPPInit(); |
101 | 98 |
102 return command_buffer.release() != NULL; | 99 return command_buffer.release() != NULL; |
103 } | 100 } |
104 | 101 |
105 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
106 LRESULT CALLBACK WindowProc( | 103 LRESULT CALLBACK WindowProc( |
107 HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { | 104 HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { |
108 switch (msg) { | 105 switch (msg) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 ::fprintf(stdout, "Could not setup window.\n"); | 223 ::fprintf(stdout, "Could not setup window.\n"); |
227 return EXIT_FAILURE; | 224 return EXIT_FAILURE; |
228 } | 225 } |
229 | 226 |
230 demo->Setup(hwnd, kCommandBufferSize); | 227 demo->Setup(hwnd, kCommandBufferSize); |
231 | 228 |
232 ProcessMessages(hwnd); | 229 ProcessMessages(hwnd); |
233 | 230 |
234 return EXIT_SUCCESS; | 231 return EXIT_SUCCESS; |
235 } | 232 } |
OLD | NEW |