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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 2145093003: Discard correct drawing buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Discard correct drawing buffer Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (!frontColorBufferMailbox) 281 if (!frontColorBufferMailbox)
282 frontColorBufferMailbox = createNewMailbox(createTextureAndAllocateMemor y(m_size)); 282 frontColorBufferMailbox = createNewMailbox(createTextureAndAllocateMemor y(m_size));
283 283
284 if (m_preserveDrawingBuffer == Discard) { 284 if (m_preserveDrawingBuffer == Discard) {
285 std::swap(frontColorBufferMailbox->textureInfo, m_colorBuffer); 285 std::swap(frontColorBufferMailbox->textureInfo, m_colorBuffer);
286 attachColorBufferToReadFramebuffer(); 286 attachColorBufferToReadFramebuffer();
287 287
288 if (m_discardFramebufferSupported) { 288 if (m_discardFramebufferSupported) {
289 // Explicitly discard framebuffer to save GPU memory bandwidth for t ile-based GPU arch. 289 // Explicitly discard framebuffer to save GPU memory bandwidth for t ile-based GPU arch.
290 const GLenum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTAC HMENT, GL_STENCIL_ATTACHMENT }; 290 const GLenum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTAC HMENT, GL_STENCIL_ATTACHMENT };
291 // It appears safe to overwrite the context's framebuffer binding in the Discard case since there will always be a
Zhenyao Mo 2016/07/14 17:27:03 This comment is unnecessary because there is a res
qiankun 2016/07/14 23:40:00 Thanks for reminding. The comments was added previ
292 // WebGLRenderingContext::clearIfComposited() call made before the n ext draw call which restores the framebuffer binding.
293 // If this stops being true at some point, we should track the curre nt framebuffer binding in the DrawingBuffer and restore
294 // it after attaching the new back buffer here.
295 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
291 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); 296 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments);
qiankun 2016/07/14 12:37:10 This only makes framebuffer undefined to save some
292 } 297 }
293 } else { 298 } else {
294 m_gl->CopySubTextureCHROMIUM(m_colorBuffer.textureId, frontColorBufferMa ilbox->textureInfo.textureId, 299 m_gl->CopySubTextureCHROMIUM(m_colorBuffer.textureId, frontColorBufferMa ilbox->textureInfo.textureId,
295 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_ FALSE); 300 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_ FALSE);
296 } 301 }
297 302
298 restoreFramebufferBindings(); 303 restoreFramebufferBindings();
299 m_contentsChanged = false; 304 m_contentsChanged = false;
300 305
301 m_gl->ProduceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo.text ureId, frontColorBufferMailbox->textureInfo.parameters.target, frontColorBufferM ailbox->mailbox.name); 306 m_gl->ProduceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo.text ureId, frontColorBufferMailbox->textureInfo.parameters.target, frontColorBufferM ailbox->mailbox.name);
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 1106
1102 void DrawingBuffer::restoreTextureBindings() 1107 void DrawingBuffer::restoreTextureBindings()
1103 { 1108 {
1104 // This class potentially modifies the bindings for GL_TEXTURE_2D and 1109 // This class potentially modifies the bindings for GL_TEXTURE_2D and
1105 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since 1110 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since
1106 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. 1111 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE.
1107 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1112 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1108 } 1113 }
1109 1114
1110 } // namespace blink 1115 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698