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

Unified Diff: cc/output/gl_renderer.cc

Issue 2089753003: cc: Use the correct internal format for glCopyTexImage2D calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copytextureformat: comments Created 4 years, 6 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
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index b8893474e9173c66e4a15acbc64f126f71a58245..096bf107b25b283fb5dfb1cdf72eea66113c8b04 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -833,7 +833,7 @@ std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture(
{
ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
device_background_texture->id());
- GetFramebufferTexture(lock.texture_id(), RGBA_8888, bounding_rect);
+ GetFramebufferTexture(lock.texture_id(), bounding_rect);
}
return device_background_texture;
}
@@ -2869,7 +2869,7 @@ void GLRenderer::GetFramebufferPixelsAsync(
texture_id =
gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
}
- GetFramebufferTexture(texture_id, RGBA_8888, window_rect);
+ GetFramebufferTexture(texture_id, window_rect);
const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM();
gl_->ShallowFlushCHROMIUM();
@@ -3009,7 +3009,6 @@ void GLRenderer::FinishedReadback(unsigned source_buffer,
}
void GLRenderer::GetFramebufferTexture(unsigned texture_id,
- ResourceFormat texture_format,
const gfx::Rect& window_rect) {
DCHECK(texture_id);
DCHECK_GE(window_rect.x(), 0);
@@ -3017,9 +3016,19 @@ void GLRenderer::GetFramebufferTexture(unsigned texture_id,
DCHECK_LE(window_rect.right(), current_surface_size_.width());
DCHECK_LE(window_rect.bottom(), current_surface_size_.height());
+ // If copying a non-root renderpass then use the format of the bound
+ // texture. Otherwise, we use the format of the default framebuffer.
+ GLenum format = current_framebuffer_lock_
+ ? GLCopyTextureInternalFormat(current_framebuffer_format_)
+ : output_surface_->GetFramebufferCopyTextureFormat();
+ // Verify the format is valid for GLES2's glCopyTexImage2D.
+ DCHECK(format == GL_ALPHA || format == GL_LUMINANCE ||
+ format == GL_LUMINANCE_ALPHA || format == GL_RGB || format == GL_RGBA)
+ << format;
+
gl_->BindTexture(GL_TEXTURE_2D, texture_id);
- gl_->CopyTexImage2D(GL_TEXTURE_2D, 0, GLDataFormat(texture_format),
- window_rect.x(), window_rect.y(), window_rect.width(),
+ gl_->CopyTexImage2D(GL_TEXTURE_2D, 0, format, window_rect.x(),
+ window_rect.y(), window_rect.width(),
window_rect.height(), 0);
gl_->BindTexture(GL_TEXTURE_2D, 0);
}
@@ -3049,6 +3058,7 @@ bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame,
current_framebuffer_lock_ =
base::WrapUnique(new ResourceProvider::ScopedWriteLockGL(
resource_provider_, texture->id()));
+ current_framebuffer_format_ = texture->format();
unsigned texture_id = current_framebuffer_lock_->texture_id();
gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
texture_id, 0);
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698