OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/gles2/gles2_context.h" | 5 #include "mojo/gles2/gles2_context.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 9 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
8 #include "gpu/command_buffer/client/gles2_implementation.h" | 10 #include "gpu/command_buffer/client/gles2_implementation.h" |
9 #include "gpu/command_buffer/client/transfer_buffer.h" | 11 #include "gpu/command_buffer/client/transfer_buffer.h" |
10 #include "mojo/public/c/gles2/gles2.h" | 12 #include "mojo/public/c/gles2/gles2.h" |
11 #include "mojo/public/cpp/system/core.h" | 13 #include "mojo/public/cpp/system/core.h" |
12 | 14 |
13 namespace gles2 { | 15 namespace gles2 { |
14 | 16 |
15 namespace { | 17 namespace { |
16 const size_t kDefaultCommandBufferSize = 1024 * 1024; | 18 const size_t kDefaultCommandBufferSize = 1024 * 1024; |
17 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; | 19 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; |
18 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; | 20 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; |
19 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; | 21 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; |
20 } | 22 } |
21 | 23 |
22 GLES2Context::GLES2Context(const std::vector<int32_t>& attribs, | 24 GLES2Context::GLES2Context(const std::vector<int32_t>& attribs, |
23 const MojoAsyncWaiter* async_waiter, | 25 const MojoAsyncWaiter* async_waiter, |
24 mojo::ScopedMessagePipeHandle command_buffer_handle, | 26 mojo::ScopedMessagePipeHandle command_buffer_handle, |
25 MojoGLES2ContextLost lost_callback, | 27 MojoGLES2ContextLost lost_callback, |
26 void* closure) | 28 void* closure) |
27 : command_buffer_(this, attribs, async_waiter, | 29 : command_buffer_(this, |
28 command_buffer_handle.Pass()), | 30 attribs, |
| 31 async_waiter, |
| 32 std::move(command_buffer_handle)), |
29 lost_callback_(lost_callback), | 33 lost_callback_(lost_callback), |
30 closure_(closure) { | 34 closure_(closure) {} |
31 } | |
32 | 35 |
33 GLES2Context::~GLES2Context() {} | 36 GLES2Context::~GLES2Context() {} |
34 | 37 |
35 bool GLES2Context::Initialize() { | 38 bool GLES2Context::Initialize() { |
36 if (!command_buffer_.Initialize()) | 39 if (!command_buffer_.Initialize()) |
37 return false; | 40 return false; |
38 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_)); | 41 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_)); |
39 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize)) | 42 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize)) |
40 return false; | 43 return false; |
41 gles2_helper_->SetAutomaticFlushes(false); | 44 gles2_helper_->SetAutomaticFlushes(false); |
(...skipping 15 matching lines...) Expand all Loading... |
57 &command_buffer_)); | 60 &command_buffer_)); |
58 return implementation_->Initialize(kDefaultStartTransferBufferSize, | 61 return implementation_->Initialize(kDefaultStartTransferBufferSize, |
59 kDefaultMinTransferBufferSize, | 62 kDefaultMinTransferBufferSize, |
60 kDefaultMaxTransferBufferSize, | 63 kDefaultMaxTransferBufferSize, |
61 gpu::gles2::GLES2Implementation::kNoLimit); | 64 gpu::gles2::GLES2Implementation::kNoLimit); |
62 } | 65 } |
63 | 66 |
64 void GLES2Context::ContextLost() { lost_callback_(closure_); } | 67 void GLES2Context::ContextLost() { lost_callback_(closure_); } |
65 | 68 |
66 } // namespace gles2 | 69 } // namespace gles2 |
OLD | NEW |