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

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

Issue 1974163003: Expose GpuMemoryBufferId through glGetImageivCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from piman. 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 | « 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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 m_gl->TexImage2D(target, level, internalformat, width, height, border, forma t, type, 0); 927 m_gl->TexImage2D(target, level, internalformat, width, height, border, forma t, type, 0);
928 } 928 }
929 929
930 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) 930 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info)
931 { 931 {
932 if (info->imageId) { 932 if (info->imageId) {
933 m_gl->BindTexture(info->parameters.target, info->textureId); 933 m_gl->BindTexture(info->parameters.target, info->textureId);
934 m_gl->ReleaseTexImage2DCHROMIUM(info->parameters.target, info->imageId); 934 m_gl->ReleaseTexImage2DCHROMIUM(info->parameters.target, info->imageId);
935 m_gl->DestroyImageCHROMIUM(info->imageId); 935 m_gl->DestroyImageCHROMIUM(info->imageId);
936 info->imageId = 0; 936 info->imageId = 0;
937 info->gpuMemoryBufferId = -1;
937 } 938 }
938 } 939 }
939 940
940 void DrawingBuffer::clearChromiumImageAlpha(const TextureInfo& info) 941 void DrawingBuffer::clearChromiumImageAlpha(const TextureInfo& info)
941 { 942 {
942 if (m_wantAlphaChannel) 943 if (m_wantAlphaChannel)
943 return; 944 return;
944 if (!contextProvider()->getCapabilities().chromium_image_rgb_emulation) 945 if (!contextProvider()->getCapabilities().chromium_image_rgb_emulation)
945 return; 946 return;
946 947
(...skipping 18 matching lines...) Expand all
965 966
966 // First, try to allocate a CHROMIUM_image. This always has the potential to 967 // First, try to allocate a CHROMIUM_image. This always has the potential to
967 // fail. 968 // fail.
968 TextureParameters parameters = chromiumImageTextureParameters(); 969 TextureParameters parameters = chromiumImageTextureParameters();
969 GLuint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), size .height(), parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIUM); 970 GLuint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), size .height(), parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIUM);
970 if (!imageId) 971 if (!imageId)
971 return createDefaultTextureAndAllocateMemory(size); 972 return createDefaultTextureAndAllocateMemory(size);
972 973
973 GLuint textureId = createColorTexture(parameters); 974 GLuint textureId = createColorTexture(parameters);
974 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId); 975 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId);
976 GLint gpuMemoryBufferId = -1;
977 m_gl->GetImageivCHROMIUM(imageId, GC3D_GPU_MEMORY_BUFFER_ID, &gpuMemoryBuffe rId);
Ken Russell (switch to Gerrit) 2016/05/27 01:02:10 Questions: 1. Does glGetImageivCHROMIUM require a
erikchen 2016/05/27 01:13:37 The GMB id is cached client side.
978 DCHECK_NE(-1, gpuMemoryBufferId);
975 979
976 TextureInfo info; 980 TextureInfo info;
977 info.textureId = textureId; 981 info.textureId = textureId;
978 info.imageId = imageId; 982 info.imageId = imageId;
983 info.gpuMemoryBufferId = gpuMemoryBufferId;
979 info.parameters = parameters; 984 info.parameters = parameters;
980 clearChromiumImageAlpha(info); 985 clearChromiumImageAlpha(info);
981 return info; 986 return info;
982 } 987 }
983 988
984 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory( const IntSize& size) 989 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory( const IntSize& size)
985 { 990 {
986 TextureParameters parameters = defaultTextureParameters(); 991 TextureParameters parameters = defaultTextureParameters();
987 GLuint textureId = createColorTexture(parameters); 992 GLuint textureId = createColorTexture(parameters);
988 texImage2DResourceSafe(parameters.target, 0, parameters.creationInternalColo rFormat, size.width(), size.height(), 0, parameters.colorFormat, GL_UNSIGNED_BYT E); 993 texImage2DResourceSafe(parameters.target, 0, parameters.creationInternalColo rFormat, size.width(), size.height(), 0, parameters.colorFormat, GL_UNSIGNED_BYT E);
989 994
990 DrawingBuffer::TextureInfo info; 995 DrawingBuffer::TextureInfo info;
991 info.textureId = textureId; 996 info.textureId = textureId;
992 info.parameters = parameters; 997 info.parameters = parameters;
993 return info; 998 return info;
994 } 999 }
995 1000
996 void DrawingBuffer::resizeTextureMemory(TextureInfo* info, const IntSize& size) 1001 void DrawingBuffer::resizeTextureMemory(TextureInfo* info, const IntSize& size)
997 { 1002 {
998 ASSERT(info->textureId); 1003 ASSERT(info->textureId);
999 if (info->imageId) { 1004 if (info->imageId) {
1000 deleteChromiumImageForTexture(info); 1005 deleteChromiumImageForTexture(info);
1001 info->imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s ize.height(), info->parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIU M); 1006 info->imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s ize.height(), info->parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIU M);
1002 if (info->imageId) { 1007 if (info->imageId) {
1003 m_gl->BindTexture(info->parameters.target, info->textureId); 1008 m_gl->BindTexture(info->parameters.target, info->textureId);
1004 m_gl->BindTexImage2DCHROMIUM(info->parameters.target, info->imageId) ; 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
1005 clearChromiumImageAlpha(*info); 1016 clearChromiumImageAlpha(*info);
1006 return; 1017 return;
1007 } 1018 }
1008 1019
1009 // If the desired texture target is different, there's no way to fall ba ck 1020 // If the desired texture target is different, there's no way to fall ba ck
1010 // to a non CHROMIUM_image texture. 1021 // to a non CHROMIUM_image texture.
1011 if (chromiumImageTextureParameters().target != defaultTextureParameters( ).target) 1022 if (chromiumImageTextureParameters().target != defaultTextureParameters( ).target)
1012 return; 1023 return;
1013 } 1024 }
1014 1025
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 1067
1057 void DrawingBuffer::restoreTextureBindings() 1068 void DrawingBuffer::restoreTextureBindings()
1058 { 1069 {
1059 // This class potentially modifies the bindings for GL_TEXTURE_2D and 1070 // This class potentially modifies the bindings for GL_TEXTURE_2D and
1060 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since 1071 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since
1061 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. 1072 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE.
1062 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1073 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1063 } 1074 }
1064 1075
1065 } // namespace blink 1076 } // 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