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

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

Issue 2021443003: Remove WebGL CHROMIUM image fallback logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from danakj. 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 | third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp » ('j') | 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 { 208 {
209 return !m_drawFramebufferBinding && defaultBufferRequiresAlphaChannelToBePre served(); 209 return !m_drawFramebufferBinding && defaultBufferRequiresAlphaChannelToBePre served();
210 } 210 }
211 211
212 bool DrawingBuffer::defaultBufferRequiresAlphaChannelToBePreserved() 212 bool DrawingBuffer::defaultBufferRequiresAlphaChannelToBePreserved()
213 { 213 {
214 if (wantExplicitResolve()) { 214 if (wantExplicitResolve()) {
215 return !m_wantAlphaChannel && getMultisampledRenderbufferFormat() == GL_ RGBA8_OES; 215 return !m_wantAlphaChannel && getMultisampledRenderbufferFormat() == GL_ RGBA8_OES;
216 } 216 }
217 217
218 return !m_wantAlphaChannel && m_colorBuffer.imageId && contextProvider()->ge tCapabilities().chromium_image_rgb_emulation; 218 return !m_wantAlphaChannel && RuntimeEnabledFeatures::webGLImageChromiumEnab led() && contextProvider()->getCapabilities().chromium_image_rgb_emulation;
219 } 219 }
220 220
221 void DrawingBuffer::freeRecycledMailboxes() 221 void DrawingBuffer::freeRecycledMailboxes()
222 { 222 {
223 if (m_recycledMailboxQueue.isEmpty()) 223 if (m_recycledMailboxQueue.isEmpty())
224 return; 224 return;
225 while (!m_recycledMailboxQueue.isEmpty()) 225 while (!m_recycledMailboxQueue.isEmpty())
226 deleteMailbox(m_recycledMailboxQueue.takeLast()); 226 deleteMailbox(m_recycledMailboxQueue.takeLast());
227 } 227 }
228 228
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 restoreFramebufferBindings(); 957 restoreFramebufferBindings();
958 m_gl->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], m_clearC olor[3]); 958 m_gl->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], m_clearC olor[3]);
959 m_gl->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], m_colorMask[ 3]); 959 m_gl->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], m_colorMask[ 3]);
960 } 960 }
961 961
962 DrawingBuffer::TextureInfo DrawingBuffer::createTextureAndAllocateMemory(const I ntSize& size) 962 DrawingBuffer::TextureInfo DrawingBuffer::createTextureAndAllocateMemory(const I ntSize& size)
963 { 963 {
964 if (!RuntimeEnabledFeatures::webGLImageChromiumEnabled()) 964 if (!RuntimeEnabledFeatures::webGLImageChromiumEnabled())
965 return createDefaultTextureAndAllocateMemory(size); 965 return createDefaultTextureAndAllocateMemory(size);
966 966
967 // First, try to allocate a CHROMIUM_image. This always has the potential to
968 // fail.
969 TextureParameters parameters = chromiumImageTextureParameters(); 967 TextureParameters parameters = chromiumImageTextureParameters();
970 GLuint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), size .height(), parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIUM); 968 GLuint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), size .height(), parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIUM);
971 if (!imageId) 969 GLint gpuMemoryBufferId = -1;
972 return createDefaultTextureAndAllocateMemory(size); 970 GLuint textureId = createColorTexture(parameters);
973 971
974 GLuint textureId = createColorTexture(parameters); 972 if (imageId) {
975 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId); 973 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId);
976 GLint gpuMemoryBufferId = -1; 974 m_gl->GetImageivCHROMIUM(imageId, GC3D_GPU_MEMORY_BUFFER_ID, &gpuMemoryB ufferId);
977 m_gl->GetImageivCHROMIUM(imageId, GC3D_GPU_MEMORY_BUFFER_ID, &gpuMemoryBuffe rId); 975 DCHECK_NE(-1, gpuMemoryBufferId);
978 DCHECK_NE(-1, gpuMemoryBufferId); 976 }
979 977
980 TextureInfo info; 978 TextureInfo info;
981 info.textureId = textureId; 979 info.textureId = textureId;
982 info.imageId = imageId; 980 info.imageId = imageId;
983 info.gpuMemoryBufferId = gpuMemoryBufferId; 981 info.gpuMemoryBufferId = gpuMemoryBufferId;
984 info.parameters = parameters; 982 info.parameters = parameters;
985 clearChromiumImageAlpha(info); 983 clearChromiumImageAlpha(info);
986 return info; 984 return info;
987 } 985 }
988 986
989 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory( const IntSize& size) 987 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory( const IntSize& size)
990 { 988 {
991 TextureParameters parameters = defaultTextureParameters(); 989 TextureParameters parameters = defaultTextureParameters();
992 GLuint textureId = createColorTexture(parameters); 990 GLuint textureId = createColorTexture(parameters);
993 texImage2DResourceSafe(parameters.target, 0, parameters.creationInternalColo rFormat, size.width(), size.height(), 0, parameters.colorFormat, GL_UNSIGNED_BYT E); 991 texImage2DResourceSafe(parameters.target, 0, parameters.creationInternalColo rFormat, size.width(), size.height(), 0, parameters.colorFormat, GL_UNSIGNED_BYT E);
994 992
995 DrawingBuffer::TextureInfo info; 993 DrawingBuffer::TextureInfo info;
996 info.textureId = textureId; 994 info.textureId = textureId;
997 info.parameters = parameters; 995 info.parameters = parameters;
998 return info; 996 return info;
999 } 997 }
1000 998
1001 void DrawingBuffer::resizeTextureMemory(TextureInfo* info, const IntSize& size) 999 void DrawingBuffer::resizeTextureMemory(TextureInfo* info, const IntSize& size)
1002 { 1000 {
1003 ASSERT(info->textureId); 1001 ASSERT(info->textureId);
1004 if (info->imageId) { 1002 if (!RuntimeEnabledFeatures::webGLImageChromiumEnabled()) {
1005 deleteChromiumImageForTexture(info); 1003 m_gl->BindTexture(info->parameters.target, info->textureId);
1006 info->imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s ize.height(), info->parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIU M); 1004 texImage2DResourceSafe(info->parameters.target, 0, info->parameters.crea tionInternalColorFormat, size.width(), size.height(), 0, info->parameters.colorF ormat, GL_UNSIGNED_BYTE);
1007 if (info->imageId) { 1005 return;
1008 m_gl->BindTexture(info->parameters.target, info->textureId);
1009 m_gl->BindTexImage2DCHROMIUM(info->parameters.target, info->imageId) ;
1010
1011 GLint gpuMemoryBufferId = -1;
1012 m_gl->GetImageivCHROMIUM(info->imageId, GC3D_GPU_MEMORY_BUFFER_ID, & gpuMemoryBufferId);
1013 DCHECK_NE(-1, gpuMemoryBufferId);
1014 info->gpuMemoryBufferId = gpuMemoryBufferId;
1015
1016 clearChromiumImageAlpha(*info);
1017 return;
1018 }
1019
1020 // If the desired texture target is different, there's no way to fall ba ck
1021 // to a non CHROMIUM_image texture.
1022 if (chromiumImageTextureParameters().target != defaultTextureParameters( ).target)
1023 return;
1024 } 1006 }
1025 1007
1026 m_gl->BindTexture(info->parameters.target, info->textureId); 1008 deleteChromiumImageForTexture(info);
1027 texImage2DResourceSafe(info->parameters.target, 0, info->parameters.creation InternalColorFormat, size.width(), size.height(), 0, info->parameters.colorForma t, GL_UNSIGNED_BYTE); 1009 info->imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), size. height(), info->parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIUM);
1010 if (info->imageId) {
1011 m_gl->BindTexture(info->parameters.target, info->textureId);
1012 m_gl->BindTexImage2DCHROMIUM(info->parameters.target, info->imageId);
1013
1014 GLint gpuMemoryBufferId = -1;
1015 m_gl->GetImageivCHROMIUM(info->imageId, GC3D_GPU_MEMORY_BUFFER_ID, &gpuM emoryBufferId);
1016 DCHECK_NE(-1, gpuMemoryBufferId);
1017 info->gpuMemoryBufferId = gpuMemoryBufferId;
1018
1019 clearChromiumImageAlpha(*info);
1020 } else {
1021 info->gpuMemoryBufferId = -1;
1022
1023 // At this point, the texture still exists, but has no allocated
1024 // storage. This is intentional, and mimics the behavior of a texImage2D
1025 // failure.
1026 }
1028 } 1027 }
1029 1028
1030 void DrawingBuffer::attachColorBufferToReadFramebuffer() 1029 void DrawingBuffer::attachColorBufferToReadFramebuffer()
1031 { 1030 {
1032 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); 1031 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
1033 1032
1034 GLenum target = m_colorBuffer.parameters.target; 1033 GLenum target = m_colorBuffer.parameters.target;
1035 GLenum id = m_colorBuffer.textureId; 1034 GLenum id = m_colorBuffer.textureId;
1036 1035
1037 m_gl->BindTexture(target, id); 1036 m_gl->BindTexture(target, id);
(...skipping 15 matching lines...) Expand all
1053 bool DrawingBuffer::wantDepthOrStencil() 1052 bool DrawingBuffer::wantDepthOrStencil()
1054 { 1053 {
1055 return m_wantDepth || m_wantStencil; 1054 return m_wantDepth || m_wantStencil;
1056 } 1055 }
1057 1056
1058 GLenum DrawingBuffer::getMultisampledRenderbufferFormat() 1057 GLenum DrawingBuffer::getMultisampledRenderbufferFormat()
1059 { 1058 {
1060 DCHECK(wantExplicitResolve()); 1059 DCHECK(wantExplicitResolve());
1061 if (m_wantAlphaChannel) 1060 if (m_wantAlphaChannel)
1062 return GL_RGBA8_OES; 1061 return GL_RGBA8_OES;
1063 if (m_colorBuffer.imageId && contextProvider()->getCapabilities().chromium_i mage_rgb_emulation) 1062 if (RuntimeEnabledFeatures::webGLImageChromiumEnabled() && contextProvider() ->getCapabilities().chromium_image_rgb_emulation)
1064 return GL_RGBA8_OES; 1063 return GL_RGBA8_OES;
1065 return GL_RGB8_OES; 1064 return GL_RGB8_OES;
1066 } 1065 }
1067 1066
1068 void DrawingBuffer::restoreTextureBindings() 1067 void DrawingBuffer::restoreTextureBindings()
1069 { 1068 {
1070 // This class potentially modifies the bindings for GL_TEXTURE_2D and 1069 // This class potentially modifies the bindings for GL_TEXTURE_2D and
1071 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since 1070 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since
1072 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. 1071 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE.
1073 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1072 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1074 } 1073 }
1075 1074
1076 } // namespace blink 1075 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698