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

Unified Diff: gpu/command_buffer/service/framebuffer_manager.cc

Issue 1309333003: Get ReadPixels to work with INT and UNSIGNED_INT format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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: gpu/command_buffer/service/framebuffer_manager.cc
diff --git a/gpu/command_buffer/service/framebuffer_manager.cc b/gpu/command_buffer/service/framebuffer_manager.cc
index 9c3a522be2039a239eb5a5aab931fe385b07abf7..4a4ffde26f240c07849d2eb09ba59f093002b234 100644
--- a/gpu/command_buffer/service/framebuffer_manager.cc
+++ b/gpu/command_buffer/service/framebuffer_manager.cc
@@ -359,7 +359,8 @@ void Framebuffer::ChangeDrawBuffersHelper(bool recover) const {
for (AttachmentMap::const_iterator it = attachments_.begin();
it != attachments_.end(); ++it) {
if (it->first >= GL_COLOR_ATTACHMENT0 &&
- it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) {
+ it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_ &&
+ !GLES2Util::IsIntegerFormat(it->second->internal_format())) {
buffers[it->first - GL_COLOR_ATTACHMENT0] = it->first;
}
}
@@ -388,6 +389,26 @@ void Framebuffer::RestoreDrawBuffersAfterClear() const {
ChangeDrawBuffersHelper(recover);
}
+void Framebuffer::ClearIntegerBuffers() {
+ for (AttachmentMap::const_iterator it = attachments_.begin();
+ it != attachments_.end(); ++it) {
+ GLenum internal_format = it->second->internal_format();
+ if (it->first >= GL_COLOR_ATTACHMENT0 &&
+ it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_ &&
+ !it->second->cleared() &&
+ GLES2Util::IsIntegerFormat(internal_format)) {
+ GLint drawbuffer = it->first - GL_COLOR_ATTACHMENT0;
+ if (GLES2Util::IsUnsignedIntegerFormat(internal_format)) {
+ const static GLuint kZero[] = { 0u, 0u, 0u, 0u };
+ glClearBufferuiv(GL_COLOR, drawbuffer, kZero);
+ } else { // IsUnsignedIntegerFormat(internal_format)
+ const static GLint kZero[] = { 0, 0, 0, 0 };
+ glClearBufferiv(GL_COLOR, drawbuffer, kZero);
+ }
+ }
+ }
+}
+
void Framebuffer::MarkAttachmentAsCleared(
RenderbufferManager* renderbuffer_manager,
TextureManager* texture_manager,
@@ -696,17 +717,21 @@ void Framebuffer::OnTextureRefDetached(TextureRef* texture) {
manager_->OnTextureRefDetached(texture);
}
-void Framebuffer::OnWillRenderTo() const {
+void Framebuffer::OnWillRenderTo(GLenum attachment) const {
for (AttachmentMap::const_iterator it = attachments_.begin();
it != attachments_.end(); ++it) {
- it->second->OnWillRenderTo();
+ if (attachment == 0 || attachment == it->first) {
+ it->second->OnWillRenderTo();
+ }
}
}
-void Framebuffer::OnDidRenderTo() const {
+void Framebuffer::OnDidRenderTo(GLenum attachment) const {
for (AttachmentMap::const_iterator it = attachments_.begin();
it != attachments_.end(); ++it) {
- it->second->OnDidRenderTo();
+ if (attachment == 0 || attachment == it->first) {
+ it->second->OnDidRenderTo();
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698