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

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

Issue 1952913002: Use GL_RGBA renderbuffer for antialiased, no-alpha DrawingBuffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp42_drawingbuffer_cleanup2
Patch Set: Rebase. 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 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 return m_wantDepth || m_wantStencil; 1056 return m_wantDepth || m_wantStencil;
1055 } 1057 }
1056 1058
1057 GLenum DrawingBuffer::getMultisampledRenderbufferFormat() 1059 GLenum DrawingBuffer::getMultisampledRenderbufferFormat()
1058 { 1060 {
1059 DCHECK(wantExplicitResolve()); 1061 DCHECK(wantExplicitResolve());
1060 if (m_wantAlphaChannel) 1062 if (m_wantAlphaChannel)
1061 return GL_RGBA8_OES; 1063 return GL_RGBA8_OES;
1062 if (RuntimeEnabledFeatures::webGLImageChromiumEnabled() && contextProvider() ->getCapabilities().chromium_image_rgb_emulation) 1064 if (RuntimeEnabledFeatures::webGLImageChromiumEnabled() && contextProvider() ->getCapabilities().chromium_image_rgb_emulation)
1063 return GL_RGBA8_OES; 1065 return GL_RGBA8_OES;
1066 if (contextProvider()->getCapabilities().disable_webgl_rgb_multisampling_usa ge)
1067 return GL_RGBA8_OES;
1064 return GL_RGB8_OES; 1068 return GL_RGB8_OES;
1065 } 1069 }
1066 1070
1067 void DrawingBuffer::restoreTextureBindings() 1071 void DrawingBuffer::restoreTextureBindings()
1068 { 1072 {
1069 // This class potentially modifies the bindings for GL_TEXTURE_2D and 1073 // This class potentially modifies the bindings for GL_TEXTURE_2D and
1070 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since 1074 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since
1071 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. 1075 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE.
1072 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1076 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1073 } 1077 }
1074 1078
1075 } // namespace blink 1079 } // 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