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 "base/memory/scoped_vector.h" | |
7 #include "content/browser/compositor/image_transport_factory.h" | 8 #include "content/browser/compositor/image_transport_factory.h" |
8 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 9 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
9 #include "content/common/gpu/client/context_provider_command_buffer.h" | 10 #include "content/common/gpu/client/context_provider_command_buffer.h" |
10 #include "content/common/gpu/client/gl_helper.h" | 11 #include "content/common/gpu/client/gl_helper.h" |
11 #include "gpu/GLES2/gl2extchromium.h" | 12 #include "gpu/GLES2/gl2extchromium.h" |
12 #include "gpu/command_buffer/client/gles2_interface.h" | 13 #include "gpu/command_buffer/client/gles2_interface.h" |
13 #include "gpu/command_buffer/service/image_factory.h" | 14 #include "gpu/command_buffer/service/image_factory.h" |
14 #include "third_party/skia/include/core/SkRect.h" | 15 #include "third_party/skia/include/core/SkRect.h" |
15 #include "third_party/skia/include/core/SkRegion.h" | 16 #include "third_party/skia/include/core/SkRegion.h" |
16 #include "ui/gfx/gpu_memory_buffer.h" | 17 #include "ui/gfx/gpu_memory_buffer.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 | 161 |
161 unsigned int texture = 0; | 162 unsigned int texture = 0; |
162 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 163 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
163 gl->GenTextures(1, &texture); | 164 gl->GenTextures(1, &texture); |
164 if (!texture) | 165 if (!texture) |
165 return AllocatedSurface(); | 166 return AllocatedSurface(); |
166 | 167 |
167 // We don't want to allow anything more than triple buffering. | 168 // We don't want to allow anything more than triple buffering. |
168 DCHECK_LT(allocated_count_, 4U); | 169 DCHECK_LT(allocated_count_, 4U); |
169 | 170 |
170 scoped_ptr<gfx::GpuMemoryBuffer> buffer( | 171 std::vector<gfx::GpuMemoryBuffer::Format> gpu_memory_buffer_formats; |
171 gpu_memory_buffer_manager_->AllocateGpuMemoryBufferForScanout( | 172 gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormats( |
172 size_, gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat( | 173 internalformat_, &gpu_memory_buffer_formats); |
173 internalformat_), | 174 int num_buffers = gpu_memory_buffer_formats.size(); |
174 surface_id_)); | 175 |
175 if (!buffer) { | 176 DCHECK_GE(num_buffers, 1); |
reveman
2015/03/05 19:35:32
I don't think this code need to support multiple p
emircan
2015/03/09 21:07:22
Done. Reverted to original single buffer usage. I
| |
176 gl->DeleteTextures(1, &texture); | 177 |
177 DLOG(ERROR) << "Failed to allocate GPU memory buffer"; | 178 ScopedVector<gfx::GpuMemoryBuffer> buffers; |
178 return AllocatedSurface(); | 179 ClientBuffer client_buffers[num_buffers]; |
180 for (int i = 0; i < num_buffers; ++i) { | |
181 buffers.push_back( | |
182 gpu_memory_buffer_manager_->AllocateGpuMemoryBufferForScanout( | |
183 size_, gpu_memory_buffer_formats[i], | |
184 surface_id_)); | |
185 | |
186 if (!buffers[i]) { | |
187 gl->DeleteTextures(1, &texture); | |
188 DLOG(ERROR) << "Failed to allocate GPU memory buffer"; | |
189 return AllocatedSurface(); | |
190 } | |
191 | |
192 client_buffers[i] = buffers[i]->AsClientBuffer(); | |
179 } | 193 } |
180 | 194 |
181 unsigned int id = gl->CreateImageCHROMIUM( | 195 unsigned int id = gl->CreateImageCHROMIUM(client_buffers, size_.width(), |
182 buffer->AsClientBuffer(), size_.width(), size_.height(), internalformat_); | 196 size_.height(), internalformat_); |
183 | 197 |
184 if (!id) { | 198 if (!id) { |
185 LOG(ERROR) << "Failed to allocate backing image surface"; | 199 LOG(ERROR) << "Failed to allocate backing image surface"; |
186 gl->DeleteTextures(1, &texture); | 200 gl->DeleteTextures(1, &texture); |
187 return AllocatedSurface(); | 201 return AllocatedSurface(); |
188 } | 202 } |
189 allocated_count_++; | 203 allocated_count_++; |
190 gl->BindTexture(GL_TEXTURE_2D, texture); | 204 gl->BindTexture(GL_TEXTURE_2D, texture); |
191 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, id); | 205 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, id); |
192 return AllocatedSurface(texture, id, gfx::Rect(size_)); | 206 return AllocatedSurface(texture, id, gfx::Rect(size_)); |
193 } | 207 } |
194 | 208 |
195 } // namespace content | 209 } // namespace content |
OLD | NEW |