| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // 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> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 GLES2Demo::GLES2Demo() { | 49 GLES2Demo::GLES2Demo() { |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool GLES2Demo::Setup(void* hwnd, int32 size) { | 52 bool GLES2Demo::Setup(void* hwnd, int32 size) { |
| 53 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); | 53 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); |
| 54 if (!command_buffer->Initialize(size)) | 54 if (!command_buffer->Initialize(size)) |
| 55 return NULL; | 55 return NULL; |
| 56 | 56 |
| 57 scoped_refptr<GPUProcessor> gpu_processor( | 57 GPUProcessor* gpu_processor = new GPUProcessor(command_buffer.get()); |
| 58 new GPUProcessor(command_buffer.get())); | 58 if (!gpu_processor->Initialize(reinterpret_cast<HWND>(hwnd), |
| 59 if (!gpu_processor->Initialize(reinterpret_cast<HWND>(hwnd))) { | 59 NULL, |
| 60 gfx::Size(), |
| 61 0)) { |
| 60 return NULL; | 62 return NULL; |
| 61 } | 63 } |
| 62 | 64 |
| 63 command_buffer->SetPutOffsetChangeCallback( | 65 command_buffer->SetPutOffsetChangeCallback( |
| 64 NewCallback(gpu_processor.get(), &GPUProcessor::ProcessCommands)); | 66 NewCallback(gpu_processor, &GPUProcessor::ProcessCommands)); |
| 65 | 67 |
| 66 GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get()); | 68 GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get()); |
| 67 if (!helper->Initialize()) { | 69 if (!helper->Initialize()) { |
| 68 // TODO(gman): cleanup. | 70 // TODO(gman): cleanup. |
| 69 return false; | 71 return false; |
| 70 } | 72 } |
| 71 | 73 |
| 72 size_t transfer_buffer_size = 512 * 1024; | 74 size_t transfer_buffer_size = 512 * 1024; |
| 73 int32 transfer_buffer_id = | 75 int32 transfer_buffer_id = |
| 74 command_buffer->CreateTransferBuffer(transfer_buffer_size); | 76 command_buffer->CreateTransferBuffer(transfer_buffer_size); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 209 } |
| 208 | 210 |
| 209 demo->Setup(hwnd, kCommandBufferSize); | 211 demo->Setup(hwnd, kCommandBufferSize); |
| 210 | 212 |
| 211 ProcessMessages(hwnd); | 213 ProcessMessages(hwnd); |
| 212 | 214 |
| 213 return EXIT_SUCCESS; | 215 return EXIT_SUCCESS; |
| 214 } | 216 } |
| 215 | 217 |
| 216 | 218 |
| OLD | NEW |