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 #include <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include "gpu/command_buffer/service/gpu_processor.h" | 7 #include "gpu/command_buffer/service/gpu_processor.h" |
8 | 8 |
9 using ::base::SharedMemory; | 9 using ::base::SharedMemory; |
10 | 10 |
11 namespace gpu { | 11 namespace gpu { |
12 | 12 |
| 13 GPUProcessor::GPUProcessor(CommandBuffer* command_buffer) |
| 14 : command_buffer_(command_buffer), |
| 15 commands_per_update_(100) { |
| 16 DCHECK(command_buffer); |
| 17 decoder_.reset(gles2::GLES2Decoder::Create()); |
| 18 decoder_->set_engine(this); |
| 19 } |
| 20 |
| 21 GPUProcessor::GPUProcessor(CommandBuffer* command_buffer, |
| 22 gles2::GLES2Decoder* decoder, |
| 23 CommandParser* parser, |
| 24 int commands_per_update) |
| 25 : command_buffer_(command_buffer), |
| 26 commands_per_update_(commands_per_update) { |
| 27 DCHECK(command_buffer); |
| 28 decoder_.reset(decoder); |
| 29 parser_.reset(parser); |
| 30 } |
| 31 |
13 bool GPUProcessor::Initialize(gfx::PluginWindowHandle handle) { | 32 bool GPUProcessor::Initialize(gfx::PluginWindowHandle handle) { |
14 DCHECK(handle); | 33 DCHECK(handle); |
15 | 34 |
16 // Cannot reinitialize. | 35 // Cannot reinitialize. |
17 if (decoder_->hwnd() != NULL) | 36 if (decoder_->hwnd() != NULL) |
18 return false; | 37 return false; |
19 | 38 |
20 // Map the ring buffer and create the parser. | 39 // Map the ring buffer and create the parser. |
21 Buffer ring_buffer = command_buffer_->GetRingBuffer(); | 40 Buffer ring_buffer = command_buffer_->GetRingBuffer(); |
22 if (ring_buffer.ptr) { | 41 if (ring_buffer.ptr) { |
(...skipping 14 matching lines...) Expand all Loading... |
37 } | 56 } |
38 | 57 |
39 void GPUProcessor::Destroy() { | 58 void GPUProcessor::Destroy() { |
40 // Destroy GAPI if window handle has not already become invalid. | 59 // Destroy GAPI if window handle has not already become invalid. |
41 if (decoder_->hwnd()) { | 60 if (decoder_->hwnd()) { |
42 decoder_->Destroy(); | 61 decoder_->Destroy(); |
43 decoder_->set_hwnd(NULL); | 62 decoder_->set_hwnd(NULL); |
44 } | 63 } |
45 } | 64 } |
46 } // namespace gpu | 65 } // namespace gpu |
OLD | NEW |