Chromium Code Reviews| 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" | |
|
reveman
2015/03/12 19:37:22
I don't think you use this anymore.
emircan
2015/03/12 22:34:26
Right. Sorry for missing that.
| |
| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 } | 160 } |
| 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); |
| 170 DCHECK_EQ( | |
| 171 gpu::ImageFactory::GpuMemoryBufferCountForImageFormat(internalformat_), | |
| 172 1); | |
| 169 | 173 |
| 170 scoped_ptr<gfx::GpuMemoryBuffer> buffer( | 174 scoped_ptr<gfx::GpuMemoryBuffer> buffer( |
| 171 gpu_memory_buffer_manager_->AllocateGpuMemoryBufferForScanout( | 175 gpu_memory_buffer_manager_->AllocateGpuMemoryBufferForScanout( |
| 172 size_, gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat( | 176 size_, gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat( |
| 173 internalformat_), | 177 internalformat_, 0), |
| 174 surface_id_)); | 178 surface_id_)); |
| 175 if (!buffer) { | 179 if (!buffer) { |
| 176 gl->DeleteTextures(1, &texture); | 180 gl->DeleteTextures(1, &texture); |
| 177 DLOG(ERROR) << "Failed to allocate GPU memory buffer"; | 181 DLOG(ERROR) << "Failed to allocate GPU memory buffer"; |
| 178 return AllocatedSurface(); | 182 return AllocatedSurface(); |
| 179 } | 183 } |
| 180 | 184 |
| 181 unsigned int id = gl->CreateImageCHROMIUM( | 185 ClientBuffer client_buffers[] = {buffer->AsClientBuffer()}; |
| 182 buffer->AsClientBuffer(), size_.width(), size_.height(), internalformat_); | 186 unsigned int id = gl->CreateImageCHROMIUM(client_buffers, size_.width(), |
| 187 size_.height(), internalformat_); | |
| 183 | 188 |
| 184 if (!id) { | 189 if (!id) { |
| 185 LOG(ERROR) << "Failed to allocate backing image surface"; | 190 LOG(ERROR) << "Failed to allocate backing image surface"; |
| 186 gl->DeleteTextures(1, &texture); | 191 gl->DeleteTextures(1, &texture); |
| 187 return AllocatedSurface(); | 192 return AllocatedSurface(); |
| 188 } | 193 } |
| 189 allocated_count_++; | 194 allocated_count_++; |
| 190 gl->BindTexture(GL_TEXTURE_2D, texture); | 195 gl->BindTexture(GL_TEXTURE_2D, texture); |
| 191 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, id); | 196 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, id); |
| 192 return AllocatedSurface(texture, id, gfx::Rect(size_)); | 197 return AllocatedSurface(texture, id, gfx::Rect(size_)); |
| 193 } | 198 } |
| 194 | 199 |
| 195 } // namespace content | 200 } // namespace content |
| OLD | NEW |