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 "content/browser/compositor/buffer_queue.h" | 5 #include "content/browser/compositor/buffer_queue.h" |
6 | 6 |
7 #include "content/browser/compositor/image_transport_factory.h" | 7 #include "content/browser/compositor/image_transport_factory.h" |
8 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 8 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
9 #include "content/common/gpu/client/context_provider_command_buffer.h" | 9 #include "content/common/gpu/client/context_provider_command_buffer.h" |
10 #include "content/common/gpu/client/gl_helper.h" | 10 #include "content/common/gpu/client/gl_helper.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 | 160 |
161 unsigned int texture = 0; | 161 unsigned int texture = 0; |
162 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 162 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
163 gl->GenTextures(1, &texture); | 163 gl->GenTextures(1, &texture); |
164 if (!texture) | 164 if (!texture) |
165 return AllocatedSurface(); | 165 return AllocatedSurface(); |
166 | 166 |
167 // We don't want to allow anything more than triple buffering. | 167 // We don't want to allow anything more than triple buffering. |
168 DCHECK_LT(allocated_count_, 4U); | 168 DCHECK_LT(allocated_count_, 4U); |
| 169 DCHECK_EQ(gpu::ImageFactory::NumberOfPlanesForImageFormat(internalformat_), |
| 170 1u); |
169 | 171 |
170 scoped_ptr<gfx::GpuMemoryBuffer> buffer( | 172 scoped_ptr<gfx::GpuMemoryBuffer> buffer( |
171 gpu_memory_buffer_manager_->AllocateGpuMemoryBufferForScanout( | 173 gpu_memory_buffer_manager_->AllocateGpuMemoryBufferForScanout( |
172 size_, gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat( | 174 size_, gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat( |
173 internalformat_), | 175 internalformat_, 0), |
174 surface_id_)); | 176 surface_id_)); |
175 if (!buffer) { | 177 if (!buffer) { |
176 gl->DeleteTextures(1, &texture); | 178 gl->DeleteTextures(1, &texture); |
177 DLOG(ERROR) << "Failed to allocate GPU memory buffer"; | 179 DLOG(ERROR) << "Failed to allocate GPU memory buffer"; |
178 return AllocatedSurface(); | 180 return AllocatedSurface(); |
179 } | 181 } |
180 | 182 |
181 unsigned int id = gl->CreateImageCHROMIUM( | 183 ClientBuffer client_buffers[] = {buffer->AsClientBuffer()}; |
182 buffer->AsClientBuffer(), size_.width(), size_.height(), internalformat_); | 184 unsigned int id = gl->CreateImageCHROMIUM(client_buffers, size_.width(), |
| 185 size_.height(), internalformat_); |
183 | 186 |
184 if (!id) { | 187 if (!id) { |
185 LOG(ERROR) << "Failed to allocate backing image surface"; | 188 LOG(ERROR) << "Failed to allocate backing image surface"; |
186 gl->DeleteTextures(1, &texture); | 189 gl->DeleteTextures(1, &texture); |
187 return AllocatedSurface(); | 190 return AllocatedSurface(); |
188 } | 191 } |
189 allocated_count_++; | 192 allocated_count_++; |
190 gl->BindTexture(GL_TEXTURE_2D, texture); | 193 gl->BindTexture(GL_TEXTURE_2D, texture); |
191 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, id); | 194 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, id); |
192 return AllocatedSurface(texture, id, gfx::Rect(size_)); | 195 return AllocatedSurface(texture, id, gfx::Rect(size_)); |
193 } | 196 } |
194 | 197 |
195 } // namespace content | 198 } // namespace content |
OLD | NEW |