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

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

Issue 1474763002: Revert of webgl: use immutable texture for the default FBO. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h ('k') | 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 , m_drawFramebufferBinding(0) 144 , m_drawFramebufferBinding(0)
145 , m_readFramebufferBinding(0) 145 , m_readFramebufferBinding(0)
146 , m_activeTextureUnit(GL_TEXTURE0) 146 , m_activeTextureUnit(GL_TEXTURE0)
147 , m_context(context) 147 , m_context(context)
148 , m_extensionsUtil(extensionsUtil) 148 , m_extensionsUtil(extensionsUtil)
149 , m_size(-1, -1) 149 , m_size(-1, -1)
150 , m_requestedAttributes(requestedAttributes) 150 , m_requestedAttributes(requestedAttributes)
151 , m_multisampleExtensionSupported(multisampleExtensionSupported) 151 , m_multisampleExtensionSupported(multisampleExtensionSupported)
152 , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupporte d) 152 , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupporte d)
153 , m_discardFramebufferSupported(discardFramebufferSupported) 153 , m_discardFramebufferSupported(discardFramebufferSupported)
154 , m_storageTextureSupported(false)
155 , m_fbo(0) 154 , m_fbo(0)
156 , m_depthStencilBuffer(0) 155 , m_depthStencilBuffer(0)
157 , m_depthBuffer(0) 156 , m_depthBuffer(0)
158 , m_stencilBuffer(0) 157 , m_stencilBuffer(0)
159 , m_multisampleFBO(0) 158 , m_multisampleFBO(0)
160 , m_multisampleColorBuffer(0) 159 , m_multisampleColorBuffer(0)
161 , m_contentsChanged(true) 160 , m_contentsChanged(true)
162 , m_contentsChangeCommitted(false) 161 , m_contentsChangeCommitted(false)
163 , m_bufferClearNeeded(false) 162 , m_bufferClearNeeded(false)
164 , m_antiAliasingMode(None) 163 , m_antiAliasingMode(None)
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COL OR_ATTACHMENT0, GL_TEXTURE_2D, m_colorBuffer.textureId, 0, m_sampleCount); 298 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COL OR_ATTACHMENT0, GL_TEXTURE_2D, m_colorBuffer.textureId, 0, m_sampleCount);
300 else 299 else
301 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D, m_colorBuffer.textureId, 0); 300 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D, m_colorBuffer.textureId, 0);
302 301
303 if (m_discardFramebufferSupported) { 302 if (m_discardFramebufferSupported) {
304 // Explicitly discard framebuffer to save GPU memory bandwidth for t ile-based GPU arch. 303 // Explicitly discard framebuffer to save GPU memory bandwidth for t ile-based GPU arch.
305 const WGC3Denum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_AT TACHMENT, GL_STENCIL_ATTACHMENT}; 304 const WGC3Denum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_AT TACHMENT, GL_STENCIL_ATTACHMENT};
306 m_context->discardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); 305 m_context->discardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments);
307 } 306 }
308 } else { 307 } else {
309 m_context->copySubTextureCHROMIUM(GL_TEXTURE_2D, m_colorBuffer.textureId , frontColorBufferMailbox->textureInfo.textureId, 308 m_context->copyTextureCHROMIUM(GL_TEXTURE_2D, m_colorBuffer.textureId, f rontColorBufferMailbox->textureInfo.textureId, GL_RGBA, GL_UNSIGNED_BYTE, GL_FAL SE, GL_FALSE, GL_FALSE);
310 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_ FALSE);
311 } 309 }
312 310
313 restoreFramebufferBindings(); 311 restoreFramebufferBindings();
314 m_contentsChanged = false; 312 m_contentsChanged = false;
315 313
316 m_context->produceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo .textureId, GL_TEXTURE_2D, frontColorBufferMailbox->mailbox.name); 314 m_context->produceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo .textureId, GL_TEXTURE_2D, frontColorBufferMailbox->mailbox.name);
317 m_context->flush(); 315 m_context->flush();
318 frontColorBufferMailbox->mailbox.validSyncToken = m_context->insertSyncPoint (frontColorBufferMailbox->mailbox.syncToken); 316 frontColorBufferMailbox->mailbox.validSyncToken = m_context->insertSyncPoint (frontColorBufferMailbox->mailbox.syncToken);
319 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex tureInfo.imageId != 0; 317 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex tureInfo.imageId != 0;
320 setBufferClearNeeded(true); 318 setBufferClearNeeded(true);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) { 442 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) {
445 m_context->getIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); 443 m_context->getIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount);
446 m_antiAliasingMode = MSAAExplicitResolve; 444 m_antiAliasingMode = MSAAExplicitResolve;
447 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t exture")) { 445 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t exture")) {
448 m_antiAliasingMode = MSAAImplicitResolve; 446 m_antiAliasingMode = MSAAImplicitResolve;
449 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space _antialiasing")) { 447 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space _antialiasing")) {
450 m_antiAliasingMode = ScreenSpaceAntialiasing; 448 m_antiAliasingMode = ScreenSpaceAntialiasing;
451 } 449 }
452 } 450 }
453 m_sampleCount = std::min(4, maxSampleCount); 451 m_sampleCount = std::min(4, maxSampleCount);
454 m_storageTextureSupported = m_extensionsUtil->supportsExtension("GL_EXT_text ure_storage");
455 452
456 m_fbo = m_context->createFramebuffer(); 453 m_fbo = m_context->createFramebuffer();
457 454
458 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); 455 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
459 m_colorBuffer.textureId = createColorTexture(); 456 m_colorBuffer.textureId = createColorTexture();
460 if (m_antiAliasingMode == MSAAImplicitResolve) 457 if (m_antiAliasingMode == MSAAImplicitResolve)
461 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A TTACHMENT0, GL_TEXTURE_2D, m_colorBuffer.textureId, 0, m_sampleCount); 458 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A TTACHMENT0, GL_TEXTURE_2D, m_colorBuffer.textureId, 0, m_sampleCount);
462 else 459 else
463 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL _TEXTURE_2D, m_colorBuffer.textureId, 0); 460 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL _TEXTURE_2D, m_colorBuffer.textureId, 0);
464 createSecondaryBuffers(); 461 createSecondaryBuffers();
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 unsigned count = height / 2; 952 unsigned count = height / 2;
956 for (unsigned i = 0; i < count; i++) { 953 for (unsigned i = 0; i < count; i++) {
957 uint8* rowA = framebuffer + i * rowBytes; 954 uint8* rowA = framebuffer + i * rowBytes;
958 uint8* rowB = framebuffer + (height - i - 1) * rowBytes; 955 uint8* rowB = framebuffer + (height - i - 1) * rowBytes;
959 memcpy(scanline, rowB, rowBytes); 956 memcpy(scanline, rowB, rowBytes);
960 memcpy(rowB, rowA, rowBytes); 957 memcpy(rowB, rowA, rowBytes);
961 memcpy(rowA, scanline, rowBytes); 958 memcpy(rowA, scanline, rowBytes);
962 } 959 }
963 } 960 }
964 961
962 void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in ternalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLint unpackAlignment)
963 {
964 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8);
965 m_context->texImage2D(target, level, internalformat, width, height, border, format, type, 0);
966 }
967
965 void DrawingBuffer::allocateTextureMemory(TextureInfo* info, const IntSize& size ) 968 void DrawingBuffer::allocateTextureMemory(TextureInfo* info, const IntSize& size )
966 { 969 {
967 if (RuntimeEnabledFeatures::webGLImageChromiumEnabled()) { 970 if (RuntimeEnabledFeatures::webGLImageChromiumEnabled()) {
968 deleteChromiumImageForTexture(info); 971 deleteChromiumImageForTexture(info);
969 972
970 info->imageId = m_context->createGpuMemoryBufferImageCHROMIUM(size.width (), size.height(), GL_RGBA, GC3D_SCANOUT_CHROMIUM); 973 info->imageId = m_context->createGpuMemoryBufferImageCHROMIUM(size.width (), size.height(), GL_RGBA, GC3D_SCANOUT_CHROMIUM);
971 if (info->imageId) { 974 if (info->imageId) {
972 m_context->bindTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); 975 m_context->bindTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId);
973 return; 976 return;
974 } 977 }
975 } 978 }
976 979
977 if (m_storageTextureSupported) { 980 texImage2DResourceSafe(GL_TEXTURE_2D, 0, m_internalColorFormat, size.width() , size.height(), 0, m_colorFormat, GL_UNSIGNED_BYTE);
978 if (info->immutable) {
979 m_context->deleteTexture(info->textureId);
980 info->textureId = createColorTexture();
981 }
982
983 // TODO(dshwang): GL_BGRA8_EXT can be better in some platforms. crbug.co m/557848
984 m_context->texStorage2DEXT(GL_TEXTURE_2D, 1, m_internalRenderbufferForma t, size.width(), size.height());
985 info->immutable = true;
986 return;
987 }
988 m_context->texImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, size.width(), size.height(), 0, m_colorFormat, GL_UNSIGNED_BYTE, 0);
989 } 981 }
990 982
991 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) 983 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info)
992 { 984 {
993 if (info->imageId) { 985 if (info->imageId) {
994 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); 986 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId);
995 m_context->destroyImageCHROMIUM(info->imageId); 987 m_context->destroyImageCHROMIUM(info->imageId);
996 info->imageId = 0; 988 info->imageId = 0;
997 } 989 }
998 } 990 }
999 991
1000 } // namespace blink 992 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698