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

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

Issue 367002: Added Pepper 3D render context that instantiates the GPU plugin.... (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) 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>
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 gpu::Buffer;
28 using gpu::GPUProcessor; 29 using gpu::GPUProcessor;
29 using gpu::CommandBufferService; 30 using gpu::CommandBufferService;
30 using gpu::gles2::GLES2CmdHelper; 31 using gpu::gles2::GLES2CmdHelper;
31 using gpu::gles2::GLES2Implementation; 32 using gpu::gles2::GLES2Implementation;
32 33
33 class GLES2Demo { 34 class GLES2Demo {
34 public: 35 public:
35 GLES2Demo(); 36 GLES2Demo();
36 37
37 bool GLES2Demo::Setup(void* hwnd, int32 size); 38 bool GLES2Demo::Setup(void* hwnd, int32 size);
38 39
39 private: 40 private:
40 DISALLOW_COPY_AND_ASSIGN(GLES2Demo); 41 DISALLOW_COPY_AND_ASSIGN(GLES2Demo);
41 }; 42 };
42 43
43 GLES2Demo::GLES2Demo() { 44 GLES2Demo::GLES2Demo() {
44 } 45 }
45 46
46 bool GLES2Demo::Setup(void* hwnd, int32 size) { 47 bool GLES2Demo::Setup(void* hwnd, int32 size) {
47 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); 48 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService);
48 if (!command_buffer->Initialize(size)) { 49 if (!command_buffer->Initialize(size))
49 return NULL; 50 return NULL;
50 }
51 51
52 scoped_refptr<GPUProcessor> gpu_processor( 52 scoped_refptr<GPUProcessor> gpu_processor(
53 new GPUProcessor(command_buffer.get())); 53 new GPUProcessor(command_buffer.get()));
54 if (!gpu_processor->Initialize(reinterpret_cast<HWND>(hwnd))) { 54 if (!gpu_processor->Initialize(reinterpret_cast<HWND>(hwnd))) {
55 return NULL; 55 return NULL;
56 } 56 }
57 57
58 command_buffer->SetPutOffsetChangeCallback( 58 command_buffer->SetPutOffsetChangeCallback(
59 NewCallback(gpu_processor.get(), &GPUProcessor::ProcessCommands)); 59 NewCallback(gpu_processor.get(), &GPUProcessor::ProcessCommands));
60 60
61 GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get()); 61 GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get());
62 if (!helper->Initialize()) { 62 if (!helper->Initialize()) {
63 // TODO(gman): cleanup. 63 // TODO(gman): cleanup.
64 return false; 64 return false;
65 } 65 }
66 66
67 size_t transfer_buffer_size = 512 * 1024; 67 size_t transfer_buffer_size = 512 * 1024;
68 int32 transfer_buffer_id = 68 int32 transfer_buffer_id =
69 command_buffer->CreateTransferBuffer(transfer_buffer_size); 69 command_buffer->CreateTransferBuffer(transfer_buffer_size);
70 ::base::SharedMemory* shared_memory = 70 Buffer transfer_buffer =
71 command_buffer->GetTransferBuffer(transfer_buffer_id); 71 command_buffer->GetTransferBuffer(transfer_buffer_id);
72 if (!shared_memory->Map(transfer_buffer_size)) { 72 if (!transfer_buffer.ptr)
73 return false; 73 return false;
74 } 74
75 void* transfer_buffer = shared_memory->memory();
76 if (!transfer_buffer) {
77 return false;
78 }
79 75
80 gles2::g_gl_impl = new GLES2Implementation(helper, 76 gles2::g_gl_impl = new GLES2Implementation(helper,
81 transfer_buffer_size, 77 transfer_buffer.size,
82 transfer_buffer, 78 transfer_buffer.ptr,
83 transfer_buffer_id); 79 transfer_buffer_id);
84 80
85 return command_buffer.release() != NULL; 81 return command_buffer.release() != NULL;
86 } 82 }
87 83
88 #if defined(OS_WIN) 84 #if defined(OS_WIN)
89 LRESULT CALLBACK WindowProc( 85 LRESULT CALLBACK WindowProc(
90 HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { 86 HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
91 switch (msg) { 87 switch (msg) {
92 case WM_CLOSE: 88 case WM_CLOSE:
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 196 }
201 197
202 demo->Setup(hwnd, kCommandBufferSize); 198 demo->Setup(hwnd, kCommandBufferSize);
203 199
204 ProcessMessages(hwnd); 200 ProcessMessages(hwnd);
205 201
206 return EXIT_SUCCESS; 202 return EXIT_SUCCESS;
207 } 203 }
208 204
209 205
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_cmd_helper.h ('k') | gpu/command_buffer/client/gles2_implementation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698