Chromium Code Reviews| Index: components/mus/surfaces/buffer_queue.cc |
| diff --git a/content/browser/compositor/buffer_queue.cc b/components/mus/surfaces/buffer_queue.cc |
| similarity index 85% |
| copy from content/browser/compositor/buffer_queue.cc |
| copy to components/mus/surfaces/buffer_queue.cc |
| index 798c010e6d74a01300d0f1750cb6757585cef02b..ae4b70d2cb416ff8ee976512574c45c8e1fadd01 100644 |
| --- a/content/browser/compositor/buffer_queue.cc |
| +++ b/components/mus/surfaces/buffer_queue.cc |
| @@ -1,40 +1,34 @@ |
| -// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "content/browser/compositor/buffer_queue.h" |
| +#include "components/mus/surfaces/buffer_queue.h" |
| #include "base/containers/adapters.h" |
| #include "base/memory/ptr_util.h" |
| -#include "build/build_config.h" |
| #include "cc/output/context_provider.h" |
| -#include "content/browser/compositor/gl_helper.h" |
| +#include "components/mus/gles2/gl_helper.h" |
| +#include "components/mus/gles2/ozone_gpu_memory_buffer.h" |
| #include "gpu/GLES2/gl2extchromium.h" |
| #include "gpu/command_buffer/client/gles2_interface.h" |
| -#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" |
| -#include "gpu/command_buffer/service/image_factory.h" |
| #include "third_party/skia/include/core/SkRect.h" |
| #include "third_party/skia/include/core/SkRegion.h" |
| #include "ui/gfx/gpu_memory_buffer.h" |
| #include "ui/gfx/skia_util.h" |
| -namespace content { |
| +namespace mus { |
| BufferQueue::BufferQueue(scoped_refptr<cc::ContextProvider> context_provider, |
| unsigned int texture_target, |
| unsigned int internalformat, |
| - GLHelper* gl_helper, |
| - gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| - int surface_id) |
| + gfx::AcceleratedWidget widget) |
| : context_provider_(context_provider), |
| fbo_(0), |
| allocated_count_(0), |
| texture_target_(texture_target), |
| internal_format_(internalformat), |
| - gl_helper_(gl_helper), |
| - gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
| - surface_id_(surface_id) {} |
| + widget_(widget) {} |
| BufferQueue::~BufferQueue() { |
| FreeAllSurfaces(); |
| @@ -45,7 +39,9 @@ BufferQueue::~BufferQueue() { |
| } |
| void BufferQueue::Initialize() { |
| + DCHECK(context_provider_); |
| gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| + DCHECK(gl); |
| gl->GenFramebuffers(1, &fbo_); |
| } |
| @@ -66,10 +62,10 @@ void BufferQueue::CopyBufferDamage(int texture, |
| int source_texture, |
| const gfx::Rect& new_damage, |
| const gfx::Rect& old_damage) { |
| - gl_helper_->CopySubBufferDamage( |
| - texture_target_, texture, source_texture, |
| - SkRegion(gfx::RectToSkIRect(new_damage)), |
| - SkRegion(gfx::RectToSkIRect(old_damage))); |
| + GLCopySubBufferDamage(context_provider_->ContextGL(), texture_target_, |
| + texture, source_texture, |
| + SkRegion(gfx::RectToSkIRect(new_damage)), |
| + SkRegion(gfx::RectToSkIRect(old_damage))); |
| } |
| void BufferQueue::UpdateBufferDamage(const gfx::Rect& damage) { |
| @@ -116,12 +112,7 @@ void BufferQueue::SwapBuffers(const gfx::Rect& damage) { |
| void BufferQueue::Reshape(const gfx::Size& size, float scale_factor) { |
| if (size == size_) |
| return; |
| - // TODO(ccameron): This assert is being hit on Mac try jobs. Determine if that |
| - // is cause for concern or if it is benign. |
| - // http://crbug.com/524624 |
| -#if !defined(OS_MACOSX) |
| - DCHECK(!current_surface_); |
| -#endif |
| + |
| size_ = size; |
| // TODO: add stencil buffer when needed. |
| @@ -199,6 +190,7 @@ void BufferQueue::FreeSurfaceResources(AllocatedSurface* surface) { |
| gl->BindTexture(texture_target_, surface->texture); |
| gl->ReleaseTexImage2DCHROMIUM(texture_target_, surface->image); |
| gl->DeleteTextures(1, &surface->texture); |
| + // TODO(rjk): Implement image deletion. |
| gl->DestroyImageCHROMIUM(surface->image); |
| surface->buffer.reset(); |
| allocated_count_--; |
| @@ -222,18 +214,22 @@ std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() { |
| DCHECK_LT(allocated_count_, 4U); |
| std::unique_ptr<gfx::GpuMemoryBuffer> buffer( |
| - gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
| + OzoneGpuMemoryBuffer::CreateOzoneGpuMemoryBuffer( |
| size_, gpu::DefaultBufferFormatForImageFormat(internal_format_), |
| - gfx::BufferUsage::SCANOUT, surface_id_)); |
| + gfx::BufferUsage::SCANOUT, widget_)); |
| + |
| if (!buffer.get()) { |
| gl->DeleteTextures(1, &texture); |
| DLOG(ERROR) << "Failed to allocate GPU memory buffer"; |
| return nullptr; |
| } |
| - unsigned int id = gl->CreateImageCHROMIUM( |
| - buffer->AsClientBuffer(), size_.width(), size_.height(), |
| - internal_format_); |
| + // This ends up calling back into the CommandBufferLocal via its |
|
Fady Samuel
2016/04/12 19:31:52
nit: extra space between via and its
rjkroege
2016/04/12 19:36:24
Done.
|
| + // implementation of the GpuControl interface. In that case, we need to handle |
| + // the given buffer pointer there. |
| + unsigned int id = |
| + gl->CreateImageCHROMIUM(buffer->AsClientBuffer(), size_.width(), |
| + size_.height(), internal_format_); |
| if (!id) { |
| LOG(ERROR) << "Failed to allocate backing image surface"; |
| gl->DeleteTextures(1, &texture); |
| @@ -243,6 +239,7 @@ std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() { |
| allocated_count_++; |
| gl->BindTexture(texture_target_, texture); |
| gl->BindTexImage2DCHROMIUM(texture_target_, id); |
| + // It doesn't end up in the queue to re-use until we handle the page flip. |
| return base::WrapUnique(new AllocatedSurface(this, std::move(buffer), texture, |
| id, gfx::Rect(size_))); |
| } |
| @@ -263,4 +260,4 @@ BufferQueue::AllocatedSurface::~AllocatedSurface() { |
| buffer_queue->FreeSurfaceResources(this); |
| } |
| -} // namespace content |
| +} // namespace mus |