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

Unified Diff: components/display_compositor/buffer_queue.cc

Issue 2612023002: cc: Implement overdraw feedback debugging feature. (Closed)
Patch Set: make sure overdraw_feedback_ is initialized and reset properly Created 3 years, 11 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 a827812a7796c5a4ee545b129d7d68b9e694cd84..afb40e1a4912accfc68929b8d7b72d70e7ac8cb8 100644
--- a/components/display_compositor/buffer_queue.cc
+++ b/components/display_compositor/buffer_queue.cc
@@ -60,6 +60,10 @@ void BufferQueue::BindFramebuffer() {
if (current_surface_) {
gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
texture_target_, current_surface_->texture, 0);
+ if (current_surface_->stencil) {
+ gl_->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
+ GL_RENDERBUFFER, current_surface_->stencil);
+ }
}
}
@@ -115,8 +119,10 @@ void BufferQueue::SwapBuffers(const gfx::Rect& damage) {
void BufferQueue::Reshape(const gfx::Size& size,
float scale_factor,
- const gfx::ColorSpace& color_space) {
- if (size == size_ && color_space == color_space_)
+ const gfx::ColorSpace& color_space,
+ bool use_stencil) {
+ if (size == size_ && color_space == color_space_ &&
+ use_stencil == use_stencil_)
return;
#if !defined(OS_MACOSX)
// TODO(ccameron): This assert is being hit on Mac try jobs. Determine if that
@@ -126,11 +132,13 @@ void BufferQueue::Reshape(const gfx::Size& size,
#endif
size_ = size;
color_space_ = color_space;
+ use_stencil_ = use_stencil;
- // TODO: add stencil buffer when needed.
gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
texture_target_, 0, 0);
+ gl_->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
+ GL_RENDERBUFFER, 0);
FreeAllSurfaces();
}
@@ -200,6 +208,8 @@ void BufferQueue::FreeSurfaceResources(AllocatedSurface* surface) {
gl_->ReleaseTexImage2DCHROMIUM(texture_target_, surface->image);
gl_->DeleteTextures(1, &surface->texture);
gl_->DestroyImageCHROMIUM(surface->image);
+ if (surface->stencil)
+ gl_->DeleteRenderbuffers(1, &surface->stencil);
surface->buffer.reset();
allocated_count_--;
}
@@ -215,6 +225,15 @@ std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() {
GLuint texture;
gl_->GenTextures(1, &texture);
+ GLuint stencil = 0;
+ if (use_stencil_) {
+ gl_->GenRenderbuffers(1, &stencil);
+ gl_->BindRenderbuffer(GL_RENDERBUFFER, stencil);
+ gl_->RenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, size_.width(),
+ size_.height());
+ gl_->BindRenderbuffer(GL_RENDERBUFFER, 0);
+ }
+
// We don't want to allow anything more than triple buffering.
DCHECK_LT(allocated_count_, 4U);
std::unique_ptr<gfx::GpuMemoryBuffer> buffer(
@@ -240,7 +259,7 @@ std::unique_ptr<BufferQueue::AllocatedSurface> BufferQueue::GetNextSurface() {
gl_->BindTexture(texture_target_, texture);
gl_->BindTexImage2DCHROMIUM(texture_target_, id);
return base::MakeUnique<AllocatedSurface>(this, std::move(buffer), texture,
- id, gfx::Rect(size_));
+ id, stencil, gfx::Rect(size_));
}
BufferQueue::AllocatedSurface::AllocatedSurface(
@@ -248,11 +267,13 @@ BufferQueue::AllocatedSurface::AllocatedSurface(
std::unique_ptr<gfx::GpuMemoryBuffer> buffer,
uint32_t texture,
uint32_t image,
+ uint32_t stencil,
const gfx::Rect& rect)
: buffer_queue(buffer_queue),
buffer(buffer.release()),
texture(texture),
image(image),
+ stencil(stencil),
damage(rect) {}
BufferQueue::AllocatedSurface::~AllocatedSurface() {
« 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