Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 TextureParameters parameters; | 332 TextureParameters parameters; |
| 333 parameters.target = GC3D_TEXTURE_RECTANGLE_ARB; | 333 parameters.target = GC3D_TEXTURE_RECTANGLE_ARB; |
| 334 | 334 |
| 335 if (m_wantAlphaChannel) { | 335 if (m_wantAlphaChannel) { |
| 336 parameters.creationInternalColorFormat = GL_RGBA; | 336 parameters.creationInternalColorFormat = GL_RGBA; |
| 337 parameters.internalColorFormat = GL_RGBA; | 337 parameters.internalColorFormat = GL_RGBA; |
| 338 } else if (contextProvider()->getCapabilities().chromium_image_rgb_emulation ) { | 338 } else if (contextProvider()->getCapabilities().chromium_image_rgb_emulation ) { |
| 339 parameters.creationInternalColorFormat = GL_RGB; | 339 parameters.creationInternalColorFormat = GL_RGB; |
| 340 parameters.internalColorFormat = GL_RGBA; | 340 parameters.internalColorFormat = GL_RGBA; |
| 341 } else { | 341 } else { |
| 342 parameters.creationInternalColorFormat = GL_RGB; | 342 GLenum format = defaultBufferRequiresAlphaChannelToBePreserved() ? GL_RG BA : GL_RGB; |
| 343 parameters.internalColorFormat = GL_RGB; | 343 parameters.creationInternalColorFormat = format; |
| 344 parameters.internalColorFormat = format; | |
| 344 } | 345 } |
| 345 | 346 |
| 346 // Unused when CHROMIUM_image is being used. | 347 // Unused when CHROMIUM_image is being used. |
| 347 parameters.colorFormat = 0; | 348 parameters.colorFormat = 0; |
| 348 return parameters; | 349 return parameters; |
| 349 #else | 350 #else |
| 350 return defaultTextureParameters(); | 351 return defaultTextureParameters(); |
| 351 #endif | 352 #endif |
| 352 } | 353 } |
| 353 | 354 |
| 354 DrawingBuffer::TextureParameters DrawingBuffer::defaultTextureParameters() | 355 DrawingBuffer::TextureParameters DrawingBuffer::defaultTextureParameters() |
| 355 { | 356 { |
| 356 TextureParameters parameters; | 357 TextureParameters parameters; |
| 357 parameters.target = GL_TEXTURE_2D; | 358 parameters.target = GL_TEXTURE_2D; |
| 358 if (m_wantAlphaChannel) { | 359 if (m_wantAlphaChannel) { |
| 359 parameters.internalColorFormat = GL_RGBA; | 360 parameters.internalColorFormat = GL_RGBA; |
| 360 parameters.creationInternalColorFormat = GL_RGBA; | 361 parameters.creationInternalColorFormat = GL_RGBA; |
| 361 parameters.colorFormat = GL_RGBA; | 362 parameters.colorFormat = GL_RGBA; |
| 362 } else { | 363 } else { |
| 363 parameters.internalColorFormat = GL_RGB; | 364 GLenum format = defaultBufferRequiresAlphaChannelToBePreserved() ? GL_RG BA : GL_RGB; |
| 364 parameters.creationInternalColorFormat = GL_RGB; | 365 parameters.creationInternalColorFormat = format; |
| 365 parameters.colorFormat = GL_RGB; | 366 parameters.internalColorFormat = format; |
| 367 parameters.colorFormat = format; | |
| 366 } | 368 } |
| 367 return parameters; | 369 return parameters; |
| 368 } | 370 } |
| 369 | 371 |
| 370 void DrawingBuffer::mailboxReleasedWithoutRecycling(const WebExternalTextureMail box& mailbox) | 372 void DrawingBuffer::mailboxReleasedWithoutRecycling(const WebExternalTextureMail box& mailbox) |
| 371 { | 373 { |
| 372 ASSERT(m_textureMailboxes.size()); | 374 ASSERT(m_textureMailboxes.size()); |
| 373 // Ensure not to call the destructor until deleteMailbox() is completed. | 375 // Ensure not to call the destructor until deleteMailbox() is completed. |
| 374 RefPtr<DrawingBuffer> self = this; | 376 RefPtr<DrawingBuffer> self = this; |
| 375 deleteMailbox(mailbox); | 377 deleteMailbox(mailbox); |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1044 return m_wantDepth || m_wantStencil; | 1046 return m_wantDepth || m_wantStencil; |
| 1045 } | 1047 } |
| 1046 | 1048 |
| 1047 GLenum DrawingBuffer::getMultisampledRenderbufferFormat() | 1049 GLenum DrawingBuffer::getMultisampledRenderbufferFormat() |
| 1048 { | 1050 { |
| 1049 DCHECK(wantExplicitResolve()); | 1051 DCHECK(wantExplicitResolve()); |
| 1050 if (m_wantAlphaChannel) | 1052 if (m_wantAlphaChannel) |
| 1051 return GL_RGBA8_OES; | 1053 return GL_RGBA8_OES; |
| 1052 if (m_colorBuffer.imageId && contextProvider()->getCapabilities().chromium_i mage_rgb_emulation) | 1054 if (m_colorBuffer.imageId && contextProvider()->getCapabilities().chromium_i mage_rgb_emulation) |
| 1053 return GL_RGBA8_OES; | 1055 return GL_RGBA8_OES; |
| 1056 if (contextProvider()->getCapabilities().disable_webgl_rgb_multisampling_usa ge) | |
|
Ken Russell (switch to Gerrit)
2016/05/19 00:06:41
It seems a little strange that this checks a diffe
erikchen
2016/06/02 00:14:06
defaultBufferRequiresAlphaChannelToBePreserved cal
Ken Russell (switch to Gerrit)
2016/06/02 00:46:10
Ah, I see. Thanks for the explanation.
| |
| 1057 return GL_RGBA8_OES; | |
| 1054 return GL_RGB8_OES; | 1058 return GL_RGB8_OES; |
| 1055 } | 1059 } |
| 1056 | 1060 |
| 1057 void DrawingBuffer::restoreTextureBindings() | 1061 void DrawingBuffer::restoreTextureBindings() |
| 1058 { | 1062 { |
| 1059 // This class potentially modifies the bindings for GL_TEXTURE_2D and | 1063 // This class potentially modifies the bindings for GL_TEXTURE_2D and |
| 1060 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since | 1064 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since |
| 1061 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. | 1065 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. |
| 1062 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1066 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1063 } | 1067 } |
| 1064 | 1068 |
| 1065 } // namespace blink | 1069 } // namespace blink |
| OLD | NEW |