OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "gpu/command_buffer/service/gpu_processor.h" | 5 #include "gpu/command_buffer/service/gpu_processor.h" |
6 | 6 |
7 using ::base::SharedMemory; | 7 using ::base::SharedMemory; |
8 | 8 |
9 namespace gpu { | 9 namespace gpu { |
10 | 10 |
11 bool GPUProcessor::Initialize(gfx::PluginWindowHandle handle) { | 11 bool GPUProcessor::Initialize(gfx::PluginWindowHandle handle, |
| 12 GPUProcessor* parent, |
| 13 const gfx::Size& size, |
| 14 uint32 parent_texture_id) { |
12 // At this level we do not need the PluginWindowHandle. It is only | 15 // At this level we do not need the PluginWindowHandle. It is only |
13 // needed at the CommandBufferStub level to identify which GPU | 16 // needed at the CommandBufferStub level to identify which GPU |
14 // plugin instance is creating a new backing store in response to a | 17 // plugin instance is creating a new backing store in response to a |
15 // resize event. | 18 // resize event. |
16 | 19 |
17 // Map the ring buffer and create the parser. | 20 // Map the ring buffer and create the parser. |
18 Buffer ring_buffer = command_buffer_->GetRingBuffer(); | 21 Buffer ring_buffer = command_buffer_->GetRingBuffer(); |
19 if (ring_buffer.ptr) { | 22 if (ring_buffer.ptr) { |
20 parser_.reset(new CommandParser(ring_buffer.ptr, | 23 parser_.reset(new CommandParser(ring_buffer.ptr, |
21 ring_buffer.size, | 24 ring_buffer.size, |
22 0, | 25 0, |
23 ring_buffer.size, | 26 ring_buffer.size, |
24 0, | 27 0, |
25 decoder_.get())); | 28 decoder_.get())); |
26 } else { | 29 } else { |
27 parser_.reset(new CommandParser(NULL, 0, 0, 0, 0, | 30 parser_.reset(new CommandParser(NULL, 0, 0, 0, 0, |
28 decoder_.get())); | 31 decoder_.get())); |
29 } | 32 } |
30 | 33 |
31 // Initialize GAPI. | 34 // Initialize GAPI. |
32 return decoder_->Initialize(); | 35 gles2::GLES2Decoder* parent_decoder = parent ? parent->decoder_.get() : NULL; |
| 36 if (!decoder_->Initialize(parent_decoder, |
| 37 size, |
| 38 parent_texture_id)) { |
| 39 Destroy(); |
| 40 return false; |
| 41 } |
| 42 |
| 43 return true; |
33 } | 44 } |
34 | 45 |
35 void GPUProcessor::Destroy() { | 46 void GPUProcessor::Destroy() { |
36 decoder_->Destroy(); | 47 // Destroy decoder if initialized. |
| 48 if (decoder_.get()) { |
| 49 decoder_->Destroy(); |
| 50 decoder_.reset(); |
| 51 } |
| 52 |
| 53 parser_.reset(); |
37 } | 54 } |
38 } // namespace gpu | 55 } // namespace gpu |
39 | 56 |
OLD | NEW |