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

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

Issue 465099: Removed command buffer's last dependency on NPAPI.... (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 is here so other GLES2 related files can have a common set of 5 // This file is here so other GLES2 related files can have a common set of
6 // includes where appropriate. 6 // includes where appropriate.
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <windowsx.h> 9 #include <windowsx.h>
10 #include <shellapi.h> 10 #include <shellapi.h>
11 #include <stdlib.h> 11 #include <stdlib.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 #include "base/ref_counted.h" 13 #include "base/ref_counted.h"
14 #include "base/shared_memory.h" 14 #include "base/shared_memory.h"
15 #include "base/scoped_ptr.h" 15 #include "base/scoped_ptr.h"
16 #include "gpu/command_buffer/service/gpu_processor.h" 16 #include "gpu/command_buffer/service/gpu_processor.h"
17 #include "gpu/command_buffer/service/command_buffer_service.h" 17 #include "gpu/command_buffer/service/command_buffer_service.h"
18 #include "gpu/np_utils/np_utils.h"
19 #include "gpu/command_buffer/client/gles2_implementation.h" 18 #include "gpu/command_buffer/client/gles2_implementation.h"
20 #include "gpu/command_buffer/client/gles2_lib.h" 19 #include "gpu/command_buffer/client/gles2_lib.h"
21 #include "gpu/command_buffer/client/gles2_demo_c.h" 20 #include "gpu/command_buffer/client/gles2_demo_c.h"
22 #include "gpu/command_buffer/client/gles2_demo_cc.h" 21 #include "gpu/command_buffer/client/gles2_demo_cc.h"
23 22
24 using base::SharedMemory; 23 using base::SharedMemory;
25 using command_buffer::GPUProcessor; 24 using command_buffer::GPUProcessor;
26 using command_buffer::CommandBufferService; 25 using command_buffer::CommandBufferService;
27 using command_buffer::gles2::GLES2CmdHelper; 26 using command_buffer::gles2::GLES2CmdHelper;
28 using command_buffer::gles2::GLES2Implementation; 27 using command_buffer::gles2::GLES2Implementation;
29 28
30 class GLES2Demo { 29 class GLES2Demo {
31 public: 30 public:
32 GLES2Demo(); 31 GLES2Demo();
33 32
34 bool GLES2Demo::Setup(NPP npp, void* hwnd, int32 size); 33 bool GLES2Demo::Setup(void* hwnd, int32 size);
35 34
36 private: 35 private:
37 DISALLOW_COPY_AND_ASSIGN(GLES2Demo); 36 DISALLOW_COPY_AND_ASSIGN(GLES2Demo);
38 }; 37 };
39 38
40 GLES2Demo::GLES2Demo() { 39 GLES2Demo::GLES2Demo() {
41 } 40 }
42 41
43 bool GLES2Demo::Setup(NPP npp, void* hwnd, int32 size) { 42 bool GLES2Demo::Setup(void* hwnd, int32 size) {
44 scoped_ptr<SharedMemory> ring_buffer(new SharedMemory); 43 scoped_ptr<SharedMemory> ring_buffer(new SharedMemory);
45 if (!ring_buffer->Create(std::wstring(), false, false, size)) { 44 if (!ring_buffer->Create(std::wstring(), false, false, size)) {
46 return NULL; 45 return NULL;
47 } 46 }
48 47
49 if (!ring_buffer->Map(size)) { 48 if (!ring_buffer->Map(size)) {
50 return NULL; 49 return NULL;
51 } 50 }
52 51
53 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); 52 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService);
54 if (!command_buffer->Initialize(ring_buffer.release())) { 53 if (!command_buffer->Initialize(ring_buffer.release())) {
55 return NULL; 54 return NULL;
56 } 55 }
57 56
58 scoped_refptr<GPUProcessor> gpu_processor( 57 scoped_refptr<GPUProcessor> gpu_processor(
59 new GPUProcessor(npp, command_buffer.get())); 58 new GPUProcessor(command_buffer.get()));
60 if (!gpu_processor->Initialize(reinterpret_cast<HWND>(hwnd))) { 59 if (!gpu_processor->Initialize(reinterpret_cast<HWND>(hwnd))) {
61 return NULL; 60 return NULL;
62 } 61 }
63 62
64 command_buffer->SetPutOffsetChangeCallback( 63 command_buffer->SetPutOffsetChangeCallback(
65 NewCallback(gpu_processor.get(), &GPUProcessor::ProcessCommands)); 64 NewCallback(gpu_processor.get(), &GPUProcessor::ProcessCommands));
66 65
67 GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get()); 66 GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get());
68 if (!helper->Initialize()) { 67 if (!helper->Initialize()) {
69 // TODO(gman): cleanup. 68 // TODO(gman): cleanup.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 int main(int argc, const char** argv) { 193 int main(int argc, const char** argv) {
195 const int32 kCommandBufferSize = 1024 * 1024; 194 const int32 kCommandBufferSize = 1024 * 1024;
196 GLES2Demo* demo = new GLES2Demo(); 195 GLES2Demo* demo = new GLES2Demo();
197 196
198 void* hwnd = SetupWindow(); 197 void* hwnd = SetupWindow();
199 if (!hwnd) { 198 if (!hwnd) {
200 ::fprintf(stdout, "Could not setup window.\n"); 199 ::fprintf(stdout, "Could not setup window.\n");
201 return EXIT_FAILURE; 200 return EXIT_FAILURE;
202 } 201 }
203 202
204 demo->Setup(NULL, hwnd, kCommandBufferSize); 203 demo->Setup(hwnd, kCommandBufferSize);
205 204
206 ProcessMessages(hwnd); 205 ProcessMessages(hwnd);
207 206
208 return EXIT_SUCCESS; 207 return EXIT_SUCCESS;
209 } 208 }
210 209
211 210
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/fenced_allocator_test.cc ('k') | gpu/command_buffer/service/cmd_parser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698