Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Unified Diff: components/mus/surfaces/buffer_queue.cc

Issue 1881793002: SurfacelessSurfaces for Mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 78%
copy from content/browser/compositor/buffer_queue.cc
copy to components/mus/surfaces/buffer_queue.cc
index e5c60b9ca25fa0c2007588f58b9ac98734ce8b89..a475251e4e189cc76f644d99d2e4721e9a009172 100644
--- a/content/browser/compositor/buffer_queue.cc
+++ b/components/mus/surfaces/buffer_queue.cc
@@ -1,41 +1,33 @@
-// 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 "content/browser/compositor/gl_helper.h"
-#include "content/browser/compositor/image_transport_factory.h"
-#include "content/common/gpu/client/context_provider_command_buffer.h"
+#include "cc/output/context_provider.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();
@@ -46,7 +38,9 @@ BufferQueue::~BufferQueue() {
}
void BufferQueue::Initialize() {
+ DCHECK(context_provider_);
gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
+ DCHECK(gl);
gl->GenFramebuffers(1, &fbo_);
}
@@ -67,10 +61,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) {
@@ -117,12 +111,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.
@@ -157,12 +146,12 @@ void BufferQueue::RecreateBuffers() {
}
}
-std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::RecreateBuffer(
- std::unique_ptr<AllocatedSurface> surface) {
+scoped_ptr<BufferQueue::AllocatedSurface> BufferQueue::RecreateBuffer(
Fady Samuel 2016/04/12 02:54:40 nit: std::unique_ptr.
rjkroege 2016/04/12 19:27:54 Done.
+ scoped_ptr<AllocatedSurface> surface) {
Fady Samuel 2016/04/12 02:54:40 nit: std::unique_ptr.
rjkroege 2016/04/12 19:27:54 Done.
if (!surface)
return nullptr;
- std::unique_ptr<AllocatedSurface> new_surface(GetNextSurface());
+ scoped_ptr<AllocatedSurface> new_surface(GetNextSurface());
Fady Samuel 2016/04/12 02:54:41 nit: std::unique_ptr.
rjkroege 2016/04/12 19:27:54 Done.
if (!new_surface)
return nullptr;
@@ -200,14 +189,15 @@ 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_--;
}
-std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() {
+scoped_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() {
Fady Samuel 2016/04/12 02:54:40 nit: std::unique_ptr.
rjkroege 2016/04/12 19:27:54 Done.
if (!available_surfaces_.empty()) {
- std::unique_ptr<AllocatedSurface> surface =
+ scoped_ptr<AllocatedSurface> surface =
Fady Samuel 2016/04/12 02:54:40 nit: std::unique_ptr.
rjkroege 2016/04/12 19:27:54 Done.
std::move(available_surfaces_.back());
available_surfaces_.pop_back();
return surface;
@@ -222,19 +212,24 @@ std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() {
// We don't want to allow anything more than triple buffering.
DCHECK_LT(allocated_count_, 4U);
- std::unique_ptr<gfx::GpuMemoryBuffer> buffer(
- gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(
+ scoped_ptr<gfx::GpuMemoryBuffer> buffer(
Fady Samuel 2016/04/12 02:54:41 nit: std::unique_ptr.
rjkroege 2016/04/12 19:27:54 Done.
+ 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_);
+ // Thanks to the convolutions of Chrome source code, this ends up calling back
+ // into the CommandBufferLocal via
+ // its implementation of the GpuControl interface. In that case, we need to
Fady Samuel 2016/04/12 02:54:40 nit: weird wrapping.
rjkroege 2016/04/12 19:27:54 Done.
+ // 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);
@@ -244,13 +239,14 @@ std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() {
allocated_count_++;
gl->BindTexture(texture_target_, texture);
gl->BindTexImage2DCHROMIUM(texture_target_, id);
- return base::WrapUnique(new AllocatedSurface(this, std::move(buffer), texture,
- id, gfx::Rect(size_)));
+ // It doesn't end up in the queue to re-use until we handle the page flip.
+ return make_scoped_ptr(new AllocatedSurface(this, std::move(buffer), texture,
Fady Samuel 2016/04/12 02:54:41 WrapUnique
rjkroege 2016/04/12 19:27:54 Done.
+ id, gfx::Rect(size_)));
}
BufferQueue::AllocatedSurface::AllocatedSurface(
BufferQueue* buffer_queue,
- std::unique_ptr<gfx::GpuMemoryBuffer> buffer,
+ scoped_ptr<gfx::GpuMemoryBuffer> buffer,
Fady Samuel 2016/04/12 02:54:40 nit: std::unique_ptr.
rjkroege 2016/04/12 19:27:54 Done.
unsigned int texture,
unsigned int image,
const gfx::Rect& rect)
@@ -264,4 +260,4 @@ BufferQueue::AllocatedSurface::~AllocatedSurface() {
buffer_queue->FreeSurfaceResources(this);
}
-} // namespace content
+} // namespace mus

Powered by Google App Engine
This is Rietveld 408576698