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; |
121 | 122 |
122 // Create the object exposing the OpenGL API. | 123 // Create the object exposing the OpenGL API. |
123 gles2_impl_.reset(new gpu::gles2::GLES2Implementation( | 124 gles2_impl_.reset(new gpu::gles2::GLES2Implementation( |
124 gles2_helper_.get(), | 125 gles2_helper_.get(), |
125 share_gles2 ? share_gles2->share_group() : NULL, | 126 share_gles2 ? share_gles2->share_group() : NULL, |
126 transfer_buffer_.get(), | 127 transfer_buffer_.get(), |
127 bind_creates_resources, | 128 bind_creates_resources, |
| 129 lose_context_when_out_of_memory, |
128 GetGpuControl())); | 130 GetGpuControl())); |
129 | 131 |
130 if (!gles2_impl_->Initialize( | 132 if (!gles2_impl_->Initialize( |
131 transfer_buffer_size, | 133 transfer_buffer_size, |
132 kMinTransferBufferSize, | 134 kMinTransferBufferSize, |
133 std::max(kMaxTransferBufferSize, transfer_buffer_size), | 135 std::max(kMaxTransferBufferSize, transfer_buffer_size), |
134 gpu::gles2::GLES2Implementation::kNoLimit)) { | 136 gpu::gles2::GLES2Implementation::kNoLimit)) { |
135 return false; | 137 return false; |
136 } | 138 } |
137 | 139 |
138 gles2_impl_->PushGroupMarkerEXT(0, "PPAPIContext"); | 140 gles2_impl_->PushGroupMarkerEXT(0, "PPAPIContext"); |
139 | 141 |
140 return true; | 142 return true; |
141 } | 143 } |
142 | 144 |
143 void PPB_Graphics3D_Shared::DestroyGLES2Impl() { | 145 void PPB_Graphics3D_Shared::DestroyGLES2Impl() { |
144 gles2_impl_.reset(); | 146 gles2_impl_.reset(); |
145 transfer_buffer_.reset(); | 147 transfer_buffer_.reset(); |
146 gles2_helper_.reset(); | 148 gles2_helper_.reset(); |
147 } | 149 } |
148 | 150 |
149 } // namespace ppapi | 151 } // namespace ppapi |
OLD | NEW |