| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return AllocatedSurface(); | 211 return AllocatedSurface(); |
| 212 | 212 |
| 213 // We don't want to allow anything more than triple buffering. | 213 // We don't want to allow anything more than triple buffering. |
| 214 DCHECK_LT(allocated_count_, 4U); | 214 DCHECK_LT(allocated_count_, 4U); |
| 215 | 215 |
| 216 scoped_ptr<gfx::GpuMemoryBuffer> buffer( | 216 scoped_ptr<gfx::GpuMemoryBuffer> buffer( |
| 217 gpu_memory_buffer_manager_->AllocateGpuMemoryBufferForScanout( | 217 gpu_memory_buffer_manager_->AllocateGpuMemoryBufferForScanout( |
| 218 size_, gpu::ImageFactory::DefaultBufferFormatForImageFormat( | 218 size_, gpu::ImageFactory::DefaultBufferFormatForImageFormat( |
| 219 internal_format_), | 219 internal_format_), |
| 220 surface_id_)); | 220 surface_id_)); |
| 221 if (!buffer) { | 221 if (!buffer.get()) { |
| 222 gl->DeleteTextures(1, &texture); | 222 gl->DeleteTextures(1, &texture); |
| 223 DLOG(ERROR) << "Failed to allocate GPU memory buffer"; | 223 DLOG(ERROR) << "Failed to allocate GPU memory buffer"; |
| 224 return AllocatedSurface(); | 224 return AllocatedSurface(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 unsigned int id = gl->CreateImageCHROMIUM( | 227 unsigned int id = gl->CreateImageCHROMIUM( |
| 228 buffer->AsClientBuffer(), size_.width(), size_.height(), | 228 buffer->AsClientBuffer(), size_.width(), size_.height(), |
| 229 internal_format_); | 229 internal_format_); |
| 230 | 230 |
| 231 if (!id) { | 231 if (!id) { |
| 232 LOG(ERROR) << "Failed to allocate backing image surface"; | 232 LOG(ERROR) << "Failed to allocate backing image surface"; |
| 233 gl->DeleteTextures(1, &texture); | 233 gl->DeleteTextures(1, &texture); |
| 234 return AllocatedSurface(); | 234 return AllocatedSurface(); |
| 235 } | 235 } |
| 236 allocated_count_++; | 236 allocated_count_++; |
| 237 gl->BindTexture(texture_target_, texture); | 237 gl->BindTexture(texture_target_, texture); |
| 238 gl->BindTexImage2DCHROMIUM(texture_target_, id); | 238 gl->BindTexImage2DCHROMIUM(texture_target_, id); |
| 239 return AllocatedSurface(texture, id, gfx::Rect(size_)); | 239 return AllocatedSurface(buffer.Pass(), texture, id, gfx::Rect(size_)); |
| 240 } | 240 } |
| 241 | 241 |
| 242 BufferQueue::AllocatedSurface::AllocatedSurface() : texture(0), image(0) {} |
| 243 |
| 244 BufferQueue::AllocatedSurface::AllocatedSurface( |
| 245 scoped_ptr<gfx::GpuMemoryBuffer> buffer, |
| 246 unsigned int texture, |
| 247 unsigned int image, |
| 248 const gfx::Rect& rect) |
| 249 : buffer(buffer.release()), texture(texture), image(image), damage(rect) {} |
| 250 |
| 251 BufferQueue::AllocatedSurface::~AllocatedSurface() {} |
| 252 |
| 242 } // namespace content | 253 } // namespace content |
| OLD | NEW |