| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 m_gl->ProduceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo.text
ureId, frontColorBufferMailbox->textureInfo.parameters.target, frontColorBufferM
ailbox->mailbox.name); | 301 m_gl->ProduceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo.text
ureId, frontColorBufferMailbox->textureInfo.parameters.target, frontColorBufferM
ailbox->mailbox.name); |
| 302 const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); | 302 const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); |
| 303 if (RuntimeEnabledFeatures::webGLImageChromiumEnabled()) | 303 if (RuntimeEnabledFeatures::webGLImageChromiumEnabled()) |
| 304 m_gl->DescheduleUntilFinishedCHROMIUM(); | 304 m_gl->DescheduleUntilFinishedCHROMIUM(); |
| 305 m_gl->Flush(); | 305 m_gl->Flush(); |
| 306 m_gl->GenSyncTokenCHROMIUM(fenceSync, frontColorBufferMailbox->mailbox.syncT
oken); | 306 m_gl->GenSyncTokenCHROMIUM(fenceSync, frontColorBufferMailbox->mailbox.syncT
oken); |
| 307 frontColorBufferMailbox->mailbox.validSyncToken = true; | 307 frontColorBufferMailbox->mailbox.validSyncToken = true; |
| 308 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex
tureInfo.imageId != 0; | 308 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex
tureInfo.imageId != 0; |
| 309 frontColorBufferMailbox->mailbox.textureTarget = frontColorBufferMailbox->te
xtureInfo.parameters.target; | 309 frontColorBufferMailbox->mailbox.textureTarget = frontColorBufferMailbox->te
xtureInfo.parameters.target; |
| 310 frontColorBufferMailbox->mailbox.textureSize = WebSize(m_size.width(), m_siz
e.height()); | 310 frontColorBufferMailbox->mailbox.textureSize = WebSize(m_size.width(), m_siz
e.height()); |
| 311 frontColorBufferMailbox->mailbox.gpuMemoryBufferId = frontColorBufferMailbox
->textureInfo.gpuMemoryBufferId; | |
| 312 setBufferClearNeeded(true); | 311 setBufferClearNeeded(true); |
| 313 | 312 |
| 314 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes | 313 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes |
| 315 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); | 314 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); |
| 316 frontColorBufferMailbox->m_parentDrawingBuffer = this; | 315 frontColorBufferMailbox->m_parentDrawingBuffer = this; |
| 317 *outMailbox = frontColorBufferMailbox->mailbox; | 316 *outMailbox = frontColorBufferMailbox->mailbox; |
| 318 m_frontColorBuffer = { frontColorBufferMailbox->textureInfo, frontColorBuffe
rMailbox->mailbox }; | 317 m_frontColorBuffer = { frontColorBufferMailbox->textureInfo, frontColorBuffe
rMailbox->mailbox }; |
| 319 return true; | 318 return true; |
| 320 } | 319 } |
| 321 | 320 |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 m_gl->TexImage2D(target, 0, internalformat, width, height, border, format, t
ype, 0); | 966 m_gl->TexImage2D(target, 0, internalformat, width, height, border, format, t
ype, 0); |
| 968 } | 967 } |
| 969 | 968 |
| 970 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 969 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
| 971 { | 970 { |
| 972 if (info->imageId) { | 971 if (info->imageId) { |
| 973 m_gl->BindTexture(info->parameters.target, info->textureId); | 972 m_gl->BindTexture(info->parameters.target, info->textureId); |
| 974 m_gl->ReleaseTexImage2DCHROMIUM(info->parameters.target, info->imageId); | 973 m_gl->ReleaseTexImage2DCHROMIUM(info->parameters.target, info->imageId); |
| 975 m_gl->DestroyImageCHROMIUM(info->imageId); | 974 m_gl->DestroyImageCHROMIUM(info->imageId); |
| 976 info->imageId = 0; | 975 info->imageId = 0; |
| 977 info->gpuMemoryBufferId = -1; | |
| 978 } | 976 } |
| 979 } | 977 } |
| 980 | 978 |
| 981 void DrawingBuffer::clearChromiumImageAlpha(const TextureInfo& info) | 979 void DrawingBuffer::clearChromiumImageAlpha(const TextureInfo& info) |
| 982 { | 980 { |
| 983 if (m_wantAlphaChannel) | 981 if (m_wantAlphaChannel) |
| 984 return; | 982 return; |
| 985 if (!contextProvider()->getCapabilities().chromium_image_rgb_emulation) | 983 if (!contextProvider()->getCapabilities().chromium_image_rgb_emulation) |
| 986 return; | 984 return; |
| 987 | 985 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 999 m_gl->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], m_colorMask[
3]); | 997 m_gl->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], m_colorMask[
3]); |
| 1000 } | 998 } |
| 1001 | 999 |
| 1002 DrawingBuffer::TextureInfo DrawingBuffer::createTextureAndAllocateMemory(const I
ntSize& size) | 1000 DrawingBuffer::TextureInfo DrawingBuffer::createTextureAndAllocateMemory(const I
ntSize& size) |
| 1003 { | 1001 { |
| 1004 if (!RuntimeEnabledFeatures::webGLImageChromiumEnabled()) | 1002 if (!RuntimeEnabledFeatures::webGLImageChromiumEnabled()) |
| 1005 return createDefaultTextureAndAllocateMemory(size); | 1003 return createDefaultTextureAndAllocateMemory(size); |
| 1006 | 1004 |
| 1007 TextureParameters parameters = chromiumImageTextureParameters(); | 1005 TextureParameters parameters = chromiumImageTextureParameters(); |
| 1008 GLuint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), size
.height(), parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIUM); | 1006 GLuint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), size
.height(), parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIUM); |
| 1009 GLint gpuMemoryBufferId = -1; | |
| 1010 GLuint textureId = createColorTexture(parameters); | 1007 GLuint textureId = createColorTexture(parameters); |
| 1011 | |
| 1012 if (imageId) { | 1008 if (imageId) { |
| 1013 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId); | 1009 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId); |
| 1014 m_gl->GetImageivCHROMIUM(imageId, GC3D_GPU_MEMORY_BUFFER_ID, &gpuMemoryB
ufferId); | |
| 1015 DCHECK_NE(-1, gpuMemoryBufferId); | |
| 1016 } | 1010 } |
| 1017 | 1011 |
| 1018 TextureInfo info; | 1012 TextureInfo info; |
| 1019 info.textureId = textureId; | 1013 info.textureId = textureId; |
| 1020 info.imageId = imageId; | 1014 info.imageId = imageId; |
| 1021 info.gpuMemoryBufferId = gpuMemoryBufferId; | |
| 1022 info.parameters = parameters; | 1015 info.parameters = parameters; |
| 1023 clearChromiumImageAlpha(info); | 1016 clearChromiumImageAlpha(info); |
| 1024 return info; | 1017 return info; |
| 1025 } | 1018 } |
| 1026 | 1019 |
| 1027 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory(
const IntSize& size) | 1020 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory(
const IntSize& size) |
| 1028 { | 1021 { |
| 1029 DrawingBuffer::TextureInfo info; | 1022 DrawingBuffer::TextureInfo info; |
| 1030 TextureParameters parameters = defaultTextureParameters(); | 1023 TextureParameters parameters = defaultTextureParameters(); |
| 1031 info.parameters = parameters; | 1024 info.parameters = parameters; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1051 info->immutable = m_storageTextureSupported; | 1044 info->immutable = m_storageTextureSupported; |
| 1052 return; | 1045 return; |
| 1053 } | 1046 } |
| 1054 | 1047 |
| 1055 DCHECK(!info->immutable); | 1048 DCHECK(!info->immutable); |
| 1056 deleteChromiumImageForTexture(info); | 1049 deleteChromiumImageForTexture(info); |
| 1057 info->imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), size.
height(), info->parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIUM); | 1050 info->imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), size.
height(), info->parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIUM); |
| 1058 if (info->imageId) { | 1051 if (info->imageId) { |
| 1059 m_gl->BindTexture(info->parameters.target, info->textureId); | 1052 m_gl->BindTexture(info->parameters.target, info->textureId); |
| 1060 m_gl->BindTexImage2DCHROMIUM(info->parameters.target, info->imageId); | 1053 m_gl->BindTexImage2DCHROMIUM(info->parameters.target, info->imageId); |
| 1061 | |
| 1062 GLint gpuMemoryBufferId = -1; | |
| 1063 m_gl->GetImageivCHROMIUM(info->imageId, GC3D_GPU_MEMORY_BUFFER_ID, &gpuM
emoryBufferId); | |
| 1064 DCHECK_NE(-1, gpuMemoryBufferId); | |
| 1065 info->gpuMemoryBufferId = gpuMemoryBufferId; | |
| 1066 | |
| 1067 clearChromiumImageAlpha(*info); | 1054 clearChromiumImageAlpha(*info); |
| 1068 } else { | 1055 } else { |
| 1069 info->gpuMemoryBufferId = -1; | |
| 1070 | |
| 1071 // At this point, the texture still exists, but has no allocated | 1056 // At this point, the texture still exists, but has no allocated |
| 1072 // storage. This is intentional, and mimics the behavior of a texImage2D | 1057 // storage. This is intentional, and mimics the behavior of a texImage2D |
| 1073 // failure. | 1058 // failure. |
| 1074 } | 1059 } |
| 1075 } | 1060 } |
| 1076 | 1061 |
| 1077 void DrawingBuffer::attachColorBufferToReadFramebuffer() | 1062 void DrawingBuffer::attachColorBufferToReadFramebuffer() |
| 1078 { | 1063 { |
| 1079 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 1064 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 1080 | 1065 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 | 1101 |
| 1117 void DrawingBuffer::restoreTextureBindings() | 1102 void DrawingBuffer::restoreTextureBindings() |
| 1118 { | 1103 { |
| 1119 // This class potentially modifies the bindings for GL_TEXTURE_2D and | 1104 // This class potentially modifies the bindings for GL_TEXTURE_2D and |
| 1120 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since | 1105 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since |
| 1121 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. | 1106 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. |
| 1122 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1107 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1123 } | 1108 } |
| 1124 | 1109 |
| 1125 } // namespace blink | 1110 } // namespace blink |
| OLD | NEW |