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

Side by Side Diff: gpu/command_buffer/client/gles2_demo.cc

Issue 465040: Added CommandBufferClient, CommandBufferStub and some IPC messages.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 // 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 // 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/message_loop.h" 16 #include "base/message_loop.h"
17 #include "base/ref_counted.h" 17 #include "base/ref_counted.h"
18 #include "base/shared_memory.h" 18 #include "base/shared_memory.h"
19 #include "base/scoped_ptr.h" 19 #include "base/scoped_ptr.h"
20 #include "gpu/command_buffer/service/gpu_processor.h" 20 #include "gpu/command_buffer/service/gpu_processor.h"
21 #include "gpu/command_buffer/service/command_buffer_service.h" 21 #include "gpu/command_buffer/service/command_buffer_service.h"
22 #include "gpu/command_buffer/client/gles2_implementation.h" 22 #include "gpu/command_buffer/client/gles2_implementation.h"
23 #include "gpu/command_buffer/client/gles2_lib.h" 23 #include "gpu/command_buffer/client/gles2_lib.h"
24 #include "gpu/command_buffer/client/gles2_demo_c.h" 24 #include "gpu/command_buffer/client/gles2_demo_c.h"
25 #include "gpu/command_buffer/client/gles2_demo_cc.h" 25 #include "gpu/command_buffer/client/gles2_demo_cc.h"
26 26
27 using base::SharedMemory; 27 using base::SharedMemory;
28 using command_buffer::GPUProcessor; 28 using gpu::GPUProcessor;
29 using command_buffer::CommandBufferService; 29 using gpu::CommandBufferService;
30 using command_buffer::gles2::GLES2CmdHelper; 30 using gpu::gles2::GLES2CmdHelper;
31 using command_buffer::gles2::GLES2Implementation; 31 using gpu::gles2::GLES2Implementation;
32 32
33 class GLES2Demo { 33 class GLES2Demo {
34 public: 34 public:
35 GLES2Demo(); 35 GLES2Demo();
36 36
37 bool GLES2Demo::Setup(void* hwnd, int32 size); 37 bool GLES2Demo::Setup(void* hwnd, int32 size);
38 38
39 private: 39 private:
40 DISALLOW_COPY_AND_ASSIGN(GLES2Demo); 40 DISALLOW_COPY_AND_ASSIGN(GLES2Demo);
41 }; 41 };
42 42
43 GLES2Demo::GLES2Demo() { 43 GLES2Demo::GLES2Demo() {
44 } 44 }
45 45
46 bool GLES2Demo::Setup(void* hwnd, int32 size) { 46 bool GLES2Demo::Setup(void* hwnd, int32 size) {
47 scoped_ptr<SharedMemory> ring_buffer(new SharedMemory); 47 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService);
48 if (!ring_buffer->Create(std::wstring(), false, false, size)) { 48 if (!command_buffer->Initialize(size)) {
49 return NULL; 49 return NULL;
50 } 50 }
51 51
52 if (!ring_buffer->Map(size)) {
53 return NULL;
54 }
55
56 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService);
57 if (!command_buffer->Initialize(ring_buffer.release())) {
58 return NULL;
59 }
60
61 scoped_refptr<GPUProcessor> gpu_processor( 52 scoped_refptr<GPUProcessor> gpu_processor(
62 new GPUProcessor(command_buffer.get())); 53 new GPUProcessor(command_buffer.get()));
63 if (!gpu_processor->Initialize(reinterpret_cast<HWND>(hwnd))) { 54 if (!gpu_processor->Initialize(reinterpret_cast<HWND>(hwnd))) {
64 return NULL; 55 return NULL;
65 } 56 }
66 57
67 command_buffer->SetPutOffsetChangeCallback( 58 command_buffer->SetPutOffsetChangeCallback(
68 NewCallback(gpu_processor.get(), &GPUProcessor::ProcessCommands)); 59 NewCallback(gpu_processor.get(), &GPUProcessor::ProcessCommands));
69 60
70 GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get()); 61 GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get());
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 200 }
210 201
211 demo->Setup(hwnd, kCommandBufferSize); 202 demo->Setup(hwnd, kCommandBufferSize);
212 203
213 ProcessMessages(hwnd); 204 ProcessMessages(hwnd);
214 205
215 return EXIT_SUCCESS; 206 return EXIT_SUCCESS;
216 } 207 }
217 208
218 209
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_cmd_helper.cc ('k') | gpu/command_buffer/client/gles2_implementation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698