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

Unified Diff: components/display_compositor/buffer_queue.cc

Issue 2002303002: Consolidate OutputSurface constructors into GL vs Vulkan. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: outputsurface-constructors: rebase-and-fixcrash Created 4 years, 7 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/display_compositor/buffer_queue.cc
diff --git a/components/display_compositor/buffer_queue.cc b/components/display_compositor/buffer_queue.cc
index e40049f9575c5242302270b9909b3c3287630281..8649d101023ec8abf9c9c82883a795afbbeeb24c 100644
--- a/components/display_compositor/buffer_queue.cc
+++ b/components/display_compositor/buffer_queue.cc
@@ -7,7 +7,6 @@
#include "base/containers/adapters.h"
#include "base/memory/ptr_util.h"
#include "build/build_config.h"
-#include "cc/output/context_provider.h"
#include "components/display_compositor/gl_helper.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_interface.h"
@@ -20,13 +19,13 @@
namespace display_compositor {
-BufferQueue::BufferQueue(scoped_refptr<cc::ContextProvider> context_provider,
+BufferQueue::BufferQueue(gpu::gles2::GLES2Interface* gl,
unsigned int texture_target,
unsigned int internalformat,
GLHelper* gl_helper,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
gpu::SurfaceHandle surface_handle)
- : context_provider_(context_provider),
+ : gl_(gl),
fbo_(0),
allocated_count_(0),
texture_target_(texture_target),
@@ -38,26 +37,23 @@ BufferQueue::BufferQueue(scoped_refptr<cc::ContextProvider> context_provider,
BufferQueue::~BufferQueue() {
FreeAllSurfaces();
- gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
if (fbo_)
- gl->DeleteFramebuffers(1, &fbo_);
+ gl_->DeleteFramebuffers(1, &fbo_);
}
void BufferQueue::Initialize() {
- gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
- gl->GenFramebuffers(1, &fbo_);
+ gl_->GenFramebuffers(1, &fbo_);
}
void BufferQueue::BindFramebuffer() {
- gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
- gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
+ gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
if (!current_surface_)
current_surface_ = GetNextSurface();
if (current_surface_) {
- gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- texture_target_, current_surface_->texture, 0);
+ gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ texture_target_, current_surface_->texture, 0);
}
}
@@ -108,7 +104,7 @@ void BufferQueue::SwapBuffers(const gfx::Rect& damage) {
in_flight_surfaces_.push_back(std::move(current_surface_));
// Some things reset the framebuffer (CopySubBufferDamage, some GLRenderer
// paths), so ensure we restore it here.
- context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
+ gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
}
void BufferQueue::Reshape(const gfx::Size& size, float scale_factor) {
@@ -123,10 +119,9 @@ void BufferQueue::Reshape(const gfx::Size& size, float scale_factor) {
size_ = size;
// TODO: add stencil buffer when needed.
- gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
- gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
- gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- texture_target_, 0, 0);
+ gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
+ gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ texture_target_, 0, 0);
FreeAllSurfaces();
}
@@ -147,10 +142,9 @@ void BufferQueue::RecreateBuffers() {
if (current_surface_) {
// If we have a texture bound, we will need to re-bind it.
- gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
- gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
- gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- texture_target_, current_surface_->texture, 0);
+ gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
+ gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ texture_target_, current_surface_->texture, 0);
}
}
@@ -193,11 +187,10 @@ void BufferQueue::FreeSurfaceResources(AllocatedSurface* surface) {
if (!surface->texture)
return;
- gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
- gl->BindTexture(texture_target_, surface->texture);
- gl->ReleaseTexImage2DCHROMIUM(texture_target_, surface->image);
- gl->DeleteTextures(1, &surface->texture);
- gl->DestroyImageCHROMIUM(surface->image);
+ gl_->BindTexture(texture_target_, surface->texture);
+ gl_->ReleaseTexImage2DCHROMIUM(texture_target_, surface->image);
+ gl_->DeleteTextures(1, &surface->texture);
+ gl_->DestroyImageCHROMIUM(surface->image);
surface->buffer.reset();
allocated_count_--;
}
@@ -210,11 +203,8 @@ std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() {
return surface;
}
- unsigned int texture = 0;
- gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
- gl->GenTextures(1, &texture);
- if (!texture)
- return nullptr;
+ GLuint texture;
+ gl_->GenTextures(1, &texture);
// We don't want to allow anything more than triple buffering.
DCHECK_LT(allocated_count_, 4U);
@@ -224,23 +214,23 @@ std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() {
size_, gpu::DefaultBufferFormatForImageFormat(internal_format_),
gfx::BufferUsage::SCANOUT, surface_handle_));
if (!buffer.get()) {
- gl->DeleteTextures(1, &texture);
+ 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_);
+ gl_->CreateImageCHROMIUM(buffer->AsClientBuffer(), size_.width(),
+ size_.height(), internal_format_);
if (!id) {
LOG(ERROR) << "Failed to allocate backing image surface";
- gl->DeleteTextures(1, &texture);
+ gl_->DeleteTextures(1, &texture);
return nullptr;
}
allocated_count_++;
- gl->BindTexture(texture_target_, texture);
- gl->BindTexImage2DCHROMIUM(texture_target_, id);
+ gl_->BindTexture(texture_target_, texture);
+ gl_->BindTexImage2DCHROMIUM(texture_target_, id);
return base::WrapUnique(new AllocatedSurface(this, std::move(buffer), texture,
id, gfx::Rect(size_)));
}
« no previous file with comments | « components/display_compositor/buffer_queue.h ('k') | components/display_compositor/buffer_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698