| 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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 = m_gl->GetImageivCHROMIUM(imageId, GC3D_GPU_MEMORY_
BUFFER_ID); |
| 977 DCHECK_NE(-1, gpuMemoryBufferId); |
| 975 | 978 |
| 976 TextureInfo info; | 979 TextureInfo info; |
| 977 info.textureId = textureId; | 980 info.textureId = textureId; |
| 978 info.imageId = imageId; | 981 info.imageId = imageId; |
| 982 info.gpuMemoryBufferId = gpuMemoryBufferId; |
| 979 info.parameters = parameters; | 983 info.parameters = parameters; |
| 980 clearChromiumImageAlpha(info); | 984 clearChromiumImageAlpha(info); |
| 981 return info; | 985 return info; |
| 982 } | 986 } |
| 983 | 987 |
| 984 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory(
const IntSize& size) | 988 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory(
const IntSize& size) |
| 985 { | 989 { |
| 986 TextureParameters parameters = defaultTextureParameters(); | 990 TextureParameters parameters = defaultTextureParameters(); |
| 987 GLuint textureId = createColorTexture(parameters); | 991 GLuint textureId = createColorTexture(parameters); |
| 988 texImage2DResourceSafe(parameters.target, 0, parameters.creationInternalColo
rFormat, size.width(), size.height(), 0, parameters.colorFormat, GL_UNSIGNED_BYT
E); | 992 texImage2DResourceSafe(parameters.target, 0, parameters.creationInternalColo
rFormat, size.width(), size.height(), 0, parameters.colorFormat, GL_UNSIGNED_BYT
E); |
| 989 | 993 |
| 990 DrawingBuffer::TextureInfo info; | 994 DrawingBuffer::TextureInfo info; |
| 991 info.textureId = textureId; | 995 info.textureId = textureId; |
| 992 info.parameters = parameters; | 996 info.parameters = parameters; |
| 993 return info; | 997 return info; |
| 994 } | 998 } |
| 995 | 999 |
| 996 void DrawingBuffer::resizeTextureMemory(TextureInfo* info, const IntSize& size) | 1000 void DrawingBuffer::resizeTextureMemory(TextureInfo* info, const IntSize& size) |
| 997 { | 1001 { |
| 998 ASSERT(info->textureId); | 1002 ASSERT(info->textureId); |
| 999 if (info->imageId) { | 1003 if (info->imageId) { |
| 1000 deleteChromiumImageForTexture(info); | 1004 deleteChromiumImageForTexture(info); |
| 1001 info->imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s
ize.height(), info->parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIU
M); | 1005 info->imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s
ize.height(), info->parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIU
M); |
| 1002 if (info->imageId) { | 1006 if (info->imageId) { |
| 1003 m_gl->BindTexture(info->parameters.target, info->textureId); | 1007 m_gl->BindTexture(info->parameters.target, info->textureId); |
| 1004 m_gl->BindTexImage2DCHROMIUM(info->parameters.target, info->imageId)
; | 1008 m_gl->BindTexImage2DCHROMIUM(info->parameters.target, info->imageId)
; |
| 1009 |
| 1010 GLint gpuMemoryBufferId = m_gl->GetImageivCHROMIUM(info->imageId, GC
3D_GPU_MEMORY_BUFFER_ID); |
| 1011 DCHECK_NE(-1, gpuMemoryBufferId); |
| 1012 info->gpuMemoryBufferId = gpuMemoryBufferId; |
| 1013 |
| 1005 clearChromiumImageAlpha(*info); | 1014 clearChromiumImageAlpha(*info); |
| 1006 return; | 1015 return; |
| 1007 } | 1016 } |
| 1008 | 1017 |
| 1009 // If the desired texture target is different, there's no way to fall ba
ck | 1018 // If the desired texture target is different, there's no way to fall ba
ck |
| 1010 // to a non CHROMIUM_image texture. | 1019 // to a non CHROMIUM_image texture. |
| 1011 if (chromiumImageTextureParameters().target != defaultTextureParameters(
).target) | 1020 if (chromiumImageTextureParameters().target != defaultTextureParameters(
).target) |
| 1012 return; | 1021 return; |
| 1013 } | 1022 } |
| 1014 | 1023 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 | 1065 |
| 1057 void DrawingBuffer::restoreTextureBindings() | 1066 void DrawingBuffer::restoreTextureBindings() |
| 1058 { | 1067 { |
| 1059 // This class potentially modifies the bindings for GL_TEXTURE_2D and | 1068 // This class potentially modifies the bindings for GL_TEXTURE_2D and |
| 1060 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since | 1069 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since |
| 1061 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. | 1070 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. |
| 1062 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1071 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1063 } | 1072 } |
| 1064 | 1073 |
| 1065 } // namespace blink | 1074 } // namespace blink |
| OLD | NEW |