OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/shared_impl/ppb_graphics_3d_shared.h" | 5 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 8 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
9 #include "gpu/command_buffer/client/gles2_implementation.h" | 9 #include "gpu/command_buffer/client/gles2_implementation.h" |
10 #include "gpu/command_buffer/client/transfer_buffer.h" | 10 #include "gpu/command_buffer/client/transfer_buffer.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 if (!gles2_helper_->Initialize(command_buffer_size)) | 111 if (!gles2_helper_->Initialize(command_buffer_size)) |
112 return false; | 112 return false; |
113 | 113 |
114 // Create a transfer buffer used to copy resources between the renderer | 114 // Create a transfer buffer used to copy resources between the renderer |
115 // process and the GPU process. | 115 // process and the GPU process. |
116 const int32 kMinTransferBufferSize = 256 * 1024; | 116 const int32 kMinTransferBufferSize = 256 * 1024; |
117 const int32 kMaxTransferBufferSize = 16 * 1024 * 1024; | 117 const int32 kMaxTransferBufferSize = 16 * 1024 * 1024; |
118 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); | 118 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); |
119 | 119 |
120 const bool bind_creates_resources = true; | 120 const bool bind_creates_resources = true; |
121 const bool lose_context_when_out_of_memory = false; | |
122 | 121 |
123 // Create the object exposing the OpenGL API. | 122 // Create the object exposing the OpenGL API. |
124 gles2_impl_.reset(new gpu::gles2::GLES2Implementation( | 123 gles2_impl_.reset(new gpu::gles2::GLES2Implementation( |
125 gles2_helper_.get(), | 124 gles2_helper_.get(), |
126 share_gles2 ? share_gles2->share_group() : NULL, | 125 share_gles2 ? share_gles2->share_group() : NULL, |
127 transfer_buffer_.get(), | 126 transfer_buffer_.get(), |
128 bind_creates_resources, | 127 bind_creates_resources, |
129 lose_context_when_out_of_memory, | |
130 GetGpuControl())); | 128 GetGpuControl())); |
131 | 129 |
132 if (!gles2_impl_->Initialize( | 130 if (!gles2_impl_->Initialize( |
133 transfer_buffer_size, | 131 transfer_buffer_size, |
134 kMinTransferBufferSize, | 132 kMinTransferBufferSize, |
135 std::max(kMaxTransferBufferSize, transfer_buffer_size), | 133 std::max(kMaxTransferBufferSize, transfer_buffer_size), |
136 gpu::gles2::GLES2Implementation::kNoLimit)) { | 134 gpu::gles2::GLES2Implementation::kNoLimit)) { |
137 return false; | 135 return false; |
138 } | 136 } |
139 | 137 |
140 gles2_impl_->PushGroupMarkerEXT(0, "PPAPIContext"); | 138 gles2_impl_->PushGroupMarkerEXT(0, "PPAPIContext"); |
141 | 139 |
142 return true; | 140 return true; |
143 } | 141 } |
144 | 142 |
145 void PPB_Graphics3D_Shared::DestroyGLES2Impl() { | 143 void PPB_Graphics3D_Shared::DestroyGLES2Impl() { |
146 gles2_impl_.reset(); | 144 gles2_impl_.reset(); |
147 transfer_buffer_.reset(); | 145 transfer_buffer_.reset(); |
148 gles2_helper_.reset(); | 146 gles2_helper_.reset(); |
149 } | 147 } |
150 | 148 |
151 } // namespace ppapi | 149 } // namespace ppapi |
OLD | NEW |